-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
900 additions
and
792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ README.md | |
requirements.txt | ||
run.ps1 | ||
run.sh | ||
maps4fs.zip | ||
maps4fs.zip | ||
.DS_Store | ||
maps/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ bot.env | |
logs/ | ||
archives/ | ||
previews/ | ||
maps4fs.zip | ||
maps4fs.zip | ||
.DS_Store | ||
maps/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from maps4fs.generator.map import Map | ||
from maps4fs.logger import Logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from maps4fs.generator.component import Component | ||
from maps4fs.generator.config import Config | ||
from maps4fs.generator.dem import DEM | ||
from maps4fs.generator.texture import Texture | ||
|
||
BaseComponents = [Config, Texture, DEM] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Any | ||
|
||
import maps4fs as mfs | ||
|
||
|
||
class Component: | ||
"""Base class for all map generation components. | ||
Args: | ||
coordinates (tuple[float, float]): The latitude and longitude of the center of the map. | ||
distance (int): The distance from the center to the edge of the map. | ||
map_directory (str): The directory where the map files are stored. | ||
logger (Any, optional): The logger to use. Must have at least three basic methods: debug, | ||
info, warning. If not provided, default logging will be used. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
coordinates: tuple[float, float], | ||
distance: int, | ||
map_directory: str, | ||
logger: Any = None, | ||
**kwargs, | ||
): | ||
self.coordinates = coordinates | ||
self.distance = distance | ||
self.map_directory = map_directory | ||
|
||
if not logger: | ||
logger = mfs.Logger(__name__, to_stdout=True, to_file=False) | ||
self.logger = logger | ||
|
||
def process(self): | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
from typing import Any | ||
from xml.etree import ElementTree as ET | ||
|
||
from maps4fs.generator import Component | ||
|
||
|
||
class Config(Component): | ||
"""Component for map settings and configuration. | ||
Args: | ||
coordinates (tuple[float, float]): The latitude and longitude of the center of the map. | ||
distance (int): The distance from the center to the edge of the map. | ||
map_directory (str): The directory where the map files are stored. | ||
logger (Any, optional): The logger to use. Must have at least three basic methods: debug, | ||
info, warning. If not provided, default logging will be used. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
coordinates: tuple[float, float], | ||
distance: int, | ||
map_directory: str, | ||
logger: Any = None, | ||
**kwargs, | ||
): | ||
super().__init__(coordinates, distance, map_directory, logger) | ||
self._map_xml_path = os.path.join(self.map_directory, "maps", "map", "map.xml") | ||
|
||
def process(self): | ||
self._set_map_size() | ||
|
||
def _set_map_size(self): | ||
"""Edits map.xml file to set correct map size.""" | ||
if not os.path.isfile(self._map_xml_path): | ||
self.logger.warning(f"Map XML file not found: {self._map_xml_path}.") | ||
return | ||
tree = ET.parse(self._map_xml_path) | ||
self.logger.debug(f"Map XML file loaded from: {self._map_xml_path}.") | ||
root = tree.getroot() | ||
for map_elem in root.iter("map"): | ||
width = height = str(self.distance * 2) | ||
map_elem.set("width", width) | ||
map_elem.set("height", height) | ||
self.logger.debug(f"Map size set to {width}x{height} in Map XML file.") | ||
tree.write(self._map_xml_path) | ||
self.logger.debug(f"Map XML file saved to: {self._map_xml_path}.") |
Oops, something went wrong.