Created
November 23, 2014 14:31
-
-
Save geobabbler/f723b0ad2c681e1251c5 to your computer and use it in GitHub Desktop.
Code snippet 4 for blog post http://blog.geomusings.com/2014/02/18/a-little-deeper-with-node-and-postgis/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/roll up the results | |
query.on('row', function (result) { | |
if (!result) { | |
return res.send('No data found'); | |
} else { | |
if (geom == "features") { | |
coll.features.push(geojson.getFeatureResult(result, spatialcol)); //use helper function | |
} else if (geom == "geometry") { | |
var shape = JSON.parse(result.geojson); | |
coll.geometries.push(shape); | |
} | |
} | |
}); | |
//send the results | |
query.on('end', function (err, result) { | |
res.setHeader('Content-Type', 'application/json'); | |
res.send(coll); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment