From b2871fe3b8f09020fbd0a69c7404d5c9915b14dd Mon Sep 17 00:00:00 2001 From: MikkoPuustinen Date: Mon, 2 May 2022 16:55:39 +0300 Subject: [PATCH 1/3] feat: add park and ride compatibility --- middleware/confidenceScoreDT.js | 4 +++- pelias.json.docker | 8 +++++--- sanitizer/_ids.js | 12 ++++++++++-- sanitizer/_sources_and_layers.js | 4 ++++ translations.json | 8 ++++++-- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/middleware/confidenceScoreDT.js b/middleware/confidenceScoreDT.js index 389208ab..27ec4b35 100644 --- a/middleware/confidenceScoreDT.js +++ b/middleware/confidenceScoreDT.js @@ -30,6 +30,8 @@ var confidenceAddressParts = { var layers = [ 'neighbourhood', 'bikestation', + 'bikepark', + 'carpark', 'stop', 'venue', 'address', @@ -352,7 +354,7 @@ function checkLanguageNames(text, doc, stripNumbers, tryGenitive) { * @returns {number} */ function checkName(text, parsedText, hit) { - var docIsVenue = hit.layer === 'venue' || hit.layer === 'stop' || hit.layer === 'station' || hit.layer === 'bikestation'; + var docIsVenue = hit.layer === 'venue' || hit.layer === 'stop' || hit.layer === 'station' || hit.layer === 'bikestation' || hit.layer === 'carpark' || hit.layer === 'bikepark'; // parsedText name should take precedence if available since it's the cleaner name property var name = parsedText ? parsedText.name || parsedText.query : null; diff --git a/pelias.json.docker b/pelias.json.docker index f8601719..2483f8f9 100644 --- a/pelias.json.docker +++ b/pelias.json.docker @@ -31,11 +31,13 @@ "version": "1.0", "requestRetries": 0, "targets": { - "canonical_sources": ["openstreetmap", "openaddresses", "nlsfi", "gtfs", "citybikes"], + "canonical_sources": ["openstreetmap", "openaddresses", "nlsfi", "gtfs", "citybikes", "carparks", "bikeparks"], "layers_by_source": { "nlsfi": ["venue", "stop", "station"], "gtfs": ["stop", "station"], - "citybikes": ["bikestation"] + "citybikes": ["bikestation"], + "carparks": ["carpark"], + "bikeparks": ["bikepark"] }, "source_aliases": { "gtfs": ["gtfs"], @@ -114,7 +116,7 @@ "streetNumberValidator": "^[0-9].*$", "translations": "/opt/pelias/api/translations.json", "equalCharMap": { - "é":"e", + "�":"e", "'":"", "-":" " }, diff --git a/sanitizer/_ids.js b/sanitizer/_ids.js index 0488f87b..e6dbaf9f 100644 --- a/sanitizer/_ids.js +++ b/sanitizer/_ids.js @@ -19,7 +19,8 @@ var targetError = function(target, target_list) { function sanitizeId(rawId, messages) { var parts = rawId.split(ID_DELIM); - + console.log("parts", parts[0]) + console.log("type", type_mapping.source_mapping[source][0]) if ( parts.length < 3 ) { messages.errors.push( formatError(rawId) ); return; @@ -30,10 +31,16 @@ function sanitizeId(rawId, messages) { source = 'gtfs'; } else if(source.indexOf('citybikes') === 0) { source = 'citybikes'; + } else if(source.indexOf('carparks') === 0) { + source = 'carparks'; + } else if(source.indexOf('bikeparks') === 0) { + source = 'bikeparks'; } var layer = parts[1]; var id = parts.slice(2).join(ID_DELIM); + + // check if any parts of the gid are empty if (_.includes([source, layer, id], '')) { messages.errors.push( formatError(rawId) ); @@ -50,8 +57,9 @@ function sanitizeId(rawId, messages) { return; } + return { - source: source === 'gtfs' || source === 'citybikes' ? parts[0] : type_mapping.source_mapping[source][0], + source: source === 'gtfs' || source === 'citybikes' || source === 'carparks' || source === 'bikeparks' ? parts[0] : type_mapping.source_mapping[source][0], layer: layer, id: id, }; diff --git a/sanitizer/_sources_and_layers.js b/sanitizer/_sources_and_layers.js index ad218070..77ee86c5 100644 --- a/sanitizer/_sources_and_layers.js +++ b/sanitizer/_sources_and_layers.js @@ -17,6 +17,10 @@ function _sanitize( raw, clean ){ source = 'gtfs'; // map gtfs to plain gtfs } else if (source.indexOf('citybikes') === 0) { source = 'citybikes'; + } else if (source.indexOf('carparks') === 0) { + source = 'carparks'; + } else if (source.indexOf('bikeparks') === 0) { + source = 'bikeparks'; } var layers_for_source = type_mapping.layers_by_source[source]; clean.layers.forEach(function(layer) { diff --git a/translations.json b/translations.json index 40b32773..4e69c4de 100644 --- a/translations.json +++ b/translations.json @@ -5322,7 +5322,9 @@ "stop":"hÃ¥llplats", "station":"station", "street":"gata", - "bikestation":"Stadscykelstation" + "bikestation":"Stadscykelstation", + "carpark":"Infartsparkering", + "bikepark":"Anslutningsparkering för cyklar" }, "__category": { "waterway": "vattnen", @@ -5449,7 +5451,9 @@ "stop":"pysäkki", "station":"asema", "street":"katu", - "bikestation":"Kaupunkipyöräasema" + "bikestation":"Kaupunkipyöräasema", + "carpark":"Liityntäpysäköinti", + "bikepark":"Liityntäpyöräparkki" }, "__category": { "waterway": "vesistö", From 71547cac6991f61ef23d54740e444345607437b5 Mon Sep 17 00:00:00 2001 From: MikkoPuustinen Date: Mon, 2 May 2022 17:11:31 +0300 Subject: [PATCH 2/3] chore: remove console --- sanitizer/_ids.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/sanitizer/_ids.js b/sanitizer/_ids.js index e6dbaf9f..ea795233 100644 --- a/sanitizer/_ids.js +++ b/sanitizer/_ids.js @@ -19,8 +19,6 @@ var targetError = function(target, target_list) { function sanitizeId(rawId, messages) { var parts = rawId.split(ID_DELIM); - console.log("parts", parts[0]) - console.log("type", type_mapping.source_mapping[source][0]) if ( parts.length < 3 ) { messages.errors.push( formatError(rawId) ); return; From 6544b4c176bb1d81d79560e9baad1c7091ab47c3 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Tue, 3 May 2022 07:48:10 +0300 Subject: [PATCH 3/3] fix unintentionally changed character map entry --- pelias.json.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelias.json.docker b/pelias.json.docker index 2483f8f9..87526194 100644 --- a/pelias.json.docker +++ b/pelias.json.docker @@ -116,7 +116,7 @@ "streetNumberValidator": "^[0-9].*$", "translations": "/opt/pelias/api/translations.json", "equalCharMap": { - "�":"e", + "é":"e", "'":"", "-":" " },