maps4fs 1.8.216__py3-none-any.whl → 1.8.218__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.
@@ -176,7 +176,10 @@ class Component:
176
176
  self.logger.debug("Updated generation info, now contains %s fields", len(data))
177
177
 
178
178
  with open(self.generation_info_path, "w", encoding="utf-8") as file:
179
- json.dump(updated_generation_info, file, indent=4)
179
+ try:
180
+ json.dump(updated_generation_info, file, indent=4)
181
+ except Exception as e:
182
+ self.logger.warning("Could not save updated generation info: %s", e)
180
183
 
181
184
  self.logger.debug("Saved updated generation info to %s", self.generation_info_path)
182
185
 
maps4fs/generator/dem.py CHANGED
@@ -63,6 +63,8 @@ class DEM(Component):
63
63
  map=self.map,
64
64
  )
65
65
 
66
+ self.info: dict[str, Any] = {}
67
+
66
68
  @property
67
69
  def dem_path(self) -> str:
68
70
  """Returns path to the DEM file.
@@ -112,6 +114,25 @@ class DEM(Component):
112
114
  )
113
115
  return dem_size, dem_size
114
116
 
117
+ def update_info(self, state: str, data: np.ndarray) -> None:
118
+ """Update info dictionary with additional information about DEM data.
119
+
120
+ Arguments:
121
+ data (np.ndarray): DEM data.
122
+ """
123
+
124
+ try:
125
+ entry = {
126
+ "min": float(data.min()),
127
+ "max": float(data.max()),
128
+ "deviation": float(data.max() - data.min()),
129
+ "dtype": str(data.dtype),
130
+ "shape": str(data.shape),
131
+ }
132
+ self.info[state] = entry
133
+ except Exception as e:
134
+ self.logger.warning("Failed to update DEM info: %s.", e)
135
+
115
136
  def process(self) -> None:
116
137
  """Reads DTM file, crops it to map size, normalizes and blurs it,
117
138
  saves to map directory."""
@@ -141,6 +162,8 @@ class DEM(Component):
141
162
  data.max(),
142
163
  )
143
164
 
165
+ self.update_info("original", data)
166
+
144
167
  # Check if the data contains any non zero values, otherwise raise an error.
145
168
  if not np.any(data):
146
169
  self.logger.error("DTM provider returned empty data.")
@@ -151,10 +174,12 @@ class DEM(Component):
151
174
 
152
175
  # 2. Apply multiplier (-10 to 120.4 becomes -20 to 240.8)
153
176
  resampled_data = self.apply_multiplier(resampled_data)
177
+ self.update_info("multiplied", resampled_data)
154
178
 
155
179
  # 3. Raise terrain, and optionally lower to plateau level+water depth
156
180
  # e.g. -20 to 240.8m becomes 20 to 280.8m
157
181
  resampled_data = self.raise_or_lower(resampled_data)
182
+ self.update_info("raised_lowered", resampled_data)
158
183
 
159
184
  # 4. Determine actual height scale value using ceiling
160
185
  # e.g. 255 becomes 280.8+10 = 291
@@ -163,6 +188,7 @@ class DEM(Component):
163
188
  # 5. Normalize DEM data to 16-bit unsigned integer range (0 to 65535)
164
189
  # e.g. multiply by 65535/291, clip and return as uint16
165
190
  resampled_data = self.normalize_data(resampled_data, height_scale_value)
191
+ self.update_info("normalized", resampled_data)
166
192
 
167
193
  # 6. Blur DEM data.
168
194
  resampled_data = self.apply_blur(resampled_data)
@@ -211,6 +237,17 @@ class DEM(Component):
211
237
  self.map.shared_settings.height_scale_multiplier = adjusted_height_scale / 255
212
238
  self.map.shared_settings.change_height_scale = True # type: ignore
213
239
 
240
+ try:
241
+ entry = {
242
+ "height_scale_from_settings": height_scale,
243
+ "adjusted_height_scale": adjusted_height_scale,
244
+ "mesh_z_scaling_factor": self.map.shared_settings.mesh_z_scaling_factor,
245
+ "height_scale_multiplier": self.map.shared_settings.height_scale_multiplier,
246
+ }
247
+ self.info["height_scale"] = entry
248
+ except Exception as e:
249
+ self.logger.warning("Failed to update DEM info: %s.", e)
250
+
214
251
  self.logger.debug("Height scale value is %s.", adjusted_height_scale)
215
252
  return adjusted_height_scale
216
253
 
@@ -316,14 +353,9 @@ class DEM(Component):
316
353
  )
317
354
 
318
355
  def info_sequence(self) -> dict[Any, Any] | None: # type: ignore
319
- """Returns the information sequence for the component. Must be implemented in the child
320
- class. If the component does not have an information sequence, an empty dictionary must be
321
- returned.
356
+ """Returns the information sequence for the component.
322
357
 
323
358
  Returns:
324
359
  dict[Any, Any]: The information sequence for the component.
325
360
  """
326
- provider_info_sequence = self.dtm_provider.info_sequence()
327
- if provider_info_sequence is None:
328
- return {}
329
- return provider_info_sequence
361
+ return self.info
@@ -74,8 +74,6 @@ class DTMProvider(ABC):
74
74
  self.logger = logger
75
75
  self.map = map
76
76
 
77
- self._data_info: dict[str, int | str | float] | None = None
78
-
79
77
  @classmethod
80
78
  def name(cls) -> str | None:
81
79
  """Name of the provider.
@@ -94,24 +92,6 @@ class DTMProvider(ABC):
94
92
  """
95
93
  return cls._code
96
94
 
97
- @property
98
- def data_info(self) -> dict[str, int | str | float] | None:
99
- """Information about the DTM data.
100
-
101
- Returns:
102
- dict[str, int | str | float] | None: Information about the DTM data.
103
- """
104
- return self._data_info
105
-
106
- @data_info.setter
107
- def data_info(self, value: dict[str, int | str | float] | None) -> None:
108
- """Set information about the DTM data.
109
-
110
- Arguments:
111
- value (dict[str, int | str | float] | None): Information about the DTM data.
112
- """
113
- self._data_info = value
114
-
115
95
  @property
116
96
  def coordinates(self) -> tuple[float, float]:
117
97
  """Coordinates of the center point of the DTM data.
@@ -330,16 +310,6 @@ class DTMProvider(ABC):
330
310
 
331
311
  return data
332
312
 
333
- def info_sequence(self) -> dict[str, int | str | float] | None:
334
- """Returns the information sequence for the component. Must be implemented in the child
335
- class. If the component does not have an information sequence, an empty dictionary must be
336
- returned.
337
-
338
- Returns:
339
- dict[str, int | str | float] | None: Information sequence for the component.
340
- """
341
- return self.data_info
342
-
343
313
  # region helpers
344
314
  def get_bbox(self) -> tuple[float, float, float, float]:
345
315
  """Get bounding box of the tile based on the center point and size.
@@ -33,7 +33,6 @@ class SRTM30Provider(DTMProvider):
33
33
  self.gz_directory = os.path.join(self._tile_directory, "gz")
34
34
  os.makedirs(self.hgt_directory, exist_ok=True)
35
35
  os.makedirs(self.gz_directory, exist_ok=True)
36
- self.data_info: dict[str, int | str | float] | None = None # type: ignore
37
36
 
38
37
  def download_tiles(self):
39
38
  """Download SRTM tiles."""
@@ -225,4 +225,4 @@ class SatelliteSettings(SettingsModel):
225
225
 
226
226
  download_images: bool = False
227
227
  satellite_margin: int = 0
228
- zoom_level: int = 14
228
+ zoom_level: int = 16
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.8.216
3
+ Version: 1.8.218
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
@@ -1,11 +1,11 @@
1
1
  maps4fs/__init__.py,sha256=EGvLVoRpSt4jITswsGbe1ISVmGAZAMQJcBmTwtyuVxI,335
2
2
  maps4fs/logger.py,sha256=HQrDyj72mUjVYo25aR_-_SxVn2rfFjDCNbj-JKJdSnE,1488
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/dem.py,sha256=Nyz64BWM---Vpy1mi8bbhHEfd2Wc2rWw9UqHraqXDJ8,11771
4
+ maps4fs/generator/dem.py,sha256=a9B3tatj7pzvvdLIyLw7BA3JoDTibFczpqiXJnx054U,12864
5
5
  maps4fs/generator/game.py,sha256=NZaxj5z7WzMiHzAvQyr-TvVjGoHgqGldM6ZsItuYyzA,11292
6
6
  maps4fs/generator/map.py,sha256=1mbnOWXVEDeFHWDBBDX9ugzRtrGBQYrJ5ruKmPUsMe8,11136
7
7
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
8
- maps4fs/generator/settings.py,sha256=wscbtbJ8shuLshUE1RSiNXkPGY_SkGQ9qa0v0NHj_aQ,6747
8
+ maps4fs/generator/settings.py,sha256=d3NaMpyFh-IZWtHV2UQMMqUfuPP76lv7mIN2d7mORqA,6747
9
9
  maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
10
10
  maps4fs/generator/component/background.py,sha256=ppxK2RheCYrLRnBkLeZUst6Ciopo9Z_zUyjS-n8YwGE,18794
11
11
  maps4fs/generator/component/config.py,sha256=RitKgFDZPzjA1fi8GcEi1na75qqaueUvpcITHjBvCXc,3674
@@ -15,7 +15,7 @@ maps4fs/generator/component/layer.py,sha256=QPcEzTv_8N9wYvHAZy8OezfATaVLG-YetSfC
15
15
  maps4fs/generator/component/satellite.py,sha256=oZBHjP_QY0ik1-Vk7JqMS__zIG8ffw2voeozB7-HUQc,4946
16
16
  maps4fs/generator/component/texture.py,sha256=GWOE7w2maydB2LDku-YEC1w1oc8kcnnZ1SPTL6b82H8,30966
17
17
  maps4fs/generator/component/base/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
18
- maps4fs/generator/component/base/component.py,sha256=apGuQ7TcwqL0neJZiciNLGO22wZwYyqoDZM7aI1RHw8,21273
18
+ maps4fs/generator/component/base/component.py,sha256=sUinM8Q6cb26ctJTNF35Gb4rU9gbPCMkV6PKju3sfRo,21414
19
19
  maps4fs/generator/component/base/component_image.py,sha256=2QnJ9xm0D54v4whg7bc1s-kwRVjZHhOo1OR5jHr1Qp0,4786
20
20
  maps4fs/generator/component/base/component_mesh.py,sha256=pc7UVakZCnJPV-0Ukdsm6aUD3NFZbOUazuEbb44k170,8747
21
21
  maps4fs/generator/component/base/component_xml.py,sha256=6OO1dKoceO1ACk7-k1oGtnkfNud8ZN3u3ZNjdNMpTqw,3967
@@ -26,7 +26,7 @@ maps4fs/generator/dtm/bavaria.py,sha256=nH2wTxiIdQgKotauTqD-zztwFgfZzIdym2sjmSqf
26
26
  maps4fs/generator/dtm/canada.py,sha256=XJ_za2LDV9PEV7hmjPnzdwPbpr6ezAR73-HDVaTuKPk,1290
27
27
  maps4fs/generator/dtm/czech.py,sha256=sT0gwbtEnizVNcZeL7kyDdwmKvB3w8m6UgJR7ZTk1to,1058
28
28
  maps4fs/generator/dtm/denmark.py,sha256=JFuBRrCJTMXe_vdO3gRCwsnZ3nZOp_Y6671Kq8aXRGM,1591
29
- maps4fs/generator/dtm/dtm.py,sha256=dXPQH6eT0InoPtt5ZD8TUS5uhrOSqB_t4UiDjhueZMs,17812
29
+ maps4fs/generator/dtm/dtm.py,sha256=iuZ5lV5OFefpmJh8NKu37APZydcjFzcrhLe1ChxVRjc,16748
30
30
  maps4fs/generator/dtm/england.py,sha256=3URUm7uLH_RYXcQdDW3Vt09GWKAE8RAy1ZFJB94kXOA,1124
31
31
  maps4fs/generator/dtm/finland.py,sha256=VpXpvCgzbyKA6VGSa7ikSzE4B-cLfR1_2zOHvS8delc,1870
32
32
  maps4fs/generator/dtm/flanders.py,sha256=LltmowbS84_DaBHAS9XYoJPMunX6sWGy6zaVACHj5Ro,1039
@@ -42,7 +42,7 @@ maps4fs/generator/dtm/rema.py,sha256=arLE12yE92EWmWysNUTtdEzwcNiCBtEBmnfnryOriRY
42
42
  maps4fs/generator/dtm/sachsenanhalt.py,sha256=UvLrQVxJX30BqtNbKZyR6EJc-vS5fLyanh6fntjYj2k,1144
43
43
  maps4fs/generator/dtm/scotland.py,sha256=kUGPNjn3mQPOU9sgK3k-uwumPG2wrRFLaDMyPMh06Jw,4819
44
44
  maps4fs/generator/dtm/spain.py,sha256=A5QScsrd_bkVlf2n9ZfXBL9z_YoXpLsm_5FWs-5nd_o,1021
45
- maps4fs/generator/dtm/srtm.py,sha256=zeQovZCC6AKzdKAxypKQFuIn1mi2c9EUpRjaA4jSVVs,4346
45
+ maps4fs/generator/dtm/srtm.py,sha256=RcAB0PRaTLAJNvasLLdGVvjww05Lby2O2Aw5TG0M0sY,4263
46
46
  maps4fs/generator/dtm/switzerland.py,sha256=Jn3qYVEps_K6cH-9rMfB_zoXMxhzWQKPnlKkSE-TehE,3549
47
47
  maps4fs/generator/dtm/usgs_wcs.py,sha256=X8VxdhyH0-EciGE_X-KgrAM6sVLTGssYIhtebOj8MPI,1021
48
48
  maps4fs/generator/dtm/utils.py,sha256=I-wUSA_J85Xbt8sZCZAVKHSIcrMj5Ng-0adtPVhVmk0,2315
@@ -52,8 +52,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
52
52
  maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
53
53
  maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
54
54
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
55
- maps4fs-1.8.216.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
56
- maps4fs-1.8.216.dist-info/METADATA,sha256=UgfYmvQjsMnGZ7K-9NehPbnIvn3bik6VxbzzEW7D3yo,45770
57
- maps4fs-1.8.216.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
58
- maps4fs-1.8.216.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
59
- maps4fs-1.8.216.dist-info/RECORD,,
55
+ maps4fs-1.8.218.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
56
+ maps4fs-1.8.218.dist-info/METADATA,sha256=WW9AsSg2cAN09JKISXdtx8yV5O0cP5CE4IOOgafTHSw,45770
57
+ maps4fs-1.8.218.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
58
+ maps4fs-1.8.218.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
59
+ maps4fs-1.8.218.dist-info/RECORD,,