maps4fs 1.0.0__py3-none-any.whl → 1.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.
@@ -15,7 +15,7 @@ from maps4fs.generator.dem import (
15
15
  DEFAULT_MULTIPLIER,
16
16
  DEFAULT_PLATEAU,
17
17
  )
18
- from maps4fs.generator.path_steps import DEFAULT_DISTANCE, PATH_FULL_NAME, get_steps
18
+ from maps4fs.generator.path_steps import PATH_FULL_NAME, get_steps
19
19
  from maps4fs.generator.tile import Tile
20
20
 
21
21
  RESIZE_FACTOR = 1 / 4
@@ -242,119 +242,21 @@ class Background(Component):
242
242
 
243
243
  self.stl_preview_path = preview_path # pylint: disable=attribute-defined-outside-init
244
244
 
245
+ # pylint: disable=no-member
245
246
  def previews(self) -> list[str]:
246
- """Generates a preview by combining all tiles into one image.
247
- NOTE: The map itself is not included in the preview, so it will be empty.
247
+ """Returns the path to the image of full tile and the path to the STL preview file.
248
248
 
249
249
  Returns:
250
- list[str] -- A list of paths to the preview images."""
251
-
252
- self.logger.info("Generating a preview image for the background DEM")
253
-
254
- image_height = self.map_height + DEFAULT_DISTANCE * 2
255
- image_width = self.map_width + DEFAULT_DISTANCE * 2
256
- self.logger.debug("Full size of the preview image: %s x %s", image_width, image_height)
257
-
258
- image = np.zeros((image_height, image_width), np.uint16) # pylint: disable=no-member
259
- self.logger.debug("Empty image created: %s", image.shape)
260
-
261
- for tile in self.tiles:
262
- # pylint: disable=no-member
263
- if tile.code == PATH_FULL_NAME:
264
- continue
265
- tile_image = cv2.imread(tile.dem_path, cv2.IMREAD_UNCHANGED)
266
-
267
- self.logger.debug(
268
- "Tile %s image shape: %s, dtype: %s, max: %s, min: %s",
269
- tile.code,
270
- tile_image.shape,
271
- tile_image.dtype,
272
- tile_image.max(),
273
- tile_image.min(),
274
- )
275
-
276
- tile_height, tile_width = tile_image.shape
277
- self.logger.debug("Tile %s size: %s x %s", tile.code, tile_width, tile_height)
278
-
279
- # Calculate the position based on the tile code
280
- if tile.code == "N":
281
- x = DEFAULT_DISTANCE
282
- y = 0
283
- elif tile.code == "NE":
284
- x = self.map_width + DEFAULT_DISTANCE
285
- y = 0
286
- elif tile.code == "E":
287
- x = self.map_width + DEFAULT_DISTANCE
288
- y = DEFAULT_DISTANCE
289
- elif tile.code == "SE":
290
- x = self.map_width + DEFAULT_DISTANCE
291
- y = self.map_height + DEFAULT_DISTANCE
292
- elif tile.code == "S":
293
- x = DEFAULT_DISTANCE
294
- y = self.map_height + DEFAULT_DISTANCE
295
- elif tile.code == "SW":
296
- x = 0
297
- y = self.map_height + DEFAULT_DISTANCE
298
- elif tile.code == "W":
299
- x = 0
300
- y = DEFAULT_DISTANCE
301
- elif tile.code == "NW":
302
- x = 0
303
- y = 0
304
-
305
- # pylint: disable=possibly-used-before-assignment
306
- x2 = x + tile_width
307
- y2 = y + tile_height
308
-
309
- self.logger.debug(
310
- "Tile %s position. X from %s to %s, Y from %s to %s", tile.code, x, x2, y, y2
250
+ list[str] -- A list of paths to the previews.
251
+ """
252
+ full_tile = next((tile for tile in self.tiles if tile.code == PATH_FULL_NAME), None)
253
+ if full_tile:
254
+ preview_path = os.path.join(self.previews_directory, "background_dem.png")
255
+ full_tile_image = cv2.imread(full_tile.dem_path, cv2.IMREAD_UNCHANGED)
256
+ full_tile_image = cv2.normalize( # type: ignore
257
+ full_tile_image, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U
311
258
  )
