diff --git a/buildozer.spec b/buildozer.spec index a0338fa..fb17706 100644 --- a/buildozer.spec +++ b/buildozer.spec @@ -36,7 +36,7 @@ version = 0.1 # (list) Application requirements # comma separated e.g. requirements = sqlite3,kivy -requirements = hostpython3, python3, kivy, plyer, android, mapview, requests, urllib3, chardet, idna +requirements = hostpython3, python3, kivy, plyer, android, mapview, requests, urllib3, chardet, idna, geopy, geographiclib # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes @@ -49,7 +49,7 @@ requirements = hostpython3, python3, kivy, plyer, android, mapview, requests, ur presplash.filename = ./presplash.png # (str) Icon of the application -#icon.filename = %(source.dir)s/data/icon.png +icon.filename = ./icon.png # (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) orientation = portrait diff --git a/flockompass.kv b/flockompass.kv index db14ad9..6c66aeb 100644 --- a/flockompass.kv +++ b/flockompass.kv @@ -21,7 +21,7 @@ ActionButton: important: False text: 'go to current loc' - on_press: app.center_map_on_gps() + on_press: app.center_map_on_gps() ActionButton: important: True text: 'we ride together' @@ -58,13 +58,18 @@ important: True text: 'set destination' on_press: root.manager.current = 'map'; - FloatLayout: canvas: Color: rgb: .9, .9, .9 Rectangle: size: self.size + Label: + text: app.dest_distance + color: 0, 0, 0.3, 1 + size_hint: 0.5, 0.1 + pos: 0, 0.1 + font_size: '40sp' Image: source: 'needle.png' canvas.before: @@ -76,7 +81,7 @@ canvas.after: PopMatrix Image: - id: to_flock + id: to_flock source: 'needle_to_flock.png' canvas.before: PushMatrix diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..2c28f24 Binary files /dev/null and b/icon.png differ diff --git a/main.py b/main.py index c26a319..35b2bff 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ from plyer import gps from kivy.app import App from kivy.clock import Clock -from kivy.properties import DictProperty, NumericProperty +from kivy.properties import DictProperty, NumericProperty, StringProperty from kivy.clock import mainthread from kivy.utils import platform from kivy_garden.mapview import MapView @@ -12,6 +12,8 @@ from kivy.vector import Vector from kivy.animation import Animation from math import atan2, sin, cos, degrees, floor +from geopy.distance import geodesic + class MapScreen(Screen): pass @@ -28,6 +30,8 @@ class FlockompassApp(App): needle_angle = NumericProperty(0) fbearing = NumericProperty(0) + dest_distance = StringProperty("") + def dump(self, dt): print(dt, self.gps_data, self.session_data) @@ -60,7 +64,8 @@ class FlockompassApp(App): @mainthread def on_location(self, **kwargs): self.gps_data = kwargs - + self.dump(1) + if ('dest_lat' not in self.session_data and 'dest_lon' not in self.session_data): @@ -82,6 +87,11 @@ class FlockompassApp(App): self.fbearing = self.needle_angle - degrees(self.fbearing) self.fbearing = (self.fbearing + 360) % 360 + self.dest_distance = "D: %0.1f km" % geodesic( + (self.gps_data['lat'], self.gps_data['lon']), + (self.session_data['dest_lat'], self.session_data['dest_lon'])).kilometers + print(self.dest_distance) + def center_map_on_gps(self): self.ms.ids.mapview.center_on(self.gps_data['lat'], self.gps_data['lon']) @@ -96,7 +106,7 @@ class FlockompassApp(App): if self.cs.facade.field != (None, None, None): x, y, z = self.cs.facade.field - smoothingFactor = 0.9 + smoothingFactor = 0.5 angle = atan2(y, x) self.last_angle = smoothingFactor * self.last_angle + (1 - smoothingFactor) * angle