maps4fs 1.8.176__py3-none-any.whl → 1.8.178__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/__init__.py +1 -0
- maps4fs/generator/component/i3d.py +3 -7
- maps4fs/generator/dtm/dtm.py +6 -2
- maps4fs/generator/dtm/switzerland.py +104 -0
- maps4fs/generator/map.py +11 -14
- maps4fs/logger.py +1 -1
- {maps4fs-1.8.176.dist-info → maps4fs-1.8.178.dist-info}/METADATA +4 -2
- {maps4fs-1.8.176.dist-info → maps4fs-1.8.178.dist-info}/RECORD +11 -10
- {maps4fs-1.8.176.dist-info → maps4fs-1.8.178.dist-info}/LICENSE.md +0 -0
- {maps4fs-1.8.176.dist-info → maps4fs-1.8.178.dist-info}/WHEEL +0 -0
- {maps4fs-1.8.176.dist-info → maps4fs-1.8.178.dist-info}/top_level.txt +0 -0
maps4fs/__init__.py
CHANGED
@@ -16,6 +16,7 @@ from maps4fs.generator.dtm.spain import SpainProvider
|
|
16
16
|
from maps4fs.generator.dtm.france import FranceProvider
|
17
17
|
from maps4fs.generator.dtm.norway import NorwayProvider
|
18
18
|
from maps4fs.generator.dtm.denmark import DenmarkProvider
|
19
|
+
from maps4fs.generator.dtm.switzerland import SwitzerlandProvider
|
19
20
|
from maps4fs.generator.game import Game
|
20
21
|
from maps4fs.generator.map import Map
|
21
22
|
from maps4fs.generator.settings import (
|
@@ -15,8 +15,6 @@ from tqdm import tqdm
|
|
15
15
|
from maps4fs.generator.component.base.component_xml import XMLComponent
|
16
16
|
from maps4fs.generator.settings import Parameters
|
17
17
|
|
18
|
-
MAP_SIZE_LIMIT_FOR_DISPLACEMENT_LAYER = 4096
|
19
|
-
DISPLACEMENT_LAYER_SIZE_FOR_BIG_MAPS = 32768
|
20
18
|
NODE_ID_STARTING_VALUE = 2000
|
21
19
|
SPLINES_NODE_ID_STARTING_VALUE = 5000
|
22
20
|
TREE_NODE_ID_STARTING_VALUE = 10000
|
@@ -103,11 +101,9 @@ class I3d(XMLComponent):
|
|
103
101
|
|
104
102
|
self.get_and_update_element(root, sun_element_path, data)
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
self.get_and_update_element(root, displacement_layer_path, data)
|
104
|
+
displacement_layer_path = ".//Scene/TerrainTransformGroup/Layers/DisplacementLayer"
|
105
|
+
data = {"size": str(int(self.map_size * 8))}
|
106
|
+
self.get_and_update_element(root, displacement_layer_path, data)
|
111
107
|
|
112
108
|
self.save_tree(tree)
|
113
109
|
|
maps4fs/generator/dtm/dtm.py
CHANGED
@@ -12,14 +12,13 @@ from zipfile import ZipFile
|
|
12
12
|
import numpy as np
|
13
13
|
import osmnx as ox # type: ignore
|
14
14
|
import rasterio # type: ignore
|
15
|
+
import requests
|
15
16
|
from pydantic import BaseModel
|
16
17
|
from rasterio.enums import Resampling
|
17
18
|
from rasterio.merge import merge
|
18
19
|
from rasterio.warp import calculate_default_transform, reproject
|
19
|
-
import requests
|
20
20
|
from tqdm import tqdm
|
21
21
|
|
22
|
-
|
23
22
|
from maps4fs.logger import Logger
|
24
23
|
|
25
24
|
if TYPE_CHECKING:
|
@@ -79,6 +78,11 @@ class DTMProvider(ABC):
|
|
79
78
|
|
80
79
|
self._data_info: dict[str, int | str | float] | None = None
|
81
80
|
|
81
|
+
@classmethod
|
82
|
+
def name(cls) -> str | None:
|
83
|
+
"""Name of the provider."""
|
84
|
+
return cls._name
|
85
|
+
|
82
86
|
@property
|
83
87
|
def data_info(self) -> dict[str, int | str | float] | None:
|
84
88
|
"""Information about the DTM data.
|
@@ -0,0 +1,104 @@
|
|
1
|
+
"""This module contains provider of Switzerland data."""
|
2
|
+
|
3
|
+
import json
|
4
|
+
import os
|
5
|
+
|
6
|
+
import requests
|
7
|
+
|
8
|
+
from maps4fs.generator.dtm import utils
|
9
|
+
from maps4fs.generator.dtm.dtm import DTMProvider, DTMProviderSettings
|
10
|
+
|
11
|
+
|
12
|
+
class SwitzerlandProviderSettings(DTMProviderSettings):
|
13
|
+
"""Settings for the Switzerland provider."""
|
14
|
+
|
15
|
+
resolution: tuple | str = ("0.5", "2.0")
|
16
|
+
|
17
|
+
|
18
|
+
class SwitzerlandProvider(DTMProvider):
|
19
|
+
"""Provider of Switzerland."""
|
20
|
+
|
21
|
+
_code = "switzerland"
|
22
|
+
_name = "Switzerland"
|
23
|
+
_region = "CH"
|
24
|
+
_icon = "🇨🇭"
|
25
|
+
_resolution = "0.5-2"
|
26
|
+
_settings = SwitzerlandProviderSettings
|
27
|
+
_author = "[kbrandwijk](https://github.com/kbrandwijk)"
|
28
|
+
_is_community = True
|
29
|
+
|
30
|
+
_extents = (47.8308275417, 45.7769477403, 10.4427014502, 6.02260949059)
|
31
|
+
|
32
|
+
_url = (
|
33
|
+
"https://ogd.swisstopo.admin.ch/services/swiseld/"
|
34
|
+
"services/assets/ch.swisstopo.swissalti3d/search"
|
35
|
+
)
|
36
|
+
|
37
|
+
def download_tiles(self):
|
38
|
+
download_urls = self.get_download_urls()
|
39
|
+
all_tif_files = self.download_tif_files(download_urls, self.shared_tiff_path)
|
40
|
+
return all_tif_files
|
41
|
+
|
42
|
+
def __init__(self, *args, **kwargs):
|
43
|
+
super().__init__(*args, **kwargs)
|
44
|
+
self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
|
45
|
+
os.makedirs(self.shared_tiff_path, exist_ok=True)
|
46
|
+
|
47
|
+
def get_download_urls(self) -> list[str]:
|
48
|
+
"""Get download URLs of the GeoTIFF files from the USGS API.
|
49
|
+
|
50
|
+
Returns:
|
51
|
+
list: List of download URLs.
|
52
|
+
"""
|
53
|
+
urls = []
|
54
|
+
try:
|
55
|
+
bbox = self.get_bbox()
|
56
|
+
north, south, east, west = utils.transform_bbox(bbox, "EPSG:2056")
|
57
|
+
|
58
|
+
params = {
|
59
|
+
"format": "image/tiff; application=geotiff; profile=cloud-optimized",
|
60
|
+
"resolution": self.user_settings.resolution, # type: ignore
|
61
|
+
"srid": 2056,
|
62
|
+
"state": "current",
|
63
|
+
}
|
64
|
+
|
65
|
+
data = {
|
66
|
+
"geometry": json.dumps(
|
67
|
+
{
|
68
|
+
"type": "Polygon",
|
69
|
+
"crs": {"type": "name", "properties": {"name": "EPSG:2056"}},
|
70
|
+
"coordinates": [
|
71
|
+
[
|
72
|
+
[north, east],
|
73
|
+
[south, east],
|
74
|
+
[south, west],
|
75
|
+
[north, west],
|
76
|
+
[north, east],
|
77
|
+
]
|
78
|
+
],
|
79
|
+
}
|
80
|
+
)
|
81
|
+
}
|
82
|
+
|
83
|
+
response = requests.post( # pylint: disable=W3101
|
84
|
+
self.url, # type: ignore
|
85
|
+
params=params,
|
86
|
+
data=data,
|
87
|
+
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
88
|
+
timeout=60,
|
89
|
+
)
|
90
|
+
self.logger.debug("Getting file locations...")
|
91
|
+
|
92
|
+
# Check if the request was successful (HTTP status code 200)
|
93
|
+
if response.status_code == 200:
|
94
|
+
# Parse the JSON response
|
95
|
+
json_data = response.json()
|
96
|
+
items = json_data["items"]
|
97
|
+
for item in items:
|
98
|
+
urls.append(item["ass_asset_href"])
|
99
|
+
else:
|
100
|
+
self.logger.error("Failed to get data. HTTP Status Code: %s", response.status_code)
|
101
|
+
except requests.exceptions.RequestException as e:
|
102
|
+
self.logger.error("Failed to get data. Error: %s", e)
|
103
|
+
self.logger.debug("Received %s urls", len(urls))
|
104
|
+
return urls
|
maps4fs/generator/map.py
CHANGED
@@ -77,10 +77,12 @@ class Map:
|
|
77
77
|
self.coordinates = coordinates
|
78
78
|
self.map_directory = map_directory
|
79
79
|
|
80
|
-
|
80
|
+
log_entry = ""
|
81
|
+
log_entry += f"Game was set to {game.code}. "
|
82
|
+
log_entry += f"DTM provider was set to {dtm_provider.name()}. "
|
81
83
|
|
82
84
|
self.custom_osm = custom_osm
|
83
|
-
|
85
|
+
log_entry += f"Custom OSM file: {custom_osm}. "
|
84
86
|
|
85
87
|
# Make a copy of a custom osm file to the map directory, so it will be
|
86
88
|
# included in the output archive.
|
@@ -90,30 +92,26 @@ class Map:
|
|
90
92
|
self.logger.debug("Custom OSM file copied to %s", copy_path)
|
91
93
|
|
92
94
|
self.dem_settings = dem_settings
|
93
|
-
|
95
|
+
log_entry += f"DEM settings: {dem_settings}. "
|
94
96
|
if self.dem_settings.water_depth > 0:
|
95
97
|
# Make sure that the plateau value is >= water_depth
|
96
98
|
self.dem_settings.plateau = max(
|
97
99
|
self.dem_settings.plateau, self.dem_settings.water_depth
|
98
100
|
)
|
99
|
-
self.logger.info(
|
100
|
-
"Plateau value was set to %s to be >= water_depth value %s",
|
101
|
-
self.dem_settings.plateau,
|
102
|
-
self.dem_settings.water_depth,
|
103
|
-
)
|
104
101
|
|
105
102
|
self.background_settings = background_settings
|
106
|
-
|
103
|
+
log_entry += f"Background settings: {background_settings}. "
|
107
104
|
self.grle_settings = grle_settings
|
108
|
-
|
105
|
+
log_entry += f"GRLE settings: {grle_settings}. "
|
109
106
|
self.i3d_settings = i3d_settings
|
110
|
-
|
107
|
+
log_entry += f"I3D settings: {i3d_settings}. "
|
111
108
|
self.texture_settings = texture_settings
|
112
|
-
|
109
|
+
log_entry += f"Texture settings: {texture_settings}. "
|
113
110
|
self.spline_settings = spline_settings
|
114
|
-
|
111
|
+
log_entry += f"Spline settings: {spline_settings}. "
|
115
112
|
self.satellite_settings = satellite_settings
|
116
113
|
|
114
|
+
self.logger.info(log_entry)
|
117
115
|
os.makedirs(self.map_directory, exist_ok=True)
|
118
116
|
self.logger.debug("Map directory created: %s", self.map_directory)
|
119
117
|
|
@@ -148,7 +146,6 @@ class Map:
|
|
148
146
|
|
149
147
|
self.tree_custom_schema = kwargs.get("tree_custom_schema", None)
|
150
148
|
if self.tree_custom_schema:
|
151
|
-
self.logger.info("Custom tree schema contains %s trees", len(self.tree_custom_schema))
|
152
149
|
save_path = os.path.join(self.map_directory, "tree_custom_schema.json")
|
153
150
|
with open(save_path, "w", encoding="utf-8") as file:
|
154
151
|
json.dump(self.tree_custom_schema, file, indent=4)
|
maps4fs/logger.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 1.8.
|
3
|
+
Version: 1.8.178
|
4
4
|
Summary: Generate map templates for Farming Simulator from real places.
|
5
5
|
Author-email: iwatkot <iwatkot@gmail.com>
|
6
6
|
License: MIT License
|
@@ -682,7 +682,7 @@ The generator supports adding the own DTM providers, please refer to the [DTM Pr
|
|
682
682
|
|
683
683
|
### Supported DTM providers
|
684
684
|
|
685
|
-

|
686
686
|
|
687
687
|
In addition to SRTM 30m, which provides global coverage, the map above highlights all countries and/or regions where higher resolution coverage is provided by one of the DTM providers.
|
688
688
|
|
@@ -703,6 +703,8 @@ In addition to SRTM 30m, which provides global coverage, the map above highlight
|
|
703
703
|
| 🇳🇴 Norway | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
704
704
|
| 🇪🇸 Spain | 5 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
705
705
|
| 🇫🇮 Finland | 2 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
706
|
+
| 🇩🇰 Denmark | 0.4 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
707
|
+
| 🇨🇭 Switzerland | 0.5-2 meter | [kbrandwijk](https://github.com/kbrandwijk) |
|
706
708
|
|
707
709
|
## Special thanks
|
708
710
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
maps4fs/__init__.py,sha256=
|
2
|
-
maps4fs/logger.py,sha256=
|
1
|
+
maps4fs/__init__.py,sha256=vbZRLqERqH-LD2l69dSyZEU4DsuVCU93UrGX5wYs3Os,1431
|
2
|
+
maps4fs/logger.py,sha256=HQrDyj72mUjVYo25aR_-_SxVn2rfFjDCNbj-JKJdSnE,1488
|
3
3
|
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
4
4
|
maps4fs/generator/dem.py,sha256=oLN02bWNax73HzFsseRBOV47Azl_1L7qdrzuxHh4i_c,11886
|
5
5
|
maps4fs/generator/game.py,sha256=FFAyckuTW6Ix5aRACXOj2eiA72xd3OMCcOARrMhS164,11025
|
6
|
-
maps4fs/generator/map.py,sha256=
|
6
|
+
maps4fs/generator/map.py,sha256=N3lSIEmGQXSrOYXochHEib5djmxL5szFM2crT31Nwog,11312
|
7
7
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
8
8
|
maps4fs/generator/settings.py,sha256=cFlN-gK8QcySqyPtcGm-2fLnxQnlmC3Y9kQufJxwI3Y,6270
|
9
9
|
maps4fs/generator/texture.py,sha256=_IfqIuxH4934VJXKtdABHa6ToPWk3T0xknvlu-rZ5Uc,36570
|
@@ -11,7 +11,7 @@ maps4fs/generator/component/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2
|
|
11
11
|
maps4fs/generator/component/background.py,sha256=cBBp-ULrJzuNG9wfE_MaxzAn_mR24neqtL7WjxXEb3I,18749
|
12
12
|
maps4fs/generator/component/config.py,sha256=RitKgFDZPzjA1fi8GcEi1na75qqaueUvpcITHjBvCXc,3674
|
13
13
|
maps4fs/generator/component/grle.py,sha256=aKMjVJNuKHJJ2gsXaH00bz10kWaIbbZXU_JbP-ZAGw4,18990
|
14
|
-
maps4fs/generator/component/i3d.py,sha256=
|
14
|
+
maps4fs/generator/component/i3d.py,sha256=z2ZkflA5E8FrHcGleXSVKZRWvkqclz_Yh_qxJI86enE,19685
|
15
15
|
maps4fs/generator/component/satellite.py,sha256=oZBHjP_QY0ik1-Vk7JqMS__zIG8ffw2voeozB7-HUQc,4946
|
16
16
|
maps4fs/generator/component/base/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
17
17
|
maps4fs/generator/component/base/component.py,sha256=apGuQ7TcwqL0neJZiciNLGO22wZwYyqoDZM7aI1RHw8,21273
|
@@ -22,7 +22,7 @@ maps4fs/generator/dtm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
22
22
|
maps4fs/generator/dtm/bavaria.py,sha256=7njrEvSCYAC8ZVyvS-_84iXHhWA0oHKrEqSzxdnZuGs,4293
|
23
23
|
maps4fs/generator/dtm/canada.py,sha256=lYONwm6aNX5cjVggR3AiZZF9dlCDAWg0M8RMaObog8s,1288
|
24
24
|
maps4fs/generator/dtm/denmark.py,sha256=GMB9PPxXth6V1v3XuURVWVabJf4xlr158bKfeIIisek,1476
|
25
|
-
maps4fs/generator/dtm/dtm.py,sha256=
|
25
|
+
maps4fs/generator/dtm/dtm.py,sha256=vZh3Z5grfQy0gvo-xAgXwkWExk1kW1pGVw2nk54hN-8,16983
|
26
26
|
maps4fs/generator/dtm/england.py,sha256=YyCYwnNUJuBeeMNUozfKIj_yNjHpGeuH1Mz0NiAJL-U,1122
|
27
27
|
maps4fs/generator/dtm/finland.py,sha256=Chi3-3sanLIYpipjtPpTu9tqnL3DYcnygSDCPm1s24c,1753
|
28
28
|
maps4fs/generator/dtm/flanders.py,sha256=81pKkrM40SeOe1LSlcsTNXSmUNpofC4D454DG6WFSyA,1037
|
@@ -35,6 +35,7 @@ maps4fs/generator/dtm/nrw.py,sha256=1zMa10O0NdQbiTwOa7XXGrx3NhdHUqRXI4yBn_Scb2M,
|
|
35
35
|
maps4fs/generator/dtm/scotland.py,sha256=Od4dDMuCM_iteewjGBbmZXJ26S0bDwrhRhXeV4HyyOA,4803
|
36
36
|
maps4fs/generator/dtm/spain.py,sha256=HxN0MvrtRqqeTmhl47q60-1DGaMDb2wq6neMcDlDCl8,1005
|
37
37
|
maps4fs/generator/dtm/srtm.py,sha256=ob6AUuEn3G3G9kdqTA2VhT335N65RRBJsqAfHuw0gA8,4502
|
38
|
+
maps4fs/generator/dtm/switzerland.py,sha256=GC5fbWL5kkiWksB-H4dWl4I7GSmOsUZ_ywPpfkxBTo8,3547
|
38
39
|
maps4fs/generator/dtm/usgs.py,sha256=1XzLP5GJbe6xcqzkOrEBUtR2SPw7gm6rl1nw5YXmBP8,3253
|
39
40
|
maps4fs/generator/dtm/utils.py,sha256=I-wUSA_J85Xbt8sZCZAVKHSIcrMj5Ng-0adtPVhVmk0,2315
|
40
41
|
maps4fs/generator/dtm/base/wcs.py,sha256=UfkLNHqsYTr2ytjyZjWDocq2hFC_qyFCvl-_tnz6gHM,2510
|
@@ -43,8 +44,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
|
|
43
44
|
maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
|
44
45
|
maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
|
45
46
|
maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
|
46
|
-
maps4fs-1.8.
|
47
|
-
maps4fs-1.8.
|
48
|
-
maps4fs-1.8.
|
49
|
-
maps4fs-1.8.
|
50
|
-
maps4fs-1.8.
|
47
|
+
maps4fs-1.8.178.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
48
|
+
maps4fs-1.8.178.dist-info/METADATA,sha256=JwRZ0vsWJ_S0xwewgqwW3zdShEH2-HbLQF0cWKMv5no,44229
|
49
|
+
maps4fs-1.8.178.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
50
|
+
maps4fs-1.8.178.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
51
|
+
maps4fs-1.8.178.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|