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

aixm:ElevatedPoint not handled by CreateGeometryFromGML #11582

Open
vlapra opened this issue Jan 6, 2025 · 5 comments · May be fixed by #11644
Open

aixm:ElevatedPoint not handled by CreateGeometryFromGML #11582

vlapra opened this issue Jan 6, 2025 · 5 comments · May be fixed by #11644
Assignees

Comments

@vlapra
Copy link

vlapra commented Jan 6, 2025

What is the bug?

It should be solved by #4807 (I wrote my comment there but nobody noticed).

It works if the srsName is set directly on the CircleByCenterPoint element (returns a POLYGON). It also works if the srsName is defined on some parent GML elements, but not on all.

However, if the srsName is only defined on the root element (Surface), it doesn't work (returns a CURVEPOLYGON).

Is there any workaround? When processing large files, modifying the XML to insert the correct srsName for child elements is inconvenient.

PS: It is strange that when I replace nmi_i with m, km, or nm, it doesn't work (regardless of the presence of srsName) — it returns a CURVEPOLYGON. According to the comments at #4807 and #3118, it should work.

<aixm:Surface gml:id="ID_240" srsName="urn:ogc:def:crs:EPSG::4326">
  <gml:patches>
    <gml:PolygonPatch>
      <gml:exterior>
        <gml:Ring>
          <gml:curveMember>
            <gml:Curve gml:id="ID_241">
        	<gml:segments>
        	  <gml:CircleByCenterPoint numArc="1" srsName="urn:ogc:def:crs:EPSG::4326">
        	    <gml:posList>52.36666666666667 -22.1</gml:posList>
        	    <gml:radius uom="[nmi_i]">15.0</gml:radius>
        	  </gml:CircleByCenterPoint>
                </gml:segments>
             </gml:Curve>
          </gml:curveMember>
        </gml:Ring>
     </gml:exterior>
   </gml:PolygonPatch>
 </gml:patches>
 <aixm:horizontalAccuracy uom="KM">2.0</aixm:horizontalAccuracy>
</aixm:Surface>

Steps to reproduce the issue

See #4807

Versions and provenance

GDAL 3.11.0 (build from master branch)

Additional context

No response

@rouault rouault self-assigned this Jan 6, 2025
@rouault
Copy link
Member

rouault commented Jan 6, 2025

However, if the srsName is only defined on the root element (Surface), it doesn't work (returns a CURVEPOLYGON).

I don't replicate that.

from osgeo import ogr

g = ogr.CreateGeometryFromGML("""<aixm:Surface gml:id="ID_240" srsName="urn:ogc:def:crs:EPSG::4326">
  <gml:patches>
    <gml:PolygonPatch>
      <gml:exterior>
        <gml:Ring>
          <gml:curveMember>
            <gml:Curve gml:id="ID_241">
        	<gml:segments>
        	  <gml:CircleByCenterPoint numArc="1">
        	    <gml:posList>52.36666666666667 -22.1</gml:posList>
        	    <gml:radius uom="[nmi_i]">15.0</gml:radius>
        	  </gml:CircleByCenterPoint>
                </gml:segments>
             </gml:Curve>
          </gml:curveMember>
        </gml:Ring>
     </gml:exterior>
   </gml:PolygonPatch>
 </gml:patches>
 <aixm:horizontalAccuracy uom="KM">2.0</aixm:horizontalAccuracy>
</aixm:Surface>""")

print(g)

outputs