312
-
313
- # pylint: disable=possibly-used-before-assignment
314
- image[y:y2, x:x2] = tile_image
315
-
316
- # Save image to the map directory.
317
- preview_path = os.path.join(self.previews_directory, "background_dem.png")
318
-
319
- # pylint: disable=no-member
320
- image = cv2.normalize(image, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U) # type: ignore
321
- image = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR) # type: ignore
322
- cv2.imwrite(preview_path, image)
323
-
324
- return [preview_path, self.stl_preview_path]
325
-
326
-
327
- # Creates tiles around the map.
328
- # The one on corners 2048x2048, on sides and in the middle map_size x 2048.
329
- # So 2048 is a distance FROM the edge of the map, but the other size depends on the map size.
330
- # But for corner tiles it's always 2048.
331
-
332
- # In the beginning we have coordinates of the central point of the map and it's size.
333
- # We need to calculate the coordinates of central points all 8 tiles around the map.
334
-
335
- # Latitude is a vertical line, Longitude is a horizontal line.
336
-
337
- # 2048
338
- # | |
339
- # ____________________|_________|___
340
- # | | | |
341
- # | NW | N | NE | 2048
342
- # |_________|_________|_________|___
343
- # | | | |
344
- # | W | C | E |
345
- # |_________|_________|_________|
346
- # | | | |
347
- # | SW | S | SE |
348
- # |_________|_________|_________|
349
- #
350
- # N = C map_height / 2 + 1024; N_width = map_width; N_height = 2048
351
- # NW = N - map_width / 2 - 1024; NW_width = 2048; NW_height = 2048
352
- # and so on...
353
-
354
- # lat, lon = 45.28565000315636, 20.237121355049904
355
- # dst = 1024
356
-
357
- # # N
358
- # destination = distance(meters=dst).destination((lat, lon), 0)
359
- # lat, lon = destination.latitude, destination.longitude
360
- # print(lat, lon)
259
+ full_tile_image = cv2.cvtColor(full_tile_image, cv2.COLOR_GRAY2BGR)
260
+ cv2.imwrite(preview_path, full_tile_image)
261
+ return [preview_path, self.stl_preview_path]
262
+ return [self.stl_preview_path]
@@ -184,10 +184,10 @@ class Component:
184
184
  height_distance = height_distance or int(self.map_height / 2)
185
185
  width_distance = width_distance or int(self.map_width / 2)
186
186
 
187
- north, south, _, _ = ox.utils_geo.bbox_from_point(
187
+ west, south, _, _ = ox.utils_geo.bbox_from_point( # type: ignore
188
188
  coordinates, dist=height_distance, project_utm=project_utm
189
189
  )
190
- _, _, east, west = ox.utils_geo.bbox_from_point(
190
+ _, _, east, north = ox.utils_geo.bbox_from_point( # type: ignore
191
191
  coordinates, dist=width_distance, project_utm=project_utm
192
192
  )
193
193
  bbox = north, south, east, west
maps4fs/generator/dem.py CHANGED
@@ -319,7 +319,7 @@ class DEM(Component):
319
319
  def _save_empty_dem(self, dem_output_resolution: tuple[int, int]) -> None:
320
320
  """Saves empty DEM file filled with zeros."""
321
321
  dem_data = np.zeros(dem_output_resolution, dtype="uint16")
322
- cv2.imwrite(self._dem_path, dem_data) # pylint: disable=no-member
322
+ cv2.imwrite(self._dem_path, dem_data)
323
323
  self.logger.warning("DEM data filled with zeros and saved to %s.", self._dem_path)
324
324
 
325
325
  def grayscale_preview(self) -> str:
@@ -329,7 +329,6 @@ class DEM(Component):
329
329
  Returns:
330
330
  str: Path to the preview image.
331
331
  """
332
- # rgb_dem_path = self._dem_path.replace(".png", "_grayscale.png")
333
332
  grayscale_dem_path = os.path.join(self.previews_directory, "dem_grayscale.png")
334
333
 
335
334
  self.logger.debug("Creating grayscale preview of DEM data in %s.", grayscale_dem_path)
@@ -346,8 +345,6 @@ class DEM(Component):
346
345
  Returns:
347
346
  list[str]: List with a single path to the DEM file
348
347
  """
349
-
350
- # colored_dem_path = self._dem_path.replace(".png", "_colored.png")
351
348
  colored_dem_path = os.path.join(self.previews_directory, "dem_colored.png")
352
349
 
353
350
  self.logger.debug("Creating colored preview of DEM data in %s.", colored_dem_path)
@@ -4,7 +4,6 @@ from __future__ import annotations
4
4
 
5
5
  import json
6
6
  import os
7
- import warnings
8
7
  from collections import defaultdict
9
8
  from typing import Any, Callable, Generator, Optional
10
9
 
@@ -540,14 +539,12 @@ class Texture(Component):
540
539
  Generator[np.ndarray, None, None]: Numpy array of polygon points.
541
540
  """
542
541
  try:
543
- with warnings.catch_warnings():
544
- warnings.simplefilter("ignore", DeprecationWarning)
545
- objects = ox.features_from_bbox(bbox=self.bbox, tags=tags)
542
+ objects = ox.features_from_bbox(bbox=self.new_bbox, tags=tags)
546
543
  except Exception as e: # pylint: disable=W0718
547
544
  self.logger.warning("Error fetching objects for tags: %s.", tags)
548
545
  self.logger.warning(e)
549
546
  return
550
- objects_utm = ox.project_gdf(objects, to_latlong=False)
547
+ objects_utm = ox.projection.project_gdf(objects, to_latlong=False)
551
548
  self.logger.debug("Fetched %s elements for tags: %s.", len(objects_utm), tags)
552
549
 
553
550
  for _, obj in objects_utm.iterrows():
@@ -610,6 +607,7 @@ class Texture(Component):
610
607
  merged.dtype,
611
608
  )
612
609
  preview_path = os.path.join(self.previews_directory, "textures_osm.png")
613
- cv2.imwrite(preview_path, merged) # pylint: disable=no-member
610
+
611
+ cv2.imwrite(preview_path, merged) # type: ignore
614
612
  self.logger.info("Preview saved to %s.", preview_path)
615
613
  return preview_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 1.0.0
3
+ Version: 1.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: MIT License
@@ -14,7 +14,7 @@ Classifier: Operating System :: OS Independent
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE.md
16
16
  Requires-Dist: opencv-python
17
- Requires-Dist: osmnx<2.0.0
17
+ Requires-Dist: osmnx>=2.0.0
18
18
  Requires-Dist: rasterio
19
19
  Requires-Dist: folium
20
20
  Requires-Dist: geopy
@@ -1,23 +1,23 @@
1
1
  maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
2
2
  maps4fs/logger.py,sha256=B-NEYpMjPAAqlV4VpfTi6nbBFnEABVtQOaYe6nMpidg,1489
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/background.py,sha256=h6zyqMc51eOD8_Jbe8eP9DJFy27-XItzIOVEThQKFdk,14011
5
- maps4fs/generator/component.py,sha256=gtb_p_cHfRgOQwCLCxmQPNObuipqvmGaGAct7KUxAtI,11053
4
+ maps4fs/generator/background.py,sha256=VGzKELm6W1k3NFA8akaDWlw20kcyiK68j705jDroGoM,10517
5
+ maps4fs/generator/component.py,sha256=swOocaEOP3XtZgHfgDJ0ROALWoLgCJwMq8ubl0d2WrI,11085
6
6
  maps4fs/generator/config.py,sha256=qomeSaHNgSYvRyPbGkyDjgAxU1jUMND8wESuy9uXcV4,4280
7
- maps4fs/generator/dem.py,sha256=aU0syr7pu81hd6oVn1rjQoDsDAYJro-58i1STTUz3jw,17167
7
+ maps4fs/generator/dem.py,sha256=_VbQ5M7xGCtG27EHKzKkjIxMR58ghfbu7H89txNw5gg,16987
8
8
  maps4fs/generator/game.py,sha256=3Y65K-XQDKxfMRSrjsmE8qX0tQSd0aDzMUT6yGIhzXg,7450
9
9
  maps4fs/generator/grle.py,sha256=kyFiGu-2aXrLVB_8GeXlGvG5ULwlSVuqU1yfpt_0br4,3134
10
10
  maps4fs/generator/i3d.py,sha256=nlmI8SdzzKMOGQRvoZp7Pxo6lzm1jneoYNoL24v84zw,14281
11
11
  maps4fs/generator/map.py,sha256=1EJfq5928xbV7v9vBBuoC3VpD5gC1SMDBTQ7geH6yaA,4678
12
12
  maps4fs/generator/path_steps.py,sha256=yeN6hmOD8O2LMozUf4HcQMIy8WJ5sHF5pGQT_s2FfOw,3147
13
13
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
14
- maps4fs/generator/texture.py,sha256=uSuqJyZom861_BO-3aUqU8_OkroExmN25PsRBjdddkw,23799
14
+ maps4fs/generator/texture.py,sha256=FnCagiGyeCb_lIqOTHgHISZo17A_E9kHqGeUhqz_iZY,23670
15
15
  maps4fs/generator/tile.py,sha256=_UZ-iHGPghUfpYcG0OboquNczpZ1FaCVYpBgNLd72eo,2160
16
16
  maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
17
17
  maps4fs/toolbox/background.py,sha256=9BXWNqs_n3HgqDiPztWylgYk_QM4YgBpe6_ZNQAWtSc,2154
18
18
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
19
- maps4fs-1.0.0.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
20
- maps4fs-1.0.0.dist-info/METADATA,sha256=x6wxcTW4FKrS_F7hrak7CcnB8aXCQ06MPkeR18YpjCM,26085
21
- maps4fs-1.0.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
22
- maps4fs-1.0.0.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
23
- maps4fs-1.0.0.dist-info/RECORD,,
19
+ maps4fs-1.0.2.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
20
+ maps4fs-1.0.2.dist-info/METADATA,sha256=q04E_4Lu70zOHE_U0wz56CpzNtw_XyuxF4JqL5wwf94,26086
21
+ maps4fs-1.0.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
22
+ maps4fs-1.0.2.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
23
+ maps4fs-1.0.2.dist-info/RECORD,,