diff options
| author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-07-03 22:01:23 +1000 | 
|---|---|---|
| committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-07-03 22:01:23 +1000 | 
| commit | e85f724b0f4dbe9a6ff4703728c9688238955f99 (patch) | |
| tree | 827cdda87d93fbfe8e35d001cb8288b13a3b4504 /bin | |
| parent | 1e29411278a20be03096085b4f58908aef9e50f0 (diff) | |
more street types in abbr check
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/findAbbrStreets.js | 17 | 
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/findAbbrStreets.js b/bin/findAbbrStreets.js index 67e5813..095fa80 100755 --- a/bin/findAbbrStreets.js +++ b/bin/findAbbrStreets.js @@ -26,9 +26,14 @@ const streetTypes = {    'ave': 'Avenue',    'av': 'Avenue',    'ln': 'Lane', -  'cl': 'Close',    'hwy': 'Highway', -  'pl': 'Place' +  'pl': 'Place', +  'fwy': 'Freeway', +  'pde': 'Parade', +  'dr': 'Drive', +  'cr': 'Crescent', +  'cl': 'Close', +  'ct': 'Court'  }  if (!fs.existsSync(inputFile)) { @@ -37,6 +42,7 @@ if (!fs.existsSync(inputFile)) {  }  let index = 0 +let tasks = 0  const checkStreet = new Transform({    readableObjectMode: true,    writableObjectMode: true, @@ -51,11 +57,11 @@ const checkStreet = new Transform({        const street = feature.properties['addr:street'].toLowerCase()        const streetEndsWithAbbr = abbreviatedTypes.map(ab => street.endsWith(` ${ab}`)).reduce((acc, cur) => acc || cur)        if (streetEndsWithAbbr) { -        const matches = street.match(/ (rd|st|ave|av|ln|cl|hwy|pl)$/) +        const matches = street.match(/ (rd|st|ave|av|ln|cl|hwy|pl|fwy|pde|dr|cr|cl|ct)$/)          if (matches.length) {            const ab = matches[1]            const expandedStreetType = streetTypes[ab] -          const fullStreetName = feature.properties['addr:street'].replace(/ (rd|st|ave|av|ln|cl|hwy|pl)$/i, ` ${expandedStreetType}`) +          const fullStreetName = feature.properties['addr:street'].replace(/ (rd|st|ave|av|ln|cl|hwy|pl|fwy|pde|dr|cr|cl|ct)$/i, ` ${expandedStreetType}`)            // MapRoulette task            const task = { @@ -80,9 +86,9 @@ const checkStreet = new Transform({                }]              }            } +          tasks++            this.push(task)          } -        // this.push(feature)        }      } @@ -101,6 +107,7 @@ pipeline(        console.log(err)        process.exit(1)      } else { +      console.log(`${tasks} tasks`)        process.exit(0)      }    }  | 
