Commit 8b4f9fc9 authored by Eliot Blennerhassett's avatar Eliot Blennerhassett

Generate changeset tags file for JOSM

JOSM allows bulk paste of multiple key=value tags for changeset.
parent 7b9af64d
......@@ -7,7 +7,7 @@ Usage: my_program.py [-hl -o DIRECTORY --min-nodes=COUNT --max-nodes=COUNT] [-d
Options:
-d DATABASE --database DATABASE spatialite database containing linz_addr table [default: osmlinzaddr.sqlite]
-h --help show this
-o DIRECTORY --output=DIRECTORY Specify output directory. [default: places]
-o DIRECTORY --output=DIRECTORY Specify output directory. [default: linz_places]
--min-nodes=COUNT Minimum number of nodes per output file. [default: 1]
--max-nodes=COUNT Maximum number of nodes per output file. [default: 8000]
-l --include-location Include suburb and city tags in output.
......@@ -51,16 +51,17 @@ def generate_osmchange(dbfile, outdir,
changeset, include_location)
def generate_changeset_place(place, fn, outdir='.'):
osm = ET.Element('osm')
changeset = ET.SubElement(osm, 'changeset')
add_tag(changeset, "created_by", "https://git.nzoss.org.nz/ewblen/osmlinzaddr/blob/master/osmlinzaddr.py")
add_tag(changeset, "attribution", "https://wiki.openstreetmap.org/wiki/Contributors#LINZ")
add_tag(changeset, "source", "https://data.linz.govt.nz/layer/3353-nz-street-address")
add_tag(changeset, "comment", "LINZ address import %s" % fn)
tree = ET.ElementTree(osm)
path = outdir + "/linz_addr_%s.osm" % fn
tree.write(path, pretty_print=True)
def generate_josm_tags_place(place, fn, outdir='.', source_rev='53'):
tags = []
tags.append('created_by=https://git.nzoss.org.nz/ewblen/osmlinzaddr/blob/master/osmlinzaddr.py')
tags.append('attribution=https://wiki.openstreetmap.org/wiki/Contributors#LINZ')
tags.append('source=https://data.linz.govt.nz/layer/3353-nz-street-address')
tags.append('source:revision=%s' % source_rev)
tags.append('comment=LINZ address import %s' % fn)
tags.append('')
path = outdir + "/%s.changeset_tags" % fn
with open(path, 'w') as f:
f.write('\n'.join(tags))
def generate_osmchange_place(place, dbcursor, outdir,
......@@ -96,9 +97,11 @@ def generate_osmchange_place(place, dbcursor, outdir,
print("No addresses in %s!?" % str(place))
return
path = outdir + "/%s.osc" % fn
print("%s : %d nodes" % (fn, len(lrows)))
generate_changeset_place(place, fn, outdir)
# generate_changeset_place(place, fn, outdir)
generate_josm_tags_place(place, fn, outdir)
osmchange = ET.Element('osmChange', version="0.6",
generator="osmlinzaddr.py")
......@@ -116,7 +119,7 @@ def generate_osmchange_place(place, dbcursor, outdir,
}
node = ET.SubElement(create, "node", dnode)
add_tag(node, "LINZ:address_id", str(linz_id))
add_tag(node, "ref:linz:address_id", str(linz_id))
if unit is not None:
add_tag(node, "addr:unit", unit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment