0.0.1 • Published 6 years ago

cgeo-calc v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

cgeo-calc

npm version

Adds some computational geometry algorithms to cgeo.

This augments all geometry types (in a TypeScript-friendly way) with several methods.

The following treat coordinates as lying on a Cartesian plane, any projections are ignored. Degrees as input coordinates produce nonsensical output.

  • getSimpleArea(), returns a number.
  • getSimpleCentroid(), returns a cgeo.Point.

Usage

import * as cgeo from 'cgeo';
import 'cgeo-calc';
import 'cgeo-wkt';

const line = new cgeo.LineString([{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 2 }]);

console.log(line.getSimpleCentroid().toWKT());

License

The MIT License

Copyright (c) 2017 BusFaster Ltd