From fad3f801a3dc1185779b8c7b8b9442811aaa1982 Mon Sep 17 00:00:00 2001 From: Andrew Harvey Date: Fri, 7 May 2021 22:36:33 +1000 Subject: because OSM tag values are limited to 255 characters, implement code to split addr:flats across addr:flatsN --- lib/valueLimits.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/valueLimits.js (limited to 'lib/valueLimits.js') 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 +} -- cgit v1.2.3