Fork me on GitHub

JSTS

JSTS is a JavaScript library of spatial predicates and functions for processing geometry conforming to the Simple Features Specification for SQL published by the Open Geospatial Consortium. JSTS is also a JavaScript port of the well established Java library JTS with a built in parser for OpenLayers interopability.

JSTS is licensed with a dual BSD/EPL liceence. For more details go to the project page.

Example use

NOTE: OpenLayers specific code omitted. Please refer to this page for a complete example of usage with OpenLayers 3.

Read two point geometries A and B from WKT format

var reader = new jsts.io.WKTReader()
var a = reader.read('POINT (-20 0)')
var b = reader.read('POINT (20 0)')

Buffer A and B by 40 units

a = a.buffer(40)
b = b.buffer(40)

Intersection of A and B

var intersection = a.intersection(b)

Difference of A and B

var difference = a.difference(b)

Union of A and B

var union = a.union(b)

Symmetric difference of A and B

var symDifference = a.symDifference(b)