0.1.2 • Published 5 months ago
@envisim/geojson-utils v0.1.2
@envisim/geojson-utils
A TypeScript library with utility functions for working with GeoJSON data.
Installation
npm install @envisim/geojson-utils
Usage
Package exposes the following entry points:
@envisim/geojson-utils
@envisim/geojson-utils/geojson
@envisim/geojson-utils/type-guards
@envisim/geojson-utils/geodesic
@envisim/geojson-utils/plate-carree
@envisim/geojson-utils/rhumb
Default entry point
import { normalizeLongitude } from "@envisim/geojson-utils";
// Normalize the longitude to (-180, 180]
normalizeLongitude(150.0); // 150.0
normalizeLongitude(190.0); // -170.0
GeoJSON types
import type * as GJ from "@envisim/geojson-utils/geojson";
const p: GJ.Position = [0, 1];
Type guards
Type guards for GeoJSON types.
import { isCircle } from "@envisim/geojson-utils/type-guards";
const circle = { type: "Point", radius: 2, coordinates: [0, 0] };
isCircle(circle);
Geodesic segments
Geodesic segment operations using geographiclib-geodesic
.
import { distance } from "@envisim/geojson-utils/geodesic";
distance([0, 0], [1, 0]);
Platé carrée segments
Platé carrée segment operations.
import { distance } from "@envisim/geojson-utils/plate-carree";
distance([0, 0], [1, 0]);
Rhumb segments
Rhumb segment operations.
import { distance } from "@envisim/geojson-utils/rhumb";
distance([0, 0], [1, 0]);