maps4fs 0.6.7__py3-none-any.whl → 0.6.8__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/texture.py +4 -129
- {maps4fs-0.6.7.dist-info → maps4fs-0.6.8.dist-info}/METADATA +63 -6
- {maps4fs-0.6.7.dist-info → maps4fs-0.6.8.dist-info}/RECORD +6 -6
- {maps4fs-0.6.7.dist-info → maps4fs-0.6.8.dist-info}/WHEEL +1 -1
- {maps4fs-0.6.7.dist-info → maps4fs-0.6.8.dist-info}/LICENSE.md +0 -0
- {maps4fs-0.6.7.dist-info → maps4fs-0.6.8.dist-info}/top_level.txt +0 -0
maps4fs/generator/texture.py
CHANGED
@@ -16,134 +16,6 @@ from shapely.geometry.base import BaseGeometry # type: ignore
|
|
16
16
|
|
17
17
|
from maps4fs.generator.component import Component
|
18
18
|
|
19
|
-
# region constants
|
20
|
-
# texture = {
|
21
|
-
# "name": "concrete",
|
22
|
-
# "count": 4,
|
23
|
-
# "tags": {"building": True},
|
24
|
-
# "width": 8,
|
25
|
-
# "color": (130, 130, 130),
|
26
|
-
# }
|
27
|
-
|
28
|
-
# textures = [
|
29
|
-
# {
|
30
|
-
# "name": "animalMud",
|
31
|
-
# "count": 4,
|
32
|
-
# },
|
33
|
-
# {
|
34
|
-
# "name": "asphalt",
|
35
|
-
# "count": 4,
|
36
|
-
# "tags": {"highway": ["motorway", "trunk", "primary"]},
|
37
|
-
# "width": 8,
|
38
|
-
# "color": (70, 70, 70),
|
39
|
-
# },
|
40
|
-
# {
|
41
|
-
# "name": "cobbleStone",
|
42
|
-
# "count": 4,
|
43
|
-
# },
|
44
|
-
# {
|
45
|
-
# "name": "concrete",
|
46
|
-
# "count": 4,
|
47
|
-
# "tags": {"building": True},
|
48
|
-
# "width": 8,
|
49
|
-
# "color": (130, 130, 130),
|
50
|
-
# },
|
51
|
-
# {
|
52
|
-
# "name": "concreteRubble",
|
53
|
-
# "count": 4,
|
54
|
-
# },
|
55
|
-
# {
|
56
|
-
# "name": "concreteTiles",
|
57
|
-
# "count": 4,
|
58
|
-
# },
|
59
|
-
# {
|
60
|
-
# "name": "dirt",
|
61
|
-
# "count": 4,
|
62
|
-
# },
|
63
|
-
# {
|
64
|
-
# "name": "dirtDark",
|
65
|
-
# "count": 2,
|
66
|
-
# "tags": {"highway": ["unclassified", "residential", "track"]},
|
67
|
-
# "width": 2,
|
68
|
-
# "color": (33, 67, 101),
|
69
|
-
# },
|
70
|
-
# {
|
71
|
-
# "name": "forestGround",
|
72
|
-
# "count": 4,
|
73
|
-
# "tags": {"landuse": "farmland"},
|
74
|
-
# "color": (47, 107, 85),
|
75
|
-
# },
|
76
|
-
# {
|
77
|
-
# "name": "forestGroundLeaves",
|
78
|
-
# "count": 4,
|
79
|
-
# },
|
80
|
-
# {
|
81
|
-
# "name": "grass",
|
82
|
-
# "count": 4,
|
83
|
-
# "tags": {"natural": "grassland"},
|
84
|
-
# "color": (34, 255, 34),
|
85
|
-
# },
|
86
|
-
# {
|
87
|
-
# "name": "grassDirt",
|
88
|
-
# "count": 4,
|
89
|
-
# "tags": {"natural": ["wood", "tree_row"]},
|
90
|
-
# "width": 2,
|
91
|
-
# "color": (0, 252, 124),
|
92
|
-
# },
|
93
|
-
# {
|
94
|
-
# "name": "gravel",
|
95
|
-
# "count": 4,
|
96
|
-
# "tags": {"highway": ["secondary", "tertiary", "road"]},
|
97
|
-
# "width": 4,
|
98
|
-
# "color": (140, 180, 210),
|
99
|
-
# },
|
100
|
-
# {
|
101
|
-
# "name": "groundBricks",
|
102
|
-
# "count": 4,
|
103
|
-
# },
|
104
|
-
# {
|
105
|
-
# "name": "mountainRock",
|
106
|
-
# "count": 4,
|
107
|
-
# },
|
108
|
-
# {
|
109
|
-
# "name": "mountainRockDark",
|
110
|
-
# "count": 4,
|
111
|
-
# },
|
112
|
-
# {
|
113
|
-
# "name": "riverMud",
|
114
|
-
# "count": 4,
|
115
|
-
# },
|
116
|
-
# {
|
117
|
-
# "name": "waterPuddle",
|
118
|
-
# "count": 0,
|
119
|
-
# "tags": {"natural": "water", "waterway": True},
|
120
|
-
# "width": 10,
|
121
|
-
# "color": (255, 20, 20),
|
122
|
-
# },
|
123
|
-
# ]
|
124
|
-
|
125
|
-
# TEXTURES = {
|
126
|
-
# ? "animalMud": 4,
|
127
|
-
# ? "asphalt": 4,
|
128
|
-
# ? "cobbleStone": 4,
|
129
|
-
# ? "concrete": 4,
|
130
|
-
# "concreteRubble": 4,
|
131
|
-
# "concreteTiles": 4,
|
132
|
-
# "dirt": 4,
|
133
|
-
# "dirtDark": 2,
|
134
|
-
# "forestGround": 4,
|
135
|
-
# "forestGroundLeaves": 4,
|
136
|
-
# "grass": 4,
|
137
|
-
# "grassDirt": 4,
|
138
|
-
# "gravel": 4,
|
139
|
-
# "groundBricks": 4,
|
140
|
-
# "mountainRock": 4,
|
141
|
-
# "mountainRockDark": 4,
|
142
|
-
# "riverMud": 4,
|
143
|
-
# "waterPuddle": 0,
|
144
|
-
# }
|
145
|
-
# endregion
|
146
|
-
|
147
19
|
|
148
20
|
# pylint: disable=R0902
|
149
21
|
class Texture(Component):
|
@@ -365,6 +237,9 @@ class Texture(Component):
|
|
365
237
|
def draw(self) -> None:
|
366
238
|
"""Iterates over layers and fills them with polygons from OSM data."""
|
367
239
|
for layer in self.layers:
|
240
|
+
if not layer.tags:
|
241
|
+
self.logger.debug("Layer %s has no tags, there's nothing to draw.", layer.name)
|
242
|
+
continue
|
368
243
|
layer_path = layer.path(self._weights_dir)
|
369
244
|
self.logger.debug("Drawing layer %s.", layer_path)
|
370
245
|
|
@@ -372,7 +247,7 @@ class Texture(Component):
|
|
372
247
|
for polygon in self.polygons(layer.tags, layer.width): # type: ignore
|
373
248
|
cv2.fillPoly(img, [polygon], color=255) # type: ignore
|
374
249
|
cv2.imwrite(layer_path, img)
|
375
|
-
self.logger.debug("Texture %s saved.",
|
250
|
+
self.logger.debug("Texture %s saved.", layer_path)
|
376
251
|
|
377
252
|
def get_relative_x(self, x: float) -> int:
|
378
253
|
"""Converts UTM X coordinate to relative X coordinate in map image.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.8
|
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
|
@@ -34,6 +34,7 @@ Requires-Dist: tqdm
|
|
34
34
|
|
35
35
|
|
36
36
|
[](https://github.com/iwatkot/maps4fs/releases)
|
37
|
+
[](https://pypi.org/project/maps4fs)
|
37
38
|
[](https://hub.docker.com/repository/docker/iwatkot/maps4fs/general)
|
38
39
|
[](https://github.com/iwatkot/maps4fs/issues)
|
39
40
|
[](https://codeclimate.com/github/iwatkot/maps4fs/maintainability)<br>
|
@@ -50,8 +51,11 @@ Requires-Dist: tqdm
|
|
50
51
|
🔃 Farming Simulator 25 (changes in the library are ready, waiting for the Giants to release the Giants Editor v10)<br>
|
51
52
|
|
52
53
|
## Quick Start
|
53
|
-
|
54
|
-
|
54
|
+
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>
|
55
|
+
### 🚜 For most users
|
56
|
+
**Option 1:** open the [maps4fs](https://maps4fs.streamlit.app) on StreamLit and generate a map template in a few clicks.<br>
|
57
|
+
|
58
|
+
### 😎 For advanced users
|
55
59
|
**Option 2:** run the Docker version in your browser. Launch the following command in your terminal:
|
56
60
|
```bash
|
57
61
|
docker run -d -p 8501:8501 iwatkot/maps4fs
|
@@ -59,6 +63,13 @@ docker run -d -p 8501:8501 iwatkot/maps4fs
|
|
59
63
|
And open [http://localhost:8501](http://localhost:8501) in your browser.<br>
|
60
64
|
If you don't know how to use Docker, navigate to the [Docker version](#option-2-docker-version), it's really simple.<br>
|
61
65
|
|
66
|
+
### 🤯 For developers
|
67
|
+
**Option 3:** Python package. Install the package using the following command:
|
68
|
+
```bash
|
69
|
+
pip install maps4fs
|
70
|
+
```
|
71
|
+
And refer to the [Python package](#option-3-python-package) section to learn how to use it.<br>
|
72
|
+
|
62
73
|
## Overview
|
63
74
|
The core idea is coming from the awesome [maps4cim](https://github.com/klamann/maps4cim) project.<br>
|
64
75
|
|
@@ -78,14 +89,14 @@ You'll find detailed instructions on how to run the project below. But if you pr
|
|
78
89
|
### Option 1: StreamLit
|
79
90
|
**🗺️ Supported map sizes:** 2x2, 4x4, 8x8, 16x16 km.<br>
|
80
91
|
🟢 Recommended for all users, you don't need to install anything.<br>
|
81
|
-
Using
|
92
|
+
Using the [StreamLit](https://maps4fs.streamlit.app) version of the tool is the easiest way to generate a map template. Just open the link and follow the instructions.
|
82
93
|
Note: due to CPU and RAM limitations of the hosting, the generation may take some time. If you need faster processing, use the [Docker version](#option-2-docker-version).<br>
|
83
94
|
|
84
95
|
Using it is easy and doesn't require any guides. Enjoy!
|
85
96
|
|
86
97
|
### Option 2: Docker version
|
87
98
|
**🗺️ Supported map sizes:** 2x2, 4x4, 8x8, 16x16 km.<br>
|
88
|
-
|
99
|
+
🟠 Recommended for users who want faster processing, very simple installation.<br>
|
89
100
|
You can launch the project with minimalistic UI in your browser using Docker. Follow these steps:
|
90
101
|
|
91
102
|
1. Install [Docker](https://docs.docker.com/get-docker/) for your OS.
|
@@ -99,6 +110,53 @@ docker run -d -p 8501:8501 iwatkot/maps4fs
|
|
99
110
|
|
100
111
|

|
101
112
|
|
113
|
+
### Option 3: Python package
|
114
|
+
**🗺️ Supported map sizes:** 2x2, 4x4, 8x8, 16x16 km (and ANY other you may add).<br>
|
115
|
+
🔴 Recommended for developers.<br>
|
116
|
+
You can use the Python package to generate maps. Follow these steps:
|
117
|
+
|
118
|
+
1. Install the package from PyPI:
|
119
|
+
```bash
|
120
|
+
pip install maps4fs
|
121
|
+
```
|
122
|
+
2. Import the Game class and create an instance of it:
|
123
|
+
```python
|
124
|
+
import maps4fs as mfs
|
125
|
+
|
126
|
+
game = mfs.Game.from_code("FS25")
|
127
|
+
```
|
128
|
+
In this case the library will use the default templates, which should be present in the `data` directory, which should be placed in the current working directory.<br>
|
129
|
+
Structure example:<br>
|
130
|
+
|
131
|
+
```text
|
132
|
+
📁 data
|
133
|
+
┣ 📄 fs22-map-template.zip
|
134
|
+
┗ 📄 fs22-texture-schema.json
|
135
|
+
```
|
136
|
+
|
137
|
+
So it's recommended to download the `data` directory from the repository and place it in the root of your project.<br>
|
138
|
+
|
139
|
+
3. Create an instance of the Map class:
|
140
|
+
```python
|
141
|
+
import maps4fs as mfs
|
142
|
+
|
143
|
+
map = mfs.Map(
|
144
|
+
game,
|
145
|
+
(52.5200, 13.4050), # Latitude and longitude of the map center.
|
146
|
+
distance=1024, # The DISTANCE from the center to the edge of the map in meters. The map will be 2048x2048 meters.
|
147
|
+
map_directory="path/to/your/map/directory", # The directory where the map will be saved.
|
148
|
+
blur_seed=5, # The seed for the blur algorithm. The default value is 5, which means 5 meters.
|
149
|
+
max_height=400 # The maximum height of the map.
|
150
|
+
)
|
151
|
+
```
|
152
|
+
|
153
|
+
4. Generate the map:
|
154
|
+
```python
|
155
|
+
map.generate()
|
156
|
+
```
|
157
|
+
|
158
|
+
The map will be saved in the `map_directory` directory.
|
159
|
+
|
102
160
|
## Settings
|
103
161
|
Advanced settings are available in the tool's UI under the **Advanced Settings** tab. Here's the list of them:
|
104
162
|
- `max_height` - the maximum height of the map. The default value is 400. Select smaller values for plain-like maps and bigger values for mountainous maps. You may need to experiment with this value to get the desired result.
|
@@ -143,4 +201,3 @@ You can use this information to adjust some other sources of data to the map, e.
|
|
143
201
|
|
144
202
|
## Bugs and feature requests
|
145
203
|
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>
|
146
|
-
ℹ️ Please, don't bother me if the Telegram bot is down. As I said before this is related to the hosting limitations, if you want you can always run the tool locally or support the project by donating, so maybe I'll be able to afford better hosting.
|
@@ -6,9 +6,9 @@ maps4fs/generator/config.py,sha256=3X9E6luYh0dBlYcGvE4Exzp-ShAMCFjGB_8SK3qPBtM,1
|
|
6
6
|
maps4fs/generator/dem.py,sha256=_1d_TPMOGBgl2-R_CRMbKumzxCbQyb-hcpqsElhYbQ4,8546
|
7
7
|
maps4fs/generator/game.py,sha256=IyXjNEC5epJmDdqjsrl4wKL85T1F23km73pUkBiuDWU,4468
|
8
8
|
maps4fs/generator/map.py,sha256=Y7ERUB6ivxJilDAjE9UD0-vl0SKtzj6J2f8QPXM6i48,3712
|
9
|
-
maps4fs/generator/texture.py,sha256=
|
10
|
-
maps4fs-0.6.
|
11
|
-
maps4fs-0.6.
|
12
|
-
maps4fs-0.6.
|
13
|
-
maps4fs-0.6.
|
14
|
-
maps4fs-0.6.
|
9
|
+
maps4fs/generator/texture.py,sha256=f5dPD5q17CTg8aY6G3i33vFk9ckbpndVb1W3hbT1wL4,15318
|
10
|
+
maps4fs-0.6.8.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
|
11
|
+
maps4fs-0.6.8.dist-info/METADATA,sha256=q6HMaXkmT1mkfskzOS9EQrTILUTfAIb_D5BJF4ObMKc,10652
|
12
|
+
maps4fs-0.6.8.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
13
|
+
maps4fs-0.6.8.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
14
|
+
maps4fs-0.6.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|