Skip to content

MultiLineString is converted to Geometry when writing #67

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

Closed
ErickChacon opened this issue Jun 10, 2023 · 1 comment
Closed

MultiLineString is converted to Geometry when writing #67

ErickChacon opened this issue Jun 10, 2023 · 1 comment

Comments

@ErickChacon
Copy link
Contributor

A MultiLineString is currently being saved as a Polygon. This creates problems when interfacing with other geometry packages because MultiLineStrings are saved as invalid Polygons. So we obtain errors when trying to load this invalid Polygons. This is happening in our GeoTables.jl when intarfecing with GeoJSON.jl (JuliaEarth/GeoTables.jl#24).

Let's consider the following geometry:

d = """{
    "type": "Feature",
    "id": "1",
    "bbox": [-180.0, -90.0, 180.0, 90.0],
    "geometry": {"type": "MultiLineString", "coordinates": [[[3.75, 9.25], [-130.95, 1.52]], [[23.15, -34.25], [-1.35, -4.65], [3.45, 77.95]]]},
    "properties": {"title": "Dict 1"}
}"""
featu = GJS.read(d)

Given that featu is a GeoJSONT, writing to a file works well because it does not to use the _lower function.

GJS.write("nolower.json", featu)
# {"type":"Feature","id":"1","bbox":[-180.0,-90.0,180.0,90.0],"geometry":{"type":"MultiLineString","coordinates":[[[3.75,9.25],[-130.95,1.52]],[[23.15,-34.25],[-1.35,-4.65],[3.45,77.95]]]},"properties":{"title":"Dict 1"}}

However, if we use the _lower function, the MultiLineString is saved as a Polygon.

featul = GJS._lower(featu)
JSON3.write("lower.json", featul)
# {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[3.75,9.25],[-130.95,1.52]],[[23.15,-34.25],[-1.35,-4.65],[3.45,77.95]]]},"properties":{"title":"Dict 1"},"bbox":[-180.0,-90.0,180.0,90.0]}

The outputs are different when the geometry type should actually be MultiLineString.

@juliohm
Copy link
Member

juliohm commented Jun 16, 2023

Fixed on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants