diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-07 22:36:33 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-07 22:36:33 +1000 |
commit | fad3f801a3dc1185779b8c7b8b9442811aaa1982 (patch) | |
tree | 230a764977c3a95d2815abd4cf2c3bc299f18251 /lib | |
parent | bb58cd0921d16268a6a1ff3f9d61a141184dded8 (diff) |
because OSM tag values are limited to 255 characters, implement code to split addr:flats across addr:flatsN
Diffstat (limited to 'lib')
-rw-r--r-- | lib/valueLimits.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/valueLimits.js b/lib/valueLimits.js new file mode 100644 index 0000000..c902883 --- /dev/null +++ b/lib/valueLimits.js @@ -0,0 +1,17 @@ +/** + * In OSM tag values are limited to 255 characters. + * Search for addr:flats beyond that limit and wrap into addr:flats2 addr:flats3 etc. + * + * @param {Object} feature + * @returns {boolean} + */ +module.exports = (feature) => { + if ('addr:flats' in feature.properties && feature.properties['addr:flats'].length > 255) { + // need to wrap + const value = feature.properties['addr:flats'] + for (let i = 0; i < value.length; i += 255) { + feature.properties[`addr:flats${i === 0 ? '' : i / 255 + 1}`] = value.slice(i, i + 255) + } + } + return feature +} |