BRGM / gml_application_schema_toolbox

GML Application Schema toolbox is a QGIS plugin allowing to manipulate OGC Complex Features
https://brgm.github.io/gml_application_schema_toolbox/
GNU General Public License v2.0
28 stars 18 forks source link

Support gml:boundedBy / Envelope #56

Closed mhugo closed 6 years ago

mhugo commented 6 years ago

Display a polygon that corresponds to the bounding box when the information is present in the source

sgrellet commented 6 years ago

-> loading the attached file

in XML mode

RuntimeError: A file system object called 'C:\Users\grellets\AppData\Local\Temp\tmp7efpwpdh_nogeom.gpkg' already exists. Traceback (most recent call last): File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_panel.py", line 318, in on_loadFromFileButton_clicked self.xml_panel.do_load() File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\import_xml_panel.py", line 71, in do_load swap_xy = self.swapXYCheck.isChecked()) File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 57, in load_as_xml_layer return s.load_complex_gml(xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy) File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 315, in load_complex_gml layer = self._create_layer('none', None, attr_list, src.title, "nogeom") File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 434, in _create_layer ds = driver.CreateDataSource(fn) File "C:\OSGEO4~1\apps\Python36\lib\site-packages\osgeo\ogr.py", line 417, in CreateDataSource return _ogr.Driver_CreateDataSource(self, *args, **kwargs) RuntimeError: A file system object called 'C:\Users\grellets\AppData\Local\Temp\tmp7efpwpdh_nogeom.gpkg' already exists.

Version de Python : 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] Version de QGIS : 2.99.0-Master Master, b4be39f98b

in GMLAS mode

5 tables are created but apparently no geom detected ModelView_Envelope.zip

sgrellet commented 6 years ago

on v1.2.0-rc2 using the xml attached previously

Traceback (most recent call last): File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_panel.py", line 318, in on_loadFromFileButton_clicked self.xml_panel.do_load() File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\import_xml_panel.py", line 71, in do_load swap_xy = self.swapXYCheck.isChecked()) File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 57, in load_as_xml_layer return s.load_complex_gml(xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy) File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 324, in load_complex_gml layer = self._create_layer('none', None, attr_list, src.title, "nogeom") File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 444, in _create_layer layer = ds.CreateLayer("meta", geom_type = ogr.wkbNone) AttributeError: 'NoneType' object has no attribute 'CreateLayer'

Version de Python : 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] Version de QGIS : 3.1.0-Master Master, a483ef817a

sgrellet commented 6 years ago

ko in both modes on v1.2.0-rc6 using the xml attached previously

in XML mode

Traceback (most recent call last): File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_wizard_xml.py", line 58, in validatePage swap_xy=self.swapXYCheck.isChecked()) File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 59, in load_as_xml_layer return s.load_complex_gml(xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy) File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 327, in load_complex_gml layer = self._create_layer('none', None, attr_list, src.title, "nogeom") File "C:/Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 447, in _create_layer layer = ds.CreateLayer("meta", geom_type = ogr.wkbNone) AttributeError: 'NoneType' object has no attribute 'CreateLayer'

GMLAS mode

5 tables generated but no spatialised information with this commandeLine "ogrinfo -ro --debug on --config CPL_CURL_VERBOSE YES --config GDAL_HTTP_UNSAFESSL YES GMLAS:ModelView_Envelope.xml > stdout.txt 2>stderr.txt" I got the following message in stderr.txt "GMLAS: Element with xpath=gsmlp:ModelView/gml:boundedBy found in document but ignored according to configuration" @rouault : I tried to check 'drv_gmlas' and did not find the cause. any idea ?

Python : 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] QGIS : 3.0.1-Girona Girona, a86bec25ebw

rouault commented 6 years ago

Ah this document/schemas has a rather unfriendly way of embedding GML geometries.

            <gsmlp:boundingBox gml:id="polygon.2" srsName="EPSG:4326">
                <gml:exterior>
                    <gml:LinearRing>
                        <gml:posList>1.8 49.2 1.8 48.48 0.45 48.48 0.45 49.2</gml:posList>
                    </gml:LinearRing>
                </gml:exterior>
            </gsmlp:boundingBox>

The schema indeeds uses <element name="boundingBox" type="gml:PolygonType"> But the driver is not ready for such constructs. A more friendly way would be to make boundingBox a gml:PolygonPropertyType and then have a element as child of

sgrellet commented 6 years ago

Actually my question was on gsmlp:ModelView/gml:boundedBy and not gsmlp:ModelView/gsmlp:boundingBox Yes we have gsmlp:boundingBox but the idea would be to replace it by gml:boundedBy

6.468348 47.387213 8.238393 49.106426 But it seems the driver overlooks this
rouault commented 6 years ago

But it seems the driver overlooks this

Yes gml:boundedBy elements are ignored by default. You can remove the following lines in gmlasconf.xml

        <XPath warnIfIgnoredXPathFoundInDocInstance="false">gml:boundedBy</XPath>
        <XPath warnIfIgnoredXPathFoundInDocInstance="false">gml32:boundedBy</XPath>

but that will result in something not so usable

OGRFeature(envelope):1
  ogr_pkid (String) = 5D073E2E01B5E4E5F60F57518FE27E95_Envelope_1
  srsname (String) = EPSG:4326
  srsdimension (Integer) = 2
  axislabels (StringList) = (2:x,y)
  lowercorner (String) = 6.468348 47.387213
  uppercorner (String) = 8.238393 49.106426
  coordinates_decimal (String) = .
  coordinates_cs (String) = ,
  coordinates_ts (String) =  
sgrellet commented 6 years ago

Uncommenting those 2 lines leads to the attached sqlite db. Any reason why the gml:Envelope information does not lead to the generation of a geometry ? I now have an enveloppe table with the correct info but no geom. From a domain points of view this is 'usable' info. Were you refering to something else by saying 'not so usable'? tmp.zip

rouault commented 6 years ago

Any reason why the gml:Envelope information does not lead to the generation of a geometry ?

Addressed by https://github.com/OSGeo/gdal/commit/54e3273cb47a552d04cfe22b4ffc791db49b474e (provided that gml:boundedBy is removed from the ignored elements of gmlasconf.xml)

sgrellet commented 6 years ago

ok thanks. will close this issue and create 2 specific ones as the XML mode needs also to be fixed