Skip to content

Commit

Permalink
respect addresses that were manually merged using alt_addr:housenumber
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yle committed Sep 19, 2024
1 parent 1f9a17e commit 88380bd
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/__tests__/mock/linz-dump.csv
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,10 @@
,70200,,Road,,199,B,,,,Oakleigh,,199B,Example Street,,,,,,,,,,,174.200,-36.9
,70201,,Road,,201,A,,,,Oakleigh,,201A,Example Street,,,,,,,,,,,174.201,-36.9
,70202,,Road,,201,B,,,,Oakleigh,,201B,Example Street,,,,,,,,,,,174.202,-36.9
,70203,,Road,,203,A,,,,Oakleigh,,203A,Example Street,,,,,,,,,,,174.203,-36.9
,3000204,,Road,1,203,,,,,Oakleigh,,1/203,Example Street,,,,,,,,,,,174.204,-36.9
,70205,,Road,,203,B,,,,Oakleigh,,203B,Example Street,,,,,,,,,,,174.205,-36.9
,3000206,,Road,2,203,,,,,Oakleigh,,2/203,Example Street,,,,,,,,,,,174.206,-36.9
,70207,,Road,,203,C,,,,Oakleigh,,203C,Example Street,,,,,,,,,,,174.207,-36.9
,3000208,,Road,3,203,,,,,Oakleigh,,3/203,Example Street,,,,,,,,,,,174.208,-36.9
,70209,,Road,,203,D,,,,Oakleigh,,203D,Example Street,,,,,,,,,,,174.209,-36.9
28 changes: 28 additions & 0 deletions src/__tests__/mock/planet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,34 @@
<tag k="linz:stack" v="yes" />
</node>

<!-- someone has manually added alt_addr:housenumber, which we respect -->
<node id="203" version="1" changeset="1" lat="-36.9" lon="174.203" user="" uid="0" visible="true" timestamp="2012-05-19T11:22:33Z">
<tag k="addr:housenumber" v="203A" />
<tag k="alt_addr:housenumber" v="1/203" />
<tag k="addr:street" v="Example Street" />
<tag k="addr:hamlet" v="Oakleigh" />
<tag k="ref:linz:address_id" v="70203" />
</node>
<node id="205" version="1" changeset="1" lat="-36.9" lon="174.205" user="" uid="0" visible="true" timestamp="2012-05-19T11:22:33Z">
<tag k="addr:housenumber" v="203B" />
<tag k="alt_addr:housenumber" v="2/203" />
<tag k="addr:street" v="Example Street" />
<tag k="addr:hamlet" v="Oakleigh" />
<tag k="ref:linz:address_id" v="70205" />
</node>
<node id="207" version="1" changeset="1" lat="-36.9" lon="174.207" user="" uid="0" visible="true" timestamp="2012-05-19T11:22:33Z">
<tag k="addr:housenumber" v="203C" />
<tag k="addr:street" v="Example Street" />
<tag k="addr:hamlet" v="Oakleigh" />
<tag k="ref:linz:address_id" v="70207" />
</node>
<node id="209" version="1" changeset="1" lat="-36.9" lon="174.209" user="" uid="0" visible="true" timestamp="2012-05-19T11:22:33Z">
<tag k="addr:housenumber" v="203D" />
<tag k="addr:street" v="Example Street" />
<tag k="addr:hamlet" v="Oakleigh" />
<tag k="ref:linz:address_id" v="70209" />
</node>

<!-- <ways> -->
<way id="31" version="1" changeset="1" user="" uid="0" visible="true" timestamp="2012-05-19T11:22:33Z">
<nd ref="28" />
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/snapshot/data-wrong.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Oakleigh
70188 https://osm.org/node/188 housenumberAlt|188A|
70189 https://osm.org/node/189 housenumberAlt|188B|
70197 https://osm.org/node/197 suburb|addr:suburb=Oakleigh|addr:suburb=Oakleigh!*@typo
70207 https://osm.org/node/207 housenumberAlt|3/203|
stack(70079-70081) https://osm.org/node/79 suburb|addr:hamlet=Oakleigh|addr:hamlet=The City of Ember
stack(70082-70084) https://osm.org/node/82 housenumber|82|82typo
stack(70111-70113) https://osm.org/node/111 flatCount|3|0
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/snapshot/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@
"url": "https://linz-addr-cdn.kyle.kiwi/suburbs/AddressUpdateOakleigh_4b67jq.osmPatch.geo.json",
"name": "Address Update - Oakleigh",
"title": "Address Update - Oakleigh",
"totalCount": 71,
"totalCount": 72,
"source": "",
"snippet": "add 24, delete 13, edit 34",
"snippet": "add 24, delete 13, edit 35",
"extent": [
[
174.144,
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/snapshot/stats.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"date": "MOCK",
"count": {
"PERFECT": 21,
"EXISTS_BUT_WRONG_DATA": 34,
"PERFECT": 24,
"EXISTS_BUT_WRONG_DATA": 35,
"EXISTS_BUT_NO_LINZ_REF": 5,
"MULTIPLE_EXIST_BUT_NO_LINZ_REF": 1,
"MULTIPLE_EXIST": 4,
Expand All @@ -16,5 +16,5 @@
"NEEDS_DELETE_ON_BUILDING": 1,
"REPLACED_BY_BUILDING": 1
},
"total": 134
"total": 138
}
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,41 @@
"addr:suburb": "Oakleigh"
}
},
{
"type": "Feature",
"id": "n207",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
174.20700000000002,
-36.899800000000006
],
[
174.20720000000003,
-36.900000000000006
],
[
174.20700000000002,
-36.900200000000005
],
[
174.20680000000002,
-36.900000000000006
],
[
174.20700000000002,
-36.899800000000006
]
]
]
},
"properties": {
"__action": "edit",
"alt_addr:housenumber": "3/203"
}
},
{
"type": "Feature",
"id": "n79",
Expand Down
8 changes: 7 additions & 1 deletion src/preprocess/matchAlternativeAddrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ export function matchAlternativeAddrs(
return addrIdsToSkip.has(addrId) || duplicateMap[addrId] || isRoot;
});

if (seenEverything) {
// if someone has manually added alt_addr:housenumber, then
// we respect that.
const someAlreadyHaveAltTag = addrIds.some(
([addrId]) => osmData.linz[addrId]?.housenumberAlt,
);

if (seenEverything || someAlreadyHaveAltTag) {
return { duplicateMap, addrIdsToSkip };
}
return undefined;
Expand Down

0 comments on commit 88380bd

Please sign in to comment.