Open kaiwinter opened 3 years ago
I think you've identified a bug here. Any interest in working on it?
The Contributing guide has some info about that here: https://github.com/locationtech/jts/blob/master/CONTRIBUTING.md
Yes sure. Currently I'm using a workaround with a GeometryFactory
but I would love to get rid of it as it most probably impacts performance.
When thinking of a fix my first thought was to do an instanceof
check of the result of g.getCoordinate()
in writeGeometry
. But that would be pretty ugly. Is there a better way to get the subtype of the Coordinate
(whether it is CoordinateXYM
)?
When looking at the WKTWriter
there is the method setOutputOrdinates()
. I was using this method to correctly write XYM coordinates as text, so I think this pattern may be applied to the WTBWriter
as well. Do you have other ideas?
When using
WKBWriter
to write a Geometry which has XYM coordinates and afterwards usingWKBReader
for reading the result. The Geometry has XYZ coordinates instead of XYM coordinates.Here is small example:
When running this you get the following output:
The
geometryBefore
has XYM coordinates. ThegeometryAfter
has XYZ coordinates. InWKBReader.readGeometry
are two variables evaluatedhasZ
andhasM
. In the above examplehasZ
is true andhasM
is false. I think this is becauseWKBWriter.writeGeometryType
always writes0x80000000
regardless of the coordinate type. DebuggingWKBReader.readGeometry
makes me think0x40000000
should be used for M coordinates inWKBWriter.writeGeometryType
.What do you think? Can this be improved or did I just misunderstood how this should work.