geojson-lookup

1.1.4 • Public • Published

Build

Build

geojson-lookup

ITS ALL ABOUT SPEED and no alteration to your GEOJSONs

Lookup 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

  1. Require the module

var geoIndex = require("geojson-lookup");

  1. 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);

  1. 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());

  1. You can query by Lattitude and Longitude

geoQuery.getByPoint(LAT, LONG)

example:
var resByPoint = geoQuery.getByPoint(28.98066, 36.25222);

returns [ ARRAY_OF_FEATURES ]

Readme

Keywords

none

Package Sidebar

Install

npm i geojson-lookup

Weekly Downloads

0

Version

1.1.4

License

MIT

Last publish

Collaborators

  • ywadi