Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nestrom/geojson-lookup
Lookup Geojson feature collections by indexing them by feature properties and by a GeoIndex for polygons to find polygons by a point
https://github.com/nestrom/geojson-lookup
Last synced: 3 months ago
JSON representation
Lookup Geojson feature collections by indexing them by feature properties and by a GeoIndex for polygons to find polygons by a point
- Host: GitHub
- URL: https://github.com/nestrom/geojson-lookup
- Owner: nestrom
- License: mit
- Created: 2017-02-13T11:52:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-15T08:13:00.000Z (almost 8 years ago)
- Last Synced: 2024-04-26T17:45:08.537Z (9 months ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-jordan - geojson-lookup - Lookup Geojson feature collections by indexing them by feature properties (INDEX TABLES) and by a Geometry (R-TREE) all in memory. (NodeJS / Gists)
README
![Build](https://api.travis-ci.org/nestrom/geojson-lookup.svg?branch=master)
![Build](https://nodei.co/npm/geojson-lookup.png)
# geojson-lookup
ITS ALL ABOUT SPEED and no alteration to your GEOJSONsLookup Geojson feature collections by indexing them by feature properties (INDEX TABLES) and by a Geometry (R-TREE) all in memory.
###Usage
1) Install through npm
`npm install geojson-lookup`
2) Require the module
`var geoIndex = require("geojson-lookup");`
3) Initialize by passing Properties to indexBy and by passing a geoJson
`var geo = geoIndex.buildIndex([ PROPERTIES_TO_INDEX ],GEOJSON_OBJECT);`
example:
`var geo = geoIndex.buildIndex(["areaType","parentId"],geojs);`
4) Query your polygon by indexed property
- Start by creating an instance of the Querying mechanism `var geoQuery = new geoIndex.Queries();`
- Call the query method on the instantiated object as `.query(INDEXED_PROPERTY, OPERATOR("==" or "!="), VALUE_TO_QUERY)`
- Now you can chain `.and()` , `or.()` to your query with the same parameter as `.query()`
- Once done call the method `.get()` to get your results as an `[ ARRAY_OF_FEATURES ]`
example:
`var resByProp = (geoQuery.query("areaType", "!=" ,'1').and("parentId", "=", "null").or("areaType","=","3").get());`
5) You can query by Lattitude and Longitude
`geoQuery.getByPoint(LAT, LONG)`
example:
`var resByPoint = geoQuery.getByPoint(28.98066, 36.25222);`
returns `[ ARRAY_OF_FEATURES ]`