Skip to content

Commit

Permalink
Merge branch 'main' into fs25
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatkot authored Nov 22, 2024
2 parents 76e71d6 + d8b8058 commit cbbefcb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
📦 Provides a ready-to-use map template for the Giants Editor<br>
🚜 Supports Farming Simulator 22 and 25*<br>

\* changes in the library are ready, waiting for the Giants to release the Giants Editor v10. Meanwhile the option to generate a map for FS25 is disabled.
\* in process, ETA: 24.11.2024.

## Quick Start
There are several ways to use the tool. You obviously need the **first one**, but you can choose any of the others depending on your needs.<br>
Expand Down Expand Up @@ -152,13 +152,14 @@ The map will be saved in the `map_directory` directory.
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.
- "building": True
- "highway": ["motorway", "trunk", "primary"]
- "highway": ["secondary", "tertiary", "road"]
- "highway": ["secondary", "tertiary", "road", "service"]
- "highway": ["unclassified", "residential", "track"]
- "natural": "grassland"
- "natural": ["grassland", "scrub"]
- "landuse": "farmland"
- "natural": ["water"]
- "waterway": True
- "natural": ["wood", "tree_row"]
- "railway": True

The list will be updated as the project develops.

Expand Down
11 changes: 7 additions & 4 deletions data/fs22-texture-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
{
"name": "grass",
"count": 4,
"tags": { "natural": "grassland" },
"color": [34, 255, 34]
"tags": { "natural": ["grassland", "scrub"] },
"width": 2
},
{
"name": "grassDirt",
Expand All @@ -66,7 +66,7 @@
{
"name": "gravel",
"count": 4,
"tags": { "highway": ["secondary", "tertiary", "road"] },
"tags": { "highway": ["secondary", "tertiary", "road", "service"] },
"width": 4,
"color": [140, 180, 210]
},
Expand All @@ -76,7 +76,10 @@
},
{
"name": "mountainRock",
"count": 4
"count": 4,
"tags": { "railway": true },
"width": 4,
"color": [100, 100, 100]
},
{
"name": "mountainRockDark",
Expand Down
8 changes: 5 additions & 3 deletions maps4fs/generator/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ def colored_preview(self) -> str:
colored_dem_path = self._dem_path.replace(".png", "_colored.png")
dem_data = cv2.imread(self._dem_path, cv2.IMREAD_GRAYSCALE)

# Normalize the DEM data to the range [0, 255]
# dem_data_normalized = cv2.normalize(dem_data, None, 0, 255, cv2.NORM_MINMAX)
# Create an empty array with the same shape and type as dem_data
dem_data_normalized = np.empty_like(dem_data)

dem_data_colored = cv2.applyColorMap(dem_data, cv2.COLORMAP_JET)
# Normalize the DEM data to the range [0, 255]
cv2.normalize(dem_data, dem_data_normalized, 0, 255, cv2.NORM_MINMAX)
dem_data_colored = cv2.applyColorMap(dem_data_normalized, cv2.COLORMAP_JET)

cv2.imwrite(colored_dem_path, dem_data_colored)
return colored_dem_path
Expand Down
21 changes: 5 additions & 16 deletions maps4fs/generator/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,23 +407,12 @@ def _osm_preview(self) -> str:
preview_size,
)

images = []
for layer in self.layers:
self.logger.debug(
"Reading layer %s from %s.", layer.name, layer.path(self._weights_dir)
)
images.append(
cv2.resize(
cv2.imread(layer.path(self._weights_dir), cv2.IMREAD_UNCHANGED), preview_size
)
images = [
cv2.resize(
cv2.imread(layer.path(self._weights_dir), cv2.IMREAD_UNCHANGED), preview_size
)

# images = [
# cv2.resize(
# cv2.imread(layer.path(self._weights_dir), cv2.IMREAD_UNCHANGED), preview_size
# )
# for layer in self.layers
# ]
for layer in self.layers
]
colors = [layer.color for layer in self.layers]
color_images = []
for img, color in zip(images, colors):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "maps4fs"
version = "0.7.3"
version = "0.7.5"
description = "Generate map templates for Farming Simulator from real places."
authors = [{name = "iwatkot", email = "iwatkot@gmail.com"}]
license = {text = "MIT License"}
Expand Down

0 comments on commit cbbefcb

Please sign in to comment.