Skip to content

Commit

Permalink
change SOI OSM route, add ancillary file routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramSeraph committed Jul 13, 2024
1 parent e32a3c7 commit 2d69c0a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion routes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/raster/soi/osm/": {
"/soi/osm/": {
"handlertype": "mosaic",
"type": "raster",
"category": ["raster"],
Expand Down
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const PMTilesHandler = require('./pmtiles_handler');

const routes = require('./routes.json');

const getLocaterPage = require('./wikidata_locater')
const getLocaterPage = require('./wikidata_locater');

const addSOIAncillaryRoutes = require('./soi_ancillary_routes');

const logger = fastify.log;

Expand Down Expand Up @@ -90,6 +92,7 @@ function addRoutes() {
return reply.sendFile("view.css");
});
});
addSOIAncillaryRoutes(fastify);
logger.info('done adding routes');
}

Expand Down
19 changes: 19 additions & 0 deletions soi_ancillary_routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fetch = require('node-fetch');

const ancillaryUrl = 'https://github.com/ramSeraph/opendata/releases/download/soi-ancillary/';

function getCorsProxyFn(targetUrl, request, reply) {
return async function(request, reply) {
const tResp = await fetch(targetUrl)
const stream = tResp.body;
return reply.header("Access-Control-Allow-Origin", "*")
.send(stream);
}
}

function addSOIAncillaryRoutes(fastify) {
fastify.get('/soi/osm/index.geojson', getCorsProxyFn(ancillaryUrl + 'index.geojson'));
fastify.get('/soi/india_boundary.geojson', getCorsProxyFn(ancillaryUrl + 'polymap15m_area.geojson'));
}

module.exports = addSOIAncillaryRoutes;

0 comments on commit 2d69c0a

Please sign in to comment.