def endDocument(self): errors = 0 for x in houses: xy = [float(v) for v in (x.attrs["lon"], x.attrs["lat"])] n = quad.get_children_under_point(xy[0], xy[1]) if (n): if len(n) > 1: # now look at the polygon n2 = [] for b in n : way = b.data if b.data.point_in(xy): n2.append(way) if len(n2) > 1: house = " ".join(x.tags[k] for k in ( "addr:street", "addr:housenumber", )) #raise Exception("Overlapping Buildings:" + house + "\n"+ str(n) ) print ("Overlapping Buildings:" + house + "\n"+ str(n2) ) errors = errors + 1 n = n[0] # extract the way id and make sure we dont assign it twice wayid = n.data.attrs['id'] if wayid not in used : used[wayid]=1 else: vals = [] for k in ( "addr:street", "addr:housenumber", ): vals.append(x.tags[k]) print ("each way can only be used once: " + " ".join(vals) + "\n"+ str(n.data.__dict__)) errors = errors + 1 # copy the tags from the node to the way for k in x.tags: n.data.tags[k] = x.tags[k] # modify the way ele = self.doc.createElement('modify') ele.appendChild(way2xml(n.data)) self.base.appendChild(ele) # call delete on node because it has been merged ele2 = self.doc.createElement('delete') ele2.appendChild(node2xml(x)) self.base.appendChild(ele2) else: #print ("Missing:" +str(x.__dict__)) pass OSMHandler.endDocument(self)
def modifyElement(self): """Modify this element""" ele = self.doc.createElement('modify') if self.name == 'node': ele.appendChild(node2xml(self)) elif self.name == 'way': ele.appendChild(way2xml(self)) elif self.name == 'relation': ele.appendChild(relation2xml(self)) self.base.appendChild(ele)
def preDeleteElement(self): """Returns the string to delete the element. Please use with caution!""" ele = self.doc.createElement('delete') if self.name == 'node': ele.appendChild(node2xml(self)) elif self.name == 'way': ele.appendChild(way2xml(self)) elif self.name == 'relation': ele.appendChild(relation2xml(self)) return ele
def endDocument(self): errors = 0 for x in houses: xy = [float(v) for v in (x.attrs["lon"], x.attrs["lat"])] n = quad.get_children_under_point(xy[0], xy[1]) if (n): if len(n) > 1: # now look at the polygon n2 = [] for b in n: way = b.data if b.data.point_in(xy): n2.append(way) if len(n2) > 1: house = " ".join(x.tags[k] for k in ( "addr:street", "addr:housenumber", )) #raise Exception("Overlapping Buildings:" + house + "\n"+ str(n) ) print("Overlapping Buildings:" + house + "\n" + str(n2)) errors = errors + 1 n = n[0] # extract the way id and make sure we dont assign it twice wayid = n.data.attrs['id'] if wayid not in used: used[wayid] = 1 else: vals = [] for k in ( "addr:street", "addr:housenumber", ): vals.append(x.tags[k]) print("each way can only be used once: " + " ".join(vals) + "\n" + str(n.data.__dict__)) errors = errors + 1 # copy the tags from the node to the way for k in x.tags: n.data.tags[k] = x.tags[k] # modify the way ele = self.doc.createElement('modify') ele.appendChild(way2xml(n.data)) self.base.appendChild(ele) # call delete on node because it has been merged ele2 = self.doc.createElement('delete') ele2.appendChild(node2xml(x)) self.base.appendChild(ele2) else: #print ("Missing:" +str(x.__dict__)) pass OSMHandler.endDocument(self)