Ticket #1377 (closed defect: fixed)

Opened 5 months ago

Last modified 4 months ago

GML for empty geometries should be NULL

Reported by: strk Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: trunk
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

Changed 5 months ago by aperi2007

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.

Changed 5 months ago by strk

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.

Changed 5 months ago by strk

  • keywords gml added

Changed 4 months ago by pramsey

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.

Changed 4 months ago by pramsey

  • status changed from new to closed
  • resolution set to fixed

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.