This project provides the basic functions for geometries.
- Construct
Point
,LineString
,Polygon
,MultiPoint
,MultiLineString
,MultiPolygon
andGeometryCollection
with will defined APIs. - Calculate geometry self information such as area, perimeter etc.
- Converts geometry format between
wkt
,wkb
,json
and Ginkgoch geometry classes. - Support popular geo-spatial analyzing methods.
yarn add ginkgoch-geom
Visit https://ginkgoch.github.io/node-geom for detail.
Full demo, please play on RunKit at: https://runkit.com/ginkgoch/geometry-demo
This is about how to use ginkgoch-geom
library to create your own geometries and convert to various formats. The first on is about location. I will create a point that is located to a city in LA. It is easy to convert to GeoJSON format.
const geom = require("ginkgoch-geom")
const point = new geom.Point(-119.698189, 34.420830);
point.toJSON();
Except point, it is also allow to create other geometries such as line, polygon or multi-point, multi-line, multi-polygon etc.
const getJSON = require("async-get-json");
const geomURL = 'https://github.com/ginkgoch/map-data-demo/raw/master/json/geometries.json';
const geomJson = (await getJSON(geomURL));
geom.FeatureCollection.create(geomJson).toJSON();
For more demos about converting to well-known text (WKT), well-known binary (WKB) or spatial analyzing, please try on RunKit directly. If anything interesting, feel free to contact me with ginkgoch@outlook.com, I'm glad to help.
The is the low-level library in my mapping echo system
. Please watch me on github for more function with map support on Node.js.
Happy Mapping!