Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haoliangyu/geojson-offset
Add coordinate offest to GeoJSON
https://github.com/haoliangyu/geojson-offset
editing geojson
Last synced: about 1 month ago
JSON representation
Add coordinate offest to GeoJSON
- Host: GitHub
- URL: https://github.com/haoliangyu/geojson-offset
- Owner: haoliangyu
- License: mit
- Created: 2016-12-14T00:26:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-19T05:13:53.000Z (almost 8 years ago)
- Last Synced: 2024-10-01T09:14:23.415Z (about 1 month ago)
- Topics: editing, geojson
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# geojson-offset
Add coordinate offest to the GeoJSON
## Installation
``` bash
npm install geojson-offset
```## Usage
Noted this function will **UPDATE** the input geojson. If there is a need to return a copy of original geojson, please let me know by openning an issue.
`geojson-offset` supports all GeoJSON types:
* FeatureCollection
* Feature
* Geometery
* Point
* MultiPoint
* LineString
* MultiLineString
* Polygon
* MultiPolygon``` javascript
const offset = require('geojson-offset').offset;
const randomOffset = require('geojson-offset').randomOffset;let geojson = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [-78, 48]
},
properties: {}
}
]
};/**
* Pass the geojson and the x/y coordinate offset
*/
gejson = offset(geojson, -1, 1);/**
* Pass the geojson and x/y coordinate offset range. The same offset will be
* applied to all features in the input GeoJSON.
*/
geojson = randomOffset(geojson, [0, 10], [-10, 10]);
```