Opened 13 years ago

Closed 12 years ago

#1059 closed defect (fixed)

Regress failure after gserialized: ST_ASGML/ST_GeomFromGML POINT empty invalid GML

Reported by: robe Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: master
Keywords: gml Cc:


This is the first of several bug reports comparing our new PostGIS 2.0 with PostGIS 2.0 circa r7331.

SELECT ST_GeomFromGML(ST_AsGML(ST_GeomFromText('POINT EMPTY',4326))); 

In prior would return something and if I did an ST_AsText on the geometry returned, I would get:

SELECT ST_AsText(ST_GeomFromGML(ST_AsGML(ST_GeomFromText('POINT EMPTY',4326)))); 


In current trunk I get:

ERROR:  invalid GML representation
CONTEXT:  SQL function "st_geomfromgml" statement 1

-- note ST_AsGML for point empty now returns:
<gml:Point srsName="EPSG:4326"><gml:coordinates></gml:coordinates></gml:Point>

Which looks all well and good, but I guess the GeomFromGML can't handle it.

Change History (5)

comment:1 by strk, 12 years ago

Keywords: gml added

Paul: I'd love to have such symmetric behavior, we couldn't get it by returning NULL. See also #1377

comment:2 by pramsey, 12 years ago

Actually I get

select st_asgml('POINT EMPTY');

and I have a patch fixed up now that correctly handles that as input so that the behavior is symmetric

postgis20=# select st_astext(st_geomfromgml(st_asgml('POINT EMPTY')));
(1 row)

As long as we agree that select st_asgml('POINT EMPTY') == <gml:Point/> then we're good to go. I'm ready to commit. The regression suite for in_gml right now insists that the correct answer to GeomFromGML('<gml:Point/>') is an ERROR

comment:3 by pramsey, 12 years ago

Regarding #1377, I think I'd rather not handle empty geometries at all than emit that kind of junk on empty. The old behaviour never caused anyone any harm, why not keep it?

comment:4 by rouault, 12 years ago

<gml:Point/> is invalid GML 2. See :

pointempty.xsd :

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="" xmlns:ogr="" xmlns:xs="" xmlns:gml="" elementFormDefault="qualified" version="1.0">
<xs:import namespace="" schemaLocation=""/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
    <xs:extension base="gml:AbstractFeatureCollectionType">
      <xs:attribute name="lockId" type="xs:string" use="optional"/>
      <xs:attribute name="scope" type="xs:string" use="optional"/>
<xs:element name="pointempty" type="ogr:pointempty_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="pointempty_Type">
    <xs:extension base="gml:AbstractFeatureType">
        <xs:element name="geometryProperty" type="gml:GeometryPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
        <xs:element name="foo" nillable="true" minOccurs="0" maxOccurs="1">
            <xs:restriction base="xs:string">

pointempty.gml (hand edited since OGR doesn't allow to write <gml:Point/> :

<?xml version="1.0" encoding="utf-8" ?>
     xsi:schemaLocation=" pointempty.xsd"
    <ogr:pointempty fid="pointempty.0">
      <ogr:geometryProperty><gml:Point /></ogr:geometryProperty>

Now, let's validate the file :

$ LD_LIBRARY_PATH=/home/even/install-libxml2-2.7.8git/lib xmllint --schema pointempty.xsd pointempty.gml  -noout
pointempty.gml:12: element Point: Schemas validity error : Element '{}Point': Missing child element(s). Expected is one of ( {}coord, {}coordinates ).
pointempty.gml fails to validate

comment:5 by pramsey, 12 years ago

Resolution: fixed
Status: newclosed

I've decided to make the behavior in accepting these more liberal, I think what we emit (#1377) is a separate issue. Closed at r8963

Note: See TracTickets for help on using tickets.