extend database fields
This commit is contained in:
parent
f661055ced
commit
14935a0ba6
4 changed files with 70 additions and 10 deletions
Binary file not shown.
|
@ -8,28 +8,88 @@ KML = "{http://www.opengis.net/kml/2.2}"
|
||||||
def iterate_kml(filepath):
|
def iterate_kml(filepath):
|
||||||
fp = open(filepath)
|
fp = open(filepath)
|
||||||
parser = ET.XMLPullParser(["end"])
|
parser = ET.XMLPullParser(["end"])
|
||||||
|
autoincrement = 0
|
||||||
while True:
|
while True:
|
||||||
chunk = fp.read(1024 * 8)
|
chunk = fp.read(1024 * 8)
|
||||||
parser.feed(chunk)
|
parser.feed(chunk)
|
||||||
for event, element in parser.read_events():
|
for event, element in parser.read_events():
|
||||||
assert event == "end"
|
assert event == "end"
|
||||||
if element.tag == f"{KML}Placemark":
|
if element.tag == f"{KML}Placemark":
|
||||||
|
autoincrement += 1
|
||||||
name = element.find(f".//{KML}name").text
|
name = element.find(f".//{KML}name").text
|
||||||
description = 'soon'
|
description = 'soon'
|
||||||
#description = element.find(f".//{KML}description").text
|
#description = element.find(f".//{KML}description").text
|
||||||
longitude, latitude, unknown = map(
|
longitude, latitude, unknown = map(
|
||||||
float, element.find(f".//{KML}coordinates").text.split(",")
|
float, element.find(f".//{KML}coordinates").text.split(",")
|
||||||
)
|
)
|
||||||
|
|
||||||
yield {
|
yield {
|
||||||
"name": name,
|
"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,
|
"x": latitude,
|
||||||
"y": longitude,
|
"y": longitude,
|
||||||
"description": description,
|
"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:
|
if not chunk:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
db = sqlite_utils.Database("fountains.db")
|
db = sqlite_utils.Database("fountains.db")
|
||||||
|
|
||||||
db["locations"].insert_all(iterate_kml(sys.argv[-1]))
|
db["locations"].insert_all(iterate_kml(sys.argv[-1]))
|
|
@ -39,7 +39,7 @@ class ForestMapView(MapView):
|
||||||
|
|
||||||
def add_tree(self, tree):
|
def add_tree(self, tree):
|
||||||
# Create TreeMarker
|
# Create TreeMarker
|
||||||
lat, lon = tree[1], tree[2]
|
lat, lon = tree[20], tree[21]
|
||||||
treemarker = TreeMarker(lat=lat, lon=lon)
|
treemarker = TreeMarker(lat=lat, lon=lon)
|
||||||
treemarker.tree_data = treemarker
|
treemarker.tree_data = treemarker
|
||||||
|
|
||||||
|
@ -47,5 +47,5 @@ class ForestMapView(MapView):
|
||||||
self.add_widget(treemarker)
|
self.add_widget(treemarker)
|
||||||
|
|
||||||
# Keep track of the TreeMarker's name
|
# Keep track of the TreeMarker's name
|
||||||
name = tree[0]
|
name = tree[1]
|
||||||
self.tree_names.append(name)
|
self.tree_names.append(name)
|
||||||
|
|
|
@ -5,8 +5,8 @@ class TreePopupMenu(ListMDDialog):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Set all of the fields of tree data
|
# Set all of the fields of tree data
|
||||||
headers = "Name,Lat,Lon,Description"
|
#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 = "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(',')
|
headers = headers.split(',')
|
||||||
|
|
||||||
for i in range(len(headers)):
|
for i in range(len(headers)):
|
||||||
|
|
Loading…
Reference in a new issue