mirror of
https://github.com/markqvist/Sideband.git
synced 2026-12-03 05:10:03 -05:00
modernize
This commit is contained in:
parent
5e15c43ab7
commit
2a13ed0921
103 changed files with 822 additions and 906 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# coding=utf-8
|
||||
"""
|
||||
MapView
|
||||
=======
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# coding=utf-8
|
||||
"""
|
||||
Layer that support point clustering
|
||||
===================================
|
||||
|
|
@ -265,9 +264,7 @@ class Marker:
|
|||
self.widget = None
|
||||
|
||||
def __repr__(self):
|
||||
return "<Marker lon={} lat={} source={}>".format(
|
||||
self.lon, self.lat, self.source
|
||||
)
|
||||
return f"<Marker lon={self.lon} lat={self.lat} source={self.source}>"
|
||||
|
||||
|
||||
class SuperCluster:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# coding=utf-8
|
||||
|
||||
__all__ = ["Downloader"]
|
||||
|
||||
import logging
|
||||
|
|
@ -52,7 +50,7 @@ class Downloader:
|
|||
self._futures = []
|
||||
Clock.schedule_interval(self._check_executor, 1 / 60.0)
|
||||
if not exists(self.cache_dir):
|
||||
RNS.log("Creating cache dir "+str(self.cache_dir), RNS.LOG_WARNING)
|
||||
RNS.log(f"Creating cache dir {self.cache_dir)}", RNS.LOG_WARNING)
|
||||
makedirs(self.cache_dir)
|
||||
|
||||
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
||||
|
|
@ -134,7 +132,7 @@ class Downloader:
|
|||
# Logger.debug("Downloaded {} bytes: {}".format(len(data), uri))
|
||||
return tile.set_source, (cache_fn,)
|
||||
except Exception as e:
|
||||
print("Downloader error: {!r}".format(e))
|
||||
print(f"Downloader error: {e!r}")
|
||||
|
||||
def _check_executor(self, dt):
|
||||
start = time()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# coding=utf-8
|
||||
"""
|
||||
Geojson layer
|
||||
=============
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# coding=utf-8
|
||||
"""
|
||||
MBTiles provider for MapView
|
||||
============================
|
||||
|
|
@ -87,7 +86,7 @@ class MBTilesMapSource(MapSource):
|
|||
im = CoreImage(
|
||||
data,
|
||||
ext='png',
|
||||
filename="{}.{}.{}.png".format(tile.zoom, tile.tile_x, tile.tile_y),
|
||||
filename=f"{tile.zoom}.{tile.tile_x}.{tile.tile_y}.png",
|
||||
)
|
||||
|
||||
if im is None:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# coding=utf-8
|
||||
|
||||
__all__ = ["MapSource"]
|
||||
|
||||
import hashlib
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# coding=utf-8
|
||||
|
||||
__all__ = ["Coordinate", "Bbox"]
|
||||
|
||||
from collections import namedtuple
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# coding=utf-8
|
||||
|
||||
__all__ = ["clamp", "haversine", "get_zoom_for_radius"]
|
||||
|
||||
from math import asin, cos, pi, radians, sin, sqrt
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# coding=utf-8
|
||||
|
||||
__all__ = ["MapView", "MapMarker", "MapMarkerPopup", "MapLayer", "MarkerMapLayer"]
|
||||
|
||||
import webbrowser
|
||||
|
|
@ -174,7 +172,7 @@ class CustomMapMarker(ButtonBehavior, Image):
|
|||
else:
|
||||
self.source = join(dirname(__file__), "icons", "marker_dark.png")
|
||||
|
||||
super(CustomMapMarker, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
self.texture_update()
|
||||
|
||||
def detach(self):
|
||||
|
|
@ -212,7 +210,7 @@ class MapMarker(ButtonBehavior, Image):
|
|||
_layer = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(MapMarker, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
self.texture_update()
|
||||
|
||||
def detach(self):
|
||||
|
|
@ -312,7 +310,7 @@ class MarkerMapLayer(MapLayer):
|
|||
bbox = None
|
||||
# reposition the markers depending the latitude
|
||||
markers = sorted(self.markers, key=lambda x: -x.lat)
|
||||
margin = max((max(marker.size) for marker in markers))
|
||||
margin = max(max(marker.size) for marker in markers)
|
||||
bbox = mapview.get_bbox(margin)
|
||||
for marker in markers:
|
||||
if bbox.collide(marker.lat, marker.lon):
|
||||
|
|
@ -783,7 +781,7 @@ class MapView(Widget):
|
|||
# self.animated_diff_scale_at(2.0 - cur_scale, *touch.pos)
|
||||
self._pause = False
|
||||
return True
|
||||
return super(MapView, self).on_touch_up(touch)
|
||||
return super().on_touch_up(touch)
|
||||
|
||||
def on_transform(self, *args):
|
||||
self._invalid_scale = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue