Skip to content

Instantly share code, notes, and snippets.

@buganini
Last active August 29, 2015 14:07
Show Gist options
  • Save buganini/9b9628e3a8858ea47174 to your computer and use it in GitHub Desktop.
Save buganini/9b9628e3a8858ea47174 to your computer and use it in GitHub Desktop.
Find node/way with addr:housenumber which contains full width number
#python fullwidth-addr-housenumber.py taiwan-latest.osm.pbf
import sys
from imposm.parser import OSMParser
def hasFW(s):
import re
return re.match(ur'[\uFF10-\uFF19]', s)
class Handler():
def __init__(self):
self.ways=[]
self.nodes=[]
def waysHandler(self, ways):
for way in ways:
osmid, tags, refs = way
needUpdate=False
if hasFW(tags.get(u"addr:housenumber", u"")):
needUpdate=True
if needUpdate:
self.ways.append(way)
def nodesHandler(self, nodes):
for node in nodes:
osmid, tags, ll = node
needUpdate=False
if hasFW(tags.get(u"addr:housenumber", u"")):
needUpdate=True
if needUpdate:
self.nodes.append(node)
def getWays(self):
return self.ways
def getNodes(self):
return self.nodes
if len(sys.argv)<2:
sys.exit()
handler=Handler()
p = OSMParser(ways_callback=handler.waysHandler, nodes_callback=handler.nodesHandler)
p.parse(sys.argv[1])
for u in ["http://www.openstreetmap.org/edit?way="+str(x[0])+" "+x[1].get(u"addr:housenumber", u"") for x in handler.getWays()]:
print u
for u in ["http://www.openstreetmap.org/edit?node="+str(x[0])+" "+x[1].get(u"addr:housenumber", u"") for x in handler.getNodes()]:
print u
@buganini
Copy link
Author

buganini commented Oct 3, 2014

hasFW改用
return re.match(ur'[^0-9A-Za-z]', s)
可以找到更多可能有問題的資料,像是addr:housenumber裡面寫著「號」的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment