JTS 1.15.1 upgrades for everyoneWe have had an exciting couple of months with Jim Hughes and myself taking a code-sprint to:
- Release JTS 1.15.1
- Help projects upgrade to JTS 1.15 starting with GeoTools, GeoServer, GeoWebCache, JAI-EXT, JAITools, GeoDB, HatBox, and java-vector-tile project.
JTS XYZM coordinatesThe 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.
CoordinateThe 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.
CoordinateSequenceThe 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.