Skip to content

Commit

Permalink
Fix null errors when evaluating style expressions (#186)
Browse files Browse the repository at this point in the history
Problems solved:
- nulls when evaluating station count
- nulls when evaluating maxspeed hover for highspeed lines


![image](https://github.com/user-attachments/assets/21c58821-ccba-4aaa-82e2-65f4b2caebbd)


![image](https://github.com/user-attachments/assets/340f8ff0-9c4b-4c40-aa2d-4bb77d571ae4)
  • Loading branch information
hiddewie authored Dec 28, 2024
1 parent 8e33eda commit adbab16
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions features/stations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ features:
feature: tram_stop
example:
name: Llacuna
count: 2

- description: Service station
feature: service_station
Expand Down
20 changes: 20 additions & 0 deletions import/sql/tile_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,26 @@ CREATE OR REPLACE FUNCTION signals_signal_boxes(z integer, x integer, y integer)
WHERE way IS NOT NULL
);

-- Function metadata
DO $do$ BEGIN
EXECUTE 'COMMENT ON FUNCTION signals_signal_boxes IS $tj$' || $$
{
"vector_layers": [
{
"id": "signals_signal_boxes",
"fields": {
"id": "integer",
"osm_id": "integer",
"feature": "string",
"ref": "string",
"name": "string"
}
}
]
}
$$::json || '$tj$';
END $do$;

CREATE OR REPLACE VIEW signals_railway_signals AS
SELECT
id,
Expand Down
6 changes: 3 additions & 3 deletions proxy/js/styles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ const endHue = 284;

const speedColor = theme => ['case',
['boolean', ['feature-state', 'hover'], false], ['case',
['all', ['>=', ['get', 'maxspeed'], 260], ['<=', ['get', 'maxspeed'], 300]], colors[theme].hover.alternative,
['all', ['!=', ['get', 'maxspeed'], null], ['>=', ['get', 'maxspeed'], 260], ['<=', ['get', 'maxspeed'], 300]], colors[theme].hover.alternative,
colors[theme].hover.main,
],
['==', ['get', 'maxspeed'], null], 'gray',
Expand Down Expand Up @@ -2221,7 +2221,7 @@ const layers = Object.fromEntries(knownThemes.map(theme => [theme, {
['get', 'name'],
15,
['case',
['>', ['get', 'count'], 1], ['concat', ['get', 'name'], ' (', ['get', 'count'], ')'],
['>', ['coalesce', ['get', 'count'], 0], 1], ['concat', ['get', 'name'], ' (', ['get', 'count'], ')'],
['get', 'name'],
],
],
Expand Down Expand Up @@ -2254,7 +2254,7 @@ const layers = Object.fromEntries(knownThemes.map(theme => [theme, {
['get', 'name'],
15,
['case',
['>', ['get', 'count'], 1], ['concat', ['get', 'name'], ' (', ['get', 'count'], ')'],
['>', ['coalesce', ['get', 'count'], 0], 1], ['concat', ['get', 'name'], ' (', ['get', 'count'], ')'],
['get', 'name'],
],
],
Expand Down

0 comments on commit adbab16

Please sign in to comment.