Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support gml:boundedBy / Envelope #56

Closed
mhugo opened this issue Jan 22, 2018 · 9 comments
Closed

Support gml:boundedBy / Envelope #56

mhugo opened this issue Jan 22, 2018 · 9 comments

Comments

@mhugo
Copy link
Collaborator

mhugo commented Jan 22, 2018

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

@sgrellet
Copy link
Member

sgrellet commented Feb 5, 2018

-> 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
Copy link
Member

sgrellet commented Mar 1, 2018

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
Copy link
Member

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
Copy link
Collaborator

rouault commented Apr 16, 2018

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 gml:Polygon element as child of gsmlp:boundingBox

@sgrellet
Copy link
Member

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

gml:boundedBy
<gml:Envelope srsDimension="2" axisLabels="x y" srsName="EPSG:4326">
gml:lowerCorner6.468348 47.387213</gml:lowerCorner>
gml:upperCorner8.238393 49.106426</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>

But it seems the driver overlooks this

@rouault
Copy link
Collaborator

rouault commented Apr 17, 2018

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
Copy link
Member

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
Copy link
Collaborator

rouault commented Apr 17, 2018

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

Addressed by OSGeo/gdal@54e3273 (provided that gml:boundedBy is removed from the ignored elements of gmlasconf.xml)

@sgrellet
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants