maps4fs 1.4.1__py3-none-any.whl → 1.5.0__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.
maps4fs/generator/grle.py CHANGED
@@ -116,6 +116,11 @@ class GRLE(Component):
116
116
 
117
117
  self.logger.info("Found %s fields in textures info layer.", len(fields))
118
118
 
119
+ farmyards: list[list[tuple[int, int]]] | None = textures_info_layer.get("farmyards")
120
+ if farmyards and self.map.grle_settings.add_farmyards:
121
+ fields.extend(farmyards)
122
+ self.logger.info("Found %s farmyards in textures info layer.", len(farmyards))
123
+
119
124
  info_layer_farmlands_path = os.path.join(
120
125
  self.game.weights_dir_path(self.map_directory), "infoLayer_farmlands.png"
121
126
  )
maps4fs/generator/i3d.py CHANGED
@@ -184,6 +184,10 @@ class I3d(Component):
184
184
 
185
185
  if shapes_node is not None and scene_node is not None:
186
186
  node_id = SPLINES_NODE_ID_STARTING_VALUE
187
+ user_attributes_node = root.find(".//UserAttributes")
188
+ if user_attributes_node is None:
189
+ self.logger.warning("UserAttributes node not found in I3D file.")
190
+ return
187
191
 
188
192
  for road_id, road in enumerate(roads_polylines, start=1):
189
193
  # Add to scene node
@@ -254,6 +258,25 @@ class I3d(Component):
254
258
 
255
259
  shapes_node.append(nurbs_curve_node)
256
260
 
261
+ # Add UserAttributes to the shape node.
262
+ # <UserAttribute nodeId="5000">
263
+ # <Attribute name="maxSpeedScale" type="integer" value="1"/>
264
+ # <Attribute name="speedLimit" type="integer" value="100"/>
265
+ # </UserAttribute>
266
+
267
+ user_attribute_node = ET.Element("UserAttribute")
268
+ user_attribute_node.set("nodeId", str(node_id))
269
+
270
+ attributes = [
271
+ ("maxSpeedScale", "integer", "1"),
272
+ ("speedLimit", "integer", "100"),
273
+ ]
274
+
275
+ for name, attr_type, value in attributes:
276
+ user_attribute_node.append(I3d.create_attribute_node(name, attr_type, value))
277
+
278
+ user_attributes_node.append(user_attribute_node) # type: ignore
279
+
257
280
  node_id += 1
258
281
 
259
282
  tree.write(splines_i3d_path) # type: ignore
maps4fs/generator/map.py CHANGED
@@ -47,6 +47,19 @@ class SettingsModel(BaseModel):
47
47
 
48
48
  return settings
49
49
 
50
+ @classmethod
51
+ def all_settings(cls) -> list[SettingsModel]:
52
+ """Get all settings of the current class and its subclasses.
53
+
54
+ Returns:
55
+ list[SettingsModel]: List with settings of the current class and its subclasses.
56
+ """
57
+ settings = []
58
+ for subclass in cls.__subclasses__():
59
+ settings.append(subclass())
60
+
61
+ return settings
62
+
50
63
 
51
64
  class DEMSettings(SettingsModel):
52
65
  """Represents the advanced settings for DEM component.
@@ -89,10 +102,13 @@ class GRLESettings(SettingsModel):
89
102
  Attributes:
90
103
  farmland_margin (int): margin around the farmland.
91
104
  random_plants (bool): generate random plants on the map or use the default one.
105
+ add_farmyards (bool): If True, regions of frarmyards will be added to the map
106
+ without corresponding fields.
92
107
  """
93
108
 
94
109
  farmland_margin: int = 0
95
110
  random_plants: bool = True
111
+ add_farmyards: bool = False
96
112
 
97
113
 
98
114
  class I3DSettings(SettingsModel):
@@ -114,7 +130,7 @@ class TextureSettings(SettingsModel):
114
130
  skip_drains (bool): skip drains generation.
115
131
  """
116
132
 
117
- dissolve: bool = True
133
+ dissolve: bool = False
118
134
  fields_padding: int = 0
119
135
  skip_drains: bool = False
120
136
 
@@ -127,7 +143,7 @@ class SplineSettings(SettingsModel):
127
143
  existing points.
128
144
  """
129
145
 
