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: [-hl -o DIRECTORY --min-nodes=COUNT --max-nodes=COUNT] [-d
-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", "")
add_tag(changeset, "attribution", "")
add_tag(changeset, "source", "")
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('source:revision=%s' % source_rev)
tags.append('comment=LINZ address import %s' % fn)
path = outdir + "/%s.changeset_tags" % fn
with open(path, 'w') as f:
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))
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",
......@@ -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