from objects.baseObjects import Node, NodeTag, Way, WayTag, Place
from objects.metaObjects import Address, Contact
class OSM:
# TODO Average value of "last updated" to see how up to date the data is.
def __init__(self, _osmContent):
self.osmContent = str(_osmContent)
self.nodeList = []
self.nodeTagList = []
self.wayList = []
self.wayTagList = []
self.placeList = []
self.parseOsmContent()
def parseOsmContent(self):
lines = self.osmContent.split("\n")
nodeLines = []
wayLines = []
for line in lines:
if "" in line:
try:
self.createNode([line])
except:
print("Node could not be inserted")
else:
nodeLines.append(line)
elif "" in line:
try:
self.createNode(nodeLines)
except:
print("Node could not be inserted")
nodeLines = []
elif len(nodeLines) > 0:
nodeLines.append(line)
elif "" in line:
try:
self.createWay(wayLines)
except:
print("Way could not be inserted")
wayLines = []
elif len(wayLines) > 0:
wayLines.append(line)
def createContact(self, lines):
c = Contact()
for line in lines:
if '