maps4fs 0.8.3__py3-none-any.whl → 0.8.5__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.
@@ -8,7 +8,6 @@ import os
8
8
  import cv2
9
9
  import numpy as np
10
10
  import trimesh # type: ignore
11
- from pyproj import Transformer
12
11
 
13
12
  from maps4fs.generator.component import Component
14
13
  from maps4fs.generator.path_steps import DEFAULT_DISTANCE, get_steps
@@ -83,17 +82,7 @@ class Background(Component):
83
82
  data = {}
84
83
  for tile in self.tiles:
85
84
  north, south, east, west = tile.bbox
86
-
87
- # The default CMS in library is EPSG:4326.
88
- # It needed to be converted to EPSG:3857 for convinient usage in QGIS.
89
-
90
- transformer = Transformer.from_crs("epsg:4326", "epsg:3857")
91
- epsg3857_north, epsg3857_west = transformer.transform(north, west)
92
- epsg3857_south, epsg3857_east = transformer.transform(south, east)
93
-
94
- epsg3857_string = (
95
- f"{epsg3857_north},{epsg3857_south},{epsg3857_east},{epsg3857_west} [EPSG:3857]"
96
- )
85
+ epsg3857_string = tile.get_epsg3857_string()
97
86
 
98
87
  tile_entry = {
99
88
  "center_latitude": tile.coordinates[0],
@@ -8,6 +8,7 @@ from copy import deepcopy
8
8
  from typing import TYPE_CHECKING, Any
9
9
 
10
10
  import osmnx as ox # type: ignore
11
+ from pyproj import Transformer
11
12
 
12
13
  if TYPE_CHECKING:
13
14
  from maps4fs.generator.game import Game
@@ -134,21 +135,34 @@ class Component:
134
135
 
135
136
  self.logger.debug("Saved updated generation info to %s", self.generation_info_path)
136
137
 
137
- def get_bbox(self, project_utm: bool = False) -> tuple[int, int, int, int]:
138
+ def get_bbox(
139
+ self,
140
+ coordinates: tuple[float, float] | None = None,
141
+ distance: int | None = None,
142
+ project_utm: bool = False,
143
+ ) -> tuple[int, int, int, int]:
138
144
  """Calculates the bounding box of the map from the coordinates and the height and
139
145
  width of the map.
146
+ If coordinates and distance are not provided, the instance variables are used.
140
147
 
141
148
  Args:
149
+ coordinates (tuple[float, float], optional): The latitude and longitude of the center of
150
+ the map. Defaults to None.
151
+ distance (int, optional): The distance from the center of the map to the edge of the
152
+ map. Defaults to None.
142
153
  project_utm (bool, optional): Whether to project the bounding box to UTM.
143
154
 
144
155
  Returns:
145
156
  tuple[int, int, int, int]: The bounding box of the map.
146
157
  """
158
+ coordinates = coordinates or self.coordinates
159
+ distance = distance or int(self.map_height / 2)
160
+
147
161
  north, south, _, _ = ox.utils_geo.bbox_from_point(
148
- self.coordinates, dist=self.map_height / 2, project_utm=project_utm
162
+ coordinates, dist=distance, project_utm=project_utm
149
163
  )
150
164
  _, _, east, west = ox.utils_geo.bbox_from_point(
151
- self.coordinates, dist=self.map_width / 2, project_utm=project_utm
165
+ coordinates, dist=distance, project_utm=project_utm
152
166
  )
153
167
  bbox = north, south, east, west
154
168
  self.logger.debug(
@@ -165,3 +179,21 @@ class Component:
165
179
  """
166
180
  self.bbox = self.get_bbox(project_utm=False)
167
181
  self.logger.debug("Saved bounding box: %s", self.bbox)
182
+
183
+ def get_epsg3857_string(self, bbox: tuple[int, int, int, int] | None = None) -> str:
184
+ """Converts the bounding box to EPSG:3857 string.
185
+ If the bounding box is not provided, the instance variable is used.
186
+
187
+ Args:
188
+ bbox (tuple[int, int, int, int], optional): The bounding box to convert.
189
+
190
+ Returns:
191
+ str: The bounding box in EPSG:3857 string.
192
+ """
193
+ bbox = bbox or self.bbox
194
+ north, south, east, west = bbox
195
+ transformer = Transformer.from_crs("epsg:4326", "epsg:3857")
196
+ epsg3857_north, epsg3857_west = transformer.transform(north, west)
197
+ epsg3857_south, epsg3857_east = transformer.transform(south, east)
198
+
199
+ return f"{epsg3857_north},{epsg3857_south},{epsg3857_east},{epsg3857_west} [EPSG:3857]"
@@ -55,3 +55,34 @@ class Config(Component):
55
55
  list[str]: An empty list.
56
56
  """
57
57
  return []
58
+
59
+ def info_sequence(self) -> dict[str, dict[str, str | float | int]]:
60
+ """Returns information about the component.
61
+ Overview section is needed to create the overview file (in-game map).
62
+
63
+ Returns:
64
+ dict[str, dict[str, str | float | int]]: Information about the component.
65
+ """
66
+ # The overview file is exactly 2X bigger than the map size, does not matter
67
+ # if the map is 2048x2048 or 4096x4096, the overview will be 4096x4096
68
+ # and the map will be in the center of the overview.
69
+ # That's why the distance is set to the map height not as a half of it.
70
+ bbox = self.get_bbox(distance=self.map_height)
71
+ south, west, north, east = bbox
72
+ epsg3857_string = self.get_epsg3857_string(bbox=bbox)
73
+
74
+ overview_data = {
75
+ "epsg3857_string": epsg3857_string,
76
+ "south": south,
77
+ "west": west,
78
+ "north": north,
79
+ "east": east,
80
+ "height": self.map_height * 2,
81
+ "width": self.map_width * 2,
82
+ }
83
+
84
+ data = {
85
+ "Overview": overview_data,
86
+ }
87
+
88
+ return data # type: ignore
maps4fs/generator/game.py CHANGED
@@ -180,7 +180,7 @@ class FS25(Game):
180
180
 
181
181
  Returns:
182
182
  str: The path to the DEM file."""
183
- return os.path.join(map_directory, "mapUS", "data", "dem.png")
183
+ return os.path.join(map_directory, "map", "data", "dem.png")
184
184
 
185
185
  def map_xml_path(self, map_directory: str) -> str:
186
186
  """Returns the path to the map.xml file.
@@ -191,7 +191,7 @@ class FS25(Game):
191
191
  Returns:
192
192
  str: The path to the map.xml file.
193
193
  """
194
- return os.path.join(map_directory, "mapUS", "mapUS.xml")
194
+ return os.path.join(map_directory, "map", "map.xml")
195
195
 
196
196
  def weights_dir_path(self, map_directory: str) -> str:
197
197
  """Returns the path to the weights directory.
@@ -201,7 +201,7 @@ class FS25(Game):
201
201
 
202
202
  Returns:
203
203
  str: The path to the weights directory."""
204
- return os.path.join(map_directory, "mapUS", "data")
204
+ return os.path.join(map_directory, "map", "data")
205
205
 
206
206
  def i3d_file_path(self, map_directory: str) -> str:
207
207
  """Returns the path to the i3d file.
@@ -211,4 +211,4 @@ class FS25(Game):
211
211
 
212
212
  Returns:
213
213
  str: The path to the i3d file."""
214
- return os.path.join(map_directory, "mapUS", "mapUS.i3d")
214
+ return os.path.join(map_directory, "map", "map.i3d")
maps4fs/generator/map.py CHANGED
@@ -6,7 +6,6 @@ import os
6
6
  import shutil
7
7
  from typing import Any, Generator
8
8
 
9
- # from maps4fs.generator.background import Background
10
9
  from maps4fs.generator.component import Component
11
10
  from maps4fs.generator.game import Game
12
11
  from maps4fs.logger import Logger
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 0.8.3
3
+ Version: 0.8.5
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
@@ -19,6 +19,8 @@ Requires-Dist: rasterio
19
19
  Requires-Dist: folium
20
20
  Requires-Dist: geopy
21
21
  Requires-Dist: trimesh
22
+ Requires-Dist: imageio
23
+ Requires-Dist: tifffile
22
24
 
23
25
  <div align="center" markdown>
24
26
  <img src="https://github.com/iwatkot/maps4fs/assets/118521851/ffd7f0a3-e317-4c3f-911f-2c2fb736fbfa">
@@ -30,9 +32,11 @@ Requires-Dist: trimesh
30
32
  <a href="#Supported-objects">Supported objects</a> •
31
33
  <a href="#Generation-info">Generation info</a> •
32
34
  <a href="#Texture-schema">Texture schema</a> •
33
- <a href="Background-terrain">Background terrain</a><br>
35
+ <a href="#Background-terrain">Background terrain</a>
36
+ <a href="#Overview-image">Overview image</a><br>
37
+ <a href="#DDS-conversion">DDS conversion</a> •
34
38
  <a href="#For-advanced-users">For advanced users</a> •
35
- <a jref="#Resources">Resources</a> •
39
+ <a href="#Resources">Resources</a> •
36
40
  <a href="#Bugs-and-feature-requests">Bugs and feature requests</a>
37
41
  </p>
38
42
 
@@ -63,6 +67,8 @@ There are several ways to use the tool. You obviously need the **first one**, bu
63
67
  ### 🚜 For most users
64
68
  **Option 1:** open the [maps4fs](https://maps4fs.streamlit.app) on StreamLit and generate a map template in a few clicks.<br>
65
69
 
70
+ ![Basic WebUI](https://github.com/user-attachments/assets/14620044-9e92-47ae-8531-d61460740f58)
71
+
66
72
  ### 😎 For advanced users
67
73
  **Option 2:** run the Docker version in your browser. Launch the following command in your terminal:
68
74
  ```bash
@@ -128,8 +134,6 @@ docker run -d -p 8501:8501 iwatkot/maps4fs
128
134
  4. Fill in the required fields and click on the `Generate` button.
129
135
  5. When the map is generated click on the `Download` button to get the map.
130
136
 
131
- ![Basic WebUI](https://github.com/user-attachments/assets/14620044-9e92-47ae-8531-d61460740f58)
132
-
133
137
  ### Option 3: Python package
134
138
  🔴 Recommended for developers.<br>
135
139
  You can use the Python package to generate maps. Follow these steps:
@@ -205,6 +209,31 @@ List of components:
205
209
  Below you'll find descriptions of the components and the fields that they contain.<br>
206
210
  ℹ️ If there's no information about the component, it means that at the moment it does not store any data in the `generation_info.json` file.
207
211
 
212
+ ### Config
213
+ Example of the `Config` component:
214
+ ```json
215
+ "Config": {
216
+ "Overview": {
217
+ "epsg3857_string": "2249906.6679576184,2255734.9033189337,5663700.389039194,5669528.6247056825 [EPSG:3857]",
218
+ "south": 45.304132173367165,
219
+ "west": 45.267296012425376,
220
+ "north": 20.263611405732693,
221
+ "east": 20.211255476687537,
222
+ "height": 4096,
223
+ "width": 4096
224
+ }
225
+ },
226
+ ```
227
+ The `Overview` section contains information to create an overview image, which represents the in-game map. You can use the `epsg3857_string` to obtain the satellite images in the QGIS. So this section describes the region of the map plus the borders. Usually, it's exact 2X the size of the map.<br>
228
+ And here's the list of the fields:
229
+ - `"epsg3857_string"` - the string representation of the bounding box in the EPSG:3857 projection, it's required to obtain the satellite images in the QGIS,<br>
230
+ - `"south"` - the southern border of overview region,<br>
231
+ - `"west"` - the western border of overview region,<br>
232
+ - `"north"` - the northern border of overview region,<br>
233
+ - `"east"` - the eastern border of overview region,<br>
234
+ - `"height"` - the height of the overview region in meters (2X the size of the map),<br>
235
+ - `"width"` - the width of the overview region in meters,<br>
236
+
208
237
  ### Texture
209
238
 
210
239
  Example of the `Texture` component:
@@ -337,6 +366,33 @@ If you're afraid of this task, please don't be. It's really simple and I've prep
337
366
  2. [Prepare the i3d files](README_i3d.md).
338
367
  3. [Import the i3d files to Giants Editor](README_giants_editor.md).
339
368
 
369
+ ## Overview image
370
+ The overview image is an image that is used as in-game map. No matter what the size of the map, this file is always `4096x4096 pixels`, while the region of your map is `2048x2048 pixels` in center of this file. The rest of the image is just here for nice view, but you still may add satellite pictures to this region.<br>
371
+
372
+ <img width="400" src="https://github.com/user-attachments/assets/ede9ea81-ef97-4914-9dbf-9761ef1eb7ca">
373
+
374
+ Cool image by [@ZenJakey](https://github.com/ZenJakey).
375
+
376
+ So, the same way you've downloaded the satellite images for the background terrain, you can download them for the overview image. Just use the `epsg3857_string` from the `generation_info.json` file. You'll find the needed string in the `Config` component in the `Overview` section:
377
+
378
+ ```json
379
+ "Config": {
380
+ "Overview": {
381
+ "epsg3857_string": "2249906.6679576184,2255734.9033189337,5663700.389039194,5669528.6247056825 [EPSG:3857]",
382
+ }
383
+ },
384
+ ```
385
+
386
+ After it you need to resize the image to 4096x4096 pixels and convert it to the `.dds` format.
387
+
388
+ ## DDS conversion
389
+ The `.dds` format is the format used in the Farming Simulator for the textures, icons, overview and preview images. There's a plenty of options to convert the images to the `.dds` format, you can just google something like `png to dds` and the first link probably will help you with it.<br>
390
+
391
+ List of the important DDS files:
392
+ - `icon.dds` - 256x256 pixels, the icon of the map,
393
+ - `preview.dds` - 2048x2048 pixels, the preview image of the map on loading screen,
394
+ - `mapsUS/overview.dds` - 4096x4096 pixels, the overview image of the map (in-game map)
395
+
340
396
  ## For advanced users
341
397
  The tool supports the custom size of the map. To use this feature select `Custom` in the `Map size` dropdown and enter the desired size. The tool will generate a map with the size you entered.<br>
342
398
 
@@ -362,4 +418,4 @@ To create a basic map, you only need the Giants Editor. But if you want to creat
362
418
  4. [QGIS](https://qgis.org/download/) - the open-source GIS software that you can use to obtain high-resolution satellite images for your map.
363
419
 
364
420
  ## Bugs and feature requests
365
- 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).<br>
421
+ 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`.
@@ -0,0 +1,18 @@
1
+ maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
2
+ maps4fs/logger.py,sha256=CneeHxQywjNUJXqQrUUSeiDxu95FfrfyK_Si1v0gMZ8,1477
3
+ maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
+ maps4fs/generator/background.py,sha256=YZbTSijKgNQOvpWJHqCJNHeoV5GxUjp79b8PoQwRQH0,10778
5
+ maps4fs/generator/component.py,sha256=9uGWSIVQzxO_u0yZ3luQJOrpg9x61uBcAHdIr_SaNlw,7402
6
+ maps4fs/generator/config.py,sha256=RIqRCPS-ki23JmiFRyt98DVocf-ZaxMsa6yFvoOcHes,3425
7
+ maps4fs/generator/dem.py,sha256=FsYcaf0IQSYykKdbkHxAN5-Rc_PZZEBJfdZA2Z-b8AU,14514
8
+ maps4fs/generator/game.py,sha256=94HjPNOyy6XSSOnBp-uxrkBglKyC-X3ULIrrucfdlKw,6825
9
+ maps4fs/generator/i3d.py,sha256=UuQiQRusPQ2f6PvGKxJ_UZeXsx3uG15efmy8Ysnm3F8,3597
10
+ maps4fs/generator/map.py,sha256=BS8ylTCRlHRmbImg73wnHMpBB2ODckVyVZq5KJhCMfM,4236
11
+ maps4fs/generator/path_steps.py,sha256=rKslIiG9mriCVL9_0i8Oet2p0DITrpBWi0pECpvuyUM,2707
12
+ maps4fs/generator/texture.py,sha256=0gkohGmamZbmqc9VpPqt8pli_x9w9SnUh2JjYGaiI3I,18170
13
+ maps4fs/generator/tile.py,sha256=3vmfjQiPiiUZKPuIo5tg2rOKkgcP1NRVkMGK-Vo10-A,2138
14
+ maps4fs-0.8.5.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
15
+ maps4fs-0.8.5.dist-info/METADATA,sha256=FhpVmF65LgMWkcv1atzYjmtnu4UebcsTQZbRqaEros4,23152
16
+ maps4fs-0.8.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
+ maps4fs-0.8.5.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
18
+ maps4fs-0.8.5.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
2
- maps4fs/logger.py,sha256=CneeHxQywjNUJXqQrUUSeiDxu95FfrfyK_Si1v0gMZ8,1477
3
- maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/background.py,sha256=KsErhYERWXzMedGLg1H7wO94OXyaqw_XQYnotKNTStE,11267
5
- maps4fs/generator/component.py,sha256=w5hUttO8m5bXcujLxB0pZjf25hxMnMPP4yPikQyoOkQ,6010
6
- maps4fs/generator/config.py,sha256=ln_XGUdiPnc4zzhMVEueZRf-FGljeHtCHUnJ6FRlE4w,2264
7
- maps4fs/generator/dem.py,sha256=FsYcaf0IQSYykKdbkHxAN5-Rc_PZZEBJfdZA2Z-b8AU,14514
8
- maps4fs/generator/game.py,sha256=yry1tJYQi-tNLHlEY85Vz71KN_o2PVjxrAc4HDNB_Sg,6837
9
- maps4fs/generator/i3d.py,sha256=UuQiQRusPQ2f6PvGKxJ_UZeXsx3uG15efmy8Ysnm3F8,3597
10
- maps4fs/generator/map.py,sha256=2MXOIQxj7mDxhp76uh7EXqLP-v3T4TbiKQdx6my7GFc,4290
11
- maps4fs/generator/path_steps.py,sha256=rKslIiG9mriCVL9_0i8Oet2p0DITrpBWi0pECpvuyUM,2707
12
- maps4fs/generator/texture.py,sha256=0gkohGmamZbmqc9VpPqt8pli_x9w9SnUh2JjYGaiI3I,18170
13
- maps4fs/generator/tile.py,sha256=3vmfjQiPiiUZKPuIo5tg2rOKkgcP1NRVkMGK-Vo10-A,2138
14
- maps4fs-0.8.3.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
15
- maps4fs-0.8.3.dist-info/METADATA,sha256=UbKREWFL9CnOpTHk1I76Q-4S5DEGOGbWoNro-qREB9c,20081
16
- maps4fs-0.8.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
- maps4fs-0.8.3.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
18
- maps4fs-0.8.3.dist-info/RECORD,,