OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.68k stars 2.47k forks source link

Support for GML ArcByCenterPoint tag #10374

Closed miladmoradi89 closed 2 weeks ago

miladmoradi89 commented 2 weeks ago

Feature description

Dear community,

I was working with GML 3 data and I realized that GDAL driver has only level SF0 support to write GML 3.

I think it is not well-developed for GML yet. I have already requested the development of OrientableCurve tag and I think someone is working on it.

I think ArcByCenterPoint is another tag that is not yet supported by GDAL or its python package. May I ask you to add support for this tag?

This is the xsd description for this tag: http://www.datypic.com/sc/niem21/e-gml32_ArcByCenterPoint.html

CircleByCenterPoint that is almost similar to this tag is supported but I was not able to read ArcByCenterPoint tag!!

`

1.0 1.0 1.0 1.0 1.0 ` ![image](https://github.com/OSGeo/gdal/assets/33375968/2c74127a-940b-4670-9308-86c7e2fa5da6) ### Additional context _No response_
rouault commented 2 weeks ago

This works for me (using latest GDAL version)

but I was not able to read ArcByCenterPoint tag!!

>>>f rom osgeo import ogr
>>> g = ogr.CreateGeometryFromGML("""<gml:ArcByCenterPoint numArc="1"> <gml:pos>1.0 1.0</gml:pos> <gml:radius uom="">1.0</gml:radius> <gml:startAngle uom="">1.0</gml:startAngle> <gml:endAngle uom="">1.0</gml:endAngle> </gml:ArcByCenterPoint>""")
>>> g.ExportToWkt()
'CIRCULARSTRING (1.99984769515639 1.01745240643728,1.99984769515639 1.01745240643728,1.99984769515639 1.01745240643728)'

On the write side, arc geometries are written using for arcs, or for full circle.

miladmoradi89 commented 2 weeks ago

Do you mean it works with GDAL python library from OSGEO or do you mean in the GDAL command line tool? In fact, I was trying with both but I could not make it work!

Maybe it was not well-structured!

rouault commented 2 weeks ago

Do you mean it works with GDAL python library from OSGEO or do you mean in the GDAL command line tool?

it should work with both. I was just using Python as the fastest way to reproduce

Maybe it was not well-structured!

Perhaps the geometry is nested at a place where the OGR GML driver doesn't expect it? Can you manage to provide a minimum example that could reproduce an issue?

rouault commented 2 weeks ago

closing. Re-open if there is a remaining issue

miladmoradi89 commented 2 weeks ago

Today I have access to my files, this is an example of circlebycenterpoint that IS READABLE by my GDAL after I removed OrientableCurve tag and baseCurve tag that came after it:


<geometry>
    <gml:surfaceProperty xlink:href="#s611">
        <gml:Surface srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="s611">
            <gml:patches>
                <gml:PolygonPatch>
                    <gml:exterior>
                        <gml:Ring>
                            <gml:curveMember xlink:href="#cc754">
                                <gml:CompositeCurve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="cc754">
                                    <gml:curveMember xlink:href="#oc984">
                                        <gml:OrientableCurve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="oc984" orientation="+">
                                            <gml:baseCurve xlink:href="#c767">
                                                <gml:Curve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="c767">
                                                    <gml:segments>
                                                        <gml:CircleByCenterPoint>
                                                            <gml:pos>44.4725 -63.620281</gml:pos>
                                                            <gml:radius uom="m">1481599.99297019</gml:radius>
                                                        </gml:CircleByCenterPoint>
                                                    </gml:segments>
                                                </gml:Curve>
                                            </gml:baseCurve>
                                        </gml:OrientableCurve>
                                    </gml:curveMember>
                                </gml:CompositeCurve>
                            </gml:curveMember>
                        </gml:Ring>
                    </gml:exterior>
                </gml:PolygonPatch>
            </gml:patches>
        </gml:Surface>
    </gml:surfaceProperty>
</geometry>

In addition, I tried this example for arcbycenterpoint:

        <geometry>
    <gml:surfaceProperty xlink:href="#s611">
        <gml:Surface srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="s611">
            <gml:patches>
                <gml:PolygonPatch>
                    <gml:exterior>
                        <gml:Ring>
                            <gml:curveMember xlink:href="#cc754">
                                <gml:CompositeCurve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="cc754">
                                    <gml:curveMember xlink:href="#oc984">
                                            <gml:Curve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="c767">
                                                    <gml:segments>
                                                        <gml:ArcByCenterPoint>
                                                            <gml:pos>44.4725 -63.620281</gml:pos>
                                                            <gml:radius uom="m">1481599.99297019</gml:radius>
                                                            <gml:startAngle uom="">0</gml:startAngle>
                                                            <gml:endAngle uom="">180.0</gml:endAngle>
                                                        </gml:ArcByCenterPoint>
                                                    </gml:segments>
                                                </gml:Curve>

                                    </gml:curveMember>
                                </gml:CompositeCurve>
                            </gml:curveMember>
                        </gml:Ring>
                    </gml:exterior>
                </gml:PolygonPatch>
            </gml:patches>
        </gml:Surface>
    </gml:surfaceProperty>
</geometry>

This is not working while when I change endAngle to "360" it works but with "180" or "180.0" it does not work for me.

Maybe my tags are not 100% valid.

rouault commented 2 weeks ago

Today I have access to my files, this is an example of circlebycenterpoint that IS READABLE by my GDAL after I removed OrientableCurve tag and baseCurve tag that came after it:

this is expected if you don't use a version that has the e20037f47b0e173e18bc61bb9b08d45c9cdc6157 fix in it. Works for me with GDAL master

This is not working while when I change endAngle to "360" it works

this is also expected. A Ring must be closed. So if you use only a single , its endAngle - startAngle must be equal to 360 to have a full circle.

miladmoradi89 commented 2 weeks ago

Yes, you are right.

I have added two arcs that make a circle and it is supported by GDAL.

        <geometry>
    <gml:surfaceProperty xlink:href="#s611">
        <gml:Surface srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="s611">
            <gml:patches>
                <gml:PolygonPatch>
                    <gml:exterior>
                        <gml:Ring>
                            <gml:curveMember xlink:href="#cc754">
                                <gml:CompositeCurve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="cc754">
                                    <gml:curveMember xlink:href="#oc984">
                                            <gml:Curve srsName="http://www.opengis.net/def/crs/EPSG/0/4326" gml:id="c767">
                                                    <gml:segments>
                                                        <gml:ArcByCenterPoint>
                                                            <gml:pos>44.4725 -63.620281</gml:pos>
                                                            <gml:radius uom="m">1481599.99297019</gml:radius>
                                                            <gml:startAngle uom="">0</gml:startAngle>
                                                            <gml:endAngle uom="">180.0</gml:endAngle>
                                                        </gml:ArcByCenterPoint>
                                                        <gml:ArcByCenterPoint>
                                                            <gml:pos>44.4725 -63.620281</gml:pos>
                                                            <gml:radius uom="m">1481599.99297019</gml:radius>
                                                            <gml:startAngle uom="">180.0</gml:startAngle>
                                                            <gml:endAngle uom="">360.0</gml:endAngle>
                                                        </gml:ArcByCenterPoint>
                                                    </gml:segments>
                                                </gml:Curve>

                                    </gml:curveMember>
                                </gml:CompositeCurve>
                            </gml:curveMember>
                        </gml:Ring>
                    </gml:exterior>
                </gml:PolygonPatch>
            </gml:patches>
        </gml:Surface>
    </gml:surfaceProperty>
</geometry>