More road filters into new file

load-bicycle-parking
Jake Coppinger 2023-01-28 13:10:10 +11:00
rodzic 9861006cf1
commit 865be63b88
2 zmienionych plików z 24 dodań i 9 usunięć

Wyświetl plik

@ -4,6 +4,7 @@ import {
} from "./interfaces";
import { FeatureCollection, Geometry, GeoJsonProperties, Feature, GeometryObject } from 'geojson';
import { isGreenRoad, isOrangeRoad, isRedRoad } from "./osm-selectors";
export function drawMarkerAndCard(
item: RawOverpassNode,
@ -80,16 +81,14 @@ export function addStreetLayers(map: mapboxgl.Map, geoJson: FeatureCollection<Ge
map.addSource('redRoads', {
type: 'geojson',
data: {
features: geoJson.features.filter(feature => feature.properties &&
(feature.properties.maxspeed > 40 || (feature.properties.highway === 'residential' && feature.properties.maxspeed === undefined))),
features: geoJson.features.filter(isRedRoad),
type: "FeatureCollection"
}
});
map.addSource('orangeRoads', {
type: 'geojson',
data: {
features: geoJson.features.filter(feature => feature.properties &&
(feature.properties.maxspeed <= 40 || feature.properties.cycleway === 'lane'))
features: geoJson.features.filter(isOrangeRoad)
,
type: "FeatureCollection"
}
@ -98,11 +97,7 @@ export function addStreetLayers(map: mapboxgl.Map, geoJson: FeatureCollection<Ge
map.addSource('greenRoads', {
type: 'geojson',
data: {
features: geoJson.features.filter(feature => feature.properties &&
(feature.properties.maxspeed <= 30 || feature.properties.highway === 'cycleway' || feature.properties.highway === 'pedestrian'
|| feature.properties.highway === 'living_street'
))
features: geoJson.features.filter(isGreenRoad)
,
type: "FeatureCollection"
}

Wyświetl plik

@ -0,0 +1,20 @@
import { FeatureCollection, Geometry, GeoJsonProperties, Feature, GeometryObject } from 'geojson';
export function isRedRoad(feature: Feature<Geometry, GeoJsonProperties>) {
return feature.properties &&
(feature.properties.maxspeed > 40 || (feature.properties.highway === 'residential' && feature.properties.maxspeed === undefined))
}
export function isOrangeRoad(feature: Feature<Geometry, GeoJsonProperties>) {
return feature.properties &&
(feature.properties.maxspeed <= 40 || feature.properties.cycleway === 'lane')
}
export function isGreenRoad(feature: Feature<Geometry, GeoJsonProperties>) {
return feature.properties &&
(feature.properties.maxspeed <= 30 || feature.properties.highway === 'cycleway' || feature.properties.highway === 'pedestrian'
|| feature.properties.highway === 'living_street'
)
}