Skip to content
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

Geometry supported by ogr2ogr not supported by gdal-next #13

Open
ekulno opened this issue Sep 21, 2020 · 4 comments
Open

Geometry supported by ogr2ogr not supported by gdal-next #13

ekulno opened this issue Sep 21, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@ekulno
Copy link

ekulno commented Sep 21, 2020

I have a GML file which I want to convert to another format. I am able to do this with the ogr2ogr tool, but with gdal-next I get an error when I try to do the same thing.

With ogr2ogr:

$ ogr2ogr -f GeoJSON test.json test.gml && cat test.json
{
"type": "FeatureCollection",
"name": "_",
"features": [
{ "type": "Feature", "properties": { "gml_id": "" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ], [ 7.0, 8.0 ], [ 1.0, 2.0 ] ] ] } }
]
}

With gdal-next:

const gdal = require("gdal-next");
const dataset = gdal.open('test.gml', 'r', "GML");
const feature = dataset.layers.get(0).features.get(0);
const geometry = feature.getGeometry();

I get the following error for the getGeometry call:

Error: Tried to create unsupported geometry type

test.gml has the following content.

<CityModel>
    <cityObjectMember>
        <_ gml:id="">
            <gml:Polygon
                xmlns:gml="http://www.opengis.net/gml">
                <gml:exterior>
                    <gml:Ring>
                        <gml:curveMember>
                            <gml:Curve>
                                <gml:segments>
                                    <gml:LineStringSegment>
                                        <gml:posList srsDimension="2">1 2 3 4</gml:posList>
                                    </gml:LineStringSegment>
                                    <gml:Arc>
                                        <gml:posList srsDimension="2">3 4 5 6 7 8</gml:posList>
                                    </gml:Arc>
                                    <gml:LineStringSegment>
                                        <gml:posList srsDimension="2">7 8 1 2</gml:posList>
                                    </gml:LineStringSegment>
                                </gml:segments>
                            </gml:Curve>
                        </gml:curveMember>
                    </gml:Ring>
                </gml:exterior>
            </gml:Polygon>
        </_>
    </cityObjectMember>
</CityModel>
@yocontra
Copy link
Owner

yocontra commented Sep 21, 2020

Hmm, that is odd since we support GML in our list of bundled drivers: https://github.com/contra/node-gdal-next/blob/master/deps/libgdal/gyp-formats/ogr_gml.gyp

I can look into it - I just read through the driver docs and saw this:

The reading part of the driver only works if OGR is built with Xerces linked in. When Xerces is unavailable, read support also works if OGR is built with Expat linked in. XML validation is disabled by default. GML writing is always supported, even without Xerces or Expat.

Issue may be that we aren't linking it with libexpat correctly.

@yocontra yocontra added the bug Something isn't working label Sep 21, 2020
@mmomtchev
Copy link
Contributor

@Ysgorg, I just tried to load your geometry with the latest version of node-gdal-next and it works fine for me - I get the feature geometry. I just had to modify the code to load a JSON (the gdal.open call), but since you report a geometry error and not a dataset opening error, I guess it was correct on your side. Can you try again and report your findings?

@ekulno
Copy link
Author

ekulno commented Nov 11, 2020

When I submitted this ticket I was using version 2.1.0 of the gdal-next package. I now upgraded to 2.4.0 and reran the example code given in the ticket description. I got the same result.

@mmomtchev , I'm not sure what you mean by modifying the code to load JSON. In my use-case I have a large amount of input data and manually rewriting it to JSON is not an option.

@mmomtchev
Copy link
Contributor

@Ysgorg, I am sorry, in fact I tried loading the JSON.
This is a duplicate of #8, add support for curve geometries.
ogr2ogr silently eliminates the curve geometry, that's why it creates the impression that it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants