qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.39k stars 2.98k forks source link

GML import is missing one feature without geometry #50215

Closed pathmapper closed 2 years ago

pathmapper commented 2 years ago

What is the bug or the crash?

GML import is missing one feature without geometry.

There are 1759 features in total, but one feature without geometry is not shown for the import dialog:

image

Steps to reproduce the issue

Drag'n'drop the following GML into QGIS: xplansynwfs-4.zip

The following feature is missing (the first one in the document):

<wfs:member>
    <xplan:FP_BebauungsFlaeche xmlns:xplan="http://www.deegree.org/xplanung/1/0" gml:id="XPLAN_FP_BEBAUUNGSFLAECHE_cc4f50a8-a2e7-4c5c-bc5d-c5b82d5079b0">
      <xplan:gmlId>XPLAN_FP_BEBAUUNGSFLAECHE_cc4f50a8-a2e7-4c5c-bc5d-c5b82d5079b0</xplan:gmlId>
      <xplan:xpVersion>5.1</xplan:xpVersion>
      <xplan:xpPlanType>FP_Plan</xplan:xpPlanType>
      <xplan:xpPlanName>FP Krefeld (Urschrift)</xplan:xpPlanName>
      <xplan:xplanMgrPlanId>144</xplan:xplanMgrPlanId>
      <xplan:ebene>0</xplan:ebene>
      <xplan:gehoertZuBereich>[XPLAN_FP_BEREICH_8f95f31c-fb74-40d6-a77d-78666cbff16e]</xplan:gehoertZuBereich>
      <xplan:rechtscharakter>Darstellung</xplan:rechtscharakter>
      <xplan:rechtscharakterCode>1000</xplan:rechtscharakterCode>
      <xplan:flaechenschluss>true</xplan:flaechenschluss>
      <xplan:allgArtDerBaulNutzung>GemischteBauflaeche</xplan:allgArtDerBaulNutzung>
      <xplan:allgArtDerBaulNutzungCode>2000</xplan:allgArtDerBaulNutzungCode>
      <xplan:besondereArtDerBaulNutzung>Kerngebiet</xplan:besondereArtDerBaulNutzung>
      <xplan:besondereArtDerBaulNutzungCode>1600</xplan:besondereArtDerBaulNutzungCode>
    </xplan:FP_BebauungsFlaeche>
  </wfs:member>

Versions

QGIS version 3.27.0-Master QGIS code revision 9c4d0a2064
Qt version 5.15.3
Python version 3.10.4
GDAL/OGR version 3.4.1
PROJ version 8.2.1
EPSG Registry database version v10.041 (2021-12-03)
GEOS version 3.10.2-CAPI-1.16.0
SQLite version 3.37.2
PostgreSQL client version unknown
SpatiaLite version 5.0.1
QWT version 6.1.4
QScintilla2 version 2.11.6
OS version Ubuntu 22.04.1 LTS
       

Active Python plugins sagaprovider | 2.12.99 grassprovider | 2.12.99 MetaSearch | 0.3.6 processing | 2.12.99 db_manager | 0.1.20

Supported QGIS version

New profile

Additional context

No response

elpaso commented 2 years ago

This happens because GDAL (OGR) doesn't know the geometry type until it encounters the first feature with a geometry (which is the second one in your sample file), so it discards the first feature.

If you invert the second and the first features it works as expected:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd http://www.deegree.org/xplanung/1/0 https://xplanservicesq.rz.krzn.de/xplansyn-wfs/services/xplansynwfs?SERVICE=WFS&amp;VERSION=2.0.0&amp;REQUEST=DescribeFeatureType&amp;OUTPUTFORMAT=application%2Fgml%2Bxml%3B+version%3D3.2&amp;TYPENAME=xplan:FP_BebauungsFlaeche&amp;NAMESPACES=xmlns(xplan,http%3A%2F%2Fwww.deegree.org%2Fxplanung%2F1%2F0)" xmlns:wfs="http://www.opengis.net/wfs/2.0" timeStamp="2022-09-14T13:24:46Z" xmlns:gml="http://www.opengis.net/gml/3.2" numberMatched="unknown" numberReturned="0">
  <!--NOTE: numberReturned attribute should be 'unknown' as well, but this would not validate against the current version of the WFS 2.0 schema (change upcoming). See change request (CR 144): https://portal.opengeospatial.org/files?artifact_id=43925.-->  
  <wfs:member>
    <xplan:FP_BebauungsFlaeche xmlns:xplan="http://www.deegree.org/xplanung/1/0" gml:id="XPLAN_FP_BEBAUUNGSFLAECHE_7892f214-7554-4d52-aa7f-4b250b4d4f6e">
      <xplan:gmlId>XPLAN_FP_BEBAUUNGSFLAECHE_7892f214-7554-4d52-aa7f-4b250b4d4f6e</xplan:gmlId>      
      <xplan:position>
        <!--Inlined geometry 'XPLAN_FP_BEBAUUNGSFLAECHE_7892f214-7554-4d52-aa7f-4b250b4d4f6e_XPLAN_POSITION'-->
        <gml:Polygon gml:id="XPLAN_FP_BEBAUUNGSFLAECHE_7892f214-7554-4d52-aa7f-4b250b4d4f6e_XPLAN_POSITION" srsName="EPSG:25832">
          <gml:exterior>
            <gml:LinearRing>
              <gml:posList>326475.876 5694450.665 326475.781 5694451.124 326466.788 5694449.251 326453.960 5694446.550 326441.796 5694443.989 326435.627 5694442.688 326435.491 5694442.659 326439.354 5694418.982 326442.578 5694399.220 326443.390 5694394.229 326444.556 5694387.072 326445.041 5694384.094 326445.784 5694379.530 326447.328 5694370.048 326455.720 5694368.206 326456.679 5694367.996 326462.137 5694366.902 326474.932 5694365.391 326478.853 5694365.261 326483.570 5694365.104 326490.525 5694366.056 326496.581 5694367.483 326500.266 5694368.352 326508.953 5694370.866 326530.543 5694377.115 326532.331 5694378.060 326533.563 5694379.563 326534.191 5694381.520 326534.061 5694384.019 326525.438 5694419.593 326483.968 5694411.814 326475.876 5694450.665</gml:posList>
            </gml:LinearRing>
          </gml:exterior>
        </gml:Polygon>
      </xplan:position>      
    </xplan:FP_BebauungsFlaeche>
  </wfs:member>
  <wfs:member>
    <xplan:FP_BebauungsFlaeche xmlns:xplan="http://www.deegree.org/xplanung/1/0" gml:id="XPLAN_FP_BEBAUUNGSFLAECHE_cc4f50a8-a2e7-4c5c-bc5d-c5b82d5079b0">
      <xplan:gmlId>XPLAN_FP_BEBAUUNGSFLAECHE_cc4f50a8-a2e7-4c5c-bc5d-c5b82d5079b0</xplan:gmlId>      
    </xplan:FP_BebauungsFlaeche>
  </wfs:member>
</wfs:FeatureCollection>

@rouault do you have a clue about a possible fix?