
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
geojson-geometries-lookup
Advanced tools
⚡️ Fast geometry in geometry lookup for large GeoJSONs.
Coded with ❤️ by Simone Primarosa.
With this package you can perform the following operations (and more) on a given GeoJSON.
$ npm install --save geojson-geometries-lookup
Do you use geojson-geometries-lookup in your application? Please open a Pull Request to include it here.
We would love to have it in our list:
const GeoJsonGeometriesLookup = require('geojson-geometries-lookup');
const geojson = {type: 'FeatureCollection',
features: [{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [102.0, 0.5]
},
properties: {prop0: 'value0'}
}, {
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0]]
},
properties: {prop1: 'value1'}
}, {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]
]
},
properties: {prop2: 'value2'}
}]
};
const glookup = new GeoJsonGeometriesLookup(geojson);
const point1 = {type: "Point", coordinates: [102.0, 0.5]};
glookup.getContainers(point1);
// => {
// type: 'FeatureCollection',
// features: [{
// type: 'Feature',
// geometry: {
// type: 'Point',
// coordinates: [102.0, 0.5]
// },
// properties: {prop0: 'value0'}
// }]
// }
glookup.countContainers(point1);
// => 1
glookup.getContainers(point1, {ignorePoints: true});
// => {
// type: 'FeatureCollection',
// features: []
// }
glookup.countContainers(point1, {ignorePoints: true});
// => 0
const point2 = {type: "Point", coordinates: [101.0, 0.0]};
glookup.getContainers(point2);
// => {
// type: 'FeatureCollection',
// features: [{
// type: 'Feature',
// geometry: {
// type: 'LineString',
// coordinates: [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0]]
// },
// properties: {prop1: 'value1'}
// }, {
// type: 'Feature',
// geometry: {
// type: 'Polygon',
// coordinates: [
// [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]
// ]
// },
// properties: {prop2: 'value2'}
// }]
// }
glookup.getContainers(point2, {ignorePolygons: true});
// => {
// type: 'FeatureCollection',
// features: [{
// type: 'Feature',
// geometry: {
// type: 'LineString',
// coordinates: [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0]]
// },
// properties: {prop1: 'value1'}
// }]
// }
glookup.hasContainers(point1, {ignorePoints: true, ignoreLines: true});
// => true
const poly1 = {
type: 'Polygon',
coordinates: [
[[100.0+0.25, 0.0+0.25], [101.0-0.25, 0.0+0.25], [101.0-0.25, 1.0-0.25], [100.0+0.25, 1.0-0.25], [100.0+0.25, 0.0+0.25]]
]
}
glookup.getContainers(poly1, {ignorePoints: true, ignoreLines: true});
// => {
// type: 'FeatureCollection',
// features: [{
// type: 'Feature',
// geometry: {
// type: 'Polygon',
// coordinates: [
// [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]
// ]
// },
// properties: {prop2: 'value2'}
// }]
// }
Create an instance of the GeoJSON lookup class.
Param | Type | Description |
---|---|---|
geoJson | Object | The GeoJSON for which create the lookup data. |
[options] | Object | Optional options. |
options.ignorePoints | boolean | If true the extractor will ignore geometries of type Point. |
options.ignoreLines | boolean | If true the extractor will ignore geometries of type LineString. |
options.ignorePolygon | boolean | If true the extractor will ignore geometries of type Polygon. |
number
Iterate on each geometry that completely contains the geometry provided.
Kind: instance method of GeoJsonGeometriesLookup
Returns: number
- The number of geometries that completely contains the
geometry provided iterated. The interiors of both geometries must intersect and,
the interior and boundary of the secondary (geometry b) must not intersect
the exterior of the primary (geometry a).
Param | Type | Description |
---|---|---|
geometry | Object | The geometry of type Point, LineString or Polygon for which to check if a container exists. |
[options] | Object | Optional options. |
options.limit | number | If greater than 0 it will limit the number of results on which iterate. |
options.ignorePoints | boolean | If true will ignore geometries of type Point. |
options.ignoreLines | boolean | If true will ignore geometries of type LineString. |
options.ignorePolygon | boolean | If true will ignore geometries of type Polygon. |
Object
Gets the geometries that completely contains the geometry provided.
Kind: instance method of GeoJsonGeometriesLookup
Returns: Object
- A FatureCollection of geometries that completely contains
the geometry provided. The interiors of both geometries must intersect
and, the interior and boundary of the secondary (geometry b) must not
intersect the exterior of the primary (geometry a).
Param | Type | Description |
---|---|---|
geometry | Object | The geometry of type Point, LineString or Polygon for which to count containers. |
[options] | Object | Optional options. |
options.limit | number | If greater than 0 it will limit the number of results returned. |
options.ignorePoints | boolean | If true will ignore geometries of type Point. |
options.ignoreLines | boolean | If true will ignore geometries of type LineString. |
options.ignorePolygon | boolean | If true will ignore geometries of type Polygon. |
boolean
Checks if there is at least one geometry that completely contains the geometry provided.
Kind: instance method of GeoJsonGeometriesLookup
Returns: boolean
- True if there is at least one geometry that completely
contains the geometry provided. The interiors of both geometries must
intersect and, the interior and boundary of the secondary (geometry b)
must not intersect the exterior of the primary (geometry a).
Param | Type | Description |
---|---|---|
geometry | Object | The geometry of type Point, LineString or Polygon for which to check if a container exists. |
[options] | Object | Optional options. |
options.ignorePoints | boolean | If true will ignore geometries of type Point. |
options.ignoreLines | boolean | If true will ignore geometries of type LineString. |
options.ignorePolygon | boolean | If true will ignore geometries of type Polygon. |
number
Counts the number of geometries that completely contains the geometry provided.
Kind: instance method of GeoJsonGeometriesLookup
Returns: number
- The number of geometries that completely contains the
geometry provided. The interiors of both geometries must intersect and,
the interior and boundary of the secondary (geometry b) must not intersect
the exterior of the primary (geometry a).
Param | Type | Description |
---|---|---|
geometry | Object | The geometry of type Point, LineString or Polygon for which to count containers. |
[options] | Object | Optional options. |
options.limit | number | If greater than 0 it will stop counting when this number of containers has been found. |
options.ignorePoints | boolean | If true will ignore geometries of type Point. |
options.ignoreLines | boolean | If true will ignore geometries of type LineString. |
options.ignorePolygon | boolean | If true will ignore geometries of type Polygon. |
Contributions are REALLY welcome and if you find a security flaw in this code, PLEASE report it.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the license file for details.
FAQs
Fast geometry in geometry lookup for large GeoJSONs
The npm package geojson-geometries-lookup receives a total of 5,699 weekly downloads. As such, geojson-geometries-lookup popularity was classified as popular.
We found that geojson-geometries-lookup demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.