Coverage for gws-app/gws/plugin/ows_client/wms/__init__.py: 100%

0 statements  

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

1"""WMS client. 

2 

3Uses the layers of a remote WMS service (versions 1.1.x and 1.3.0) as image 

4layers, search sources and models. 

5 

6Submodules: 

7 

8- ``provider``: the WMS service provider. Reads the capabilities and runs 

9 GetMap and GetFeatureInfo requests. 

10- ``caps``: parser for the WMS capabilities document. Builds the source layer 

11 tree, including the properties that child layers inherit from their parents. 

12- ``layer``: the ``wms`` tree layer, a group that mirrors the layer tree of 

13 the service, with ``wmsflat`` layers as leaves. 

14- ``flatlayer``: the ``wmsflat`` image layer that renders selected source 

15 layers as a single image. 

16- ``grabber``: the box grabber used by ``wmsflat`` to fetch map images with GetMap. 

17- ``finder``: the ``wms`` finder that queries source layers with 

18 GetFeatureInfo at a clicked point. 

19- ``model``: the ``wms`` read-only model for features returned by GetFeatureInfo. 

20 

21The ``wmsflat`` layer creates a ``wms`` model and, if any of its source layers 

22is queryable, a ``wms`` finder, unless models or finders are configured 

23explicitly. Unless configured otherwise, it takes its extent from the image 

24source layers, its resolutions from the scale ranges of the source layers, 

25its legend from their legend URLs and, if there is exactly one source layer, 

26its metadata. The ``wms`` tree layer uses the service metadata, unless 

27metadata is configured. 

28 

29Map images are fetched through a grabber, which can cache them. The grabber 

30requests images in its image format; the size of a single GetMap request is 

31limited by ``maxRequestPixels`` of the provider. 

32 

33GetFeatureInfo searches only run for a point shape; other searches return 

34nothing. The provider requests a 500x500 pixel image centered at the point and 

35queries its center pixel. The box covers 500 pixels at the search resolution 

36for metric CRSs and 1 degree for geographic CRSs. The request CRS is the forced 

37CRS of the provider, or the source CRS that best matches the CRS of the shape. 

38 

39Layer order: internally, source layers are always listed topmost layer first, 

40which corresponds to the layer tree display. WMS capabilities are assumed to 

41be top-first as well. For servers with bottom-first capabilities, set 

42``bottomFirst`` on the provider; the capabilities parser then reverses all 

43layer lists. GetMap draws the leftmost layer in the list bottommost (OGC 06-042, 

447.3.3.3), so the provider reverses the layer list when it calls GetMap. 

45 

46References: 

47 

48- OGC 01-068r3: WMS 1.1.1 

49- OGC 06-042: WMS 1.3.0 

50- https://docs.geoserver.org/latest/en/user/services/wms/reference.html 

51 

52Example:: 

53 

54 map.layers+ { 

55 title "Districts" 

56 type "wmsflat" 

57 provider.url "https://example.com/wms" 

58 sourceLayers.names ["districts" "roads"] 

59 } 

60 

61 map.layers+ { 

62 title "Service tree" 

63 type "wms" 

64 provider.url "https://example.com/wms" 

65 provider.bottomFirst true 

66 } 

67"""