You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GeoJSONs cannot be read when the properties are ordered differently than expected #227
For example, reading this GeoJSON results in a NullPointerException:
{"coordinates":[[[1,0.01],[1,-0.01],[2,-0.02],[3,-0.01],[3,0.01],[1,0.01]]],"type":"Polygon"}
This might not be desirable behaviour, since JSON objects are unordered collections afaik and some JSON parsers do not preserve the order of the properties when serializing/deserializing, but instead order them alphabetically, for example.
It also sounds like this is not intended by the standard (https://www.rfc-editor.org/rfc/rfc7946#section-1.2):
"The ordering of the members of any JSON object defined in this
document MUST be considered irrelevant, as specified by [RFC7159]."
Can you share the NPE stack trace please?
At least Spatial4J has multiple options for GeoJSON reading. I recall JTS has one as well, and off the top of my head I think it's exposed as a first class thing in Spatial4J. I'm certain there is a WKT option at least (not helpful to you I know).
java.lang.NullPointerException
at org.locationtech.spatial4j.io.GeoJSONReader.readShapeFromCoordinates(GeoJSONReader.java:300)
at org.locationtech.spatial4j.io.GeoJSONReader.readShape(GeoJSONReader.java:248)
at org.locationtech.spatial4j.io.GeoJSONReader.read(GeoJSONReader.java:48)
at org.locationtech.spatial4j.io.GeoJSONReader.read(GeoJSONReader.java:54)
at com.example.App.main(App.java:29)
No worries, I just ordered my JSONs. Just thought you might want to know.
Activity
dsmiley commentedon Jan 13, 2023
Can you share the NPE stack trace please?
At least Spatial4J has multiple options for GeoJSON reading. I recall JTS has one as well, and off the top of my head I think it's exposed as a first class thing in Spatial4J. I'm certain there is a WKT option at least (not helpful to you I know).
henleo commentedon Jan 14, 2023
java.lang.NullPointerException
at org.locationtech.spatial4j.io.GeoJSONReader.readShapeFromCoordinates(GeoJSONReader.java:300)
at org.locationtech.spatial4j.io.GeoJSONReader.readShape(GeoJSONReader.java:248)
at org.locationtech.spatial4j.io.GeoJSONReader.read(GeoJSONReader.java:48)
at org.locationtech.spatial4j.io.GeoJSONReader.read(GeoJSONReader.java:54)
at com.example.App.main(App.java:29)
No worries, I just ordered my JSONs. Just thought you might want to know.