Coverage for gws-app/gws/base/ows/client/__init__.py: 100%

1 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Base classes and utilities for OWS clients. 

2 

3This package provides the protocol-independent parts of the OWS clients. The 

4protocol plugins (``gws.plugin.ows_client.wms``, ``wmts``, ``wfs``) and the 

5QGIS plugin subclass the provider, finder and model defined here and use the 

6parsing helpers to read capabilities documents. 

7 

8Submodules: 

9 

10- ``provider``: base ``OwsServiceProvider``. Holds the service URL, version, 

11 operations and source layers, merges the operations reported in the 

12 capabilities with those in the configuration, selects a preferred format for 

13 each operation, prepares request arguments (including basic authorization) 

14 and downloads and caches the capabilities document. 

15- ``request``: low-level HTTP helpers. Build the ``SERVICE``, ``REQUEST`` and 

16 ``VERSION`` parameters, send the request and turn OWS exception documents 

17 into ``gws.ExternalServiceError``, also when the server answers with status 200. 

18- ``parseutil``: helpers to read capabilities XML: operations, service and 

19 layer metadata, WGS84 extents, supported CRSs, styles and number conversion. 

20- ``featureinfo``: parses GetFeatureInfo and GetFeature responses in several 

21 XML formats (GML feature collections, MapServer ``msGMLOutput``, 

22 GeoServer/QGIS ``GetFeatureInfoResponse``, ArcGIS ``FeatureInfoResponse``, 

23 GeoBAK, OSIRIS) into ``gws.FeatureRecord`` objects. 

24- ``finder``: generic finder that searches the queryable source layers of a provider. 

25- ``model``: generic read-only model that reads features from a provider. 

26- ``cli``: the ``owsCaps`` CLI command that prints the parsed capabilities of a 

27 service or a local XML file as JSON. It is not imported by this package. 

28 

29A provider subclass typically downloads the capabilities in ``configure``, 

30parses them with a protocol-specific parser built on ``parseutil``, calls 

31``configure_operations`` with the parsed operations, and later uses 

32``get_operation`` and ``prepare_operation`` to build requests, which are sent 

33with ``request.get``. 

34 

35Example:: 

36 

37 op = provider.get_operation(gws.OwsVerb.GetFeatureInfo) 

38 args = provider.prepare_operation(op, params={'QUERY_LAYERS': 'roads'}) 

39 text = gws.base.ows.client.request.get_text(args) 

40 records = gws.base.ows.client.featureinfo.parse(text, default_crs=provider.forceCrs) 

41""" 

42 

43from . import ( 

44 featureinfo, 

45 finder, 

46 model, 

47 parseutil, 

48 provider, 

49 request, 

50)