POLYGON ((52.6166666666667 -22.1,52.616054213686 -22.0712773264022,52.6142198898112 -22.0426969804554,52.6111727844343 -22.0144005488689,52.6069279939409 -21.9865281409271,52.6015065431515 -21.9592176611003,52.5949352760201 -21.9326040954407,52.5872467162643 -21.9068188156587,52.5784788987812 -21.8819889053983,52.5686751728783 -21.8582365124718,52.557883978511 -21.8356782307928,52.5461585968723 -21.8144245155942,52.5335568768224 -21.7945791349254,52.5201409387707 -21.7762386604027,52.5059768577417 -21.7594919996858,52.4911343274525 -21.7444199728642,52.4756863073163 -21.7310949346414,52.4597086543567 -21.7195804437279,52.4432797420734 -21.7099309806596,52.4264800683379 -21.7021917147767,52.4093918544281 -21.6963983208637,52.3920986373194 -21.6925768455919,52.3746848573503 -21.6907436235691,52.3572354433671 -21.6909052425783,52.339835397427 -21.6930585572763,52.322569381102 -21.6971907503897,52.3055213053803 -21.7032794402004,52.2887739261083 -21.71129283296,52.2724084468512 -21.7211899186504,52.2565041309815 -21.7329207083755,52.2411379247299 -21.7464265115135,52.2263840928498 -21.7616402506751,52.212313868463 -21.7784868124134,52.1989951185648 -21.796883431541,52.186492026576 -21.816740106887,52.1748647932338 -21.8379600462154,52.1641693570212 -21.8604401381247,52.1544571352349 -21.8840714485838,52.1457747866991 -21.9087397398313,52.1381639970309 -21.9343260094109,52.1316612872708 -21.9607070470006,52.1262978465901 -21.9877560068003,52.1220993896945 -22.0153429931956,52.1190860394452 -22.0433356575496,52.1172722351228 -22.0715998036167,52.1166666666667 -22.1,52.1172722351228 -22.1284001963833,52.1190860394452 -22.1566643424504,52.1220993896945 -22.1846570068044,52.1262978465901 -22.2122439931997,52.1316612872708 -22.2392929529994,52.1381639970309 -22.2656739905891,52.1457747866991 -22.2912602601687,52.1544571352349 -22.3159285514162,52.1641693570212 -22.3395598618753,52.1748647932338 -22.3620399537846,52.186492026576 -22.383259893113,52.1989951185648 -22.403116568459,52.212313868463 -22.4215131875866,52.2263840928498 -22.4383597493249,52.2411379247299 -22.4535734884865,52.2565041309815 -22.4670792916245,52.2724084468512 -22.4788100813496,52.2887739261083 -22.4887071670437,52.3055213053803 -22.4967205597996,52.322569381102 -22.5028092496103,52.339835397427 -22.5069414427238,52.3572354433671 -22.5090947574217,52.3746848573503 -22.5092563764309,52.3920986373194 -22.5074231544081,52.4093918544281 -22.5036016791363,52.4264800683379 -22.4978082852233,52.4432797420734 -22.4900690193404,52.4597086543567 -22.4804195562721,52.4756863073163 -22.4689050653586,52.4911343274525 -22.4555800271358,52.5059768577417 -22.4405080003142,52.5201409387707 -22.4237613395973,52.5335568768224 -22.4054208650746,52.5461585968723 -22.3855754844058,52.557883978511 -22.3643217692072,52.5686751728783 -22.3417634875282,52.5784788987812 -22.3180110946017,52.5872467162643 -22.2931811843413,52.5949352760201 -22.2673959045593,52.6015065431515 -22.2407823388997,52.6069279939409 -22.2134718590729,52.6111727844343 -22.1855994511311,52.6142198898112 -22.1573030195446,52.616054213686 -22.1287226735978,52.6166666666667 -22.1))

@rouault
Copy link
Member

rouault commented Jan 6, 2025

It is strange that when I replace nmi_i with m, km, or nm

You must use "km" and not "[km]". The bracket in "[nmi_i]" are just for this unit. Cf https://ext.eurocontrol.int/aixm_confluence/display/ACG/Arc+by+Centre+Point#ArcbyCentrePoint-Unitsofmeasurement

So all in all, I don't see any bug

@jratike80
Copy link
Collaborator

I am curious about one detail. I read that "(case sensitive) values shall be used for gml:radius in AIXM/GML data sets"
'km' – when the radius is expressed in kilometers

However, in the test data I see also
<aixm:horizontalAccuracy uom="KM">2.0</aixm:horizontalAccuracy>

Is it true that within the same AIXM/GML file the kilometers must be km in one place, and KM in another?

@vlapra
Copy link
Author

vlapra commented Jan 8, 2025

Thank you very much for the explanation and the example. It really works the way you showed. However, I was using it differently in Java through the Java bindings, and the conversion worked correctly only when the srsName was specified in the inner element. But your way is better, so I will use it. Thanks!

I have a different question, can you tell me, why ElevatedPoint doesn't work but other like ElevatedCurve or ElavatedSurface work?

from osgeo import ogr
from osgeo import gdal

print(f"GDAL Version: {gdal.VersionInfo()}")

g = ogr.CreateGeometryFromGML(""" <aixm:Point gml:id="gmlAranID1208" srsDimension="3" srsName="urn:ogc:def:crs:EPSG:4326">
                                                         <gml:pos>57.1013332810643 24.0008427132439 762</gml:pos>
                                                     </aixm:Point>""")
print("Point: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:Point srsName="urn:ogc:def:crs:EPSG::4326" gml:id="pTEMPO">
                                                         <gml:pos>56.84 -29.8600000000003</gml:pos>
                                                         <aixm:horizontalAccuracy uom="M">100</aixm:horizontalAccuracy>
                                                     </aixm:Point>""")
print("Point: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:ElevatedCurve srsName="urn:ogc:def:crs:EPSG::4326" gml:id="ID-foo">
                                                             <gml:segments>
                                                                 <gml:Geodesic>
                                                                     <gml:posList>49 2 50 3
                                                                     </gml:posList>
                                                                 </gml:Geodesic>
                                                             </gml:segments>
                                                         </aixm:ElevatedCurve>""")
print("ElevatedCurve: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:Surface gml:id="ID_240" srsName="urn:ogc:def:crs:EPSG::4326">
  <gml:patches>
    <gml:PolygonPatch>
      <gml:exterior>
        <gml:Ring>
          <gml:curveMember>
            <gml:Curve gml:id="ID_241">
        	<gml:segments>
        	  <gml:CircleByCenterPoint numArc="1">
        	    <gml:posList>52.36666666666667 -22.1</gml:posList>
        	    <gml:radius uom="[nmi_i]">15.0</gml:radius>
        	  </gml:CircleByCenterPoint>
                </gml:segments>
             </gml:Curve>
          </gml:curveMember>
        </gml:Ring>
     </gml:exterior>
   </gml:PolygonPatch>
 </gml:patches>
 <aixm:horizontalAccuracy uom="KM">2.0</aixm:horizontalAccuracy>
</aixm:Surface>""")
print("Surface: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:Surface gml:id="ID_240" srsName="urn:ogc:def:crs:EPSG::4326">
                                   <gml:patches>
                                     <gml:PolygonPatch>
                                       <gml:exterior>
                                         <gml:Ring>
                                           <gml:curveMember>
                                             <gml:Curve gml:id="ID_241">
                                         	<gml:segments>
                                         	  <gml:CircleByCenterPoint numArc="1">
                                         	    <gml:posList>52.36666666666667 -22.1</gml:posList>
                                         	    <gml:radius uom="[nmi_i]">15.0</gml:radius>
                                         	  </gml:CircleByCenterPoint>
                                                 </gml:segments>
                                              </gml:Curve>
                                           </gml:curveMember>
                                         </gml:Ring>
                                      </gml:exterior>
                                    </gml:PolygonPatch>
                                  </gml:patches>
                                  <aixm:horizontalAccuracy uom="KM">2.0</aixm:horizontalAccuracy>
                                 </aixm:Surface>""")
