diff --git a/import/openrailwaymap.lua b/import/openrailwaymap.lua index 43266e65b..dda5a5a2d 100644 --- a/import/openrailwaymap.lua +++ b/import/openrailwaymap.lua @@ -1770,6 +1770,39 @@ function osm2pgsql.process_relation(object) way = object:as_multipolygon(), }) end + + local station_feature, station_state, name = railway_feature_and_state(tags, railway_station_values) + if station_feature and tags.type == 'multipolygon' then + local position, position_exact, line_positions = find_position_tags(tags) + + for station, _ in pairs(station_type(tags)) do + stations:insert({ + id = string.format("%s-%d-%s", object.type, object.id, station), + way = object:as_multipolygon(), + feature = station_feature, + state = station_state, + name = name, + station = station, + name_tags = name_tags(tags), + map_reference = map_station_reference(tags), + references = station_references(tags), + operator = split_semicolon_to_sql_array(tags.operator), + owner = tags.owner, + network = split_semicolon_to_sql_array(tags.network), + position = to_sql_array(map(parse_railway_positions(position, position_exact, line_positions), format_railway_position)), + yard_purpose = split_semicolon_to_sql_array(tags['railway:yard:purpose']), + yard_hump = tags['railway:yard:hump'] == 'yes' or nil, + wikidata = tags.wikidata, + wikimedia_commons = wikimedia_commons, + wikimedia_commons_file = wikimedia_commons_file, + image = image, + mapillary = tags.mapillary, + wikipedia = tags.wikipedia, + note = tags.note, + description = tags.description, + }) + end + end end function osm2pgsql.process_gen() diff --git a/import/test/test_import_station.lua b/import/test/test_import_station.lua index 669196bf3..70337535e 100644 --- a/import/test/test_import_station.lua +++ b/import/test/test_import_station.lua @@ -214,3 +214,20 @@ assert.eq(osm2pgsql.get_and_clear_imported_data(), { { id = 'way-123-train', feature = 'station', state = 'present', map_reference = 'ref', references = { ['railway-ref'] = 'ref' }, operator = '{"operator"}', station = 'train', name_tags = { name = 'name' }, name = 'name', way = way }, }, }) + +osm2pgsql.process_relation({ + id = 123, + type = 'relation', + tags = { + ['type'] = 'multipolygon', + ['railway'] = 'yard', + }, + as_multipolygon = function() + return way + end, +}) +assert.eq(osm2pgsql.get_and_clear_imported_data(), { + stations = { + { id = 'relation-123-train', way = way, name_tags = {}, station = 'train', state = 'present', references = {}, feature = 'yard' }, + }, +})