Giter Site home page Giter Site logo

iwatkot / maps4fs Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 5.24 MB

Generate map templates for Farming Simulator from real places.

Home Page: https://t.me/maps4fsbot

License: MIT License

Shell 2.10% Python 96.84% PowerShell 0.38% Dockerfile 0.67%
farming-simulator farmingsimulator22 osm osmnx gaming openstreetmap rasterio dem farming-simulator-mods fs

maps4fs's Introduction

Overview

The core idea is coming from the awesome maps4cim project.
The main goal of this project is to generate map templates, based on real-world data, for the Farming Simulator. It's important to mention that templates are not maps. They are just a starting point for creating a map. This tool just uses built-in textures to highlight different types of terrain and buildings with correct shapes and scales and to generate a height map. The rest of the work is up to you. So if you thought that you could just run this tool and get a playable map, then I'm sorry to disappoint you. But if you are a map maker, then this tool will save you a lot of time.
So, if you're new to map making, here's a quick overview of the process:

  1. Generate a map template using this tool.
  2. Download the Giants Editor.
  3. Open the map template in the Giants Editor.
  4. Now you can start creating your map (adding roads, fields, buildings, etc.).

Features

  • Allows to enter a location by lat and lon (e.g. from Google Maps).
  • Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
  • Generates a map template (check the list of supported objects in this section).
  • Generates a height map.

Supported objects

The project is based on the OpenStreetMap data. So, refer to this page to understand the list below.

  • "building": True
  • "highway": ["motorway", "trunk", "primary"]
  • "highway": ["secondary", "tertiary", "road"]
  • "highway": ["unclassified", "residential", "track"]
  • "natural": "grassland"
  • "landuse": "farmland"
  • "natural": ["water"]
  • "waterway": True
  • "natural": ["wood", "tree_row"]

The list will be updated as the project develops.

How-To-Run

Option 1 (recommended):
Using Telegram bot @maps4fs.
Note: due to CPU and RAM limitations of the hosting, only 2x2 and 4x4 km maps are available. If you need bigger maps, use the local version.
ℹ️ By the way, since I don't want to spend a lot of money on hosting, the bot may be unavailable from time to time or even be shut down. If you want to support this project, you can donate using Buy me a coffee.

Telegram bot

Using it is easy and doesn't require any guides. Enjoy!

Option 2:
Launch the project locally following these steps (or watch the video tutorial):

  1. Navigate to the releases page and download the latest version of the tool. If you are familiar with Git, you can clone the repository instead.
  2. Unzip the archive.
  3. Install Python 3.12 for your OS.
  4. Launch the script to create a virtual environment, install dependencies and run the tool:
    • Windows: right-click on the run.ps1 and select Run with PowerShell (if an error occurs, run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell)
    • Linux / Mac: execute the sh run.sh in a terminal in the tool's folder (this one will work on Windows too, if you have bash installed)
  5. Minimalistic GUI will appear.
  6. Copy lat and lon from Google Maps and paste them into the corresponding fields. To do this, right-click on someplace on the map and click on the coordinates which look like this: 52.520008, 13.404954. The first number is the latitude, the second one is the longitude. This point will be the center of the map.
  7. Select the size of the map (2048, 4096, 8192 or 16384 meters). The bigger the map, the longer it takes to generate it. Warning: to open huge maps in Giants Editor, you need a powerful PC. I don't recommend generating maps bigger than 8192 meters. By the way, the default map sizes in the Farming Simulator are 2048x2048 meters.
  8. Check the advanced settings if you want to change something. I strongly recommend changing the max_height value to which suits the map better. For more plain-like maps, set it to lower values (e.g. 200). For mountainous maps, set it to higher values (e.g. 800).
  9. Click on the Generate button.
  10. Wait until the map is generated. It may take a while.
  11. The map will be saved in the output folder in the tool's folder. You can open output/maps/map/map.i3d in the Giants Editor to check if everything is ok. If you need to run the script again, start with step 4. The script will delete the previous map and generate a new one.
  12. Now you can copy the output folder somewhere and start creating your map in the Giants Editor.

Option 3:
Using command line (not available yet). I'll add this on demand.

Option 4:
Using the web version (not available yet). I'll add this on demand. But at the moment, I just don't want to host it by myself. But it's not a problem to add a simple web app.

Settings

Advanced settings are available in the tool's UI under the Advanced Settings tab. Here's the list of them:

  • 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.
  • blur_seed - the seed for the blur algorithm. The default value is 5, which means 5 meters. The bigger the value, the smoother the map will be. The smaller the value, the more detailed the map will be. Keep in mind that for some regions, where terrain is bumpy, disabling the blur algorithm may lead to a very rough map. So, I recommend leaving this value as it is.

Info sequence