print("Surface: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:ElevatedSurface srsName="urn:ogc:def:crs:EPSG::4326">
                                                                                     <gml:patches>
                                                                                             <gml:PolygonPatch>
                                                                                                     <gml:exterior>
                                                                                                             <gml:Ring>
                                                                                                                     <gml:curveMember>
                                                                                                                             <gml:Curve gml:id="foo">
                                                                                                                             <gml:segments>
                                                                                                                             <gml:GeodesicString>
                                                                                                                             <gml:posList>49 2 49 3 50 3 49 2</gml:posList>
                                                                                                                             </gml:GeodesicString>
                                                                                                                             </gml:segments>
                                                                                                                             </gml:Curve>
                                                                                                                     </gml:curveMember>
                                                                                                             </gml:Ring>
                                                                                                     </gml:exterior>
                                                                                             </gml:PolygonPatch>
                                                                                     </gml:patches>
                                                                                     <aixm:elevation uom="M">18</aixm:elevation>
                                                                             </aixm:ElevatedSurface>""")
print(g)

g = ogr.CreateGeometryFromGML("""<aixm:ElevatedPoint srsName="urn:ogc:def:crs:EPSG::4326">
                        <gml:pos>49 2</gml:pos>
                    </aixm:ElevatedPoint>""")
print("ElevatedPoint: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:ElevatedPoint srsDimension="2" srsName="urn:ogc:def:crs:EPSG::4326" gml:id="opoivsp_1">
                        <gml:pos>49 2</gml:pos>
                        <aixm:elevation uom="M">10</aixm:elevation>
                        <aixm:verticalAccuracy>0.1</aixm:verticalAccuracy>
                    </aixm:ElevatedPoint>""")
print("ElevatedPoint: ", g)

