Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invisiblefunnel/86565626cfdf97e13657 to your computer and use it in GitHub Desktop.
Save invisiblefunnel/86565626cfdf97e13657 to your computer and use it in GitHub Desktop.
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Commenting this out is preferred by some people, see
# https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
# Users Environment Variables
.lock-wscript
{
"name": "fun-with-terraformer",
"version": "0.1.0",
"main": "script.js",
"author": "CfA",
"dependencies": {
"terraformer": "1.0.3",
"terraformer-geostore": "1.0.3",
"terraformer-geostore-memory": "1.0.0",
"terraformer-rtree": "1.0.0"
},
"engines": {
"node": "0.10.x"
}
}
var GeoStore = require('terraformer-geostore').GeoStore;
var RTree = require('terraformer-rtree').RTree;
var MemoryStore = require('terraformer-geostore-memory').Memory;
var store = new GeoStore({
store: new MemoryStore(),
index: new RTree()
});
var data = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Esri PDX"
},
"id": "esri-pdx",
"geometry": {
"type": "Point",
"coordinates": [ -122.67629563808441, 45.51646293140592 ]
}
},
{
"type": "Feature",
"properties": {
"name": "Barista"
},
"id": "barista",
"geometry": {
"type": "Point",
"coordinates": [ -122.67520129680635, 45.51926322043975 ]
}
}
]
}
store.add(data, function(err, results) {
console.log('Added...');
console.log(results);
});
var polygon = {
"type": "Polygon",
"coordinates": [
[ [-122.69290924072266, 45.54038305764738], [-122.72054672241211, 45.535453299886896], [-122.69479751586914, 45.51464736754301], [-122.67848968505858, 45.495398037299395], [-122.66836166381836, 45.495398037299395], [-122.66681671142577, 45.50321887154943], [-122.67127990722655, 45.51067773196122], [-122.67127990722655, 45.522585798722176], [-122.67110824584961, 45.53028260179986], [-122.69290924072266, 45.54038305764738] ]
]
}
store.within(polygon, function(err, results) {
console.log('Queried...');
console.log(results);
});
@invisiblefunnel
Copy link
Author

need to double check that the points do fall within the polygon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment