diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-18 16:07:52 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-18 16:07:52 +1000 |
commit | c0d189a1c8c0f3417d0f4853dc2c6a1447e6ee74 (patch) | |
tree | f6043782a8f2d7f7e1473f7730f7f21c4c9c476f /bin | |
parent | eb57ce6fdec3a959288b2a30c499dcea7e81a444 (diff) |
detect when start/end regexp doesn't match
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/reduceRangeDuplicates.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/bin/reduceRangeDuplicates.js b/bin/reduceRangeDuplicates.js index 1aa232c..b5b85ac 100755 --- a/bin/reduceRangeDuplicates.js +++ b/bin/reduceRangeDuplicates.js @@ -144,15 +144,19 @@ const reduceRange = new Transform({ foundStart = true const match = start.match(regexp) - startNum = match.groups.num - pre = match.groups.pre - suf = match.groups.suf + if (match && match.groups) { + startNum = match.groups.num + pre = match.groups.pre + suf = match.groups.suf + } } if (!foundEnd && end === matchCandidate.properties['addr:housenumber']) { foundEnd = true const match = end.match(regexp) - endNum = match.groups.num + if (match && match.groups) { + endNum = match.groups.num + } } if (foundStart && foundEnd) { @@ -161,7 +165,12 @@ const reduceRange = new Transform({ } } - if (foundStart && foundEnd) { + if (foundStart && foundEnd && (!startNum || !endNum)) { + // found start and end, but couldn't parse out prefix number suffix + console.log(`Filter A: Found start + end, but couldn't parse out prefix number suffix: ${start} - ${end}`) + } + + if (foundStart && foundEnd && startNum && endNum) { // found both start and end // see if any intermediates are missing |