Thursday, 2 August 2018

JTS 1.15.1 and XYZM development

One of the things I have been working on with the LocationTech crew is the JTS Topology Suite project with a recent release of JTS 1.15.1 and looking into XYZM coordinate support.

JTS logo

JTS 1.15.1 upgrades for everyone

We have had an exciting couple of months with Jim Hughes and myself taking a code-sprint to:

JTS XYZM coordinates

The other bit of RnD I have been working has been Explicit support for XYZM coordinates. Previously this has been left as an exercise for the reader, designed for in the API but something for downstream applications to figure out. The motivation to address this in JTS is to support a WKTReader / WKT Writer enhancements Felix Obermaier has been working on, but now that it has started a wide range of projects have expressed interest.


The design trade off is between treating JTS Coordinate as a data object, managed in arrays and created and deleted as required. JTS itself only makes use of coordinate.x and coordinate.y fields (which are public as befitting a data structure).

Here is what adding XYZM support looks like for Coordinate:

Methods have beed added for getX(), getY(), getZ() and getM() - and the methods return NaN for anything they do not support.


The cloud projects at LocationTech, such as GeoMesa, run into a bit of trouble with this approach as creating and deleting Coordinate constantly during processing causes a lot of memory pressure.

The alternative provided by JTS is to manage information as a CoordinateSequence, such as Packed CoordinateSequence which is backed by an array of doubles. There is lots of room for JTS to improve in this area and we have watched downstream projects come up with all kinds of fascinating CoordinateSequence implementations we can learn from.

Here is what adding XYZM support looks like for CoordinateSequence:

The key addition here is clarifying the definition of dimension (the number of ordinates in each coordinate) and adding measures (the number of measures included in dimension for each coordinate). For for XY data dimension is 2 and measures is 0. For XYZM data dimension is 4 and measures is 1.

JTS Topology Suite at FOSS4G 2018

If you are interested in hearing more about JTS Topology Suite join Rob Emanuele and myself at FOSS4G 2018 later this month for State of JTS 2018

Post a Comment