Reformat flinger with Black.

This commit is contained in:
Sergey Vartanov 2021-06-11 00:27:46 +03:00
parent 418cff2a6d
commit 9ed5b1a645

View file

@ -10,7 +10,7 @@ from roentgen.util import MinMax
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
EQUATOR_LENGTH: float = 40_075_017 # (in meters)
EQUATOR_LENGTH: float = 40_075_017 # meters
def pseudo_mercator(coordinates: np.array) -> np.array:
@ -21,8 +21,10 @@ def pseudo_mercator(coordinates: np.array) -> np.array:
:param coordinates: geo positional in the form of (latitude, longitude)
:return: position on the plane in the form of (x, y)
"""
return np.array((coordinates[1], 180 / np.pi * np.log(
np.tan(np.pi / 4 + coordinates[0] * (np.pi / 180) / 2))))
y: float = (
180 / np.pi * np.log(np.tan(np.pi / 4 + coordinates[0] * np.pi / 360))
)
return np.array((coordinates[1], y))
def osm_zoom_level_to_pixels_per_meter(zoom_level: float):
@ -51,11 +53,12 @@ class Flinger:
self.geo_boundaries: MinMax = geo_boundaries
self.border = border
self.ratio: float = (
osm_zoom_level_to_pixels_per_meter(scale) *
EQUATOR_LENGTH / 360)
self.size: np.array = self.ratio * (
pseudo_mercator(self.geo_boundaries.max_) -
pseudo_mercator(self.geo_boundaries.min_)) + border * 2
osm_zoom_level_to_pixels_per_meter(scale) * EQUATOR_LENGTH / 360
)
self.size: np.array = border * 2 + self.ratio * (
pseudo_mercator(self.geo_boundaries.max_)
- pseudo_mercator(self.geo_boundaries.min_)
)
self.pixels_per_meter = osm_zoom_level_to_pixels_per_meter(scale)
self.size: np.array = self.size.astype(int).astype(float)
@ -66,9 +69,10 @@ class Flinger:
:param coordinates: vector to fling
"""
result: np.array = self.ratio * (
pseudo_mercator(coordinates) -
pseudo_mercator(self.geo_boundaries.min_)) + self.border
result: np.array = self.border + self.ratio * (
pseudo_mercator(coordinates)
- pseudo_mercator(self.geo_boundaries.min_)
)
# Invert y axis on coordinate plane.
result[1] = self.size[1] - result[1]