1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
const { capitalCase } = require('capital-case')
const buildingUnitType = {
ANT: 'ANTENNA',
APT: 'APARTMENT',
ATM: 'ATM',
BBOX: 'BATHING BOX',
BERT: 'BERTH',
BLDG: 'BUILDING',
BTSD: 'BOATSHED',
CARP: 'CARPARK',
CARS: 'CARSPACE',
CARW: 'CARWASH',
CHAL: 'CHALET',
CLUB: 'CLUB',
CTGE: 'COTTAGE',
CTYD: 'COURTYARD',
DUPL: 'DUPLEX',
FCTY: 'FACTORY',
FLAT: 'FLAT',
GATE: 'GARAGE',
GRGE: 'GATE',
HALL: 'HALL',
HELI: 'HELIPORT',
HNGR: 'HANGAR',
HOST: 'HOSTEL',
HSE: 'HOUSE',
KSK: 'KIOSK',
LOT: 'LOT',
MBTH: 'MAISONETTE',
OFFC: 'OFFICE',
PSWY: 'PASSAGEWAY',
PTHS: 'PENTHOUSE',
REST: 'RESTAURANT',
RESV: 'RESERVE',
ROOM: 'ROOM',
RPTN: 'RECPETION',
SAPT: 'STUDIO APARTMENT',
SE: 'SUITE',
SHCS: 'SHOWCASE',
SHED: 'SHED',
SHOP: 'SHOP',
SHRM: 'SHOWROOM',
SIGN: 'SIGN',
SITE: 'SITE',
STLL: 'STALL',
STOR: 'STORE',
STR: 'STRATA UNIT',
STU: 'STUDIO',
SUBS: 'SUBSTATION',
TNCY: 'TENANCY',
TNHS: 'TOWNHOUSE',
TWR: 'TOWER',
UNIT: 'UNIT',
VLLA: 'VILLA',
VLT: 'VAULT',
WHSE: 'WAREHOUSE',
WKSH: 'WORKSHOP'
}
// likely these are not proper names, so we will ignore them
const emptyNames = [
'UNNAMED',
'NOT NAMED'
]
// Table 13 in Vicmap Address Product Spec
const roadSuffixMap = {
N: 'North',
S: 'South',
E: 'East',
W: 'West',
LR: 'Lower',
UP: 'Upper',
NE: 'North East',
NW: 'North West',
SE: 'South East',
SW: 'South West',
CN: 'Central',
EX: 'Extension',
ML: 'Mall',
OT: 'Outer',
IN: 'Inner',
OF: 'Off',
ON: 'On',
DV: 'Deviation',
BR: 'Branch'
}
const suburbMap = {
// likely due to our capital case code
'Mccrae': 'McCrae',
'Mckinnon': 'McKinnon',
'Mcmillans': 'McMillans',
'Bend Of Islands': 'Bend of Islands',
'Bridgewater On Loddon': 'Bridgewater on Loddon',
'Hmas Cerberus': 'HMAS Cerberus',
'Mckenzie Creek': 'McKenzie Creek',
'Mcmahons Creek': 'McMahons Creek',
'Murray Sunset': 'Murray-Sunset',
'Yalla Y Poora': 'Yalla-y-poora',
// because these locality names are used more than once, the vicmap data has added a suffix for clarity
'Bellfield Greater Melbourne': 'Bellfield',
'Hillside Greater Melbourne': 'Hillside',
'Hillside Bairnsdale': 'Hillside',
'Springfield Romsey': 'Springfield',
'Springfield Sea Lake': 'Springfield',
'Moonlight Flat Castlemaine': 'Moonlight Flat',
'Moonlight Flat Maryborough': 'Moonlight Flat',
'Golden Point Castlemaine': 'Golden Point',
'Golden Point Ballarat': 'Golden Point',
'Golden Point Maryborough': 'Maryborough',
'Ascot Ballarat': 'Ascot',
'Ascot Bendigo': 'Ascot',
'Big Hill Bendigo': 'Big Hill',
'Big Hill Lorne': 'Big Hill',
'Black Range Stawell': 'Black Range',
'Fairy Dell Bairnsdale': 'Fairy Dell',
'Fairy Dell Rochester': 'Fairy Dell',
'Happy Valley Ballarat': 'Happy Valley',
'Happy Valley Robinvale': 'Happy Valley',
'Killara Casterton': 'Killara',
'Killara Wodonga': 'Killara',
'Merrijig Bairnsdale': 'Merrijig',
'Merrijig Mount Buller': 'Merrijig',
'Myall Kerang': 'Myall',
'Myall Sea Lake': 'Myall',
'Newtown Ballarat': 'Newtown',
'Newtown Geelong': 'Newtown',
'Stony Creek Foster': 'Stony Creek',
'Stony Creek Talbot': 'Stony Creek',
'Thomson Geelong': 'Thomson'
}
/**
* Transforms a GeoJSON Feature from the Vicmap address schema into OSM schema
*
* @param {Array} sourceFeature Feature in Vicmap address schema
* @returns {Object} Feature in OSM schema
*/
module.exports = (sourceFeature, options) => {
const outputFeature = Object.assign({}, sourceFeature)
const sourceProperties = sourceFeature.properties
const outputProperties = {}
if (options && options.tracing) {
outputProperties['_pfi'] = sourceProperties.PFI
}
// Building unit
// bld_unit_*
const bld_unit_1 = [
sourceProperties.BUNIT_PRE1,
sourceProperties.BUNIT_ID1 || null, // 0 is used for an empty value in the source data, so convert 0 to null
sourceProperties.BUNIT_SUF1
].join('') || null
const bld_unit_2 = [
sourceProperties.BUNIT_PRE2,
sourceProperties.BUNIT_ID2 || null, // 0 is used for an empty value in the source data, so convert 0 to null
sourceProperties.BUNIT_SUF2
].join('') || null
// if both 1 and 2 defined, then use a range 1-2 otherwise just select the one which was defined
let bld_unit = null
if (sourceProperties.HSA_FLAG === 'Y') {
bld_unit = sourceProperties.HSAUNITID
} else {
if (bld_unit_1 && bld_unit_2) {
bld_unit = `${bld_unit_1}-${bld_unit_2}`
} else if (bld_unit_1) {
bld_unit = bld_unit_1
} else if (bld_unit_2) {
bld_unit = bld_unit_2
}
}
if (bld_unit) {
// building unit type (Unit, Shop, Suite...)
// only included if a unit value is set
/* currently ommitted
if (sourceProperties.BLGUNTTYP) {
if (sourceProperties.BLGUNTTYP in buildingUnitType) {
outputProperties['addr:unit:prefix'] = capitalCase(buildingUnitType[sourceProperties.BLGUNTTYP])
} else {
if (options && options.debug) {
console.log(`Building Unity Type ${sourceProperties.BLGUNTTYP} not recognised for ${sourceFeature}`)
}
}
}
*/
outputProperties['addr:unit'] = bld_unit
}
// house number
// house_*
const house_1 = [
sourceProperties.HSE_PREF1,
sourceProperties.HSE_NUM1 || null, // 0 is used for an empty value in the source data, so convert 0 to null
sourceProperties.HSE_SUF1
].join('')
const house_2 = [
sourceProperties.HSE_PREF2,
sourceProperties.HSE_NUM2 || null, // 0 is used for an empty value in the source data, so convert 0 to null
sourceProperties.HSE_SUF2
].join('')
let housenumber = null
if (house_1 && house_2) {
housenumber = `${house_1}-${house_2}`
} else if (house_1) {
housenumber = house_1
} else if (house_2) {
housenumber = house_2
}
if (housenumber) {
outputProperties['addr:housenumber'] = housenumber
}
// display numbers used predominately in the City of Melbourne CBD by large properties.
// Primarily to simplify an assigned number range.
// so should map the assigned address or the signposted address?
// every record has at least ROAD_NAME populated
if (sourceProperties.ROAD_NAME && !emptyNames.includes(sourceProperties.ROAD_NAME)) {
outputProperties['addr:street'] = capitalCase([
sourceProperties.ROAD_NAME,
sourceProperties.ROAD_TYPE,
sourceProperties.RD_SUF in roadSuffixMap ? roadSuffixMap[sourceProperties.RD_SUF] : sourceProperties.RD_SUF
].join(' '))
}
// every record has LOCALITY populated, however some values should be empty
if (sourceProperties.LOCALITY && !emptyNames.includes(sourceProperties.LOCALITY)) {
const suburb = capitalCase(sourceProperties.LOCALITY)
// some special cases are defined in suburbMap
outputProperties['addr:suburb'] = suburb in suburbMap ? suburbMap[suburb] : suburb
}
// every record has STATE populated
if (sourceProperties.STATE) {
outputProperties['addr:state'] = sourceProperties.STATE
}
// some records have no POSTCODE populated
if (sourceProperties.POSTCODE) {
outputProperties['addr:postcode'] = sourceProperties.POSTCODE
}
outputFeature.properties = outputProperties
return outputFeature
}
|