Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
express server bounding boxes

how to set up a quick server that gives you geojson based on a bounding box, your going to need to remember to install express and rtree with

npm install rtree express
var express = require('express');
var rtree = require('rtree');
var yourData = require("./path/to/geoJson.json");
var app = express();
app.use(express.compress());
var yourIndex = rtree();
yourIndex.geoJSON(yourData);
app.get('/path', function(req, res){
var bbox,bboxParam;
if(req.query.bbox){
bbox = req.query.bbox.split(",");
bboxParam = [[parseFloat(bbox[0],10),parseFloat(bbox[1],10)],[parseFloat(bbox[2],10),parseFloat(bbox[3],10)]]
yourIndex.bbox(bboxParam, function(err,result){
res.jsonp({"type":"FeatureCollection","features":result});
});
}else{
res.jsonp(yourData);
}
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.