map with float layout, Xico's compass
@ -9,34 +9,43 @@
|
|||||||
|
|
||||||
|
|
||||||
<MapScreen>:
|
<MapScreen>:
|
||||||
BoxLayout:
|
FloatLayout:
|
||||||
orientation: 'vertical'
|
|
||||||
ActionBar:
|
|
||||||
pos_hint: {'top':1}
|
|
||||||
ActionView:
|
|
||||||
use_separator: True
|
|
||||||
ActionPrevious:
|
|
||||||
title: 'Social Cycling'
|
|
||||||
with_previous: False
|
|
||||||
ActionButton:
|
|
||||||
important: False
|
|
||||||
text: 'go to current loc'
|
|
||||||
on_press: app.center_map_on_gps()
|
|
||||||
ActionButton:
|
|
||||||
important: True
|
|
||||||
text: 'we ride together'
|
|
||||||
on_press: root.manager.current = 'compass'; app.set_destination()
|
|
||||||
MapView:
|
MapView:
|
||||||
|
|
||||||
id: mapview
|
id: mapview
|
||||||
zoom: 16
|
zoom: 16
|
||||||
|
|
||||||
on_map_relocated: centermark.lat = mapview.lat; centermark.lon = mapview.lon
|
on_map_relocated:
|
||||||
|
centermark.lat = mapview.lat
|
||||||
|
centermark.lon = mapview.lon
|
||||||
|
selfmark.lat = app.gps_data.get('lat', 0)
|
||||||
|
selfmark.lon = app.gps_data.get('lon', 0)
|
||||||
|
|
||||||
|
MapMarker:
|
||||||
|
source: 'marker_self.png'
|
||||||
|
id: selfmark
|
||||||
|
anchor_x: 0.5
|
||||||
|
anchor_y: 0
|
||||||
|
|
||||||
MapMarker:
|
MapMarker:
|
||||||
source: 'marker.png'
|
source: 'marker.png'
|
||||||
id: centermark
|
id: centermark
|
||||||
#anchor_x: 0.2
|
anchor_x: 0.5
|
||||||
#anchor_y: 0.3
|
anchor_y: 0
|
||||||
|
TextInput:
|
||||||
|
pos_hint: {"x":0.05, "top":0.97}
|
||||||
|
size_hint: 0.9, 0.07
|
||||||
|
multiline: False
|
||||||
|
Button:
|
||||||
|
pos_hint: {"x":0.35, "top":0.9}
|
||||||
|
size_hint: 0.6, 0.07
|
||||||
|
text: 'go to current loc'
|
||||||
|
on_press: app.center_map_on_gps()
|
||||||
|
Button:
|
||||||
|
pos_hint: {"x":.35, "top":0.83}
|
||||||
|
size_hint: 0.6, 0.07
|
||||||
|
text: 'we ride together'
|
||||||
|
on_press: root.manager.current = 'compass'; app.set_destination()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -91,3 +100,5 @@
|
|||||||
origin: self.center
|
origin: self.center
|
||||||
canvas.after:
|
canvas.after:
|
||||||
PopMatrix
|
PopMatrix
|
||||||
|
Image:
|
||||||
|
source: 'pivot.png'
|
||||||
24
main.py
@ -30,7 +30,7 @@ class FlockompassApp(App):
|
|||||||
needle_angle = NumericProperty(0)
|
needle_angle = NumericProperty(0)
|
||||||
fbearing = NumericProperty(0)
|
fbearing = NumericProperty(0)
|
||||||
|
|
||||||
dest_distance = StringProperty("")
|
dest_distance = StringProperty("")
|
||||||
|
|
||||||
def dump(self, dt):
|
def dump(self, dt):
|
||||||
print(dt, self.gps_data, self.session_data)
|
print(dt, self.gps_data, self.session_data)
|
||||||
@ -65,7 +65,7 @@ class FlockompassApp(App):
|
|||||||
def on_location(self, **kwargs):
|
def on_location(self, **kwargs):
|
||||||
self.gps_data = kwargs
|
self.gps_data = kwargs
|
||||||
self.dump(1)
|
self.dump(1)
|
||||||
|
|
||||||
if ('dest_lat' not in self.session_data
|
if ('dest_lat' not in self.session_data
|
||||||
and
|
and
|
||||||
'dest_lon' not in self.session_data):
|
'dest_lon' not in self.session_data):
|
||||||
@ -78,7 +78,7 @@ class FlockompassApp(App):
|
|||||||
self.dest_distance = "D: %0.1f km" % geodesic(
|
self.dest_distance = "D: %0.1f km" % geodesic(
|
||||||
(self.gps_data['lat'], self.gps_data['lon']),
|
(self.gps_data['lat'], self.gps_data['lon']),
|
||||||
(self.session_data['dest_lat'], self.session_data['dest_lon'])).kilometers
|
(self.session_data['dest_lat'], self.session_data['dest_lon'])).kilometers
|
||||||
|
|
||||||
def center_map_on_gps(self):
|
def center_map_on_gps(self):
|
||||||
self.ms.ids.mapview.center_on(self.gps_data['lat'],
|
self.ms.ids.mapview.center_on(self.gps_data['lat'],
|
||||||
self.gps_data['lon'])
|
self.gps_data['lon'])
|
||||||
@ -92,13 +92,13 @@ class FlockompassApp(App):
|
|||||||
needle_angle = 0
|
needle_angle = 0
|
||||||
if self.cs.facade.field != (None, None, None):
|
if self.cs.facade.field != (None, None, None):
|
||||||
x, y, z = self.cs.facade.field
|
x, y, z = self.cs.facade.field
|
||||||
|
|
||||||
smoothingFactor = 0.88
|
smoothingFactor = 0.676
|
||||||
angle = atan2(y, x)
|
angle = atan2(y, x)
|
||||||
self.last_angle = smoothingFactor * self.last_angle + (1 - smoothingFactor) * angle
|
self.last_angle = smoothingFactor * self.last_angle + (1 - smoothingFactor) * angle
|
||||||
|
|
||||||
needle_angle = degrees(self.last_angle) - 90
|
needle_angle = degrees(self.last_angle) - 90
|
||||||
|
|
||||||
# fix animation transition around the unit circle
|
# fix animation transition around the unit circle
|
||||||
if (self.needle_angle % 360) - needle_angle > 180:
|
if (self.needle_angle % 360) - needle_angle > 180:
|
||||||
needle_angle += 360
|
needle_angle += 360
|
||||||
@ -124,13 +124,13 @@ class FlockompassApp(App):
|
|||||||
cos(lat1) * sin(lat2)
|
cos(lat1) * sin(lat2)
|
||||||
- sin(lat1) * cos(lat2) * cos(lon2-lon1))
|
- sin(lat1) * cos(lat2) * cos(lon2-lon1))
|
||||||
fbearing = self.needle_angle - degrees(fbearing)
|
fbearing = self.needle_angle - degrees(fbearing)
|
||||||
|
|
||||||
fbearing = (fbearing + 360) % 360
|
#fbearing = (fbearing + 360) % 360
|
||||||
|
|
||||||
self.cs._anim &= Animation(fbearing=fbearing,
|
self.cs._anim &= Animation(fbearing=fbearing,
|
||||||
d=0.1,
|
d=0.1,
|
||||||
t='out_quad')
|
t='out_quad')
|
||||||
|
|
||||||
self.cs._anim.start(self)
|
self.cs._anim.start(self)
|
||||||
|
|
||||||
def compass_enable(self):
|
def compass_enable(self):
|
||||||
@ -175,13 +175,13 @@ class FlockompassApp(App):
|
|||||||
|
|
||||||
self.cs = CompassScreen(name='compass')
|
self.cs = CompassScreen(name='compass')
|
||||||
self.cs._anim = None
|
self.cs._anim = None
|
||||||
self.cs._anim1 = None
|
self.cs._anim1 = None
|
||||||
|
|
||||||
screen_manager.add_widget(self.cs)
|
screen_manager.add_widget(self.cs)
|
||||||
|
|
||||||
# smoothing vars for compass
|
# smoothing vars for compass
|
||||||
self.last_angle = 0
|
self.last_angle = 0
|
||||||
|
|
||||||
#Clock.schedule_interval(self.dump, 2.0)
|
#Clock.schedule_interval(self.dump, 2.0)
|
||||||
|
|
||||||
return screen_manager
|
return screen_manager
|
||||||
|
|||||||
BIN
marker_self.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
135
marker_self.svg
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
id="Capa_1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
width="48"
|
||||||
|
height="48"
|
||||||
|
viewBox="0 0 48 48"
|
||||||
|
xml:space="preserve"
|
||||||
|
sodipodi:docname="marker_self.svg"
|
||||||
|
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||||
|
inkscape:export-filename="/home/rgarcia/flockompass/marker_self.png"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"><metadata
|
||||||
|
id="metadata1618"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs1616" /><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1916"
|
||||||
|
inkscape:window-height="1056"
|
||||||
|
id="namedview1614"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="-0.2"
|
||||||
|
inkscape:pagecheckerboard="true"
|
||||||
|
showborder="true"
|
||||||
|
inkscape:zoom="9.15625"
|
||||||
|
inkscape:cx="12.905825"
|
||||||
|
inkscape:cy="34.886637"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="22"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="Capa_1" />
|
||||||
|
<circle
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:9.44900036;stroke-miterlimit:4;stroke-dasharray:none"
|
||||||
|
id="path2593"
|
||||||
|
cx="25.010239"
|
||||||
|
cy="15.017065"
|
||||||
|
r="9.5017061" /><g
|
||||||
|
id="g1581"
|
||||||
|
transform="matrix(0.09375,0,0,0.09375,1,0)"
|
||||||
|
style="fill:#629860;fill-opacity:1">
|
||||||
|
<path
|
||||||
|
d="M 256,0 C 167.641,0 96,71.625 96,160 c 0,24.75 5.625,48.219 15.672,69.125 C 112.234,230.313 256,512 256,512 L 398.594,232.625 C 409.719,210.844 416,186.156 416,160 416,71.625 344.375,0 256,0 Z m 0,256 c -53.016,0 -96,-43 -96,-96 0,-53 42.984,-96 96,-96 53,0 96,43 96,96 0,53 -43,96 -96,96 z"
|
||||||
|
id="path1579"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#629860;fill-opacity:1" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1583"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1585"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1587"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1589"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1591"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1593"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1595"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1597"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1599"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1601"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1603"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1605"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1607"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1609"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g1611"
|
||||||
|
transform="translate(-241,-232)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
style="overflow:inherit"
|
||||||
|
id="g2589"
|
||||||
|
transform="matrix(0.32940639,0,0,0.32940639,16.687463,6.9433558)"><path
|
||||||
|
id="path2578"
|
||||||
|
d="m 40.909,22.651 c -1.266,0 -2.469,0.26 -3.562,0.727 l -3.076,-5.271 2.318,-3.973 c 0.315,-0.542 0.132,-1.238 -0.409,-1.555 -0.238,-0.138 -0.503,-0.388 -0.754,-0.347 L 35.229,12 h -4.547 c -0.627,0 -1.136,0.873 -1.136,1.5 0,0.628 0.509,1.5 1.136,1.5 h 2.947 l -1.327,2 H 19.024 l 2.652,-5 h 1.051 c 0.627,0 1.136,-0.372 1.136,-1 0,-0.628 -0.509,-1 -1.136,-1 h -5.683 c -0.626,0 -1.136,0.372 -1.136,1 0,0.628 0.509,1 1.136,1 h 1.999 L 12.654,23.165 C 11.56,22.698 10.355,22.545 9.09,22.545 4.07,22.545 0,26.669 0,31.689 c 0,5.021 4.07,9.117 9.091,9.117 5.021,0 9.091,-4.057 9.091,-9.078 0,-2.94 -1.402,-5.541 -3.57,-7.204 l 2.433,-4.166 6.974,11.956 0.027,0.038 0.03,0.045 0.023,0.034 0.09,0.104 0.011,0.013 0.031,0.028 0.032,0.026 0.088,0.07 0.037,0.024 0.029,0.019 0.012,0.007 0.004,0.004 0.096,0.047 0.011,0.005 0.023,0.012 0.008,0.002 0.073,0.026 0.068,0.022 0.014,0.004 0.025,0.004 0.044,0.009 0.204,0.021 0.001,0.062 0.004,0.059 h 6.891 c 0.562,4 4.378,7.895 9.013,7.895 5.021,0 9.091,-4.101 9.091,-9.122 10e-4,-5.02 -4.069,-9.121 -9.09,-9.121 z m -25,9.091 c 0,3.767 -3.052,6.819 -6.818,6.819 -3.766,0 -6.818,-3.053 -6.818,-6.819 0,-3.765 3.052,-6.817 6.818,-6.817 0.847,0 1.655,0.161 2.403,0.444 l -3.385,5.802 c -0.316,0.541 -0.132,1.237 0.41,1.555 0.18,0.104 0.377,0.154 0.571,0.154 0.391,0 0.771,-0.202 0.983,-0.563 l 3.386,-5.806 c 1.496,1.251 2.45,3.13 2.45,5.231 z M 25,29.244 19.024,19 h 11.953 z m 7.954,-8.685 2.434,4.268 C 33.506,26.271 32.206,28 31.896,31 h -4.918 z m 3.587,6.345 2.391,4.096 h -4.738 c 0.274,-2 1.126,-3.075 2.347,-4.096 z m 4.368,11.719 C 37.532,38.623 34.734,36 34.193,33 h 6.713 l 0.005,-0.059 0.203,-0.053 0.046,-0.023 0.189,-0.066 0.021,-0.016 0.113,-0.058 0.027,-0.021 0.101,-0.073 0.078,-0.066 0.076,-0.083 0.068,-0.085 0.057,-0.092 0.052,-0.095 0.039,-0.104 0.031,-0.104 0.017,-0.104 0.013,-0.123 L 42.045,31.74 42.04,31.676 42.026,31.552 42.003,31.446 41.97,31.342 41.918,31.229 41.891,31.17 38.506,25.368 c 0.75,-0.283 1.557,-0.444 2.403,-0.444 3.767,0 6.819,3.083 6.819,6.848 10e-4,3.767 -3.052,6.851 -6.819,6.851 z"
|
||||||
|
inkscape:connector-curvature="0" /></g></svg>
|
||||||
|
After Width: | Height: | Size: 5.5 KiB |
BIN
needle.png
|
Before Width: | Height: | Size: 566 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 866 B |
BIN
presplash.png
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 76 KiB |