maps4fs 2.0.1__py3-none-any.whl → 2.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maps4fs/generator/component/dem.py +2 -2
- maps4fs/generator/dtm/__init__.py +1 -0
- maps4fs/generator/dtm/dtm.py +1 -1
- maps4fs/generator/dtm/wales.py +123 -0
- {maps4fs-2.0.1.dist-info → maps4fs-2.0.2.dist-info}/METADATA +2 -1
- {maps4fs-2.0.1.dist-info → maps4fs-2.0.2.dist-info}/RECORD +9 -8
- {maps4fs-2.0.1.dist-info → maps4fs-2.0.2.dist-info}/WHEEL +0 -0
- {maps4fs-2.0.1.dist-info → maps4fs-2.0.2.dist-info}/licenses/LICENSE.md +0 -0
- {maps4fs-2.0.1.dist-info → maps4fs-2.0.2.dist-info}/top_level.txt +0 -0
@@ -159,7 +159,7 @@ class DEM(ImageComponent):
|
|
159
159
|
|
160
160
|
self.update_info("original", data)
|
161
161
|
|
162
|
-
# Check if the data contains any non
|
162
|
+
# Check if the data contains any non-zero values, otherwise raise an error.
|
163
163
|
if not np.any(data):
|
164
164
|
self.logger.error("DTM provider returned empty data.")
|
165
165
|
raise ValueError("DTM provider returned empty data. Try using different DTM provider.")
|
@@ -275,7 +275,7 @@ class DEM(ImageComponent):
|
|
275
275
|
np.ndarray: Multiplied DEM data.
|
276
276
|
"""
|
277
277
|
multiplier = self.map.dem_settings.multiplier
|
278
|
-
if
|
278
|
+
if multiplier == 1:
|
279
279
|
return data
|
280
280
|
|
281
281
|
multiplied_data = data * multiplier
|
@@ -24,3 +24,4 @@ from maps4fs.generator.dtm.srtm import SRTM30Provider
|
|
24
24
|
from maps4fs.generator.dtm.switzerland import SwitzerlandProvider
|
25
25
|
from maps4fs.generator.dtm.thuringia import ThuringiaProvider
|
26
26
|
from maps4fs.generator.dtm.usgs_wcs import USGSWCSProvider
|
27
|
+
from maps4fs.generator.dtm.wales import WalesProvider
|
maps4fs/generator/dtm/dtm.py
CHANGED
@@ -298,7 +298,7 @@ class DTMProvider(ABC):
|
|
298
298
|
|
299
299
|
def get_numpy(self) -> np.ndarray:
|
300
300
|
"""Get numpy array of the tile.
|
301
|
-
Resulting array must be 16 bit (signed or unsigned) integer and it should be already
|
301
|
+
Resulting array must be 16 bit (signed or unsigned) integer, and it should be already
|
302
302
|
windowed to the bounding box of ROI. It also must have only one channel.
|
303
303
|
|
304
304
|
Returns:
|
@@ -0,0 +1,123 @@
|
|
1
|
+
"""This module contains provider of Wales data."""
|
2
|
+
|
3
|
+
import os
|
4
|
+
from math import floor, ceil
|
5
|
+
|
6
|
+
import requests
|
7
|
+
from pyproj import Transformer
|
8
|
+
|
9
|
+
from maps4fs.generator.dtm.dtm import DTMProvider
|
10
|
+
|
11
|
+
|
12
|
+
class WalesProvider(DTMProvider):
|
13
|
+
"""Provider of Wales data."""
|
14
|
+
|
15
|
+
_code = "wales"
|
16
|
+
_name = "Wales 1M"
|
17
|
+
_region = "UK"
|
18
|
+
_icon = "🏴"
|
19
|
+
_resolution = 1
|
20
|
+
_author = "[garnshared](https://github.com/garnshared)"
|
21
|
+
_is_community = True
|
22
|
+
_instructions = None
|
23
|
+
_is_base = False
|
24
|
+
_extents = [(55.87708724246775, 49.85060473351981, 2.0842821419111135, -7.104775741839742)]
|
25
|
+
|
26
|
+
_url = "https://datamap.gov.wales/geoserver/ows" # pylint: disable=line-too-long
|
27
|
+
_wms_version = "1.1.1"
|
28
|
+
_source_crs = "EPSG:27700"
|
29
|
+
_size = 1000
|
30
|
+
|
31
|
+
def download_tiles(self):
|
32
|
+
download_urls = self.get_download_urls()
|
33
|
+
all_tif_files = self.download_tif_files(download_urls, self.shared_tiff_path)
|
34
|
+
return all_tif_files
|
35
|
+
|
36
|
+
def __init__(self, *args, **kwargs):
|
37
|
+
super().__init__(*args, **kwargs)
|
38
|
+
self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
|
39
|
+
os.makedirs(self.shared_tiff_path, exist_ok=True)
|
40
|
+
|
41
|
+
def get_download_urls(self) -> list[str]:
|
42
|
+
"""Get download URLs of the GeoTIFF files from the tile catalogue.
|
43
|
+
|
44
|
+
Returns:
|
45
|
+
list: List of download URLs.
|
46
|
+
"""
|
47
|
+
urls = []
|
48
|
+
|
49
|
+
transformer = Transformer.from_crs("EPSG:4326", "EPSG:27700", always_xy=True)
|
50
|
+
|
51
|
+
|
52
|
+
# Make the GET request
|
53
|
+
north, south, east, west = self.get_bbox()
|
54
|
+
|
55
|
+
# Transform the coordinates
|
56
|
+
west_transformed, south_transformed = transformer.transform(west, south)
|
57
|
+
east_transformed, north_transformed = transformer.transform(east, north)
|
58
|
+
|
59
|
+
# Helper function to snap coordinate to nearest 1000 grid
|
60
|
+
def snap_to_grid(value, func):
|
61
|
+
return int(func(value * 0.001) * 1000)
|
62
|
+
|
63
|
+
# Snap bounding box coordinates to a 1000-unit grid
|
64
|
+
x_min = snap_to_grid(west_transformed, floor)
|
65
|
+
y_min = snap_to_grid(south_transformed, floor)
|
66
|
+
x_max = snap_to_grid(east_transformed, ceil)
|
67
|
+
y_max = snap_to_grid(north_transformed, ceil)
|
68
|
+
|
69
|
+
# Calculate the number of tiles in x and y directions
|
70
|
+
x_tiles = abs(x_max - x_min) // 1000
|
71
|
+
y_tiles = abs(y_max - y_min) // 1000
|
72
|
+
|
73
|
+
|
74
|
+
for x_tile in range(x_tiles):
|
75
|
+
for y_tile in range(y_tiles):
|
76
|
+
b_west = x_min + 1000 * (x_tile + 1) - 855
|
77
|
+
b_south = y_min + 1000 * (y_tile + 1) - 855
|
78
|
+
b_east = b_west + 145
|
79
|
+
b_north = b_south + 145
|
80
|
+
|
81
|
+
try:
|
82
|
+
params = {
|
83
|
+
"service": "WMS",
|
84
|
+
"version": self._wms_version,
|
85
|
+
"request": "GetFeatureInfo",
|
86
|
+
"exceptions": "application/json",
|
87
|
+
"layers": "geonode:welsh_government_lidar_tile_catalogue_2020_2023",
|
88
|
+
"query_layers": "geonode:welsh_government_lidar_tile_catalogue_2020_2023",
|
89
|
+
"styles": "",
|
90
|
+
"x": 51,
|
91
|
+
"y": 51,
|
92
|
+
"height": 101,
|
93
|
+
"width": 101,
|
94
|
+
"srs": self._source_crs,
|
95
|
+
"bbox": f"{b_west},{b_south},{b_east},{b_north}",
|
96
|
+
"feature_count": 10,
|
97
|
+
"info_format": "application/json",
|
98
|
+
"ENV": "mapstore_language:en"
|
99
|
+
}
|
100
|
+
|
101
|
+
response = requests.get(# pylint: disable=W3101
|
102
|
+
self.url, # type: ignore
|
103
|
+
params=params, # type: ignore
|
104
|
+
timeout=60
|
105
|
+
)
|
106
|
+
|
107
|
+
self.logger.debug("Getting file locations from Welsh Government WMS GetFeatureInfo...")
|
108
|
+
|
109
|
+
# Check if the request was successful (HTTP status code 200)
|
110
|
+
if response.status_code == 200:
|
111
|
+
json_data = response.json()
|
112
|
+
features = json_data.get("features", [])
|
113
|
+
for feature in features:
|
114
|
+
dtm_link = feature.get("properties", {}).get("dtm_link")
|
115
|
+
if dtm_link:
|
116
|
+
urls.append("https://"+dtm_link)
|
117
|
+
else:
|
118
|
+
self.logger.error("Failed to get data. HTTP Status Code: %s", response.status_code)
|
119
|
+
except Exception as e:
|
120
|
+
self.logger.error("Failed to get data. Error: %s", e)
|
121
|
+
|
122
|
+
self.logger.debug("Received %s urls", len(urls))
|
123
|
+
return urls
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.2
|
4
4
|
Summary: Generate map templates for Farming Simulator from real places.
|
5
5
|
Author-email: iwatkot <iwatkot@gmail.com>
|
6
6
|
License: Apache License 2.0
|
@@ -729,6 +729,7 @@ In addition to SRTM 30m, which provides global coverage, the map above highlight
|
|
729
729
|
| 🇺🇸 USGS | 1-90 meters | [ZenJakey](https://github.com/ZenJakey) |
|
730
730
|
| 🏴 England | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
731
731
|
| 🏴 Scotland | 0.25-1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
732
|
+
| 🏴 Wales | 1 meter | [garnwenshared](https://github.com/garnshared) |
|
732
733
|
| 🇩🇪 Hessen, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
733
734
|
| 🇩🇪 Niedersachsen, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
734
735
|
| 🇩🇪 Bayern, Germany | 1 meter | [H4rdB4se](https://github.com/H4rdB4se) |
|
@@ -9,7 +9,7 @@ maps4fs/generator/statistics.py,sha256=aynS3zbAtiwnU_YLKHPTiiaKW98_suvQUhy1SGBA6
|
|
9
9
|
maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
|
10
10
|
maps4fs/generator/component/background.py,sha256=9CyT5MoQWILFwEGZThZnn3l1UEDI-5Sg0-VUV9TT240,23722
|
11
11
|
maps4fs/generator/component/config.py,sha256=IP530sapLofFskSnBEB96G0aUSd6Sno0G9ET3ca0ZOQ,3696
|
12
|
-
maps4fs/generator/component/dem.py,sha256=
|
12
|
+
maps4fs/generator/component/dem.py,sha256=PTgvSlG-lg7RJ4lq4TEf7mQBNSwBpiyStTaJzJjMHJs,11949
|
13
13
|
maps4fs/generator/component/grle.py,sha256=5ftHSg8FwSkabVlStlfG_erGZSOrilU-RUvCobfT1Yw,19539
|
14
14
|
maps4fs/generator/component/i3d.py,sha256=5703ntFt7EQKFpQWQN5ST_bM08akV3rpSwKZDvkFp6w,24462
|
15
15
|
maps4fs/generator/component/layer.py,sha256=-br4gAGcGeBNb3ldch9XFEK0lhXqb1IbArhFB5Owu54,6186
|
@@ -20,14 +20,14 @@ maps4fs/generator/component/base/component.py,sha256=HeNDaToKrS6OLeJepKZA7iQzZQD
|
|
20
20
|
maps4fs/generator/component/base/component_image.py,sha256=2NYJgCU8deHl7O2FYFYk38WKZVJygFoc2gjBXwH6vjM,5970
|
21
21
|
maps4fs/generator/component/base/component_mesh.py,sha256=7CfaEpfj_4P5LfAjFT4L76pTokqf6zmla9__sQNLUpA,8587
|
22
22
|
maps4fs/generator/component/base/component_xml.py,sha256=V9pGUvHh6UF6BP0qFARqDq9vquoAgq1zJqhOgBoeS_Y,3983
|
23
|
-
maps4fs/generator/dtm/__init__.py,sha256=
|
23
|
+
maps4fs/generator/dtm/__init__.py,sha256=UmCNfcU6i5H68bapMhZw7QgxjYLXBlUI337rOWUR-gE,1570
|
24
24
|
maps4fs/generator/dtm/arctic.py,sha256=LSivLLjtd6TJUaPYvgSYQ4KalMTaY58zFvwivSh45uM,2587
|
25
25
|
maps4fs/generator/dtm/baden.py,sha256=PQTMEPm9hrO3nKbv_DXA9oNYnGK_0ei41Q_DhtethX0,1041
|
26
26
|
maps4fs/generator/dtm/bavaria.py,sha256=nH2wTxiIdQgKotauTqD-zztwFgfZzIdym2sjmSqfujM,4295
|
27
27
|
maps4fs/generator/dtm/canada.py,sha256=XJ_za2LDV9PEV7hmjPnzdwPbpr6ezAR73-HDVaTuKPk,1290
|
28
28
|
maps4fs/generator/dtm/czech.py,sha256=sT0gwbtEnizVNcZeL7kyDdwmKvB3w8m6UgJR7ZTk1to,1058
|
29
29
|
maps4fs/generator/dtm/denmark.py,sha256=JFuBRrCJTMXe_vdO3gRCwsnZ3nZOp_Y6671Kq8aXRGM,1591
|
30
|
-
maps4fs/generator/dtm/dtm.py,sha256=
|
30
|
+
maps4fs/generator/dtm/dtm.py,sha256=rmfq3n1NiH5tx4ghrU9WmcXttaNWi0dye7VO5JB-_p4,18212
|
31
31
|
maps4fs/generator/dtm/england.py,sha256=3URUm7uLH_RYXcQdDW3Vt09GWKAE8RAy1ZFJB94kXOA,1124
|
32
32
|
maps4fs/generator/dtm/finland.py,sha256=VpXpvCgzbyKA6VGSa7ikSzE4B-cLfR1_2zOHvS8delc,1870
|
33
33
|
maps4fs/generator/dtm/flanders.py,sha256=LltmowbS84_DaBHAS9XYoJPMunX6sWGy6zaVACHj5Ro,1039
|
@@ -48,10 +48,11 @@ maps4fs/generator/dtm/switzerland.py,sha256=Jn3qYVEps_K6cH-9rMfB_zoXMxhzWQKPnlKk
|
|
48
48
|
maps4fs/generator/dtm/thuringia.py,sha256=iiIGdEZPIQJ-8tcaTeqYTvNHFmM_hFwzos4J8SW55kA,2353
|
49
49
|
maps4fs/generator/dtm/usgs_wcs.py,sha256=X8VxdhyH0-EciGE_X-KgrAM6sVLTGssYIhtebOj8MPI,1021
|
50
50
|
maps4fs/generator/dtm/utils.py,sha256=I-wUSA_J85Xbt8sZCZAVKHSIcrMj5Ng-0adtPVhVmk0,2315
|
51
|
+
maps4fs/generator/dtm/wales.py,sha256=J-fpP4Ofnjgrpr3OTMyOGxG4KK7dt9OcfbOZBzj250Y,4752
|
51
52
|
maps4fs/generator/dtm/base/wcs.py,sha256=lQAp_gVz9_XUmtyobJkskiefQpuJH4o1Vwb3CSQ0lQA,2510
|
52
53
|
maps4fs/generator/dtm/base/wms.py,sha256=6Va2UMhg_s0TMOfMhxrPbsiAPiw6-vXBglnaij032I0,2264
|
53
|
-
maps4fs-2.0.
|
54
|
-
maps4fs-2.0.
|
55
|
-
maps4fs-2.0.
|
56
|
-
maps4fs-2.0.
|
57
|
-
maps4fs-2.0.
|
54
|
+
maps4fs-2.0.2.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
55
|
+
maps4fs-2.0.2.dist-info/METADATA,sha256=3d9n2XeZKNp40kqYbycfqHssCTuI6paWRacNhQ-VtNs,47878
|
56
|
+
maps4fs-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
57
|
+
maps4fs-2.0.2.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
58
|
+
maps4fs-2.0.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|