From 66a3ad80f3d6efaa1569e0675053b51da18504f2 Mon Sep 17 00:00:00 2001 From: Jake Coppinger Date: Sat, 28 Jan 2023 13:14:08 +1100 Subject: [PATCH] Refactor selectors --- src/osm-selectors.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/osm-selectors.ts b/src/osm-selectors.ts index 0ad1798..37e2f6f 100644 --- a/src/osm-selectors.ts +++ b/src/osm-selectors.ts @@ -1,27 +1,30 @@ import { Geometry, GeoJsonProperties, Feature } from 'geojson'; export function isRedRoad(feature: Feature): boolean { - if (feature.properties === null) { + const p = feature.properties; + if (p === null) { return false; } - return (feature.properties.maxspeed > 40 || (feature.properties.highway === 'residential' && feature.properties.maxspeed === undefined)) + return (p.maxspeed > 40 || (p.highway === 'residential' && p.maxspeed === undefined)) } export function isOrangeRoad(feature: Feature): boolean { - if (feature.properties === null) { + const p = feature.properties; + if (p === null) { return false; } - return (feature.properties.maxspeed <= 40 || feature.properties.cycleway === 'lane') + return (p.maxspeed <= 40 || p.cycleway === 'lane') } export function isGreenRoad(feature: Feature): boolean { - if (feature.properties === null) { + const p = feature.properties; + if (p === null) { return false; } - return (feature.properties.maxspeed <= 30 || feature.properties.highway === 'cycleway' || feature.properties.highway === 'pedestrian' + return (p.maxspeed <= 30 || p.highway === 'cycleway' || p.highway === 'pedestrian' - || feature.properties.highway === 'living_street' + || p.highway === 'living_street' ) } \ No newline at end of file