Commit bed7e2bc authored by Eliot Blennerhassett's avatar Eliot Blennerhassett

More granular address number components in database

Allow separation of unit numbers into addr:unit
Always include city & suburb in output
parent d98e5f8d
......@@ -153,6 +153,29 @@ SELECT * from temp.linz_inexact;
-- The LINZ addresses identified as not already in OSM
drop table if exists linz_not_osm;
create table linz_not_osm as
select
linz_addr.linz_id,
linz_addr.full_address_number as housenumber,
linz_addr.full_road_name as street,
X(linz_addr.geom) as x,
Y(linz_addr.geom) as y,
linz_addr.unit_value as unit,
linz_addr.address_number as number,
linz_addr.address_number_suffix as suffix,
linz_addr.address_number_high as high,
linz_addr.suburb_locality as suburb,
linz_addr.town_city as city
from linz_addr
left outer join osm_linz
on (osm_linz.linz_id = linz_addr.linz_id)
where
osm_linz.linz_id is NULL
and linz_addr.addr_type != "Water"
order by linz_addr.town_city, linz_addr.suburb_locality
-- and h is not NULL
create table linz_not_osm as
select
linz_addr.linz_id,
......@@ -160,13 +183,17 @@ select
linz_addr.full_road_name as street,
X(linz_addr.geom) as x,
Y(linz_addr.geom) as y,
linz_addr.suburb_locality as s,
linz_addr.town_city as c
linz_addr.unit_value as unit,
linz_addr.address_number as number,
linz_addr.address_number_suffix as suffix,
linz_addr.address_number_high as high,
linz_addr.suburb_locality as suburb,
linz_addr.town_city as city
from linz_addr
left outer join osm_linz
on (osm_linz.linz_id = linz_addr.linz_id)
where
osm_linz.linz_id is NULL
and linz_addr.addr_type != "Water"
order by linz_addr.town_city, linz_addr.suburb_locality
order by linz_addr.town_city, linz_addr.suburb_locality
;
......@@ -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: bysuburb]
-o DIRECTORY --output=DIRECTORY Specify output directory. [default: 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.
......@@ -65,11 +65,11 @@ def generate_osmchange_place(place, dbcursor, outdir,
if place[0] is None:
q = '''select * from linz_not_osm
where c is NULL and s="{1}"
where city is NULL and suburb="{1}"
'''.format(*(place))
else:
q = '''select * from linz_not_osm
where c="{0}" and s="{1}"
where city="{0}" and suburb="{1}"
'''.format(*(place))
rows = dbcursor.execute(q)
......@@ -97,7 +97,8 @@ def generate_osmchange_place(place, dbcursor, outdir,
generator="osmlinzaddr.py")
for r in lrows:
linz_id, housenumber, street, x, y, suburb, city = r
(linz_id, housenumber, street, x, y,
unit, number, suffix, high, suburb, city) = r
create = ET.SubElement(osmchange, "create")
dnode = {
......@@ -109,15 +110,20 @@ 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, "addr:housenumber", housenumber)
add_tag(node, "addr:street", street)
if unit is not None:
add_tag(node, "addr:unit", unit)
number = str(number)
if suffix:
number += suffix
if include_location:
if city is not None:
add_tag(node, "addr:city", city)
add_tag(node, "addr:suburb", suburb)
else:
add_tag(node, "addr:hamlet", suburb)
add_tag(node, "addr:housenumber", number)
add_tag(node, "addr:street", street)
if city is not None:
add_tag(node, "addr:city", city)
add_tag(node, "addr:suburb", suburb)
else:
add_tag(node, "addr:hamlet", suburb)
tree = ET.ElementTree(osmchange)
tree.write(path, pretty_print=True)
......
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