Merge branch 'lost_work_rural_urban' into rural_urban

This commit is contained in:
gluap 2022-07-25 18:13:10 +02:00
commit 1ad5fe562e
5 changed files with 23 additions and 8 deletions

View file

@ -1,7 +1,7 @@
import React from 'react'
import _ from 'lodash'
import {connect} from 'react-redux'
import {List, Select, Input, Divider, Checkbox, Header} from 'semantic-ui-react'
import {List, Select, Input, Divider, Label, Checkbox, Header} from 'semantic-ui-react'
import {
MapConfig,
@ -23,6 +23,7 @@ const ROAD_ATTRIBUTE_OPTIONS = [
{value: 'distance_overtaker_median', key: 'distance_overtaker_median', text: 'Overtaker distance median'},
{value: 'overtaking_event_count', key: 'overtaking_event_count', text: 'Event count'},
{value: 'usage_count', key: 'usage_count', text: 'Usage count'},
{value: 'zone', key: 'zone', text: 'Overtaking distance zone'}
]
function LayerSidebar({
@ -96,6 +97,13 @@ function LayerSidebar({
<ColorMapLegend map={_.chunk(colorByCount('obsRoads.maxCount', mapConfig.obsRoads.maxCount, viridisSimpleHtml ).slice(3), 2)} twoTicks />
</List.Item></>
) :
attribute.endsWith('zone') ? (
<>
<List.Item>
<Label size="small" style={{background: "blue",color:"white"}}>urban (1.5&nbsp;m)</Label>
<Label size="small" style={{background: "cyan", color:"black"}}>rural (2&nbsp;m)</Label>
</List.Item></>
) :
(
<List.Item>
<span style={{color: "olive"}}>Urban</span>
@ -123,9 +131,9 @@ function LayerSidebar({
{showEvents && (
<>
<List.Item>
<span style={{color: "olive"}}>Urban</span>
<span style={{color: "blue"}}>Urban</span>
<DiscreteColorMapLegend map={colorByDistance('distance_overtaker')[3][5].slice(2)} />
<span style={{color: "brown"}}>Rural</span>
<span style={{color: "cyan"}}>Rural</span>
<DiscreteColorMapLegend map={colorByDistance('distance_overtaker')[3][3].slice(2)} />
</List.Item>
</>

View file

@ -34,7 +34,7 @@ const LABELS = {
max: 'Maximum',
mean: 'Average',
}
const ZONE_COLORS = {urban: 'olive', rural: 'brown', motorway: 'purple'}
const ZONE_COLORS = {urban: 'blue', rural: 'cyan', motorway: 'purple'}
const CARDINAL_DIRECTIONS = ['north', 'north-east', 'east', 'south-east', 'south', 'south-west', 'west', 'north-west']
const getCardinalDirection = (bearing) =>
bearing == null

View file

@ -54,6 +54,8 @@ const getRoadsLayer = (colorAttribute, maxCount) =>
? colorByDistance(colorAttribute)
: colorAttribute.endsWith('_count')
? colorByCount(colorAttribute, maxCount)
: colorAttribute.endsWith('zone')
? borderByZone()
: '#DDD'
draft.paint['line-opacity'][3] = 12
draft.paint['line-opacity'][5] = 13
@ -67,8 +69,6 @@ const getEventsLayer = () => ({
paint: {
'circle-radius': ['interpolate', ['linear'], ['zoom'], 14, 3, 17, 8],
'circle-color': colorByDistance('distance_overtaker'),
'circle-stroke-color': borderByZone(),
'circle-stroke-width':['interpolate', ['linear'], ['zoom'], 14, 1, 17, 4],
},
minzoom: 11,
})

View file

@ -11,7 +11,8 @@ type RoadAttribute =
| "distance_overtaker_max"
| "distance_overtaker_median"
| "overtaking_event_count"
| "usage_count";
| "usage_count"
| "zone";
export type MapConfig = {
baseMap: {

View file

@ -61,6 +61,8 @@ local roads = osm2pgsql.define_way_table('road', {
{ column = 'oneway', type = 'bool' },
})
local minspeed_rural = 60
function osm2pgsql.process_way(object)
if object.tags.highway and contains(HIGHWAY_TYPES, object.tags.highway) then
local tags = object.tags
@ -92,7 +94,11 @@ function osm2pgsql.process_way(object)
zone = "urban"
elseif contains(MOTORWAY_TYPES, tags.highway) then
zone = "motorway"
elseif (tags.maxspeed) and (tonumber(string.match(tags.maxspeed, '[%d]*'))) and tonumber(string.match(tags.maxspeed, '[%d]*')) > 60 then
elseif (tags.maxspeed) and (tonumber(string.match(tags.maxspeed, '[%d]*'))) and tonumber(string.match(tags.maxspeed, '[%d]*')) > minspeed_rural then
zone = "rural"
elseif (tags["maxspeed:forward"]) and (tonumber(string.match(tags["maxspeed:forward"], '[%d]*'))) and tonumber(string.match(tags["maxspeed:forward"], '[%d]*')) > minspeed_rural then
zone = "rural"
elseif (tags["maxspeed:backward"]) and (tonumber(string.match(tags["maxspeed:backward"], '[%d]*'))) and tonumber(string.match(tags["maxspeed:backward"], '[%d]*')) > minspeed_rural then
zone = "rural"
elseif tags['source:maxspeed'] and string.match(tags['source:maxspeed'], "rural") then
zone = "rural"