Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
geojson-utils
Advanced tools
Here you will find some functions to help you manipulate and work with GeoJSON objects.
Some algorithms adapted from bjwbell/canvas-geolib
Load up in a browser OR npm install geojson-utils
var gju = require('geojson-utils');
You now have an object named gju
that contains all of the helper functions.
Remember, GeoJSON coordinates are ordered [x,y] or [longitude,latitude] to comply with the Open Geospatial Consortium's recommendation!
gju.linesIntersect({ "type": "LineString", "coordinates": [[0, 2], [5, 2]] },
{ "type": "LineString", "coordinates": [[3, 0], [3, 4], [4,4], [4,0]] })
// [{"type":"Point","coordinates":[2,3]},{"type":"Point","coordinates":[2,4]}]
gju.linesIntersect({ "type": "LineString", "coordinates": [[0, 2], [5, 2]] },
{ "type": "LineString", "coordinates": [[0, 0], [5, 0]] })
// false
gju.pointInPolygon({"type":"Point","coordinates":[3,3]},
{"type":"Polygon", "coordinates":[[[0,0],[6,0],[6,6],[0,6]]]})
// [{"type":"Point","coordinates":[3,3]}]
gju.pointInPolygon({"type":"Point","coordinates":[-1,-1]},
{"type":"Polygon", "coordinates":[[[0,0],[6,0],[6,6],[0,6]]]})
// false
If you retrieve a bunch of results from a bounding box query (common with R-tree geo DBs), but you want to filter the rectangular result set by circular radius:
// get the center of the original bounding box
var center = gju.rectangleCentroid({
"type": "Polygon",
"coordinates": [[[-122.677, 45.523], [-122.675, 45.524]]]
}),
// radius (in meters)
radius = 100;
for (var i in geometryObjectsWithinBBox) {
if (gju.geometryWithinRadius(geometryObjectsWithinBBox[i], center, radius)) {
// ... do stuff with objects inside the circle
}
}
Uses the Haversine distance formula to calculate the distance between two points on the Earth's curved surface (as the crow flies, no hills!). Returns the distance in meters.
gju.pointDistance({type: 'Point', coordinates:[-122.67738461494446, 45.52319466622903]},
{type: 'Point', coordinates:[-122.67652630805969, 45.52319466622903]})
// 66.86677669313518
The MIT License
Copyright (c) 2010 Max Ogden
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
GeoJSON Utilities for JavaScript
The npm package geojson-utils receives a total of 9,050 weekly downloads. As such, geojson-utils popularity was classified as popular.
We found that geojson-utils 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.