How to use the jsts/org/locationtech/jts/geom/GeometryFactory function in jsts

To help you get started, we’ve selected a few jsts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bjornharrtell / topolis / src / utils.js View on Github external
import Coordinate from 'jsts/org/locationtech/jts/geom/Coordinate'
import GeometryFactory from 'jsts/org/locationtech/jts/geom/GeometryFactory'
import IsSimpleOp from 'jsts/org/locationtech/jts/operation/IsSimpleOp'
import RelateOp from 'jsts/org/locationtech/jts/operation/relate/RelateOp'
import DistanceOp from 'jsts/org/locationtech/jts/operation/distance/DistanceOp'
import Polygonizer from 'jsts/org/locationtech/jts/operation/polygonize/Polygonizer'
import BoundaryNodeRule from 'jsts/org/locationtech/jts/algorithm/BoundaryNodeRule'
import LengthIndexedLine from 'jsts/org/locationtech/jts/linearref/LengthIndexedLine'

const factory = new GeometryFactory()
const isSimpleOp = new IsSimpleOp()

function toLineString (coordinates) {
  return factory.createLineString(coordinates.map(c => new Coordinate(c[0], c[1])))
}

function toCoordinate (c) {
  return new Coordinate(c[0], c[1])
}

function toPoint (c) {
  return factory.createPoint(new Coordinate(c[0], c[1]))
}

function polyToCoordss (poly) {
  const cs = lineStringToCoords(poly.getExteriorRing())