GDAL Version: 3110000
Point:  POINT Z (57.1013332810643 24.0008427132439 762)
Point:  POINT (56.84 -29.8600000000003)
ElevatedCurve:  LINESTRING (49 2,50 3)
Surface:  POLYGON ((52.6166666666667 -22.1,52.616054213686 -22.0712773264022,52.6142198898112 -22.0426969804427,52.6111727844343 -22.0144005488689,52.6069279939409 -21.9865281409271,52.6015065431515 -21.9592176611055,52.5949352760201 -21.9326040954386,52.5872467162643 -21.9068188156568,52.5784788987812 -21.8819889053983,52.5686751728783 -21.8582365124702,52.557883978511 -21.8356782307901,52.5461585968723 -21.8144245155929,52.5335568768224 -21.7945791349254,52.5201409387707 -21.7762386604038,52.5059768577417 -21.7594919996858,52.4911343274525 -21.7444199728642,52.4756863073163 -21.7310949346414,52.4597086543567 -21.7195804437289,52.4432797420734 -21.7099309806596,52.4264800683379 -21.7021917147748,52.4093918544281 -21.6963983208637,52.3920986373194 -21.6925768455919,52.3746848573503 -21.6907436235673,52.3572354433671 -21.6909052425774,52.339835397427 -21.6930585572771,52.322569381102 -21.6971907503915,52.3055213053803 -21.7032794402004,52.2887739261083 -21.7112928329591,52.2724084468512 -21.7211899186504,52.2565041309815 -21.7329207083794,52.2411379247299 -21.7464265115145,52.2263840928498 -21.7616402506751,52.212313868463 -21.7784868124134,52.1989951185648 -21.796883431541,52.186492026576 -21.8167401068857,52.1748647932338 -21.8379600462141,52.1641693570212 -21.8604401381247,52.154457135235 -21.8840714485838,52.1457747866991 -21.9087397398294,52.1381639970309 -21.9343260094109,52.1316612872708 -21.9607070470006,52.1262978465901 -21.9877560068003,52.1220993896945 -22.0153429932042,52.1190860394452 -22.0433356575432,52.1172722351228 -22.0715998036424,52.1166666666667 -22.1,52.1172722351228 -22.1284001963576,52.1190860394452 -22.1566643424568,52.1220993896945 -22.1846570067958,52.1262978465901 -22.2122439931997,52.1316612872708 -22.2392929529994,52.1381639970309 -22.2656739905891,52.1457747866991 -22.2912602601706,52.154457135235 -22.3159285514162,52.1641693570212 -22.3395598618753,52.1748647932338 -22.362039953786,52.186492026576 -22.3832598931143,52.1989951185648 -22.403116568459,52.212313868463 -22.4215131875866,52.2263840928498 -22.4383597493249,52.2411379247299 -22.4535734884855,52.2565041309815 -22.4670792916206,52.2724084468512 -22.4788100813496,52.2887739261083 -22.4887071670409,52.3055213053803 -22.4967205597996,52.322569381102 -22.5028092496085,52.339835397427 -22.5069414427229,52.3572354433671 -22.5090947574226,52.3746848573503 -22.5092563764327,52.3920986373194 -22.5074231544081,52.4093918544281 -22.5036016791363,52.4264800683379 -22.4978082852252,52.4432797420734 -22.4900690193404,52.4597086543567 -22.4804195562711,52.4756863073163 -22.4689050653586,52.4911343274525 -22.4555800271358,52.5059768577417 -22.4405080003142,52.5201409387707 -22.4237613395962,52.5335568768224 -22.4054208650746,52.5461585968723 -22.3855754844071,52.557883978511 -22.3643217692099,52.5686751728783 -22.3417634875298,52.5784788987812 -22.3180110946017,52.5872467162643 -22.2931811843432,52.5949352760201 -22.2673959045615,52.6015065431515 -22.2407823388945,52.6069279939409 -22.2134718590729,52.6111727844343 -22.1855994511311,52.6142198898112 -22.1573030195573,52.616054213686 -22.1287226735978,52.6166666666667 -22.1))
Surface:  POLYGON ((52.6166666666667 -22.1,52.616054213686 -22.0712773264022,52.6142198898112 -22.0426969804427,52.6111727844343 -22.0144005488689,52.6069279939409 -21.9865281409271,52.6015065431515 -21.9592176611055,52.5949352760201 -21.9326040954386,52.5872467162643 -21.9068188156568,52.5784788987812 -21.8819889053983,52.5686751728783 -21.8582365124702,52.557883978511 -21.8356782307901,52.5461585968723 -21.8144245155929,52.5335568768224 -21.7945791349254,52.5201409387707 -21.7762386604038,52.5059768577417 -21.7594919996858,52.4911343274525 -21.7444199728642,52.4756863073163 -21.7310949346414,52.4597086543567 -21.7195804437289,52.4432797420734 -21.7099309806596,52.4264800683379 -21.7021917147748,52.4093918544281 -21.6963983208637,52.3920986373194 -21.6925768455919,52.3746848573503 -21.6907436235673,52.3572354433671 -21.6909052425774,52.339835397427 -21.6930585572771,52.322569381102 -21.6971907503915,52.3055213053803 -21.7032794402004,52.2887739261083 -21.7112928329591,52.2724084468512 -21.7211899186504,52.2565041309815 -21.7329207083794,52.2411379247299 -21.7464265115145,52.2263840928498 -21.7616402506751,52.212313868463 -21.7784868124134,52.1989951185648 -21.796883431541,52.186492026576 -21.8167401068857,52.1748647932338 -21.8379600462141,52.1641693570212 -21.8604401381247,52.154457135235 -21.8840714485838,52.1457747866991 -21.9087397398294,52.1381639970309 -21.9343260094109,52.1316612872708 -21.9607070470006,52.1262978465901 -21.9877560068003,52.1220993896945 -22.0153429932042,52.1190860394452 -22.0433356575432,52.1172722351228 -22.0715998036424,52.1166666666667 -22.1,52.1172722351228 -22.1284001963576,52.1190860394452 -22.1566643424568,52.1220993896945 -22.1846570067958,52.1262978465901 -22.2122439931997,52.1316612872708 -22.2392929529994,52.1381639970309 -22.2656739905891,52.1457747866991 -22.2912602601706,52.154457135235 -22.3159285514162,52.1641693570212 -22.3395598618753,52.1748647932338 -22.362039953786,52.186492026576 -22.3832598931143,52.1989951185648 -22.403116568459,52.212313868463 -22.4215131875866,52.2263840928498 -22.4383597493249,52.2411379247299 -22.4535734884855,52.2565041309815 -22.4670792916206,52.2724084468512 -22.4788100813496,52.2887739261083 -22.4887071670409,52.3055213053803 -22.4967205597996,52.322569381102 -22.5028092496085,52.339835397427 -22.5069414427229,52.3572354433671 -22.5090947574226,52.3746848573503 -22.5092563764327,52.3920986373194 -22.5074231544081,52.4093918544281 -22.5036016791363,52.4264800683379 -22.4978082852252,52.4432797420734 -22.4900690193404,52.4597086543567 -22.4804195562711,52.4756863073163 -22.4689050653586,52.4911343274525 -22.4555800271358,52.5059768577417 -22.4405080003142,52.5201409387707 -22.4237613395962,52.5335568768224 -22.4054208650746,52.5461585968723 -22.3855754844071,52.557883978511 -22.3643217692099,52.5686751728783 -22.3417634875298,52.5784788987812 -22.3180110946017,52.5872467162643 -22.2931811843432,52.5949352760201 -22.2673959045615,52.6015065431515 -22.2407823388945,52.6069279939409 -22.2134718590729,52.6111727844343 -22.1855994511311,52.6142198898112 -22.1573030195573,52.616054213686 -22.1287226735978,52.6166666666667 -22.1))
POLYGON ((49 2,49 3,50 3,49 2))
ERROR 1: Unrecognized geometry type <ElevatedPoint>.
ElevatedPoint:  None
ERROR 1: Unrecognized geometry type <ElevatedPoint>.
ElevatedPoint:  None

