maps4fs 1.8.244__tar.gz → 1.8.246__tar.gz

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.
Files changed (66) hide show
  1. {maps4fs-1.8.244 → maps4fs-1.8.246}/PKG-INFO +1 -1
  2. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/background.py +32 -0
  3. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/base/component_mesh.py +26 -6
  4. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs.egg-info/PKG-INFO +1 -1
  5. {maps4fs-1.8.244 → maps4fs-1.8.246}/pyproject.toml +1 -1
  6. {maps4fs-1.8.244 → maps4fs-1.8.246}/LICENSE.md +0 -0
  7. {maps4fs-1.8.244 → maps4fs-1.8.246}/README.md +0 -0
  8. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/__init__.py +0 -0
  9. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/__init__.py +0 -0
  10. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/__init__.py +0 -0
  11. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/base/__init__.py +0 -0
  12. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/base/component.py +0 -0
  13. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/base/component_image.py +0 -0
  14. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/base/component_xml.py +0 -0
  15. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/config.py +0 -0
  16. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/grle.py +0 -0
  17. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/i3d.py +0 -0
  18. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/layer.py +0 -0
  19. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/satellite.py +0 -0
  20. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/component/texture.py +0 -0
  21. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dem.py +0 -0
  22. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/__init__.py +0 -0
  23. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/arctic.py +0 -0
  24. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/baden.py +0 -0
  25. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/base/wcs.py +0 -0
  26. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/base/wms.py +0 -0
  27. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/bavaria.py +0 -0
  28. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/canada.py +0 -0
  29. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/czech.py +0 -0
  30. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/denmark.py +0 -0
  31. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/dtm.py +0 -0
  32. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/england.py +0 -0
  33. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/finland.py +0 -0
  34. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/flanders.py +0 -0
  35. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/france.py +0 -0
  36. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/hessen.py +0 -0
  37. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/italy.py +0 -0
  38. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/lithuania.py +0 -0
  39. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/mv.py +0 -0
  40. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/niedersachsen.py +0 -0
  41. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/norway.py +0 -0
  42. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/nrw.py +0 -0
  43. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/rema.py +0 -0
  44. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/sachsenanhalt.py +0 -0
  45. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/scotland.py +0 -0
  46. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/spain.py +0 -0
  47. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/srtm.py +0 -0
  48. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/switzerland.py +0 -0
  49. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/usgs_wcs.py +0 -0
  50. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/dtm/utils.py +0 -0
  51. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/game.py +0 -0
  52. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/map.py +0 -0
  53. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/qgis.py +0 -0
  54. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/settings.py +0 -0
  55. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/generator/statistics.py +0 -0
  56. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/logger.py +0 -0
  57. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/toolbox/__init__.py +0 -0
  58. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/toolbox/background.py +0 -0
  59. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/toolbox/custom_osm.py +0 -0
  60. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs/toolbox/dem.py +0 -0
  61. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs.egg-info/SOURCES.txt +0 -0
  62. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs.egg-info/dependency_links.txt +0 -0
  63. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs.egg-info/requires.txt +0 -0
  64. {maps4fs-1.8.244 → maps4fs-1.8.246}/maps4fs.egg-info/top_level.txt +0 -0
  65. {maps4fs-1.8.244 → maps4fs-1.8.246}/setup.cfg +0 -0
  66. {maps4fs-1.8.244 → maps4fs-1.8.246}/tests/test_generator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.8.244
3
+ Version: 1.8.246
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
@@ -6,10 +6,12 @@ from __future__ import annotations
6
6
  import os
7
7
  import shutil
8
8
  from copy import deepcopy
9
+ from typing import Any
9
10
 
10
11
  import cv2
11
12
  import numpy as np
12
13
  from tqdm import tqdm
14
+ from trimesh import Trimesh
13
15
 
14
16
  from maps4fs.generator.component.base.component_image import ImageComponent
15
17
  from maps4fs.generator.component.base.component_mesh import MeshComponent
@@ -44,6 +46,7 @@ class Background(MeshComponent, ImageComponent):
44
46
 
45
47
  self.background_size = self.map_size + Parameters.BACKGROUND_DISTANCE * 2
46
48
  self.rotated_size = int(self.background_size * output_size_multiplier)
49
+ self.mesh_info: list[dict[str, Any]] = []
47
50
 
48
51
  self.background_directory = os.path.join(self.map_directory, "background")
49
52
  self.water_directory = os.path.join(self.map_directory, "water")
@@ -194,6 +197,7 @@ class Background(MeshComponent, ImageComponent):
194
197
 
