mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-01 10:21:54 +02:00
Issue #76: add equator length argument.
This commit is contained in:
parent
d65c92f6b9
commit
51d522978a
2 changed files with 11 additions and 11 deletions
|
@ -49,29 +49,22 @@ class Flinger:
|
||||||
self,
|
self,
|
||||||
geo_boundaries: BoundaryBox,
|
geo_boundaries: BoundaryBox,
|
||||||
zoom_level: float = 18,
|
zoom_level: float = 18,
|
||||||
border: np.ndarray = np.array((0, 0)),
|
|
||||||
equator_length: float = 40_075_017.0,
|
equator_length: float = 40_075_017.0,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
:param geo_boundaries: minimum and maximum latitude and longitude
|
:param geo_boundaries: minimum and maximum latitude and longitude
|
||||||
:param zoom_level: zoom level in OpenStreetMap terminology
|
:param zoom_level: zoom level in OpenStreetMap terminology
|
||||||
:param border: size of padding in pixels
|
|
||||||
:param equator_length: celestial body equator length in meters, default
|
:param equator_length: celestial body equator length in meters, default
|
||||||
value is set for Earth
|
value is set for Earth
|
||||||
"""
|
"""
|
||||||
self.geo_boundaries: BoundaryBox = geo_boundaries
|
self.geo_boundaries: BoundaryBox = geo_boundaries
|
||||||
self.border: np.ndarray = border
|
self.ratio: float = 2 ** zoom_level * 256 / 360
|
||||||
self.ratio: float = (
|
self.size: np.ndarray = self.ratio * (
|
||||||
osm_zoom_level_to_pixels_per_meter(zoom_level)
|
|
||||||
* equator_length
|
|
||||||
/ 360
|
|
||||||
)
|
|
||||||
self.size: np.ndarray = border * 2 + self.ratio * (
|
|
||||||
pseudo_mercator(self.geo_boundaries.max_())
|
pseudo_mercator(self.geo_boundaries.max_())
|
||||||
- pseudo_mercator(self.geo_boundaries.min_())
|
- pseudo_mercator(self.geo_boundaries.min_())
|
||||||
)
|
)
|
||||||
self.pixels_per_meter: float = osm_zoom_level_to_pixels_per_meter(
|
self.pixels_per_meter: float = osm_zoom_level_to_pixels_per_meter(
|
||||||
zoom_level
|
zoom_level, equator_length
|
||||||
)
|
)
|
||||||
self.size: np.ndarray = self.size.astype(int).astype(float)
|
self.size: np.ndarray = self.size.astype(int).astype(float)
|
||||||
|
|
||||||
|
@ -81,7 +74,7 @@ class Flinger:
|
||||||
|
|
||||||
:param coordinates: vector to fling
|
:param coordinates: vector to fling
|
||||||
"""
|
"""
|
||||||
result: np.ndarray = self.border + self.ratio * (
|
result: np.ndarray = self.ratio * (
|
||||||
pseudo_mercator(coordinates)
|
pseudo_mercator(coordinates)
|
||||||
- pseudo_mercator(self.geo_boundaries.min_())
|
- pseudo_mercator(self.geo_boundaries.min_())
|
||||||
)
|
)
|
||||||
|
|
|
@ -85,6 +85,13 @@ def add_map_arguments(parser: argparse.ArgumentParser) -> None:
|
||||||
help="seed for random",
|
help="seed for random",
|
||||||
metavar="<string>",
|
metavar="<string>",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--equator-length",
|
||||||
|
default=40_075_017.0,
|
||||||
|
help="equator length",
|
||||||
|
type=float,
|
||||||
|
metavar="<float>",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_tile_arguments(parser: argparse.ArgumentParser) -> None:
|
def add_tile_arguments(parser: argparse.ArgumentParser) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue