31 lines
1,019 B
Python
31 lines
1,019 B
Python
from kivy.garden.mapview import MapView
|
|
from kivy.clock import Clock
|
|
from kivy.app import App
|
|
|
|
class ForestMapView(MapView):
|
|
get_trees_timer = None
|
|
|
|
def start_get_fov_trees(self):
|
|
# After one second get the trees in field of view
|
|
try:
|
|
self.get_trees_timer.cancel()
|
|
except:
|
|
pass
|
|
|
|
self.get_trees_timer = Clock.schedule_once(self.get_fov_trees, 1)
|
|
|
|
def get_fov_trees(self, *args):
|
|
# Get reference to main app and the db cursor
|
|
app = App.get_running_app()
|
|
print(self.get_bbox()) # debug gps position
|
|
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_lon, max_lon, min_lat, max_lat)
|
|
app.cursor.execute(sql_statement)
|
|
trees = app.cursor.fetchall()
|
|
print(trees)
|
|
for tree in trees:
|
|
self.add_tree(tree)
|
|
|
|
def add_tree(self, tree):
|
|
pass
|
|
|