130
- spline_density: int = 4
146
+ spline_density: int = 2
131
147
 
132
148
 
133
149
  # pylint: disable=R0913, R0902, R0914
@@ -205,6 +221,25 @@ class Map:
205
221
  os.makedirs(self.map_directory, exist_ok=True)
206
222
  self.logger.debug("Map directory created: %s", self.map_directory)
207
223
 
224
+ settings = [
225
+ dem_settings,
226
+ background_settings,
227
+ grle_settings,
228
+ i3d_settings,
229
+ texture_settings,
230
+ spline_settings,
231
+ ]
232
+
233
+ settings_json = {}
234
+
235
+ for setting in settings:
236
+ settings_json[setting.__class__.__name__] = setting.model_dump()
237
+
238
+ save_path = os.path.join(self.map_directory, "generation_settings.json")
239
+
240
+ with open(save_path, "w", encoding="utf-8") as file:
241
+ json.dump(settings_json, file, indent=4)
242
+
208
243
  self.texture_custom_schema = kwargs.get("texture_custom_schema", None)
209
244
  if self.texture_custom_schema:
210
245
  save_path = os.path.join(self.map_directory, "texture_custom_schema.json")
@@ -45,6 +45,9 @@ class Texture(Component):
45
45
  exclude_weight (bool): Flag to exclude weight from the texture.
46
46
  priority (int | None): Priority of the layer.
47
47
  info_layer (str | None): Name of the corresnponding info layer.
48
+ usage (str | None): Usage of the layer.
49
+ background (bool): Flag to determine if the layer is a background.
50
+ invisible (bool): Flag to determine if the layer is invisible.
48
51
 
49
52
  Attributes:
50
53
  name (str): Name of the layer.
@@ -65,6 +68,7 @@ class Texture(Component):
65
68
  info_layer: str | None = None,
66
69
  usage: str | None = None,
67
70
  background: bool = False,
71
+ invisible: bool = False,
68
72
  ):
69
73
  self.name = name
70
74
  self.count = count
@@ -76,6 +80,7 @@ class Texture(Component):
76
80
  self.info_layer = info_layer
77
81
  self.usage = usage
78
82
  self.background = background
83
+ self.invisible = invisible
79
84
 
80
85
  def to_json(self) -> dict[str, str | list[str] | bool]: # type: ignore
81
86
  """Returns dictionary with layer data.
@@ -93,6 +98,7 @@ class Texture(Component):
93
98
  "info_layer": self.info_layer,
94
99
  "usage": self.usage,
95
100
  "background": self.background,
101
+ "invisible": self.invisible,
96
102
  }
97
103
 
98
104
  data = {k: v for k, v in data.items() if v is not None}
@@ -301,6 +307,7 @@ class Texture(Component):
301
307
  "bbox",
302
308
  "map_height",
303
309
  "map_width",
310
+ "rotation",
304
311
  "minimum_x",
305
312
  "minimum_y",
306
313
  "maximum_x",
@@ -416,7 +423,8 @@ class Texture(Component):
416
423
  info_layer_data[layer.info_layer].append(
417
424
  self.np_to_polygon_points(polygon) # type: ignore
418
425
  )
419
- cv2.fillPoly(layer_image, [polygon], color=255) # type: ignore
426
+ if not layer.invisible:
427
+ cv2.fillPoly(layer_image, [polygon], color=255) # type: ignore
420
428
 
421
429
  if layer.info_layer == "roads":
422
430
  for linestring in self.objects_generator(
@@ -705,7 +713,11 @@ class Texture(Component):
705
713
  Generator[np.ndarray, None, None]: Numpy array of polygon points.
706
714
  """
707
715
  for _, obj in objects_utm.iterrows():
708
- polygon = self._to_polygon(obj, width)
716
+ try:
717
+ polygon = self._to_polygon(obj, width)
718
+ except Exception as e: # pylint: disable=W0703
719
+ self.logger.warning("Error converting object to polygon: %s.", e)
720
+ continue
709
721
  if polygon is None:
710
722
  continue
711
723
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 1.4.1
3
+ Version: 1.5.0
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
@@ -45,6 +45,7 @@ Requires-Dist: pydantic
45
45
  <a href="#Overview-image">Overview image</a><br>
46
46
  <a href="#DDS-conversion">DDS conversion</a> •
