-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing and reading WKB loses M dimension #733
Comments
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 When thinking of a fix my first thought was to do an When looking at the |
M coordinate is read as Z coordinate after writing/reading.
Referring to WKTReader/WKTWriter I added the EnumSet<Ordinate> ordinateFlags. The WKBWriter uses these ordinateFlags to set the correct flags on the byte stream.
Referring to WKTReader/WKTWriter I added the EnumSet<Ordinate> ordinateFlags. The WKBWriter uses these ordinateFlags to set the correct flags on the byte stream. Signed-off-by: Kai Winter <[email protected]>
M coordinate is read as Z coordinate after writing/reading.
Referring to WKTReader/WKTWriter I added the EnumSet<Ordinate> ordinateFlags. The WKBWriter uses these ordinateFlags to set the correct flags on the byte stream. Signed-off-by: Kai Winter <[email protected]>
* Unit test for #733 M coordinate is read as Z coordinate after writing/reading. * Fixed lost M coordinates (#733) Referring to WKTReader/WKTWriter I added the EnumSet<Ordinate> ordinateFlags. The WKBWriter uses these ordinateFlags to set the correct flags on the byte stream. Signed-off-by: Kai Winter <[email protected]> * Fixed Javadoc and exception message * Fixed handling of XYZM coordinates Signed-off-by: Kai Winter <[email protected]> # Conflicts: # modules/core/src/main/java/org/locationtech/jts/io/WKBWriter.java --------- Signed-off-by: Kai Winter <[email protected]>
what's the situation. is this live? What do I need to do to get this to work? Modify the source locally? I see there's a pull request but it seems to have been lost in some stuff about copyright notices. |
ok, i can get round it with but clearly that's not an optimal solution - there's no reason for the M to require the dimensions to be set in the first place, surely. You're just making hurdles unnecessarily - if i want to createXYM then obviously i want 3 dimensions at that point |
I have not seen a PR but would like to see this addressed. There is some utility methods to determine hasZ or hasM. |
There was a PR (#734) which has already been merged. The change should have been released with 1.20.0. This issue could be closed as resolved, IMHO. |
Hi Kai,
so what is the expected behaviour? I'm on 1.20.0 and I have to specify both
a dimension and the XYM
from the api docs:
Creates a writer that writes Geometry
<https://locationtech.github.io/jts/javadoc/org/locationtech/jts/geom/Geometry.html>s
with the given output dimension (2 to 4). The output follows the following
rules:
- If the specified *output dimension is 3* and the *z is measure flag is
set to false*, the Measure value of coordinates will be written if it is
present (i.e. if it is not Double.NaN)
but it doesn't say what the z is measure flag is (there's no isMeasure in
the source that I can see) or indeed say anything about M measures.
And one would have thought seting XYM as the ordinates would be sufficient
to tell the system that we actually wanted all three in the output. Instead
there's a check that says that even you've just asked for XYM but failed to
set dimensions to 3, it's going to (silently) ignore that request.
But more importantly, the "principle of least suprise" would be that the
linestring.toString method would select the most suitable output format
from the get-go.
Is the current behaviour really the behaviour you want? Or is it pehaps
what we really want but rocking the boat could cause too many problems for
too many people? In which case how about a WktWriter.createWithAutoFormat
that did the most sensible thing (display all dimensions if they exist)?
Tim
…On Mon, 27 Jan 2025 at 20:05, Kai Winter ***@***.***> wrote:
There was a PR (#734 <#734>)
which has already been merged. The change should have been released with
1.20.0. This issue could be closed as resolved, IMHO.
—
Reply to this email directly, view it on GitHub
<#733 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJWHJ7XFLECCHBT2CF7UXL2M2GPTAVCNFSM6AAAAABV6MWW6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJWG43TQOJTGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Tim Pigden
Optrak Distribution Software Limited
+44 (0)1992 517100
http://www.linkedin.com/in/timpigden
http://optrak.com
Optrak Distribution Software Ltd is a limited company registered in England
and Wales.
Company Registration No. 2327613 Registered Offices: Suite 6,The Maltings,
Hoe Lane, Ware, SG12 9LR England
This email and any attachments to it may be confidential and are intended
solely for the use of the individual to whom it is addressed. Any views or
opinions expressed are solely those of the author and do not necessarily
represent those of Optrak Distribution Software Ltd. If you are not the
intended recipient of this email, you must neither take any action based
upon its contents, nor copy or show it to anyone. Please contact the sender
if you believe you have received this email in error.
|
This library has its rough edges, without question. But keep in mind this is open source software and we can all contribute to make it continuously better. I'm not the right person to answer your question, I'm afraid. Maybe you should start a discussion or, if you have a good solution to your specific problem, describe it in an issue or a PR. |
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.In
WKBReader.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.
The text was updated successfully, but these errors were encountered: