maps4fs 0.9.4__py3-none-any.whl → 0.9.7__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.
@@ -10,13 +10,18 @@ import numpy as np
10
10
  import trimesh # type: ignore
11
11
 
12
12
  from maps4fs.generator.component import Component
13
+ from maps4fs.generator.dem import (
14
+ DEFAULT_BLUR_RADIUS,
15
+ DEFAULT_MULTIPLIER,
16
+ DEFAULT_PLATEAU,
17
+ )
13
18
  from maps4fs.generator.path_steps import DEFAULT_DISTANCE, PATH_FULL_NAME, get_steps
14
19
  from maps4fs.generator.tile import Tile
15
20
  from maps4fs.logger import timeit
16
21
 
17
22
  RESIZE_FACTOR = 1 / 4
18
23
  SIMPLIFY_FACTOR = 10
19
- FULL_RESIZE_FACTOR = 1 / 4
24
+ FULL_RESIZE_FACTOR = 1 / 8
20
25
  FULL_SIMPLIFY_FACTOR = 20
21
26
 
22
27
 
@@ -58,9 +63,9 @@ class Background(Component):
58
63
  logger=self.logger,
59
64
  tile_code=path_step.code,
60
65
  auto_process=False,
61
- blur_radius=self.kwargs.get("blur_radius"),
62
- multiplier=self.kwargs.get("multiplier", 1),
63
- plateau=self.kwargs.get("plateau", 0),
66
+ blur_radius=self.kwargs.get("blur_radius", DEFAULT_BLUR_RADIUS),
67
+ multiplier=self.kwargs.get("multiplier", DEFAULT_MULTIPLIER),
68
+ plateau=self.kwargs.get("plateau", DEFAULT_PLATEAU),
64
69
  )
65
70
 
66
71
  # Update the origin for the next tile.
@@ -217,9 +222,28 @@ class Background(Component):
217
222
  mesh = mesh.simplify_quadric_decimation(face_count=len(faces) // simplify_factor)
218
223
  self.logger.debug("Mesh simplified to %s faces", len(mesh.faces))
219
224
 
225
+ if tile_code == PATH_FULL_NAME:
226
+ self.mesh_to_stl(mesh)
227
+
220
228
  mesh.export(save_path)
221
229
  self.logger.info("Obj file saved: %s", save_path)
222
230
 
231
+ def mesh_to_stl(self, mesh: trimesh.Trimesh) -> None:
232
+ """Converts the mesh to an STL file and saves it in the previews directory.
233
+ Uses powerful simplification to reduce the size of the file since it will be used
234
+ only for the preview.
235
+
236
+ Arguments:
237
+ mesh (trimesh.Trimesh) -- The mesh to convert to an STL file.
238
+ """
239
+ preview_path = os.path.join(self.previews_directory, "background_dem.stl")
240
+ mesh = mesh.simplify_quadric_decimation(percent=0.05)
241
+ mesh.export(preview_path)
242
+
243
+ self.logger.info("STL file saved: %s", preview_path)
244
+
245
+ self.stl_preview_path = preview_path # pylint: disable=attribute-defined-outside-init
246
+
223
247
  def previews(self) -> list[str]:
224
248
  """Generates a preview by combining all tiles into one image.
225
249
  NOTE: The map itself is not included in the preview, so it will be empty.
@@ -238,6 +262,8 @@ class Background(Component):
238
262
 
239
263
  for tile in self.tiles:
240
264
  # pylint: disable=no-member
265
+ if tile.code == PATH_FULL_NAME:
266
+ continue
241
267
  tile_image = cv2.imread(tile.dem_path, cv2.IMREAD_UNCHANGED)
242
268
 
243
269
  self.logger.debug(
@@ -297,7 +323,7 @@ class Background(Component):
297
323
  image = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR) # type: ignore
298
324
  cv2.imwrite(preview_path, image)
299
325
 
300
- return [preview_path]
326
+ return [preview_path, self.stl_preview_path]
301
327
 
302
328
 
303
329
  # Creates tiles around the map.
maps4fs/generator/dem.py CHANGED
@@ -13,8 +13,9 @@ import requests
13
13
  from maps4fs.generator.component import Component
14
14
 
15
15
  SRTM = "https://elevation-tiles-prod.s3.amazonaws.com/skadi/{latitude_band}/{tile_name}.hgt.gz"
16
- DEFAULT_MULTIPLIER = 1
16
+ DEFAULT_MULTIPLIER = 1.0
17
17
  DEFAULT_BLUR_RADIUS = 35
18
+ DEFAULT_PLATEAU = 0
18
19
 
19
20
 
20
21
  # pylint: disable=R0903, R0902
@@ -134,6 +135,16 @@ class DEM(Component):
134
135
  else:
135
136
  self.logger.debug("Auto processing is disabled, DEM data will not be normalized.")
136
137
  resampled_data = resampled_data * self.multiplier
138
+ # Clip values to 16-bit unsigned integer range.
139
+ resampled_data = np.clip(resampled_data, 0, 65535)
140
+ resampled_data = resampled_data.astype("uint16")
141
+ self.logger.debug(
142
+ "DEM data was multiplied by %s and clipped to 16-bit unsigned integer range. "
143
+ "Min: %s, max: %s.",
144
+ self.multiplier,
145
+ resampled_data.min(),
146
+ resampled_data.max(),
147
+ )
137
148
 
138
149
  self.logger.debug(
139
150
  "DEM data was resampled. Shape: %s, dtype: %s. Min: %s, max: %s.",
maps4fs/generator/qgis.py CHANGED
@@ -52,7 +52,7 @@ for layer in layers:
52
52
  points = [top_left, top_right, bottom_right, bottom_left, top_left]
53
53
 
54
54
  # Create a new layer
55
- layer = QgsVectorLayer('Point?crs=EPSG:4326', name, 'memory')
55
+ layer = QgsVectorLayer('Point?crs=EPSG:3857', name, 'memory')
56
56
  provider = layer.dataProvider()
57
57
 
58
58
  # Add fields
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 0.9.4
3
+ Version: 0.9.7
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
@@ -30,7 +30,8 @@ Requires-Dist: tifffile
30
30
  <p align="center">
31
31
  <a href="#Quick-Start">Quick Start</a> •
32
32
  <a href="#Overview">Overview</a> •
33
- <a href="#How-To-Run">How-To-Run</a><br>
33
+ <a href="#How-To-Run">How-To-Run</a>
34
+ <a href="tutorials/FAQ.md">FAQ</a><br>
34
35
  <a href="#Supported-objects">Supported objects</a> •
35
36
  <a href="#Generation-info">Generation info</a> •
36
37
  <a href="#Texture-schema">Texture schema</a> •
@@ -81,7 +82,7 @@ There are several ways to use the tool. You obviously need the **first one**, bu
81
82
  ### 🚜 For most users
82
83
  **Option 1:** open the [maps4fs](https://maps4fs.streamlit.app) on StreamLit and generate a map template in a few clicks.<br>
83
84
 
84
- ![Basic WebUI](https://github.com/user-attachments/assets/14620044-9e92-47ae-8531-d61460740f58)
85
+ ![Basic WebUI](https://github.com/user-attachments/assets/52f499cc-f28a-4da3-abef-0e818abe8dbe)
85
86
 
86
87
  ### 😎 For advanced users
87
88
  **Option 2:** run the Docker version in your browser. Launch the following command in your terminal:
@@ -409,7 +410,7 @@ The tool supports the custom size of the map. To use this feature select `Custom
409
410
 
410
411
  ⛔️ Do not use this feature, if you don't know what you're doing. In most cases the Giants Editor will just crash on opening the file, because you need to enter a specific values for the map size.<br><br>
411
412
 
412
- ![Advanced settings](https://github.com/user-attachments/assets/0446cdf2-f093-49ba-ba8f-9bef18a58b47)
413
+ ![Advanced settings](https://github.com/user-attachments/assets/e7406adf-6b82-41a0-838a-13dd8877bebf)
413
414
 
414
415
  You can also apply some advanced settings to the map generation process. Note that they're ADVANCED, so you don't need to use them if you're not sure what they do.<br>
415
416
 
@@ -429,6 +430,9 @@ To create a basic map, you only need the Giants Editor. But if you want to creat
429
430
  2. [Blender](https://www.blender.org/download/) - the open-source 3D modeling software that you can use to create models for the Farming Simulator.
430
431
  3. [Blender Exporter Plugins](https://gdn.giants-software.com/downloads.php) - the official plugins for exporting models from Blender to i3d format (the format used in the Farming Simulator).
431
432
  4. [QGIS](https://qgis.org/download/) - the open-source GIS software that you can use to obtain high-resolution satellite images for your map.
433
+ 5. [CompressPngCom](https://www.compresspng.com/) - the online tool to compress the PNG images. May be useful to reduce the size of the satellite images.
434
+ 6. [AnyConv](https://anyconv.com/png-to-dds-converter/) - the online tool to convert the PNG images to the DDS format. You'll need this format for the textures, icons, overview and preview images.
432
435
 
433
436
  ## Bugs and feature requests
437
+ ➡️ Please, before creating an issue or asking some questions, check the [FAQ](tutorials/FAQ.md) section.<br>
434
438
  If you find a bug or have an idea for a new feature, please create an issue [here](https://github.com/iwatkot/maps4fs/issues) or contact me directly on [Telegram](https://t.me/iwatkot) or on Discord: `iwatkot`.
@@ -1,19 +1,19 @@
1
1
  maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
2
2
  maps4fs/logger.py,sha256=8oZzAKJllilYrVp452LX0zx-dNFwpS6UngbTrI6KfwA,2148
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/background.py,sha256=6mN2xRg5XEqsLaXPUqdNGgDR1Ats60fBK93WlDeB8EI,13002
4
+ maps4fs/generator/background.py,sha256=AP-Z3F-4I9achvA9xsaXAAoA6IHtmPLxb1RkUsVYdbg,14036
5
5
  maps4fs/generator/component.py,sha256=ZEDjChPnvqAsgnBu2f2YBOlwGOlfax4VaAYBcJerLIQ,10684
6
6
  maps4fs/generator/config.py,sha256=ZO5BWDU-S3p0-ndKDSFa8Oin3YcYy0iH8B4lqEA_07Q,4275
7
- maps4fs/generator/dem.py,sha256=p7THncPUdYWtNR2HrTXe0bCuJ8psUV8rRpYPJkzL2gA,15220
7
+ maps4fs/generator/dem.py,sha256=XLpzjJMPZCxjrF-AhwTeEb-OQoCHEtYdK0b8z3Gb-is,15712
8
8
  maps4fs/generator/game.py,sha256=94HjPNOyy6XSSOnBp-uxrkBglKyC-X3ULIrrucfdlKw,6825
9
9
  maps4fs/generator/i3d.py,sha256=UuQiQRusPQ2f6PvGKxJ_UZeXsx3uG15efmy8Ysnm3F8,3597
10
10
  maps4fs/generator/map.py,sha256=v8OOLmhAkgqq64tQgEDbV6DmbgOVm3NXJBDDy0nJf60,4226
11
11
  maps4fs/generator/path_steps.py,sha256=yeN6hmOD8O2LMozUf4HcQMIy8WJ5sHF5pGQT_s2FfOw,3147
12
- maps4fs/generator/qgis.py,sha256=vhV-EwZKK-p1qEV-2H_yckuktx8ezlCMnmJJfUt1HGI,6091
12
+ maps4fs/generator/qgis.py,sha256=R5Iv3ovyLXkhAL5Oy41u3ZLNOSEbc1byLetzPootO7o,6091
13
13
  maps4fs/generator/texture.py,sha256=CwaXZfAG4e3D3YR7yVR2MC677EHpbUWTboCS3G6jkhk,17723
14
14
  maps4fs/generator/tile.py,sha256=3vmfjQiPiiUZKPuIo5tg2rOKkgcP1NRVkMGK-Vo10-A,2138
15
- maps4fs-0.9.4.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
16
- maps4fs-0.9.4.dist-info/METADATA,sha256=WVUjB4PmrCnuWZNIVurx3_1XPqS2oBEwWdVaU22uX2Y,24130
17
- maps4fs-0.9.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
18
- maps4fs-0.9.4.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
19
- maps4fs-0.9.4.dist-info/RECORD,,
15
+ maps4fs-0.9.7.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
16
+ maps4fs-0.9.7.dist-info/METADATA,sha256=dhMICyAhvj7SiKMKyK_-ewOb07j38R574o9SMezErYE,24635
17
+ maps4fs-0.9.7.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
18
+ maps4fs-0.9.7.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
19
+ maps4fs-0.9.7.dist-info/RECORD,,