47
47
  <a href="#Advanced-settings">Advanced settings</a> •
48
+ <a href="#Expert-settings">Expert settings</a> •
48
49
  <a href="#Resources">Resources</a> •
49
50
  <a href="#Bugs-and-feature-requests">Bugs and feature requests</a><br>
50
51
  <a href="#Special-thanks">Special thanks</a>
@@ -256,18 +257,12 @@ Tools are divided into categories, which are listed below.
256
257
 
257
258
  ## Supported objects
258
259
  The project is based on the [OpenStreetMap](https://www.openstreetmap.org/) data. So, refer to [this page](https://wiki.openstreetmap.org/wiki/Map_Features) to understand the list below.
259
- - "building": True
260
- - "highway": ["motorway", "trunk", "primary"]
261
- - "highway": ["secondary", "tertiary", "road", "service"]
262
- - "highway": ["unclassified", "residential", "track"]
263
- - "natural": ["grassland", "scrub"]
264
- - "landuse": "farmland"
265
- - "natural": ["water"]
266
- - "waterway": True
267
- - "natural": ["wood", "tree_row"]
268
- - "railway": True
269
-
270
- The list will be updated as the project develops.
260
+
261
+ You can find the active schemas here:
262
+ - [FS25](/data/fs25-texture-schema.json)
263
+ - [FS22](/data/fs22-texture-schema.json)
264
+
265
+ Learn more how to work with the schema in the [Texture schema](#texture-schema) section. You can also use your own schema in the [Expert settings](#expert-settings) section.
271
266
 
272
267
  ## Generation info
273
268
  The script will generate the `generation_info.json` file in the `output` folder. It is split into different sections, which represent the components of the map generator. You may need this information to use some other tools and services to obtain additional data for your map.<br>
@@ -418,6 +413,10 @@ Let's have a closer look at the fields:
418
413
  - `priority` - the priority of the texture for overlapping. Textures with higher priorities will be drawn over the textures with lower priorities.
419
414
  ℹ️ The texture with 0 priority considers the base layer, which means that all empty areas will be filled with this texture.
420
415
  - `exclude_weight` - this is only used for the forestRockRoots texture from FS25. It just means that this texture has no `weight` postfix, that's all.
416
+ - `usage` - the usage of the texture. Mainly used to group different textures by the purpose. For example, the `grass`, `forest`, `drain`.
417
+ - `background` - set it to True for the textures, which should have impact on the Background Terrain, by default it's used to subtract the water depth from the DEM and background terrain.
418
+ - `info_layer` - if the layer is saving some data in JSON format, this section will describe it's name in the JSON file. Used to find the needed JSON data, for example for fields it will be `fields` and as a value - list of polygon coordinates.
419
+ - `invisible` - set it to True for the textures, which should not be drawn in the files, but only to save the data in the JSON file (related to the previous field).
421
420
 
422
421
  ## Background terrain
423
422
  The tool now supports the generation of the background terrain. If you don't know what it is, here's a brief explanation. The background terrain is the world around the map. It's important to create it because if you don't, the map will look like it's floating in the void. The background terrain is a simple plane that can (and should) be textured to look fine.<br>
@@ -474,44 +473,59 @@ You can also apply some advanced settings to the map generation process. Note th
474
473
 
475
474
  ### DEM Advanced settings
476
475
 
476
+ - Auto process: the tool will automatically try to find suitable multiplier. As a result, the DEM image WILL not match real world values. If this option is disabled, you'll probably see completely black DEM image, but it's not empty. It's just you can't see the values of 16-bit image by eye, because they're too small. Learn more what's DEM image and how to work with it in [docs](docs/dem.md). By default, it's set to True.
477
+
477
478
  - Multiplier: the height of the map is multiplied by this value. So the DEM map is just a 16-bit grayscale image, which means that the maximum available value there is 65535, while the actual difference between the deepest and the highest point on Earth is about 20 km. Just note that this setting mostly does not matter, because you can always adjust it in the Giants Editor, learn more about the DEM file and the heightScale parameter in [docs](docs/dem.md). By default, it's set to 1.
478
479
 
479
480
  - Blur radius: the radius of the Gaussian blur filter applied to the DEM map. By default, it's set to 21. This filter just makes the DEM map smoother, so the height transitions will be more natural. You can set it to 1 to disable the filter, but it will result in a Minecraft-like map.
480
481
 
481
- - Plateau height: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
482
+ - Plateau: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
482
483
 
483
484
  - Water depth: this value will be subtracted from each pixel of the DEM image, where water resources are located. Pay attention that it's not in meters, instead it in the pixel value of DEM, which is 16 bit image with possible values from 0 to 65535. When this value is set, the same value will be added to the plateau setting to avoid negative heights.
484
485
 
485
- ### Texture Advanced settings
486
+ ### Background terrain Advanced settings
486
487
 
487
- - Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.
488
+ - Generate background - if enabled, the obj files for the background terrain will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
488
489
 
489
- - Texture dissolving - if enabled, the values from one layer will be splitted between different layers of texture, making it look more natural. By default, it's set to True. Can be turned of for faster processing.
490
+ - Generate water - if enabled, the water planes obj files will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
490
491
 
491
- - Skip drains - if enabled, the tool will not generate the drains and ditches on the map. By default, it's set to False. Use this if you don't need the drains on the map.
492
+ - Resize factor - the factor by which the background terrain will be resized. It will be used as 1 / resize_factor while generating the models. Which means that the larger the value the more the terrain will be resized. The lowest value is 1, in this case background terrain will not be resized. Note, than low values will lead to long processing and enormous size of the obj files.
492
493
 
493
- ### Farmlands Advanced settings
494
+ ### GRLE Advanced settings
494
495
 
495
496
  - Farmlands margin - this value (in meters) will be applied to each farmland, making it bigger. You can use the value to adjust how much the farmland should be bigger than the actual field. By default, it's set to 3.
496
497
 
497
- ### Vegetation Advanced settings
498
+ - Random plants - when adding decorative foliage, enabling this option will add different species of plants to the map. If unchecked only basic grass (smallDenseMix) will be added. Defaults to True.
498
499
 
499
- - Forest density - the density of the forest in meters. The lower the value, the lower the distance between the trees, which makes the forest denser. Note, that low values will lead to enormous number of trees, which may cause the Giants Editor to crash or lead to performance issues. By default, it's set to 10.
500
+ - Add Farmyards - if enabled, the tool will create farmlands from the regions that are marked as farmyards in the OSM data. Those farmlands will not have fields and also will not be drawn on textures. By default, it's turned off.
500
501
 
501
- - Random plants - when adding decorative foliage, enabling this option will add different species of plants to the map. If unchecked only basic grass (smallDenseMix) will be added. Defaults to True.
502
+ ### I3D Advanced settings
502
503
 
503
- ### Background terrain Advanced settings
504
+ - Forest density - the density of the forest in meters. The lower the value, the lower the distance between the trees, which makes the forest denser. Note, that low values will lead to enormous number of trees, which may cause the Giants Editor to crash or lead to performance issues. By default, it's set to 10.
504
505
 
505
- - Generate background - if enabled, the obj files for the background terrain will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
506
+ ### Texture Advanced settings
506
507
 
507
- - Generate water - if enabled, the water planes obj files will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
508
+ - Dissolve - if enabled, the values from one layer will be splitted between different layers of texture, making it look more natural. Warning: it's a time-consuming process, recommended to enable it, when you generating the final version of the map, not some test versions.
508
509
 
509
- - Resize factor - the factor by which the background terrain will be resized. It will be used as 1 / resize_factor while generating the models. Which means that the larger the value the more the terrain will be resized. The lowest value is 1, in this case background terrain will not be resized. Note, than low values will lead to long processing and enormous size of the obj files.
510
+ - Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.
511
+
512
+ - Skip drains - if enabled, the tool will not generate the drains and ditches on the map. By default, it's set to False. Use this if you don't need the drains on the map.
510
513
 
511
514
  ## Splines Advanced settings
512
515
 
513
516
  - Splines density - number of points, which will be added (interpolate) between each pair of existing points. The higher the value, the denser the spline will be. It can smooth the splines, but high values can in opposite make the splines look unnatural.
514
517
 
518
+ ## Expert Settings
519
+ The tool also supports the expert settings. Do not use them until you read the documentation and understand what they do. Here's the list of the expert settings:
520
+
521
+ - Enable debug logs - if enabled, the tool will print the debug logs to the console. It can be useful if you're using with a custom OSM map, have some issues with it and want to know what's wrong.
522
+
523
+ - Upload custom OSM file - you'll be able to upload your own OSM file. Before using it, carefully read the [Custom OSM](docs/custom_osm.md) documentation, otherwise, the tool will not work as expected.
524
+
525
+ - Show raw configuration - you'll be able to change all the settings in a single JSON file. It's useful if you want to save the configuration and use it later, without changing the settings in the UI. Be extremely careful with this setting, because you can break the tool with incorrect settings.
526
+
527
+ - Show schemas - you'll be able to edit or define your own texture or tree schemas. It's useful if you want to add some custom textures or trees to the map. Refer to the [Texture schema](#texture-schema) section to learn more about the schema structure. Any incorrect value here will lead to the completely broken map.
528
+
515
529
  ## Resources
516
530
  In this section, you'll find a list of the resources that you need to create a map for the Farming Simulator.<br>
517
531
  To create a basic map, you only need the Giants Editor. But if you want to create a background terrain - the world around the map, so it won't look like it's floating in the void - you also need Blender and the Blender Exporter Plugins. To create realistic textures for the background terrain, the QGIS is required to obtain high-resolution satellite images.<br>
@@ -6,16 +6,16 @@ maps4fs/generator/component.py,sha256=58UQgdR-7KlWHTfwLesNNK76BTRsiVngRa6B64OKjh
6
6
  maps4fs/generator/config.py,sha256=0QmK052B8bxyHVhg3jzCORLfOBMMmqVfhhbqXKf6OMk,4383
7
7
  maps4fs/generator/dem.py,sha256=MZf3ZjawJ977TxqB1q9nNpvPZUNwfmm2EaJDtVU-eCU,15939
8
8
  maps4fs/generator/game.py,sha256=jjo7CTwHHSkRpeD_QgRXkhR_NxI09C4kMxz-nYOTM4A,7931
9
- maps4fs/generator/grle.py,sha256=onhZovvRtireDfw7wEOL0CZmOmoVzRPY-R4TlvbOUMI,17561
10
- maps4fs/generator/i3d.py,sha256=vbH7G0kDOGC6gbNDE-QYxMnKOMJ-vCGYdaKhWwci4ZU,23748
11
- maps4fs/generator/map.py,sha256=JwrlUdjyvSYB82HfseJ6w2-ZDFwplyfPCn84Z5awdCY,11721
9
+ maps4fs/generator/grle.py,sha256=u8ZwSs313PIOkH_0B_O2tVTaZ-eYNkc30eKGtBxWzTM,17846
10
+ maps4fs/generator/i3d.py,sha256=qeZYqfuhbhRPlSAuQHXaq6RmIO7314oMN68Ivebp1YQ,24786
11
+ maps4fs/generator/map.py,sha256=jIdekpiymhHqKx4FaAwjtq3hMnRdKYo6TvJLX1fSD0k,12814
12
12
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
13
- maps4fs/generator/texture.py,sha256=fZN0soGWk8-f3GuQWiwJ2yQTsmL9fLWVlgqeLI6ePi4,30648
13
+ maps4fs/generator/texture.py,sha256=sErusfv1AqQfP-veMrZ921Tz8DnGEhfB4ucggMmKrD4,31231
14
14
  maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
15
15
  maps4fs/toolbox/background.py,sha256=9BXWNqs_n3HgqDiPztWylgYk_QM4YgBpe6_ZNQAWtSc,2154
16
16
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
17
- maps4fs-1.4.1.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
18
- maps4fs-1.4.1.dist-info/METADATA,sha256=GYS-0gCIT-DmBEL29mDjwQIcn-7t_XYYH05ObyMOQSc,32421
19
- maps4fs-1.4.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
- maps4fs-1.4.1.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
21
- maps4fs-1.4.1.dist-info/RECORD,,
17
+ maps4fs-1.5.0.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
18
+ maps4fs-1.5.0.dist-info/METADATA,sha256=JZXcCZU91J0GD2q1YKooz_52UeA8DeCgbuv2zRrnTsQ,35026
19
+ maps4fs-1.5.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
+ maps4fs-1.5.0.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
21
+ maps4fs-1.5.0.dist-info/RECORD,,