I adapted the Python code a bit, so several .osm files are created, one for
each country:

A source tag is also added. I also added some invalid data, so it shouldn't
be possible to upload these files to the server directly. As they are now,
it is possible to cherry pick addresses on one OSM layer and copy/paste them
to another (new) layer.

The 2 adresses I already processed where both companies, so it's probably
worth it to look them up on the internet to find out what is located at
these adresses.

Enjoy!

Jo

PS: it's trivial to adapt this code so it creates a separate file per
state/city for use in the US.

#!/usr/bin/python

from xml.sax.saxutils import escape
import sys

countriesFH={}

def writeNode(node,countryISOcode):
   if not(countryISOcode in countriesFH):
       countriesFH[countryISOcode] = open('mapquest ' + countryISOcode +
'.osm', 'w')
       countriesFH[countryISOcode].write("<osm version=\"0.6\"
generator=\"anothercaf2osm v0.1\">\n")
       # Adding a node with coordinates outside the world, so osm.-file
cannot be uploaded directly without processing
       # The API will reject it
       countriesFH[countryISOcode].write('<node id="-999996" lat="90.1"
lon="0.1">\n  <tag k="name" v="Do not upload this layer directly"/>\n
</node>\n')
       # And a second one at the same position so a validation error is
presented to the user before attempting the upload
       countriesFH[countryISOcode].write('<node id="-999997" lat="90.1"
lon="0.1"/>\n')
       countriesFH[countryISOcode].write('<node id="-999998" lat="90.1"
lon="0.2">\n  <tag k="name" v="Instead copy/paste the nodes one by one to a
new layer"/>\n </node>\n')
       countriesFH[countryISOcode].write('<node id="-999999" lat="90.1"
lon="0.2"/>\n')
   countriesFH[countryISOcode].write('<node id="%d" lat="%f" lon="%f">\n' %
(node['id'], node['lat'], node['lon']))
   for (key, value) in node['tags'].items():
       countriesFH[countryISOcode].write(' <tag k="%s" v="%s" />\n' % (key,
value))
   countriesFH[countryISOcode].write('</node>\n')

id = -1
with open(sys.argv[1], 'r') as input_file:
   for a_line in input_file:
       line=a_line.split(',')
       #print(id, line)
       if id == -1:
           id = id - 1
           continue
       tags = {}
       if line[1]: tags['addr:country'] = escape(line[1])
       if line[2]: tags['addr:state'] = escape(line[2])
       if line[4]: tags['addr:postcode'] = escape(line[4])
       if line[3]: tags['addr:city'] = escape(line[3])
       if line[0]: tags['addr:street'] = escape(line[0])
       if line[5]: tags['addr:housenumber'] = escape(line[5])
       tags['source'] = 'mapquest_critical_addresses'
       lat = float(line[7]) / 1000000
       lon = float(line[8]) / 1000000

       node = {'tags': tags,
               'lat': lat,
               'lon': lon,
               'id': id}
       writeNode(node,line[1])

       id = id - 1
       #raw_input()

for country in countriesFH:
   countriesFH[country].write('</osm>\n')
   countriesFH[country].close()

2011/3/3 Pieren <pier...@gmail.com>:
> On Thu, Mar 3, 2011 at 1:13 AM, Anthony <o...@inbox.org> wrote:
>>
>> The Europe file has 707 addresses.
>>
>
> And after a quick check on the FR addresses, I've seen that about 10% of
the
> post codes are wrong.
>
> Pieren
>
> _______________________________________________
> talk mailing list
> talk@openstreetmap.org
> http://lists.openstreetmap.org/listinfo/talk
>
>
_______________________________________________
talk mailing list
talk@openstreetmap.org
http://lists.openstreetmap.org/listinfo/talk

Reply via email to