maps4fs 2.0.2__py3-none-any.whl → 2.0.3__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.
Files changed (40) hide show
  1. maps4fs/__init__.py +3 -2
  2. maps4fs/generator/component/dem.py +1 -2
  3. maps4fs/generator/map.py +2 -1
  4. {maps4fs-2.0.2.dist-info → maps4fs-2.0.3.dist-info}/METADATA +4 -44
  5. maps4fs-2.0.3.dist-info/RECORD +27 -0
  6. maps4fs/generator/dtm/__init__.py +0 -27
  7. maps4fs/generator/dtm/arctic.py +0 -74
  8. maps4fs/generator/dtm/baden.py +0 -31
  9. maps4fs/generator/dtm/base/wcs.py +0 -80
  10. maps4fs/generator/dtm/base/wms.py +0 -71
  11. maps4fs/generator/dtm/bavaria.py +0 -113
  12. maps4fs/generator/dtm/canada.py +0 -37
  13. maps4fs/generator/dtm/czech.py +0 -36
  14. maps4fs/generator/dtm/denmark.py +0 -50
  15. maps4fs/generator/dtm/dtm.py +0 -543
  16. maps4fs/generator/dtm/england.py +0 -31
  17. maps4fs/generator/dtm/finland.py +0 -56
  18. maps4fs/generator/dtm/flanders.py +0 -34
  19. maps4fs/generator/dtm/france.py +0 -69
  20. maps4fs/generator/dtm/hessen.py +0 -31
  21. maps4fs/generator/dtm/italy.py +0 -40
  22. maps4fs/generator/dtm/lithuania.py +0 -66
  23. maps4fs/generator/dtm/mv.py +0 -42
  24. maps4fs/generator/dtm/niedersachsen.py +0 -38
  25. maps4fs/generator/dtm/norway.py +0 -41
  26. maps4fs/generator/dtm/nrw.py +0 -30
  27. maps4fs/generator/dtm/rema.py +0 -74
  28. maps4fs/generator/dtm/sachsenanhalt.py +0 -36
  29. maps4fs/generator/dtm/scotland.py +0 -118
  30. maps4fs/generator/dtm/spain.py +0 -33
  31. maps4fs/generator/dtm/srtm.py +0 -122
  32. maps4fs/generator/dtm/switzerland.py +0 -104
  33. maps4fs/generator/dtm/thuringia.py +0 -60
  34. maps4fs/generator/dtm/usgs_wcs.py +0 -35
  35. maps4fs/generator/dtm/utils.py +0 -61
  36. maps4fs/generator/dtm/wales.py +0 -123
  37. maps4fs-2.0.2.dist-info/RECORD +0 -58
  38. {maps4fs-2.0.2.dist-info → maps4fs-2.0.3.dist-info}/WHEEL +0 -0
  39. {maps4fs-2.0.2.dist-info → maps4fs-2.0.3.dist-info}/licenses/LICENSE.md +0 -0
  40. {maps4fs-2.0.2.dist-info → maps4fs-2.0.3.dist-info}/top_level.txt +0 -0
maps4fs/__init__.py CHANGED
@@ -1,8 +1,9 @@
1
1
  # pylint: disable=missing-module-docstring
2
+ import pydtmdl.providers as dtm
3
+ from pydtmdl import DTMProvider
4
+
2
5
  import maps4fs.generator.component as component
3
- import maps4fs.generator.dtm as dtm
4
6
  import maps4fs.generator.settings as settings
5
- from maps4fs.generator.dtm.dtm import DTMProvider
6
7
  from maps4fs.generator.game import Game
7
8
  from maps4fs.generator.map import Map
8
9
  from maps4fs.logger import Logger
@@ -5,12 +5,12 @@ from typing import Any
5
5
 
6
6
  import cv2
7
7
  import numpy as np
8
+ from pydtmdl import DTMProvider
8
9
 
9
10
  # import rasterio # type: ignore
10
11
  from pympler import asizeof # type: ignore
11
12
 
12
13
  from maps4fs.generator.component.base.component_image import ImageComponent
13
- from maps4fs.generator.dtm.dtm import DTMProvider
14
14
 
15
15
 
16
16
  # pylint: disable=R0903, R0902
@@ -46,7 +46,6 @@ class DEM(ImageComponent):
46
46
  size=self.map_rotated_size,
47
47
  directory=self.temp_dir,
48
48
  logger=self.logger,
49
- map=self.map,
50
49
  )
51
50
 
52
51
  self.info: dict[str, Any] = {}
maps4fs/generator/map.py CHANGED
@@ -11,9 +11,10 @@ from xml.etree import ElementTree as ET
11
11
  import osmnx as ox
12
12
  from geopy.geocoders import Nominatim
13
13
  from osmnx._errors import InsufficientResponseError
14
+ from pydtmdl import DTMProvider
15
+ from pydtmdl.base.dtm import DTMProviderSettings
14
16
 
15
17
  from maps4fs.generator.component import Background, Component, Layer, Texture
16
- from maps4fs.generator.dtm.dtm import DTMProvider, DTMProviderSettings
17
18
  from maps4fs.generator.game import FS25, Game
18
19
  from maps4fs.generator.settings import (
19
20
  BackgroundSettings,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maps4fs
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Generate map templates for Farming Simulator from real places.
5
5
  Author-email: iwatkot <iwatkot@gmail.com>
6
6
  License: Apache License 2.0
@@ -26,6 +26,7 @@ Requires-Dist: pygmdl
26
26
  Requires-Dist: owslib
27
27
  Requires-Dist: tqdm
28
28
  Requires-Dist: scipy
29
+ Requires-Dist: pydtmdl
29
30
  Dynamic: license-file
30
31
 
31
32
  ⚠️ Learn more about the 2.0 changes in the [migration guide](docs/migration.md).
@@ -65,7 +66,6 @@ Dynamic: license-file
65
66
  <a href="#Resources">Resources</a> •
66
67
  <a href="#Bugs-and-feature-requests">Bugs and feature requests</a><br>
67
68
  <a href="docs/procedural_generation.md">Procedural Generation</a> •
68
- <a href="#DTM-Providers">DTM Providers</a> •
69
69
  <a href="#Special-thanks">Special thanks</a>
70
70
  </p>
71
71
 
@@ -87,7 +87,7 @@ Dynamic: license-file
87
87
  🔗 Generate maps using an [API](https://github.com/iwatkot/maps4fsapi) 🆕<br>
88
88
  ✂️ Supports map scaling<br>
89
89
  🔄 Support map rotation<br>
90
- 🌐 Supports custom [DTM Providers](#DTM-Providers)<br>
90
+ 🌐 Supports custom [DTM Providers](https://github.com/iwatkot/pydtmdl)<br>
91
91
  🌾 Automatically generates fields<br>
92
92
  🌽 Automatically generates farmlands<br>
93
93
  🌿 Automatically generates decorative foliage<br>
@@ -362,7 +362,7 @@ You can also specify any custom size of the map. Be aware that Giants Editor sup
362
362
  This setting can be useful if you want add some scaling to your map. For example, you can select a region of 3000 meters in real world and set the output size to 2048 meters. In this case, the map will be generated with a size of 2048x2048 meters, but it will contain the region of 3000x3000 meters in real world.
363
363
 
364
364
  ### DTM Provider
365
- DTM Provider is a source of the height map data. will find the list of available providers in the [DTM Providers](#dtm-providers) section. The default provider is `SRTM30Provider` which is available all aroung the globe, but the resolution is not very high. If you want to use a different provider, you can select it in the dropdown list. You will only see the providers that are available for the selected region. It's better to use the provider that has the highest resolution for the selected region.
365
+ DTM Provider is a source of the height map data. will find the list of available providers in the [pydtmdl](https://github.com/iwatkot/pydtmdl) repository. The default provider is `SRTM30Provider` which is available all aroung the globe, but the resolution is not very high. If you want to use a different provider, you can select it in the dropdown list. You will only see the providers that are available for the selected region. It's better to use the provider that has the highest resolution for the selected region.
366
366
  **NOTE:** Some of the providers are community-developed and may not work properly. I do not provide any support for them. If you have any issues with them, please contact the provider's author.
367
367
 
368
368
  ### Map Rotation
@@ -711,46 +711,6 @@ To create a basic map, you only need the Giants Editor. But if you want to creat
711
711
  ➡️ Please, before creating an issue or asking some questions, check the [FAQ](docs/FAQ.md) section.<br>
712
712
  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`.
713
713
 
714
- ## DTM Providers
715
-
716
- The generator supports adding the own DTM providers, please refer to the [DTM Providers](docs/dtm_providers.md) section to learn how to add the custom DTM provider.
717
-
718
- ### Supported DTM providers
719
-
720
- ![coverage map](https://github.com/user-attachments/assets/be5c5ce1-7318-4352-97eb-efba7ec587cd)
721
-
722
- In addition to SRTM 30m, which provides global coverage, the map above highlights all countries and/or regions where higher resolution coverage is provided by one of the DTM providers.
723
-
724
- | Provider Name | Resolution | Developer |
725
- | ---------------------------------- | ------------ | ------------------------------------------- |
726
- | 🌎 SRTM30 | 30 meters | [iwatkot](https://github.com/iwatkot) |
727
- | 🌎 ArcticDEM | 2 meters | [kbrandwijk](https://github.com/kbrandwijk) |
728
- | 🌎 REMA Antarctica | 2 meters | [kbrandwijk](https://github.com/kbrandwijk) |
729
- | 🇺🇸 USGS | 1-90 meters | [ZenJakey](https://github.com/ZenJakey) |
730
- | 🏴󠁧󠁢󠁥󠁮󠁧󠁿 England | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
731
- | 🏴󠁧󠁢󠁳󠁣󠁴󠁿 Scotland | 0.25-1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
732
- | 🏴󠁧󠁢󠁷󠁬󠁳󠁿󠁧󠁢󠁷󠁬󠁳󠁿 Wales | 1 meter | [garnwenshared](https://github.com/garnshared) |
733
- | 🇩🇪 Hessen, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
734
- | 🇩🇪 Niedersachsen, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
735
- | 🇩🇪 Bayern, Germany | 1 meter | [H4rdB4se](https://github.com/H4rdB4se) |
736
- | 🇩🇪 Nordrhein-Westfalen, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
737
- | 🇩🇪 Mecklenburg-Vorpommern, Germany | 1-25 meter | [kbrandwijk](https://github.com/kbrandwijk) |
738
- | 🇩🇪 Baden-Württemberg, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
739
- | 🇩🇪 Sachsen-Anhalt, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
740
- | 🇩🇪 Thüringen, Germany | 1 meter | [H4rdB4se](https://github.com/H4rdB4se) |
741
- | 🇨🇦 Canada | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
742
- | 🇧🇪 Flanders, Belgium | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
743
- | 🇫🇷 France | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
744
- | 🇮🇹 Italy | 10 meter | [kbrandwijk](https://github.com/kbrandwijk) |
745
- | 🇳🇴 Norway | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
746
- | 🇪🇸 Spain | 5 meter | [kbrandwijk](https://github.com/kbrandwijk) |
747
- | 🇫🇮 Finland | 2 meter | [kbrandwijk](https://github.com/kbrandwijk) |
748
- | 🇩🇰 Denmark | 0.4 meter | [kbrandwijk](https://github.com/kbrandwijk) |
749
- | 🇨🇭 Switzerland | 0.5-2 meter | [kbrandwijk](https://github.com/kbrandwijk) |
750
- | 🇨🇿 Czech Republic | 5 meter | [kbrandwijk](https://github.com/kbrandwijk) |
751
- | 🇱🇹 Lithuania | 1 meter | [Tox3](https://github.com/Tox3) |
752
-
753
-
754
714
  ## Special thanks
755
715
 
756
716
  Of course, first of all, thanks to the direct [contributors](https://github.com/iwatkot/maps4fs/graphs/contributors) of the project.
@@ -0,0 +1,27 @@
1
+ maps4fs/__init__.py,sha256=Fy521EmVAWnhu6OvOInc97yrtJotFzcV0YfRB2b9O4s,314
2
+ maps4fs/logger.py,sha256=WDfR14hxqy8b6xtwL6YIu2LGzFO1sbt0LxMgfsDTOkA,865
3
+ maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
+ maps4fs/generator/game.py,sha256=g8lMHuuRRmJLSDsQTAMv8p_-qntYMiZKnAqn7ru96i0,11645
5
+ maps4fs/generator/map.py,sha256=CiCTxw-7nuEHVIvRUjHekxZQDdBppw6f1wn-shnqzBU,16298
6
+ maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
7
+ maps4fs/generator/settings.py,sha256=8UbET3X1IbA7D4DX5HesZ7ijXLdzCCp7B3p3mFCZs8s,7429
8
+ maps4fs/generator/statistics.py,sha256=aynS3zbAtiwnU_YLKHPTiiaKW98_suvQUhy1SGBA6mc,2448
9
+ maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
10
+ maps4fs/generator/component/background.py,sha256=9CyT5MoQWILFwEGZThZnn3l1UEDI-5Sg0-VUV9TT240,23722
11
+ maps4fs/generator/component/config.py,sha256=IP530sapLofFskSnBEB96G0aUSd6Sno0G9ET3ca0ZOQ,3696
12
+ maps4fs/generator/component/dem.py,sha256=SH_2Zu5O4dhWtZeOkCwzDF4RU04XhTdpGFYaRYJkdjc,11905
13
+ maps4fs/generator/component/grle.py,sha256=5ftHSg8FwSkabVlStlfG_erGZSOrilU-RUvCobfT1Yw,19539
14
+ maps4fs/generator/component/i3d.py,sha256=5703ntFt7EQKFpQWQN5ST_bM08akV3rpSwKZDvkFp6w,24462
15
+ maps4fs/generator/component/layer.py,sha256=-br4gAGcGeBNb3ldch9XFEK0lhXqb1IbArhFB5Owu54,6186
16
+ maps4fs/generator/component/satellite.py,sha256=OsxoNOCgkUtRzL7Geuqubsf6uoKXAIN8jQvrJ7IFeAI,4958
17
+ maps4fs/generator/component/texture.py,sha256=Nc_oOHX3b4vJm8FnNOn3W4EQGFkW0zW0rGzO_0nTJMM,33392
18
+ maps4fs/generator/component/base/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
19
+ maps4fs/generator/component/base/component.py,sha256=HeNDaToKrS6OLeJepKZA7iQzZQDYy-9QRtv1A73Ire0,22090
20
+ maps4fs/generator/component/base/component_image.py,sha256=2NYJgCU8deHl7O2FYFYk38WKZVJygFoc2gjBXwH6vjM,5970
21
+ maps4fs/generator/component/base/component_mesh.py,sha256=7CfaEpfj_4P5LfAjFT4L76pTokqf6zmla9__sQNLUpA,8587
22
+ maps4fs/generator/component/base/component_xml.py,sha256=V9pGUvHh6UF6BP0qFARqDq9vquoAgq1zJqhOgBoeS_Y,3983
23
+ maps4fs-2.0.3.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
24
+ maps4fs-2.0.3.dist-info/METADATA,sha256=Olv0dQFCprAmXMZxjra3PwYZP2253btr5A5KPq9X-1E,44369
25
+ maps4fs-2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ maps4fs-2.0.3.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
27
+ maps4fs-2.0.3.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- # pylint: disable=missing-module-docstring
2
- from maps4fs.generator.dtm.arctic import ArcticProvider
3
- from maps4fs.generator.dtm.baden import BadenWurttembergProvider
4
- from maps4fs.generator.dtm.bavaria import BavariaProvider
5
- from maps4fs.generator.dtm.canada import CanadaProvider
6
- from maps4fs.generator.dtm.czech import CzechProvider
7
- from maps4fs.generator.dtm.denmark import DenmarkProvider
8
- from maps4fs.generator.dtm.england import England1MProvider
9
- from maps4fs.generator.dtm.finland import FinlandProvider
10
- from maps4fs.generator.dtm.flanders import FlandersProvider
11
- from maps4fs.generator.dtm.france import FranceProvider
12
- from maps4fs.generator.dtm.hessen import HessenProvider
13
- from maps4fs.generator.dtm.italy import ItalyProvider
14
- from maps4fs.generator.dtm.lithuania import LithuaniaProvider
15
- from maps4fs.generator.dtm.mv import MecklenburgVorpommernProvider
16
- from maps4fs.generator.dtm.niedersachsen import NiedersachsenProvider
17
- from maps4fs.generator.dtm.norway import NorwayProvider
18
- from maps4fs.generator.dtm.nrw import NRWProvider
19
- from maps4fs.generator.dtm.rema import REMAProvider
20
- from maps4fs.generator.dtm.sachsenanhalt import SachsenAnhaltProvider
21
- from maps4fs.generator.dtm.scotland import ScotlandProvider
22
- from maps4fs.generator.dtm.spain import SpainProvider
23
- from maps4fs.generator.dtm.srtm import SRTM30Provider
24
- from maps4fs.generator.dtm.switzerland import SwitzerlandProvider
25
- from maps4fs.generator.dtm.thuringia import ThuringiaProvider
26
- from maps4fs.generator.dtm.usgs_wcs import USGSWCSProvider
27
- from maps4fs.generator.dtm.wales import WalesProvider
@@ -1,74 +0,0 @@
1
- """This module contains provider of Arctic data."""
2
-
3
- import os
4
-
5
- import requests
6
-
7
- from maps4fs.generator.dtm.dtm import DTMProvider
8
-
9
-
10
- class ArcticProvider(DTMProvider):
11
- """Provider of Arctic data."""
12
-
13
- _code = "arctic"
14
- _name = "ArcticDEM"
15
- _region = "Global"
16
- _icon = "🌍"
17
- _resolution = 2
18
- _author = "[kbrandwijk](https://github.com/kbrandwijk)"
19
- _is_community = True
20
-
21
- _extents = [(83.98823036056658, 50.7492704708152, 179.99698443265999, -180)]
22
-
23
- _instructions = (
24
- "This provider source includes 2 meter DEM data for the entire Arctic region above 50 "
25
- "degrees North. The tiles are very big, around 1 GB each, so downloading and processing "
26
- "them can take a long time."
27
- )
28
-
29
- _url = "https://stac.pgc.umn.edu/api/v1/collections/arcticdem-mosaics-v4.1-2m/items"
30
-
31
- def download_tiles(self):
32
- download_urls = self.get_download_urls()
33
- all_tif_files = self.download_tif_files(download_urls, self.shared_tiff_path)
34
- return all_tif_files
35
-
36
- def __init__(self, *args, **kwargs):
37
- super().__init__(*args, **kwargs)
38
- self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
39
- os.makedirs(self.shared_tiff_path, exist_ok=True)
40
-
41
- def get_download_urls(self) -> list[str]:
42
- """Get download URLs of the GeoTIFF files from the OGC API.
43
-
44
- Returns:
45
- list: List of download URLs.
46
- """
47
- urls = []
48
-
49
- try:
50
- # Make the GET request
51
- north, south, east, west = self.get_bbox()
52
- response = requests.get( # pylint: disable=W3101
53
- self.url, # type: ignore
54
- params={
55
- "bbox": f"{west},{south},{east},{north}",
56
- "limit": "100",
57
- },
58
- timeout=60,
59
- )
60
- self.logger.debug("Getting file locations from ArcticDEM OGC API...")
61
-
62
- # Check if the request was successful (HTTP status code 200)
63
- if response.status_code == 200:
64
- # Parse the JSON response
65
- json_data = response.json()
66
- items = json_data["features"]
67
- for item in items:
68
- urls.append(item["assets"]["dem"]["href"])
69
- else:
70
- self.logger.error("Failed to get data. HTTP Status Code: %s", response.status_code)
71
- except requests.exceptions.RequestException as e:
72
- self.logger.error("Failed to get data. Error: %s", e)
73
- self.logger.debug("Received %s urls", len(urls))
74
- return urls
@@ -1,31 +0,0 @@
1
- """This module contains provider of Baden-Württemberg data."""
2
-
3
- from maps4fs.generator.dtm.base.wcs import WCSProvider
4
- from maps4fs.generator.dtm.dtm import DTMProvider
5
-
6
-
7
- class BadenWurttembergProvider(WCSProvider, DTMProvider):
8
- """Provider of Baden-Württemberg data."""
9
-
10
- _code = "baden"
11
- _name = "Baden-Württemberg"
12
- _region = "DE"
13
- _icon = "🇩🇪"
14
- _resolution = "1"
15
- _author = "[kbrandwijk](https://github.com/kbrandwijk)"
16
- _is_community = True
17
- _instructions = None
18
- _is_base = False
19
- _extents = [(49.79645444804715, 47.52877040346605, 10.54203149250156, 7.444081717803481)]
20
-
21
- _url = "https://owsproxy.lgl-bw.de/owsproxy/wcs/WCS_INSP_BW_Hoehe_Coverage_DGM1"
22
- _wcs_version = "2.0.1"
23
- _source_crs = "EPSG:25832"
24
- _tile_size = 1000
25
-
26
- def get_wcs_parameters(self, tile):
27
- return {
28
- "identifier": ["EL.ElevationGridCoverage"],
29
- "subsets": [("E", str(tile[1]), str(tile[3])), ("N", str(tile[0]), str(tile[2]))],
30
- "format": "image/tiff",
31
- }
@@ -1,80 +0,0 @@
1
- """This module contains the base WCS provider."""
2
-
3
- import os
4
- from abc import abstractmethod
5
-
6
- from owslib.wcs import WebCoverageService
7
- from tqdm import tqdm
8
-
9
- from maps4fs.generator.dtm import utils
10
- from maps4fs.generator.dtm.dtm import DTMProvider
11
-
12
-
13
- # pylint: disable=too-many-locals
14
- class WCSProvider(DTMProvider):
15
- """Generic provider of WCS sources."""
16
-
17
- _is_base = True
18
- _wcs_version = "2.0.1"
19
- _source_crs: str = "EPSG:4326"
20
- _tile_size: float = 0.02
21
-
22
- @abstractmethod
23
- def get_wcs_parameters(self, tile: tuple[float, float, float, float]) -> dict:
24
- """Get the parameters for the WCS request.
25
-
26
- Arguments:
27
- tile (tuple): The tile to download.
28
-
29
- Returns:
30
- dict: The parameters for the WCS request.
31
- """
32
-
33
- def get_wcs_instance_parameters(self) -> dict:
34
- """Get the parameters for the WCS instance.
35
-
36
- Returns:
37
- dict: The parameters for the WCS instance.
38
- """
39
- return {
40
- "url": self._url,
41
- "version": self._wcs_version,
42
- "timeout": 120,
43
- }
44
-
45
- def __init__(self, *args, **kwargs):
46
- super().__init__(*args, **kwargs)
47
- self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
48
- os.makedirs(self.shared_tiff_path, exist_ok=True)
49
-
50
- def download_tiles(self) -> list[str]:
51
- bbox = self.get_bbox()
52
- bbox = utils.transform_bbox(bbox, self._source_crs)
53
- tiles = utils.tile_bbox(bbox, self._tile_size)
54
-
55
- all_tif_files = self.download_all_tiles(tiles)
56
- return all_tif_files
57
-
58
- def download_all_tiles(self, tiles: list[tuple[float, float, float, float]]) -> list[str]:
59
- """Download tiles from the NI provider.
60
-
61
- Arguments:
62
- tiles (list): List of tiles to download.
63
-
64
- Returns:
65
- list: List of paths to the downloaded GeoTIFF files.
66
- """
67
- all_tif_files = []
68
- params = self.get_wcs_instance_parameters()
69
- wcs = WebCoverageService(**params)
70
-
71
- for tile in tqdm(tiles, desc="Downloading tiles", unit="tile"):
72
- file_name = "_".join(map(str, tile)) + ".tif"
73
- file_path = os.path.join(self.shared_tiff_path, file_name)
74
- if not os.path.exists(file_path):
75
- output = wcs.getCoverage(**self.get_wcs_parameters(tile))
76
- with open(file_path, "wb") as f:
77
- f.write(output.read())
78
-
79
- all_tif_files.append(file_path)
80
- return all_tif_files
@@ -1,71 +0,0 @@
1
- """This module contains the base WMS provider."""
2
-
3
- import os
4
- from abc import abstractmethod
5
-
6
- from owslib.wms import WebMapService
7
- from tqdm import tqdm
8
-
9
- from maps4fs.generator.dtm import utils
10
- from maps4fs.generator.dtm.dtm import DTMProvider
11
-
12
-
13
- # pylint: disable=too-many-locals
14
- class WMSProvider(DTMProvider):
15
- """Generic provider of WMS sources."""
16
-
17
- _is_base = True
18
- _wms_version = "1.3.0"
19
- _source_crs: str = "EPSG:4326"
20
- _tile_size: float = 0.02
21
-
22
- @abstractmethod
23
- def get_wms_parameters(self, tile: tuple[float, float, float, float]) -> dict:
24
- """Get the parameters for the WMS request.
25
-
26
- Arguments:
27
- tile (tuple): The tile to download.
28
-
29
- Returns:
30
- dict: The parameters for the WMS request.
31
- """
32
-
33
- def __init__(self, *args, **kwargs):
34
- super().__init__(*args, **kwargs)
35
- self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
36
- os.makedirs(self.shared_tiff_path, exist_ok=True)
37
-
38
- def download_tiles(self) -> list[str]:
39
- bbox = self.get_bbox()
40
- bbox = utils.transform_bbox(bbox, self._source_crs)
41
- tiles = utils.tile_bbox(bbox, self._tile_size)
42
-
43
- all_tif_files = self.download_all_tiles(tiles)
44
- return all_tif_files
45
-
46
- def download_all_tiles(self, tiles: list[tuple[float, float, float, float]]) -> list[str]:
47
- """Download tiles from the WMS provider.
48
-
49
- Arguments:
50
- tiles (list): List of tiles to download.
51
-
52
- Returns:
53
- list: List of paths to the downloaded GeoTIFF files.
54
- """
55
- all_tif_files = []
56
- wms = WebMapService(
57
- self._url,
58
- version=self._wms_version,
59
- # auth=Authentication(verify=False),
60
- timeout=600,
61
- )
62
- for tile in tqdm(tiles, desc="Downloading tiles", unit="tile"):
63
- file_name = "_".join(map(str, tile)) + ".tif"
64
- file_path = os.path.join(self.shared_tiff_path, file_name)
65
- if not os.path.exists(file_path):
66
- output = wms.getmap(**self.get_wms_parameters(tile))
67
- with open(file_path, "wb") as f:
68
- f.write(output.read())
69
-
70
- all_tif_files.append(file_path)
71
- return all_tif_files
@@ -1,113 +0,0 @@
1
- """This module contains provider of Bavaria data."""
2
-
3
- import hashlib
4
- import os
5
- from xml.etree import ElementTree as ET
6
-
7
- import requests
8
-
9
- from maps4fs.generator.dtm.dtm import DTMProvider
10
-
11
-
12
- class BavariaProvider(DTMProvider):
13
- """Provider of Bavaria Digital terrain model (DTM) 1m data.
14
- Data is provided by the 'Bayerische Vermessungsverwaltung' and available
15
- at https://geodaten.bayern.de/opengeodata/OpenDataDetail.html?pn=dgm1 under CC BY 4.0 license.
16
- """
17
-
18
- _code = "bavaria"
19
- _name = "Bavaria DGM1"
20
- _region = "DE"
21
- _icon = "🇩🇪󠁥󠁢󠁹󠁿"
22
- _resolution = 1
23
- _author = "[H4rdB4se](https://github.com/H4rdB4se)"
24
- _is_community = True
25
- _instructions = None
26
- _extents = [(50.56, 47.25, 13.91, 8.95)]
27
-
28
- def __init__(self, *args, **kwargs):
29
- super().__init__(*args, **kwargs)
30
- self.tiff_path = os.path.join(self._tile_directory, "tiffs")
31
- os.makedirs(self.tiff_path, exist_ok=True)
32
- self.meta4_path = os.path.join(self._tile_directory, "meta4")
33
- os.makedirs(self.meta4_path, exist_ok=True)
34
-
35
- def download_tiles(self) -> list[str]:
36
- download_urls = self.get_meta_file_from_coords()
37
- all_tif_files = self.download_tif_files(download_urls, self.tiff_path)
38
- return all_tif_files
39
-
40
- @staticmethod
41
- def get_meta_file_name(north: float, south: float, east: float, west: float) -> str:
42
- """Generate a hashed file name for the .meta4 file.
43
-
44
- Arguments:
45
- north (float): Northern latitude.
46
- south (float): Southern latitude.
47
- east (float): Eastern longitude.
48
- west (float): Western longitude.
49
-
50
- Returns:
51
- str: Hashed file name.
52
- """
53
- coordinates = f"{north}_{south}_{east}_{west}"
54
- hash_object = hashlib.md5(coordinates.encode())
55
- hashed_file_name = "download_" + hash_object.hexdigest() + ".meta4"
56
- return hashed_file_name
57
-
58
- def get_meta_file_from_coords(self) -> list[str]:
59
- """Download .meta4 (xml format) file
60
-
61
- Returns:
62
- list: List of download URLs.
63
- """
64
- (north, south, east, west) = self.get_bbox()
65
- file_path = os.path.join(self.meta4_path, self.get_meta_file_name(north, south, east, west))
66
- if not os.path.exists(file_path):
67
- try:
68
- # Make the GET request
69
- response = requests.post(
70
- "https://geoservices.bayern.de/services/poly2metalink/metalink/dgm1",
71
- (
72
- f"SRID=4326;POLYGON(({west} {south},{east} {south},"
73
- f"{east} {north},{west} {north},{west} {south}))"
74
- ),
75
- stream=True,
76
- timeout=60,
77
- )
78
-
79
- # Check if the request was successful (HTTP status code 200)
80
- if response.status_code == 200:
81
- # Write the content of the response to the file
82
- with open(file_path, "wb") as meta_file:
83
- for chunk in response.iter_content(chunk_size=8192): # Download in chunks
84
- meta_file.write(chunk)
85
- self.logger.debug("File downloaded successfully: %s", file_path)
86
- else:
87
- self.logger.error("Download error. HTTP Status Code: %s", response.status_code)
88
- except requests.exceptions.RequestException as e:
89
- self.logger.error("Failed to get data. Error: %s", e)
90
- else:
91
- self.logger.debug("File already exists: %s", file_path)
92
- return self.extract_urls_from_xml(file_path)
93
-
94
- def extract_urls_from_xml(self, file_path: str) -> list[str]:
95
- """Extract URLs from the XML file.
96
-
97
- Arguments:
98
- file_path (str): Path to the XML file.
99
-
100
- Returns:
101
- list: List of URLs.
102
- """
103
- urls: list[str] = []
104
- root = ET.parse(file_path).getroot()
105
- namespace = {"ml": "urn:ietf:params:xml:ns:metalink"}
106
-
107
- for file in root.findall(".//ml:file", namespace):
108
- url = file.find("ml:url", namespace)
109
- if url is not None:
110
- urls.append(str(url.text))
111
-
112
- self.logger.debug("Received %s urls", len(urls))
113
- return urls
@@ -1,37 +0,0 @@
1
- """This module contains provider of Canada data."""
2
-
3
- from maps4fs.generator.dtm.base.wcs import WCSProvider
4
- from maps4fs.generator.dtm.dtm import DTMProvider
5
-
6
-
7
- class CanadaProvider(WCSProvider, DTMProvider):
8
- """Provider of Canada data."""
9
-
10
- _code = "canada"
11
- _name = "Canada HRDEM"
12
- _region = "CN"
13
- _icon = "🇨🇦"
14
- _resolution = 1
15
- _author = "[kbrandwijk](https://github.com/kbrandwijk)"
16
- _is_community = True
17
- _is_base = False
18
- _extents = [(76.49491845750764, 33.66564101989275, -26.69697497450798, -157.7322455868316)]
19
- _instructions = (
20
- "HRDEM coverage for Canada is limited. Make sure to check the "
21
- "[coverage map](https://geo.ca/imagery/high-resolution-digital"
22
- "-elevation-model-hrdem-canelevation-series/)."
23
- )
24
-
25
- _url = "https://datacube.services.geo.ca/ows/elevation"
26
- _wcs_version = "1.1.1"
27
- _source_crs = "EPSG:3979"
28
- _tile_size = 1000
29
-
30
- def get_wcs_parameters(self, tile: tuple[float, float, float, float]) -> dict:
31
- return {
32
- "identifier": "dtm",
33
- "gridbasecrs": "urn:ogc:def:crs:EPSG::3979",
34
- "boundingbox": f"{tile[1]},{tile[0]},{tile[3]},{tile[2]},urn:ogc:def:crs:EPSG::3979",
35
- "format": "image/geotiff",
36
- "timeout": 600,
37
- }
@@ -1,36 +0,0 @@
1
- """This module contains provider of Czech data."""
2
-
3
- from maps4fs.generator.dtm.base.wcs import WCSProvider
4
- from maps4fs.generator.dtm.dtm import DTMProvider
5
-
6
-
7
- class CzechProvider(WCSProvider, DTMProvider):
8
- """Provider of Czech data."""
9
-
10
- _code = "czech"
11
- _name = "Czech Republic"
12
- _region = "CZ"
13
- _icon = "🇨🇿"
14
- _resolution = 5
15
- _author = "[kbrandwijk](https://github.com/kbrandwijk)"
16
- _is_community = True
17
- _instructions = None
18
- _is_base = False
19
- _extents = [
20
- (51.0576876059846754, 48.4917065572081754, 18.9775933665038821, 12.0428143585602161)
21
- ]
22
-
23
- _url = "https://ags.cuzk.cz/arcgis2/services/INSPIRE_Nadmorska_vyska/ImageServer/WCSServer" # pylint: disable=line-too-long
24
- _wcs_version = "1.0.0"
25
- _source_crs = "EPSG:4326"
26
- _tile_size = 0.05
27
-
28
- def get_wcs_parameters(self, tile):
29
- return {
30
- "identifier": "MD_LAS",
31
- "crs": "EPSG:4326",
32
- "bbox": tile,
33
- "width": 1000,
34
- "height": 1000,
35
- "format": "GeoTIFF",
36
- }