Modules
Base classes for API clients.
WMSClient
¶
Bases: ABC
Abstract base class for WMS service clients.
Source code in dovwms/base.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
wms
property
writable
¶
Get the WMS connection, establishing it if needed.
__init__(base_url, wms_version='1.3.0')
¶
Initialize the WMS client.
The reason for the property and a setter implementation is to allow lazy connection to the WMS service at the point it is needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Base URL of the WMS service |
required |
wms_version
|
str
|
WMS protocol version to use |
'1.3.0'
|
Source code in dovwms/base.py
19 20 21 22 23 24 25 26 27 28 29 30 31 | |
check_layer_exists(layer_name)
¶
Check if a layer exists in the WMS service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
Name of the layer to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if layer exists, False otherwise |
Source code in dovwms/base.py
81 82 83 84 85 86 87 88 89 90 | |
connect_wms()
¶
Connect to the WMS service and return the connected WebMapService.
Returns:
| Type | Description |
|---|---|
WebMapService
|
The connected WebMapService instance. |
Source code in dovwms/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
list_wms_layers(filter_func=None)
¶
List available WMS layers from the service, optionally filtered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_func
|
Optional[Callable[[str, str], bool]]
|
Optional function to filter layers. Takes layer name and title as arguments and returns bool. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of layer names and titles |
Source code in dovwms/base.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
parse_feature_info(content, **kwargs)
abstractmethod
¶
Parse GetFeatureInfo response content.
This method should be implemented by subclasses to handle service-specific response formats. Preferably, in these method, each data type (e.g., soil texture, elevation) gets its own parsing logic in a dedicated private method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Raw response content as string |
required |
**kwargs
|
Any
|
Additional parsing parameters |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parsed content in appropriate format |
Source code in dovwms/base.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
Client for the Belgian DOV (Databank Ondergrond Vlaanderen) API.
DOVClient
¶
Bases: WMSClient
Client for fetching soil data from the Belgian DOV API.
Source code in dovwms/dov.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
__init__()
¶
Lazy-initialize the DOV client.
Connects to the DOV Geoserver WMS service for accessing soil data and related geological information. Open for further expasion.
Source code in dovwms/dov.py
18 19 20 21 22 23 24 | |
fetch_profile(location, fetch_elevation=False, crs='EPSG:31370')
¶
Fetch soil texture information from the DOV WMS at a specific location.
This method queries the DOV WMS service for clay, silt, and sand content at different depths at the specified location. The data is used to create a SoilProfile object with appropriate layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Point
|
Point object with x, y coordinates |
required |
fetch_elevation
|
bool
|
Whether to fetch the elevation of the location from Geopunt. |
False
|
crs
|
str
|
Coordinate reference system |
'EPSG:31370'
|
Returns:
| Type | Description |
|---|---|
Optional[dict[str, Any]]
|
Dictionary with texture data ("layers" key and optional "elevation") or None if data not found |
Source code in dovwms/dov.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
list_wms_layers(filter_func=None)
¶
List available WMS layers from the DOV service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_func
|
Optional[Callable[[str, str], bool]]
|
Optional function to filter layers. Takes layer name and title as arguments and returns bool. If None, only soil-related layers are returned. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of layer names and titles |
Source code in dovwms/dov.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
parse_feature_info(content, **kwargs)
¶
Parse GetFeatureInfo response from DOV WMS.
The parsing method depends on the content type and query type: - For soil texture: Parses JSON response with layer properties - For other queries: Returns raw content for specific handling
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Raw response content |
required |
**kwargs
|
Any
|
Additional parameters: - content_type: Expected content type - query_type: Type of query (e.g., 'texture', 'properties') |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parsed content in appropriate format |
Source code in dovwms/dov.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
get_profile_from_dov(x, y, crs='EPSG:31370', fetch_elevation=True, profile_name=None)
¶
Convenience function to fetch a soil profile from DOV at given coordinates.
This function handles all the necessary client setup and coordinate conversion to get a soil profile from the DOV service. It's a simpler alternative to creating and managing DOV and Geopunt clients manually.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X-coordinate in the specified CRS (default Lambert72) |
required |
y
|
float
|
Y-coordinate in the specified CRS (default Lambert72) |
required |
profile_name
|
Optional[str]
|
Optional name for the profile. If None, will use coordinates |
None
|
crs
|
str
|
Coordinate reference system of the input coordinates |
'EPSG:31370'
|
fetch_elevation
|
bool
|
elevation data |
True
|
Returns:
| Type | Description |
|---|---|
Optional[dict[str, Any]]
|
SoilProfile object with texture and optional elevation data, |
Optional[dict[str, Any]]
|
or None if the data couldn't be fetched |
Example
profile = get_profile_from_dov(247172.56, 204590.58) print(f"Elevation: {profile.elevation:.2f}m") print(f"Number of layers: {len(profile.layers)}")
Source code in dovwms/dov.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
GeopuntClient
¶
Bases: WMSClient
Client for fetching data from the Geopunt API.
Source code in dovwms/geopunt.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
fetch_elevation(location, crs='EPSG:31370', layer_name='DHMVII_DTM_1m')
¶
Fetch elevation data from the Geopunt WMS at a specific location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Point
|
Point object with x, y coordinates |
required |
crs
|
str
|
Coordinate reference system |
'EPSG:31370'
|
Returns: Elevation in meters or None if not found
Source code in dovwms/geopunt.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
parse_feature_info(content, **kwargs)
¶
Parse GetFeatureInfo response from Geopunt WMS.
The parsing method depends on the content type and query type: - For elevation: Parses semicolon-separated response for elevation value - For other queries: Returns raw content for specific handling. - One substantial change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Raw response content |
required |
**kwargs
|
Any
|
Additional parameters: - content_type: Expected content type - query_type: Type of query (e.g., 'elevation') |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict containing either {'elevation': float or None} or {'content': str} |
Source code in dovwms/geopunt.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
get_elevation(location, crs='EPSG:31370', layer_name='DHMVII_DTM_1m')
¶
Convenience wrapper to fetch elevation using the GeopuntClient.
This helper creates a GeopuntClient, requests the elevation for the provided location and returns the value. Tests can patch this function to avoid instantiating the client or making network calls.
Source code in dovwms/geopunt.py
118 119 120 121 122 123 124 125 126 127 128 | |