[postgis-users] GML ver 3 id duplicated error

Michal Seidl michal.seidl at gmail.com
Wed May 17 01:32:28 PDT 2023


Hello:.

the Postgis documentation of function ST_AsGML 
(https://postgis.net/docs/manual-3.3/ST_AsGML.html) says that parameter 
GML version 3 referes to GML 3.1.1 standard

GML 3.1.1

The standard of GML version 3.1.1 
(https://portal.ogc.org/files/?artifact_id=4700) in chapter 7.5.6.5 and 
F.2.1.5 says (if I understand correctly) that gml:id have to be unique 
through XML document.

7.5.6.5
gml:id
<attribute name="id" type="ID"/>

This property supports provision of a database handle for the object. 
Its use is optional but recommended. It
is of XML type ID, so is constrained to be unique in the XML document 
within which it occurs. An external identifier for the object in the 
form of a URI may be constructed using standard methods [URI]. This is 
done by concatenating the URI for the document, a fragment separator 
“#”, and the value of the attribute of XML type ID.


GML 3.2.1 is similar

The standard of GML version 3.2.1 
(https://portal.ogc.org/files/?artifact_id=20509) in chapter 7.2.4.5 and 
F.2.1.5 says (if I understand correctly) that gml:id have to be unique 
through XML document.

So I think that this SQL

SELECT ST_AsGML(3, ST_GeomFromText('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 
0)))',4326), 15, 0, null, '1');

produces invalid GML 3 (3.1.1) because gml:id is not unique

<gml:MultiSurface srsName="EPSG:4326" gml:id="1">
   <gml:surfaceMember>
     <gml:Polygon gml:id="1">
       <gml:exterior>
         <gml:LinearRing>
         <gml:posList srsDimension="2">0 0 0 1 1 1 1 0 0 0</gml:posList>
         </gml:LinearRing>
       </gml:exterior>
     </gml:Polygon>
   </gml:surfaceMember>
</gml:MultiSurface>

I also found problem with GML2
while this SQL returns GML 2 document

SELECT ST_AsGML(2, ST_GeomFromText('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 
0)))',4326), 15, 0, null, '1');

this one (no explicitly given GML version) returns NULL

SELECT ST_AsGML(ST_GeomFromText('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 
0)))',4326), 15, 0, null, '1');

I hope I nailed down the problem enough.

MS


On 5/16/23 17:54, Paul Ramsey wrote:
> Bug or shortcoming, I don’t think we ever had this behaviour, and probably never encountered a validator that checked it. If you can nail down the specific GML version it applies to, that would be helpful in applying a fix. For deeply nested multi-geometries, I can see this being quite… enjoyable to repair.
> 
> P
> 
>> On May 16, 2023, at 8:52 AM, Michal Seidl <michal.seidl at gmail.com> wrote:
>>
>> Hello,
>> we use POSTGIS="3.3.1 3786b21" and have problem with validation of GML geometry. The validator complains about duplicated "id" values in generated XML in MultiSuface and Polygon.
>>
>> <gml:MultiSurface srsName="EPSG:4326" gml:id="1">
>>   <gml:surfaceMember>
>>     <gml:Polygon gml:id="1">
>>       <gml:exterior>
>>         <gml:LinearRing>
>>          <gml:posList srsDimension="2">0 0 0 1 1 1 1 0 0 0</gml:posList>
>>         </gml:LinearRing>
>>        </gml:exterior>
>>     </gml:Polygon>
>>   </gml:surfaceMember>
>> </gml:MultiSurface>
>>
>> We have not found definition for GML ver 3.1.1 but for 3.2.1 by this link https://docs.geoserver.org/2.23.x/en/user/data/app-schema/supported-gml-versions.html says:
>>
>> If a multigeometry (such as a MultiPoint or MultiSurface) is assigned a gml:id of (for example) parentid, to permit GML 3.2.1 schema-validity, each geometry that the multigeometry contains will be automatically assigned a gml:id of the form parentid.1, parentid.2, … in order.
>>
>> Is it Postgis bug or difference between GML ver 3.1.1 and 3.2.1?
>>
>> Thanks for help Michal S.
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users


More information about the postgis-users mailing list