195
198
  dem_info_sequence = self.dem.info_sequence()
196
199
  data["DEM"] = dem_info_sequence
200
+ data["Mesh"] = self.mesh_info
197
201
  return data # type: ignore
198
202
 
199
203
  def qgis_sequence(self) -> None:
@@ -300,6 +304,11 @@ class Background(MeshComponent, ImageComponent):
300
304
  remove_size=self.map_size,
301
305
  )
302
306
 
307
+ try:
308
+ self.update_mesh_info(save_path, mesh)
309
+ except Exception as e:
310
+ self.logger.error("Could not update mesh info: %s", e)
311
+
303
312
  mesh.export(save_path)
304
313
  self.logger.debug("Obj file saved: %s", save_path)
305
314
 
@@ -307,6 +316,29 @@ class Background(MeshComponent, ImageComponent):
307
316
  mesh.apply_scale([0.5, 0.5, 0.5])
308
317
  self.mesh_to_stl(mesh, save_path=self.stl_preview_path)
309
318
 
319
+ def update_mesh_info(self, save_path: str, mesh: Trimesh) -> None:
320
+ """Updates the mesh info with the data from the mesh.
321
+
322
+ Arguments:
323
+ save_path (str): The path where the mesh is saved.
324
+ mesh (Trimesh): The mesh to get the data from.
325
+ """
326
+ filename = os.path.splitext(os.path.basename(save_path))[0]
327
+ x_size, y_size, z_size = mesh.extents
328
+ x_center, y_center, z_center = mesh.centroid
329
+
330
+ entry = {
331
+ "name": filename,
332
+ "x_size": round(x_size, 4),
333
+ "y_size": round(y_size, 4),
334
+ "z_size": round(z_size, 4),
335
+ "x_center": round(x_center, 4),
336
+ "y_center": round(y_center, 4),
337
+ "z_center": round(z_center, 4),
338
+ }
339
+
340
+ self.mesh_info.append(entry)
341
+
310
342
  def previews(self) -> list[str]:
311
343
  """Returns the path to the image previews paths and the path to the STL preview file.
312
344
 
@@ -130,11 +130,12 @@ class MeshComponent(Component):
130
130
  percent=percent, aggression=decimation_agression
131
131
  )
132
132
 
133
- try:
134
- if not mesh.is_watertight:
135
- mesh = MeshComponent.fix_mesh(mesh)
136
- except Exception:
137
- pass
133
+ # * Looks like it takes some time but has no effect on the result.
134
+ # try:
135
+ # if not mesh.is_watertight:
136
+ # mesh = MeshComponent.fix_mesh(mesh)
137
+ # except Exception:
138
+ # pass
138
139
 
139
140
  mesh = MeshComponent.mesh_to_output_size(
140
141
  mesh,
@@ -249,7 +250,26 @@ class MeshComponent(Component):
249
250
 
250
251
  _, _, z_size = mesh_copy.extents
251
252
 
253
+ try:
254
+ mesh_copy = MeshComponent.mesh_to_origin(mesh_copy)
255
+ except Exception:
256
+ pass
252
257
  cube_mesh = trimesh.creation.box([remove_size, remove_size, z_size * 4])
253
- cube_mesh.apply_translation(mesh_copy.centroid - cube_mesh.centroid)
254
258
 
255
259
  return trimesh.boolean.difference([mesh_copy, cube_mesh], check_volume=False)
260
+
261
+ @staticmethod
262
+ def mesh_to_origin(mesh: trimesh.Trimesh) -> trimesh.Trimesh:
263
+ """Moves the mesh to the origin using mesh size.
264
+
265
+ Arguments:
266
+ mesh (trimesh.Trimesh): The mesh to move to the origin.
267
+
268
+ Returns:
269
+ trimesh.Trimesh: The mesh moved to the origin.
270
+ """
271
+ mesh_copy = mesh.copy()
272
+ x_size, _, _ = mesh_copy.extents
273
+ distance = int(round(x_size) / 2)
274
+ mesh_copy.apply_translation([-distance, distance, 0])
275
+ return mesh_copy
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.8.244
3
+ Version: 1.8.246
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maps4fs"
7
- version = "1.8.244"
7
+ version = "1.8.246"
8
8
  description = "Generate map templates for Farming Simulator from real places."
9
9
  authors = [{name = "iwatkot", email = "iwatkot@gmail.com"}]
10
10
  license = {text = "MIT License"}
File without changes
File without changes
File without changes
File without changes
File without changes