@rouault rouault reopened this Jan 8, 2025
@rouault rouault changed the title CreateGeometryFromGML does not handle unit for radius in CURVEPOLYGON/CIRCULARSTRING geometry aixm:ElevatedPoint not handled by CreateGeometryFromGML Jan 8, 2025
@vlapra
Copy link
Author

vlapra commented Jan 10, 2025

It looks like it is sufficient to modify the gml2ogrgeometry.cpp file and add ElevatedPoint to the condition:

if (EQUAL(pszBaseGeometry, "PointType") ||
    EQUAL(pszBaseGeometry, "Point") ||
    EQUAL(pszBaseGeometry, "ElevatedPoint") ||
    EQUAL(pszBaseGeometry, "ConnectionPoint"))
{

This adjustment is sufficient for my needs.

g = ogr.CreateGeometryFromGML("""<aixm:ElevatedPoint srsName="urn:ogc:def:crs:EPSG::4326">
                        <gml:pos>49 2</gml:pos>
                    </aixm:ElevatedPoint>""")
print("ElevatedPoint: ", g)

g = ogr.CreateGeometryFromGML("""<aixm:ElevatedPoint srsDimension="2" srsName="urn:ogc:def:crs:EPSG::4326" gml:id="opoivsp_1">
                        <gml:pos>49 2</gml:pos>
                        <aixm:elevation uom="M">10</aixm:elevation>
                        <aixm:verticalAccuracy>0.1</aixm:verticalAccuracy>
                    </aixm:ElevatedPoint>""")
print("ElevatedPoint: ", g)

ElevatedPoint:  POINT (49 2)
ElevatedPoint:  POINT (49 2)

In some cases, it would be helpful if the Z coordinate (elevation) were correctly parsed for ElevatedPoint (and other elevated geometries). However, this is a separate issue and falls outside the current scope. It is more of a suggestion for future functionality enhancements.

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

Successfully merging a pull request may close this issue.

3 participants