The script will also generate the generation_info.json file in the output folder. It contains the following keys:
"coordinates" - the coordinates of the map center which you entered,
"bbox" - the bounding box of the map in lat and lon,
"distance" - the size of the map in meters,
"minimum_x" - the minimum x coordinate of the map (UTM projection),
"minimum_y" - the minimum y coordinate of the map (UTM projection),
"maximum_x" - the maximum x coordinate of the map (UTM projection),
"maximum_y" - the maximum y coordinate of the map (UTM projection),
"height" - the height of the map in meters (it won't be equal to the distance since the Earth is not flat, sorry flat-earthers),
"width" - the width of the map in meters,
"height_coef" - since we need a texture of exact size, the height of the map is multiplied by this coefficient,
"width_coef" - same as above but for the width,
"tile_name" - the name of the SRTM tile which was used to generate the height map, e.g. "N52E013"

You can use this information to adjust some other sources of data to the map, e.g. textures, height maps, etc.

Bugs and feature requests

If you find a bug or have an idea for a new feature, please create an issue here or contact me directly on Telegram.
ℹ️ 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.

maps4fs's People

Contributors

iwatkot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

maps4fs's Issues

Suggestion: store OSM data and map coordinates for advanced users

I want to suggest you store the OSM data which is used, and that the exact corner coordinates used for the h eightmap.
This would allow advanced users to download higher resolution heightmaps from other sources and match the coordinates exactly. Plus the OSM data can be used to create curves for roads, and building outlines can be used to either generate buildings or as a basis for custom modeling in perfect scale.

All I'd ask for is the tool stores this data in a separate folder next to moddesc.xml for instance.

Missing structures

When I try to generate a map using the local method or telegram app it just shows something like this
photo_2024-05-28_16-29-25
On almost every coordinate I tried except the example one in the bot
This picture used 55.70117149841207, 21.145143669369897 ,4096x4096 ,For hills .
photo_2024-05-28_17-39-35
And this one used the same except coordinates 55.703002679267, 21.14383789155618 .

404

I have tried different locations as well and sizes, and nothing seems to work.

And if you click on link it says not key.

       Fetched 67 weight files.                                                                      generate.py:167
       Fetching map data for coordinates: (48.291146294052, -117.94518134918403)...                   generate.py:94
       Map minimum coordinates (XxY): 421566.02060560987 x 5340808.599549268.                        generate.py:303
       Map maximum coordinates (XxY): 438193.9029467169 x 5357388.232686824.                         generate.py:304
       Map dimensions (HxW): 16579.633137555793 x 16627.882341107004.                                generate.py:308
       Map coefficients (HxW): 1.0119404991183956 x 1.0148853967960818.                              generate.py:312
       Map is in east of central meridian.                                                           generate.py:318
       Map is in north hemisphere.                                                                   generate.py:319

[19:36:07] Fetched 1 elements for tags: {'highway': ['motorway', 'trunk', 'primary']}. generate.py:437
Texture C:\maps4fs\output\maps\map\data\asphalt01_weight.png saved. generate.py:452
[19:36:10] Fetched 129 elements for tags: {'building': True}. generate.py:437
Texture C:\maps4fs\output\maps\map\data\concrete01_weight.png saved. generate.py:452
[19:36:13] Fetched 176 elements for tags: {'highway': ['unclassified', 'residential', 'track']}. generate.py:437
[19:36:14] Texture C:\maps4fs\output\maps\map\data\dirtDark01_weight.png saved. generate.py:452
[19:36:16] Fetched 53 elements for tags: {'landuse': 'farmland'}. generate.py:437
[19:36:17] Texture C:\maps4fs\output\maps\map\data\forestGround01_weight.png saved. generate.py:452
[19:36:19] Fetched 23 elements for tags: {'natural': 'grassland'}. generate.py:437
[19:36:20] Texture C:\maps4fs\output\maps\map\data\grass01_weight.png saved. generate.py:452
[19:36:23] Fetched 9 elements for tags: {'natural': ['wood', 'tree_row']}. generate.py:437
Geometry type MultiPolygon not supported. generate.py:382
Geometry type MultiPolygon not supported. generate.py:382
Geometry type MultiPolygon not supported. generate.py:382
Geometry type MultiPolygon not supported. generate.py:382
Geometry type MultiPolygon not supported. generate.py:382
[19:36:24] Texture C:\maps4fs\output\maps\map\data\grassDirt01_weight.png saved. generate.py:452
[19:36:26] Fetched 8 elements for tags: {'highway': ['secondary', 'tertiary', 'road']}. generate.py:437
[19:36:27] Texture C:\maps4fs\output\maps\map\data\gravel01_weight.png saved. generate.py:452
[19:36:29] Fetched 13 elements for tags: {'natural': 'water', 'waterway': True}. generate.py:437
[19:36:30] Texture C:\maps4fs\output\maps\map\data\waterPuddle_weight.png saved. generate.py:452
SRTM tile name N48E-117 from latitude band N48. generate.py:499
Trying to get response from generate.py:477
https://elevation-tiles-prod.s3.amazonaws.com/skadi/N48/N48E-117.hgt.gz...
Response was failed with status code 404. generate.py:487
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\idaho\AppData\Local\Programs\Python\Python312\Lib\tkinter_init_.py", line 1967, in call
return self.func(*args)
^^^^^^^^^^^^^^^^
File "C:\maps4fs\src\main.py", line 28, in start
generate.Map(working_directory, (lat, lon), distance, dem_settings, logger)
File "C:\maps4fs\src\generate.py", line 99, in init
self.dem()
File "C:\maps4fs\src\generate.py", line 523, in dem
tile_path = self._srtm_tile()
^^^^^^^^^^^^^^^^^
File "C:\maps4fs\src\generate.py", line 509, in _srtm_tile
with gzip.open(compressed_file_path, "rb") as f_in:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\idaho\AppData\Local\Programs\Python\Python312\Lib\gzip.py", line 65, in open
raise TypeError("filename must be a str or bytes object, or a file")
TypeError: filename must be a str or bytes object, or a file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.