extend database fields

This commit is contained in:
Daniel afx 2020-10-15 01:13:22 +03:00
parent f661055ced
commit 14935a0ba6
4 changed files with 70 additions and 10 deletions

Binary file not shown.

View file

@ -8,28 +8,88 @@ KML = "{http://www.opengis.net/kml/2.2}"
def iterate_kml(filepath):
fp = open(filepath)
parser = ET.XMLPullParser(["end"])
autoincrement = 0
while True:
chunk = fp.read(1024 * 8)
parser.feed(chunk)
for event, element in parser.read_events():
assert event == "end"
if element.tag == f"{KML}Placemark":
autoincrement += 1
name = element.find(f".//{KML}name").text
description = 'soon'
#description = element.find(f".//{KML}description").text
longitude, latitude, unknown = map(
float, element.find(f".//{KML}coordinates").text.split(",")
)
yield {
"name": name,
"x": latitude,
"y": longitude,
"description": description,
}
"FMID": autoincrement,
"MarketName": name,
"Website": "https://deflax.net",
"Facebook": "https://facebook.com/page",
"Twitter": "tw_user",
"Youtube": "yt_user",
"OtherMedia": "om_user",
"street": "1 afxhq",
"city": "none",
"County": "none",
"State": "none",
"zip": "none",
"Season1Date": "1970-01-01",
"Season1Time": "",
"Season2Date": "",
"Season2Time": "",
"Season3Date": "",
"Season3Time": "",
"Season4Date": "",
"Season4Time": "",
"x": latitude,
"y": longitude,
"Location": description,
"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": ""
}
if not chunk:
break
if __name__ == "__main__":
db = sqlite_utils.Database("fountains.db")
db["locations"].insert_all(iterate_kml(sys.argv[-1]))
db["locations"].insert_all(iterate_kml(sys.argv[-1]))

View file

@ -39,7 +39,7 @@ class ForestMapView(MapView):
def add_tree(self, tree):
# Create TreeMarker
lat, lon = tree[1], tree[2]
lat, lon = tree[20], tree[21]
treemarker = TreeMarker(lat=lat, lon=lon)
treemarker.tree_data = treemarker
@ -47,5 +47,5 @@ class ForestMapView(MapView):
self.add_widget(treemarker)
# Keep track of the TreeMarker's name
name = tree[0]
name = tree[1]
self.tree_names.append(name)

View file

@ -5,8 +5,8 @@ class TreePopupMenu(ListMDDialog):
super().__init__()
# Set all of the fields of tree data
headers = "Name,Lat,Lon,Description"
#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 = "Name,Lat,Lon,Description"
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)):