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

get_schema() unable to fully parse 'DescribeFeatureType' response #884

Closed
soenkeliebau opened this issue Jul 27, 2023 · 2 comments
Closed
Labels

Comments

@soenkeliebau
Copy link

soenkeliebau commented Jul 27, 2023

This is probably a case of "you are holding it wrong" or me misunderstanding how wfs works, but I thought I'd ask here just to be sure ..

I am trying to describe a FeatureType from a wfs service with the get_schema() method.

One example is the FeatureType "ms:gga_lk" here: https://geoportal.freiburg.de/wfs/verma_gga/verma_gga_lageklassen?request=DescribeFeatureType&service=wfs&version=2.0.0&typeNames=ms:gga_lk

This returns the following description:

<?xml version='1.0' encoding="UTF-8" ?>
<schema
   targetNamespace="http://mapserver.gis.umn.edu/mapserver"
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns="http://www.w3.org/2001/XMLSchema"
   xmlns:gml="http://www.opengis.net/gml/3.2"
   elementFormDefault="qualified" version="0.1" >

  <import namespace="http://www.opengis.net/gml/3.2"
          schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd" />

  <element name="gga_lk"
           type="ms:gga_lkType"
           substitutionGroup="gml:AbstractFeature" />

  <complexType name="gga_lkType">
    <complexContent>
      <extension base="gml:AbstractFeatureType">
        <sequence>
          <element name="msGeometry" type="gml:GeometryPropertyType" minOccurs="0" maxOccurs="1"/>
          <element name="gid" minOccurs="0" type="string"/>
          <element name="objectid_1" minOccurs="0" type="string"/>
          <element name="nutzung" minOccurs="0" type="string"/>
          <element name="gfz14_iii" minOccurs="0" type="string"/>
          <element name="d_innenst" minOccurs="0" type="string"/>
          <element name="stadtteil" minOccurs="0" type="string"/>
          <element name="geschosse" minOccurs="0" type="string"/>
          <element name="jahr" minOccurs="0" type="string"/>
          <element name="brwz_nr" minOccurs="0" type="string"/>
          <element name="brw" minOccurs="0" type="string"/>
          <element name="zustand" minOccurs="0" type="string"/>
          <element name="lk_mod" minOccurs="0" type="string"/>
          <element name="lk_text" minOccurs="0" type="string"/>
          <element name="brw16sg" minOccurs="0" type="string"/>
        </sequence>
      </extension>
    </complexContent>
  </complexType>

</schema>

The code I use to retrieve the schema is this:

wfs = WebFeatureService(url='https://geoportal.freiburg.de/wfs/verma_gga/verma_gga_lageklassen', version="2.0.0")
schema = wfs.get_schema('ms:gga_lk')
print(schema)

And this outputs the following:

{'properties': {}, 'required': ['msGeometry', 'gid', 'objectid_1', 'nutzung', 'gfz14_iii', 'd_innenst', 'stadtteil', 'geschosse', 'jahr', 'brwz_nr', 'brw', 'zustand', 'lk_mod', 'lk_text', 'brw16sg'], 'geometry': 'GeometryCollection', 'geometry_column': 'msGeometry'}

This has me a bit confused because of the emtpy "properties" dict element. I would have expected to see the fields and their types listed in there, like in the example from the docs.
Am I somehow misunderstanding how all this should work together, or is the response of the wfs maybe in a non-compatible format?

I am using owslib version 0.29.2

Update:
I stepped through the code and I think this may be something to do with the namespaces declared by the webservice I am using.

The reason why the properties element is empty is because adding the fields is skipped here due to schema_key being None: https://github.com/geopython/OWSLib/blob/master/owslib/feature/schema.py#L130

schema_key is set here: https://github.com/geopython/OWSLib/blob/master/owslib/feature/schema.py#L100 while stepping though nsmap, which for my input has this value:

{
  'ms': 'http://mapserver.gis.umn.edu/mapserver', 
  'xsd': 'http://www.w3.org/2001/XMLSchema', 
  None: 'http://www.w3.org/2001/XMLSchema', 
  'gml': 'http://www.opengis.net/gml/3.2'
}

So schema_key first gets set to "xsd" and then clobbered with None in a subsequent pass, causing the code that would add the properties to get bypassed further down the line.

I am not the worlds biggest expert on xml, but the w3c validator at least seems to indicate that something is off with the schema here:

Schema Error: Cannot find preset schema for namespace: http://www.w3.org/2001/XMLSchema.

Copy link

github-actions bot commented Oct 6, 2024

This Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.

@github-actions github-actions bot added the stale label Oct 6, 2024
Copy link

This Issue has been closed due to there being no activity for more than 90 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant