From 32d59cbd87ddf0fce09b8557f3c869930234298a Mon Sep 17 00:00:00 2001 From: Daniel afx Date: Wed, 14 Oct 2020 19:41:26 +0300 Subject: [PATCH] implement gpsblinker --- forestmapview.kv | 1 + forestmapview.py | 6 +++--- gpsblinker.kv | 23 ++++++++++++++++++++++- gpsblinker.py | 12 ++++++++++-- treepopupmenu.py | 5 ++++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/forestmapview.kv b/forestmapview.kv index 95fb552..4ca23dc 100644 --- a/forestmapview.kv +++ b/forestmapview.kv @@ -1,5 +1,6 @@ #:import MapView kivy_garden.mapview.MapView #:import GpsBlinker gpsblinker.GpsBlinker +#:include gpsblinker.kv : lat: 42.131331 diff --git a/forestmapview.py b/forestmapview.py index b0a12d5..17b0c81 100644 --- a/forestmapview.py +++ b/forestmapview.py @@ -24,14 +24,14 @@ class ForestMapView(MapView): # Get reference to main app and the db cursor app = App.get_running_app() # Gebug gps position - #print(self.get_bbox()) + print("] Current map position: " + str(self.get_bbox())) min_lat, min_lon, max_lat, max_lon = self.get_bbox() sql_statement = "SELECT * FROM locations WHERE x > %s AND x < %s AND y > %s AND y < %s" % (min_lat, max_lat, min_lon, max_lon) #sql_statement = "SELECT * FROM locations" app.cursor.execute(sql_statement) trees = app.cursor.fetchall() for tree in trees: name = tree[0] - print("] Fountain detected: " + str(tree)) + #print("] Fountain detected: " + str(tree)) if name in self.tree_names: continue else: @@ -49,4 +49,4 @@ class ForestMapView(MapView): # Keep track of the TreeMarker's name - self.tree_names.append(name) \ No newline at end of file + self.tree_names.append(name) diff --git a/gpsblinker.kv b/gpsblinker.kv index 518466e..850ad3c 100644 --- a/gpsblinker.kv +++ b/gpsblinker.kv @@ -1 +1,22 @@ -: \ No newline at end of file +: + default_blink_size: 25 + blink_size: 25 + source: 'kivymd/images/transparent.png' + outer_opacity: 1 + + canvas.before: + # Outer circle + Color: + rgba: app.theme_cls.primary_color[:3] + [root.outer_opacity] + RoundedRectangle: + radius: [root.blink_size/2.0, ] + size: [root.blink_size, root.blink_size] + pos: root.pos[0] + root.size[0]/2.0 - root.blink_size/2.0, root.pos[1] + root.size[1]/2.0 - root.blink_size/2.0 + # Inner Circle + Color: + rgba: app.theme_cls.primary_color + RoundedRectangle: + radius: [root.default_blink_size/2.0, ] + size: [root.default_blink_size, root.default_blink_size] + pos: [root.pos[0] + root.size[0]/2.0 - root.default_blink_size/2.0, root.pos[1] + root.size[1]/2.0 - root.default_blink_size/2.0] + diff --git a/gpsblinker.py b/gpsblinker.py index 06ac1c3..7311ea3 100644 --- a/gpsblinker.py +++ b/gpsblinker.py @@ -1,7 +1,15 @@ from kivy_garden.mapview import MapMarker +from kivy.animation import Animation class GpsBlinker(MapMarker): def blink(self): - # Animantion that changes the blink size and opacity + # Animation that changes the blink size and opacity + anim = Animation(outer_opacity=0, blink_size=50) # When the animation completes, reset the animation, then repeat - pass \ No newline at end of file + anim.bind(on_complete=self.reset) + anim.start(self) + + def reset(self, *args): + self.outer_opacity = 1 + self.blink_size = self.default_blink_size + self.blink() diff --git a/treepopupmenu.py b/treepopupmenu.py index dc5a03e..55348c3 100644 --- a/treepopupmenu.py +++ b/treepopupmenu.py @@ -5,7 +5,10 @@ class TreePopupMenu(ListMDDialog): super().__init__() # Set all of the fields of tree data - headers = "Name,Lat,Lon,Description" + #headers = "Name,Lat,Lon,Description" + #headers = headers.split(',') + # Set all of the fields of market data + headers = "FMID,MarketName,Website,Facebook,Twitter,Youtube,OtherMedia,street,city,County,State,zip,Season1Date,Season1Time,Season2Date,Season2Time,Season3Date,Season3Time,Season4Date,Season4Time,x,y,Location,Credit,WIC,WICcash,SFMNP,SNAP,Organic,Bakedgoods,Cheese,Crafts,Flowers,Eggs,Seafood,Herbs,Vegetables,Honey,Jams,Maple,Meat,Nursery,Nuts,Plants,Poultry,Prepared,Soap,Trees,Wine,Coffee,Beans,Fruits,Grains,Juices,Mushrooms,PetFood,Tofu,WildHarvested,updateTime" headers = headers.split(',') for i in range(len(headers)):