From 7aa6e0be84deeeba1b5529debee8067ae2099863 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sat, 21 Nov 2020 13:48:22 +0100 Subject: [PATCH] feat: in OBSVER1, sanitize d1, d2, latitude and longitude values to null where appropriate --- logic/tracks.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/logic/tracks.js b/logic/tracks.js index d77cf1e..27adb65 100644 --- a/logic/tracks.js +++ b/logic/tracks.js @@ -153,6 +153,21 @@ function* parseObsver1(body) { continue; } + if (!record.latitude && !record.longitude) { + // invalid record, make sure lat/lng say `null` instead of `0` + record.latitude = null + record.longitude = null + } + + // in old format, 255 or 999 means "no measurement" + if (record.d1 === 255 || record.d1 === 999) { + record.d1 = null + } + + if (record.d2 === 255 || record.d2 === 999) { + record.d2 = null + } + yield record; } }