Skip to content

Commit

Permalink
define railway_line_low and railway_line_med in terms of railway_line…
Browse files Browse the repository at this point in the history
…_high
  • Loading branch information
hiddewie committed Aug 3, 2024
1 parent c9d8100 commit 152b430
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 82 deletions.
86 changes: 14 additions & 72 deletions import/sql/tile_views.sql
Original file line number Diff line number Diff line change
@@ -1,77 +1,5 @@
--- Shared ---

CREATE OR REPLACE VIEW railway_line_low AS
SELECT
id,
way,
highspeed,
-- speeds are converted to kph in this layer because it is used for colouring
maxspeed,
train_protection,
train_protection_rank,
railway_to_int(voltage) AS voltage,
railway_to_float(frequency) AS frequency,
railway_to_int(gauge) AS gaugeint0,
gauge as gauge0
FROM (
SELECT
id,
way,
railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed,
highspeed,
train_protection,
train_protection_rank,
frequency,
voltage,
railway_desired_value_from_list(1, gauge) AS gauge
FROM railway_line
WHERE railway = 'rail' AND usage = 'main' AND service IS NULL
) AS r
ORDER by
highspeed,
maxspeed NULLS FIRST;

CREATE OR REPLACE VIEW railway_line_med AS
SELECT
id,
way,
usage,
highspeed,
maxspeed,
train_protection_rank,
train_protection,
electrification_state,
voltage,
frequency,
railway_to_int(gauge) AS gaugeint0,
gauge as gauge0
FROM
(SELECT
id,
way,
railway,
usage,
highspeed,
-- speeds are converted to kph in this layer because it is used for colouring
railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed,
train_protection_rank,
train_protection,
railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, NULL, NULL, true) AS electrification_state,
railway_to_int(voltage) AS voltage,
railway_to_float(frequency) AS frequency,
railway_desired_value_from_list(1, gauge) AS gauge
FROM railway_line
WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL
) AS r
ORDER by
CASE
WHEN railway = 'rail' AND usage = 'main' AND highspeed THEN 2000
WHEN railway = 'rail' AND usage = 'main' THEN 1100
WHEN railway = 'rail' AND usage = 'branch' THEN 1000
ELSE 50
END NULLS LAST,
maxspeed NULLS FIRST;

CREATE OR REPLACE VIEW railway_line_high AS
SELECT
id,
Expand Down Expand Up @@ -187,6 +115,20 @@ CREATE OR REPLACE VIEW railway_line_high AS
rank NULLS LAST,
maxspeed NULLS FIRST;

CREATE OR REPLACE VIEW railway_line_med AS
SELECT
*
FROM
railway_line_high
WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL;

CREATE OR REPLACE VIEW railway_line_low AS
SELECT
*
FROM
railway_line_high
WHERE railway = 'rail' AND usage = 'main' AND service IS NULL;

--- Standard ---

CREATE OR REPLACE VIEW standard_railway_text_stations_low AS
Expand Down
56 changes: 46 additions & 10 deletions martin/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,35 @@ postgres:
geometry_column: way
geometry_type: LINESTRING
properties:
# TODO calculate labels in frontend
id: integer
railway: string
feature: string
usage: string
service: string
highspeed: boolean
maxspeed: integer
tunnel: boolean
bridge: boolean
ref: string
standard_label: string
track_ref: string
maxspeed: number
speed_label: string
train_protection: string
train_protection_rank: integer
frequency: double
voltage: integer
gaugeint0: integer
electrification_state: string
frequency: number
voltage: number
future_frequency: number
future_voltage: number
electrification_label: string
gauge0: string
# TODO define more properties
gaugeint0: number
gauge1: string
gaugeint1: number
gauge2: string
gaugeint2: number
gauge_label: string

railway_line_med:
schema: public
Expand All @@ -51,18 +70,35 @@ postgres:
geometry_column: way
geometry_type: LINESTRING
properties:
# TODO calculate labels in frontend
id: integer
railway: string
feature: string
usage: string
service: string
highspeed: boolean
maxspeed: integer
tunnel: boolean
bridge: boolean
ref: string
standard_label: string
track_ref: string
maxspeed: number
speed_label: string
train_protection: string
train_protection_rank: integer
electrification_state: string
frequency: double
voltage: integer
gaugeint0: integer
frequency: number
voltage: number
future_frequency: number
future_voltage: number
electrification_label: string
gauge0: string
# TODO define more properties
gaugeint0: number
gauge1: string
gaugeint1: number
gauge2: string
gaugeint2: number
gauge_label: string

railway_line_high:
schema: public
Expand Down

0 comments on commit 152b430

Please sign in to comment.