Opened 12 years ago

Closed 12 years ago

#1377 closed defect (fixed)

GML for empty geometries should be NULL

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

Description

EMPTY geometries can't be represented with a valid GML, so NULL should be returned for all of them.

Change History (5)

comment:1 by aperi2007, 12 years ago

Hi, I tested with xml-spy the available solutions so this solutions are all acceptable with the xsd rules of GML 3.1.1

        <gml:MultiCurve srsName="urn:ogc:def:crs:EPSG:3003">
          <gml:curveMember>
            <gml:Curve>
              <gml:segments>
                <gml:LineStringSegment>
                  <gml:posList srsDimension="2"></gml:posList>
                </gml:LineStringSegment>
              </gml:segments>
            </gml:Curve>
          </gml:curveMember>
        </gml:MultiCurve>

        <gml:MultiCurve srsName="urn:ogc:def:crs:EPSG:3003">
          <gml:curveMember>
            <gml:Curve>
              <gml:segments>
                <gml:LineStringSegment>
                  <gml:posList srsDimension="2" />
                </gml:LineStringSegment>
              </gml:segments>
            </gml:Curve>
          </gml:curveMember>
        </gml:MultiCurve>

<gml:LineString srsName="urn:ogc:def:crs:EPSG:3003">
   <gml:posList srsDimension="2" />
</gml:LineString>

<gml:Point srsName="urn:ogc:def:crs:EPSG:3003">
  <gml:pos srsDimension="2" />
</gml:Point>

<gml:MultiPoint srsName="urn:ogc:def:crs:EPSG:3003">
  <gml:pointMember>
    <gml:Point>
      <gml:pos srsDimension="2" />
    </gml:Point>
  </gml:pointMember>
</gml:MultiPoint>

<gml:TopoCurve>
  <gml:directedEdge>
    <gml:Edge gml:id="Edge_32_2174" >
      <gml:directedNode orientation="-">
        <gml:Node gml:id="Node_1_231068"/>
      </gml:directedNode>
      <gml:directedNode xlink:href="#Node_1_231068"/>
      <gml:curveProperty>
        <gml:LineString srsName="urn:ogc:def:crs:EPSG:3003">
          <gml:posList srsDimension="2" />
        </gml:LineString>
      </gml:curveProperty>
    </gml:Edge>
  </gml:directedEdge>
</gml:TopoCurve>



please notice that this instead give an error to validate test:

<gml:TopoCurve>
  <gml:directedEdge>
    <gml:Edge gml:id="Edge_32_2174">
      <gml:directedNode orientation="-">
        <gml:Node gml:id="Node_1_231068"/>
      </gml:directedNode>
      <gml:directedNode xlink:href="#Node_1_231068"/>
      <gml:curveProperty>
        <gml:LineString srsName="urn:ogc:def:crs:EPSG:3003"/>
      </gml:curveProperty>
    </gml:Edge>
  </gml:directedEdge>
</gml:TopoCurve>

also this is not allowed:

<gml:TopoCurve>
  <gml:directedEdge>
    <gml:Edge gml:id="Edge_32_2174" />
  </gml:directedEdge>
</gml:TopoCurve>

instead this is compliant with xsd validate:

<gml:TopoCurve>
  <gml:directedEdge>
    <gml:Edge gml:id="Edge_32_2174">
      <gml:directedNode orientation="-">
        <gml:Node gml:id="Node_1_231068"/>
      </gml:directedNode>
      <gml:directedNode xlink:href="#Node_1_231068"/>
      <gml:curveProperty />
    </gml:Edge>
  </gml:directedEdge>
</gml:TopoCurve>

So I Guess the better strategy is put always on the posList or pos tag the null, using

<posList /> or <pos />

regards,

Andrea.

comment:2 by strk, 12 years ago

Andrea: do you have any knowledge of a GML _reader_ capable of understanding one of the above asn an EMPTY geometry ? I'd love to have a lossless roundtrip between ST_AsGML and ST_GeomFromGML. See also #1059.

comment:3 by strk, 12 years ago

Keywords: gml added

comment:4 by pramsey, 12 years ago

Well, IMO we can have symmetric behavior in AsGML/FromGML or we can have valid GML: I don't feel that we can have both. Currently AsGML emits invalid GML on empty, so that needs to be changed or accepted. I don't believe that we can depend on the complex valid variants that we think signify "empty" will be generally accepted as empty, so it would be better to punt on empty, either by erroring or by emitting null.

comment:5 by pramsey, 12 years ago

Resolution: fixed
Status: newclosed

Since everyone seems pretty adamant on this ticket that we not emit the invalid empty gml strings we've been generating up until now, I've committed the behavior described in the title ticket: null on empty. r8966

Note: See TracTickets for help on using tickets.