Enhance datatype determination and improve service_ok util#994
Conversation
|
Hi @geographika. Maybe you can have a look at this. 👋 |
|
Thanks (and hi!) @KaiVolland - a very nice addition. I've been testing the branch using import json
from owslib.wfs import WebFeatureService
WFS_SERVICE_URL = 'https://geoportal.stadt-koeln.de/arcgis/services/basiskarten/adressen_stadtteil/MapServer/WFSServer?SERVICE=WFS&request=GetCapabilities'
wfs = WebFeatureService(WFS_SERVICE_URL, version="2.0.0")
schema = wfs.get_schema('adressen_stadtteil:Blumenberg')
print(json.dumps(schema, indent=4))Output: {
"properties": {
"objectid": "int",
"Nummer": "string",
"Adresse": "string",
"Strassenschl\u00fcssel": "string",
"Stra\u00dfe": "string",
"Amtl._Stra\u00dfenname": "string",
"Stra\u00dfe__Stadtbezirk_": "string",
"Hausnummer": "string",
"Geb\u00e4ude_ID_ALKIS": "string",
"Nutzung__ALKIS_Geb\u00e4udefunktion_": "string",
"Blockseite": "string",
"Stadtviertel__Nr._": "string",
"Stadtviertel": "string",
"Statistisches_Quartier__Nr._": "string",
"Statistisches_Quartier": "string",
"Stadtteil__Nr._": "string",
"Stadtteil": "string",
"Stadtbezirk__Nr._": "string",
"Stadtbezirk": "string",
"Stimmbezirk": "string",
"Postleitzahlgebiet": "string",
"Schiedsamtsbezirk": "string",
"Sozialraum__Nr._": "string",
"Sozialraum": "string",
"globalid": "string"
},
"required": [
"objectid",
"globalid"
],
"geometry": "Point",
"geometry_column": "shape"
}If I try and run the code without your PR I'm getting errors, so I guess this also fixes errors with missing types? For mocking server results an option is to use I'm also fine with the monkeypatch approach. It would be nice to get another sample test with a few other datatypes if you have one - most of the current example are I'm +1 on merging, but will leave open for a few days to see if anyone else has feedback. |
|
Thanks for the feedback. I parametrized the data_type tests to cover more cases. I kept the new test (tests/test_wfs_schema_arcgis_server.py) similiar to the existing one so i used the monkey test. 🙂 |
|
Merging - thanks @KaiVolland. |
|
Is there any chance this will be released soon? We rely on this fixes in a project but publishing a package with |
@KaiVolland - I'll raise this at a GeoPython call tomorrow, with an aim to release by the end of the month. |
|
@KaiVolland - new release available on PyPI at https://pypi.org/project/OWSLib/ (see also https://github.com/geopython/OWSLib/releases/tag/0.34.0) |
This PR contains two enhancements.
The datatype determination for featuretype attributes is updated to support all possible variants of the GML spec. Currently only the simplest case (
<xsd:element minOccurs="0" maxOccurs="1" name="objectid" type="xsd:int"/>) is supported.The
service_okutil now usesrequests.getwithstream=True. This adds support for a known bug in ArcGIS servers where the response header of theHEADrequest response with the wrongcontent-type.stream=Trueshould ensure, that there is no data fetched with the request. The traffic should be almost the same as with theHEADrequest.