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
|
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'
]
/**
* 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
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
].join(' '))
}
// every record has LOCALITY populated, however some values should be empty
if (sourceProperties.LOCALITY && !emptyNames.includes(sourceProperties.LOCALITY)) {
outputProperties['addr:suburb'] = capitalCase(sourceProperties.LOCALITY)
}
// 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
}
|