0.1.13 • Published 2 months ago

geojson-offset-ts v0.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

geojson-offset-ts

jsdelivr CDN NPM Downloads Open in unpkg npm version Open in Gitpod Twitter Follow

Add coordinate offest to the GeoJSON. This fork is rewritten in typescript.

Installation

npm install geojson-offset-ts
yarn add geojson-offset-ts

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-ts supports all GeoJSON types:

  • FeatureCollection
  • Feature
  • Geometery
    • Point
    • MultiPoint
    • LineString
    • MultiLineString
    • Polygon
    • MultiPolygon

But TopoJSON does not supported. Please convert to geojson by topojson.feature before use.

import { offset } from 'geojson-offset';
import { randomOffset } from 'geojson-offset';

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]);
0.1.13

2 months ago

0.1.11

6 months ago

0.1.12

6 months ago

0.1.10

9 months ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago