Skip to content

Commit

Permalink
Render more amenities (part 1) (#105)
Browse files Browse the repository at this point in the history
Part of #79


Requires full re-import

General railway amenities:
- [x] water tower
- [ ] subway entrance
#108
- [x] derailer
- [x] buffer stop
- [ ] landuse railway
- [ ] render border / operator boundary names / refs
- [x] crossing box
- [x] block post
- [x] fuel station
- [x] water crane
- [x] coaling_facility
- [x] sand_store
- [x] waste_disposal
- [x] compressed_air_supply
- [x] preheating
- [x] wash
- [x] loading_gauge
- [x] hump yard
- [ ] engine shed
- [ ] workshop
- [x] defect_detector
- [x] aei
- [x] traverser
- [ ] loading_rack
- [ ] loading_ramp
- [ ] loading_tower
- [ ] unloading_hole
- [ ] car_dumper
- [ ] track_scale
- [ ] carrier_truck_pit
- [ ] gauge_conversion
- [ ] car_shuttle
- [ ] rolling_highway
- [ ] ferry and ferry terminal

Elecrical
- [ ] power catenary_mast
- [ ] power catenary_portal 
- [ ] railway line: railway:main_switch_off=yes, and
railway:lower_pantograph_section=yes
- [ ] power_supply
- [ ] railway:electricity = joint
- [ ] isolated track section / Electrification system change
  • Loading branch information
hiddewie authored Sep 21, 2024
1 parent b83ac7f commit 9e15252
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 12 deletions.
33 changes: 25 additions & 8 deletions import/openrailwaymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ local railway_line = osm2pgsql.define_table({

local pois = osm2pgsql.define_table({
name = 'pois',
ids = { type = 'node', id_column = 'osm_id' },
ids = { type = 'any', id_column = 'osm_id' },
columns = {
{ column = 'id', sql_type = 'serial', create_only = true },
{ column = 'way', type = 'point' },
Expand Down Expand Up @@ -149,13 +149,14 @@ local signals = osm2pgsql.define_table({
},
})

local signal_boxes = osm2pgsql.define_table({
name = 'signal_boxes',
local boxes = osm2pgsql.define_table({
name = 'boxes',
ids = { type = 'any', id_column = 'osm_id' },
columns = {
{ column = 'id', sql_type = 'serial', create_only = true },
{ column = 'way', type = 'geometry' },
{ column = 'way_area', type = 'real' },
{ column = 'feature', type = 'text' },
{ column = 'ref', type = 'text' },
{ column = 'name', type = 'text' },
},
Expand All @@ -167,6 +168,7 @@ local turntables = osm2pgsql.define_table({
columns = {
{ column = 'id', sql_type = 'serial', create_only = true },
{ column = 'way', type = 'polygon' },
{ column = 'feature', type = 'text' },
},
})

Expand Down Expand Up @@ -243,18 +245,20 @@ end
-- TODO clean up unneeded tags

local railway_station_values = osm2pgsql.make_check_values_func({'station', 'halt', 'tram_stop', 'service_station', 'yard', 'junction', 'spur_junction', 'crossover', 'site'})
local railway_poi_values = osm2pgsql.make_check_values_func({'crossing', 'level_crossing', 'phone', 'tram_stop', 'border', 'owner_change', 'radio', 'lubricator'})
local railway_poi_values = osm2pgsql.make_check_values_func({'crossing', 'level_crossing', 'phone', 'tram_stop', 'border', 'owner_change', 'radio', 'lubricator', 'fuel', 'wash', 'water_tower', 'water_crane', 'sand_store', 'coaling_facility', 'waste_disposal', 'compressed_air_supply', 'preheating', 'loading_gauge', 'hump_yard', 'defect_detector', 'aei', 'buffer_stop', 'derail'})
local railway_signal_values = osm2pgsql.make_check_values_func({'signal', 'buffer_stop', 'derail', 'vacancy_detection'})
local railway_position_values = osm2pgsql.make_check_values_func({'milestone', 'level_crossing', 'crossing'})
local railway_switch_values = osm2pgsql.make_check_values_func({'switch', 'railway_crossing'})
local railway_box_values = osm2pgsql.make_check_values_func({'signal_box', 'crossing_box', 'blockpost'})
local known_name_tags = {'name', 'alt_name', 'short_name', 'long_name', 'official_name', 'old_name', 'uic_name'}
function osm2pgsql.process_node(object)
local tags = object.tags

if tags.railway == 'signal_box' then
signal_boxes:insert({
if railway_box_values(tags.railway) then
boxes:insert({
way = object:as_point(),
way_area = 0,
feature = tags.railway,
ref = tags['railway:ref'],
name = tags.name,
})
Expand Down Expand Up @@ -522,18 +526,31 @@ function osm2pgsql.process_way(object)
if railway_turntable_values(tags.railway) then
turntables:insert({
way = object:as_polygon(),
feature = tags.railway,
})
end

if tags.railway == 'signal_box' then
if railway_box_values(tags.railway) then
local polygon = object:as_polygon():transform(3857)
signal_boxes:insert({
boxes:insert({
way = polygon,
way_area = polygon:area(),
feature = tags.railway,
ref = tags['railway:ref'],
name = tags.name,
})
end

if railway_poi_values(tags.railway) then
pois:insert({
way = object:as_polygon():centroid(),
railway = tags.railway,
man_made = tags.man_made,
crossing_bell = tags['crossing:bell'] and (tags['crossing:bell'] ~= 'no'),
crossing_light = tags['crossing:light'] and (tags['crossing:light'] ~= 'no'),
crossing_barrier = tags['crossing:barrier'] and (tags['crossing:barrier'] ~= 'no'),
})
end
end

local route_values = osm2pgsql.make_check_values_func({'train', 'subway', 'tram', 'light_rail'})
Expand Down
20 changes: 18 additions & 2 deletions import/sql/tile_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ CREATE OR REPLACE VIEW standard_railway_symbols AS
WHEN railway = 'border' THEN 'general/border'
WHEN railway = 'owner_change' THEN 'general/owner-change'
WHEN railway = 'lubricator' THEN 'general/lubricator'
WHEN railway = 'fuel' THEN 'general/fuel'
WHEN railway = 'sand_store' THEN 'general/sand_store'
WHEN railway = 'aei' THEN 'general/aei'
WHEN railway = 'buffer_stop' THEN 'general/buffer_stop'
WHEN railway = 'derail' THEN 'general/derail'
WHEN railway = 'defect_detector' THEN 'general/defect_detector'
WHEN railway = 'hump_yard' THEN 'general/hump_yard'
WHEN railway = 'loading_gauge' THEN 'general/loading_gauge'
WHEN railway = 'preheating' THEN 'general/preheating'
WHEN railway = 'compressed_air_supply' THEN 'general/compressed_air_supply'
WHEN railway = 'waste_disposal' THEN 'general/waste_disposal'
WHEN railway = 'coaling_facility' THEN 'general/coaling_facility'
WHEN railway = 'wash' THEN 'general/wash'
WHEN railway = 'water_tower' THEN 'general/water_tower'
WHEN railway = 'water_crane' THEN 'general/water_crane'
WHEN railway = 'radio' THEN
CASE
WHEN man_made IN ('mast', 'tower') THEN 'general/radio-mast'
Expand All @@ -222,7 +237,7 @@ CREATE OR REPLACE VIEW standard_railway_symbols AS
ELSE 0
END AS priority
FROM pois
WHERE railway IN ('crossing', 'level_crossing', 'phone', 'tram_stop', 'border', 'owner_change', 'radio', 'lubricator')
WHERE railway IN ('crossing', 'level_crossing', 'phone', 'tram_stop', 'border', 'owner_change', 'radio', 'lubricator', 'fuel', 'sand_store', 'coaling_facility', 'wash', 'water_tower', 'water_crane', 'waste_disposal', 'compressed_air_supply', 'preheating', 'loading_gauge', 'hump_yard', 'defect_detector', 'aei', 'buffer_stop', 'derail')
ORDER BY priority DESC;

CREATE OR REPLACE VIEW standard_railway_text_km AS
Expand Down Expand Up @@ -279,9 +294,10 @@ CREATE OR REPLACE VIEW signals_signal_boxes AS
SELECT
id,
way,
feature,
ref,
name
FROM signal_boxes
FROM boxes
ORDER BY way_area DESC NULLS LAST;

CREATE OR REPLACE VIEW signals_railway_signals AS
Expand Down
2 changes: 2 additions & 0 deletions martin/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ postgres:
geometry_type: POLYGON
properties:
id: integer
feature: string

standard_railway_text_stations:
schema: public
Expand Down Expand Up @@ -260,6 +261,7 @@ postgres:
geometry_type: GEOMETRY
properties:
id: integer
feature: string
ref: string
name: string

Expand Down
157 changes: 155 additions & 2 deletions proxy/js/styles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,23 @@ const layers = {
['==', ['get', 'feature'], 'general/level-crossing-light'],
['==', ['get', 'feature'], 'general/level-crossing-barrier'],
['==', ['get', 'feature'], 'general/lubricator'],
['==', ['get', 'feature'], 'general/fuel'],
['==', ['get', 'feature'], 'general/sand_store'],
['==', ['get', 'feature'], 'general/aei'],
['==', ['get', 'feature'], 'general/buffer_stop'],
['==', ['get', 'feature'], 'general/derail'],
['==', ['get', 'feature'], 'general/defect_detector'],
['==', ['get', 'feature'], 'general/hump_yard'],
['==', ['get', 'feature'], 'general/loading_gauge'],
['==', ['get', 'feature'], 'general/preheating'],
['==', ['get', 'feature'], 'general/compressed_air_supply'],
['==', ['get', 'feature'], 'general/waste_disposal'],
['==', ['get', 'feature'], 'general/coaling_facility'],
['==', ['get', 'feature'], 'general/wash'],
['==', ['get', 'feature'], 'general/water_tower'],
['==', ['get', 'feature'], 'general/water_crane'],
['==', ['get', 'feature'], 'general/vacancy-detection-insulated-rail-joint'],
['==', ['get', 'feature'], 'general/vacancy-detection-axle-counter'],
],
layout: {
'symbol-z-order': 'source',
Expand Down Expand Up @@ -3281,7 +3298,17 @@ const legendData = {
{
legend: 'Turntable',
type: 'polygon',
properties: {},
properties: {
feature: 'turntable'
},
variants: [
{
legend: 'Transfer table',
properties: {
feature: 'traverser',
}
}
]
},
],
"openrailwaymap_standard-standard_railway_symbols": [
Expand Down Expand Up @@ -3363,6 +3390,113 @@ const legendData = {
feature: 'general/lubricator',
},
},
{
legend: 'Fuel',
type: 'point',
properties: {
feature: 'general/fuel',
},
},
{
legend: 'Sand store',
type: 'point',
properties: {
feature: 'general/sand_store',
},
},
{
legend: 'Defect detector',
type: 'point',
properties: {
feature: 'general/defect_detector',
},
},
{
legend: 'Automatic equipment identification',
type: 'point',
properties: {
feature: 'general/aei',
},
},
{
legend: 'Buffer stop',
type: 'point',
properties: {
feature: 'general/buffer_stop',
},
variants: [
{
legend: 'Derailer',
properties: {
feature: 'general/derail',
}
}
]
},
{
legend: 'Hump yard',
type: 'point',
properties: {
feature: 'general/hump_yard',
},
},
{
legend: 'Loading gauge',
type: 'point',
properties: {
feature: 'general/loading_gauge',
},
},
{
legend: 'Preheating',
type: 'point',
properties: {
feature: 'general/preheating',
},
},
{
legend: 'Compressed air supply',
type: 'point',
properties: {
feature: 'general/compressed_air_supply',
},
},
{
legend: 'Waste disposal',
type: 'point',
properties: {
feature: 'general/waste_disposal',
},
},
{
legend: 'Coaling facility',
type: 'point',
properties: {
feature: 'general/coaling_facility',
},
},
{
legend: 'Wash',
type: 'point',
properties: {
feature: 'general/wash',
},
},
{
legend: 'Water tower',
type: 'point',
properties: {
feature: 'general/water_tower',
},
variants: [
{
legend: 'crane',
properties: {
feature: 'general/water_crane',
},
},
]
},
{
legend: 'Axle counter',
type: 'point',
Expand Down Expand Up @@ -3614,8 +3748,27 @@ const legendData = {
type: 'point',
properties: {
ref: 'Rtd',
name: 'Rotterdam'
name: 'Rotterdam',
feature: 'signal_box',
},
variants: [
{
legend: 'crossing box',
properties: {
ref: 'Crs',
name: 'Cross',
feature: 'crossing_box',
},
},
{
legend: 'block post',
properties: {
ref: 'Blk',
name: 'KM 47',
feature: 'blockpost',
},
},
],
},
],
'openrailwaymap_signals-signals_railway_signals': [
Expand Down
4 changes: 4 additions & 0 deletions symbols/general/aei.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions symbols/general/buffer_stop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions symbols/general/coaling_facility.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions symbols/general/compressed_air_supply.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9e15252

Please sign in to comment.