Fork me on GitHub


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 WKTReader()
var a ='POINT (-20 0)')
var b ='POINT (20 0)')

Buffer A and B by 40 units

a = BufferOp.bufferOp(a, 40)
b = BufferOp.bufferOp(40)

Intersection of A and B

var intersection = OverlayOp.intersection(a, b)

Difference of A and B

var difference = OverlayOp.difference(a, b)

Union of A and B

var union = UnionOp.union(a, b)

Symmetric difference of A and B

var symDifference = OverlayOp.symDifference(a, b)