Skip to content

Commit

Permalink
Add tables for platform members and ref
Browse files Browse the repository at this point in the history
  • Loading branch information
janikkaden committed Aug 17, 2023
1 parent 6d52304 commit c944e25
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pipeline/stop_places/lua/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package.path = package.path .. ';/scripts/osm2pgsql/?.lua'

require 'stop_areas'
require 'platforms'
require 'platforms_members'
require 'stop_positions'
require 'entrances'
require 'parking'
Expand All @@ -19,6 +20,7 @@ end

function osm2pgsql.process_way(object)
if extract_platforms(object, 'way') then return end
if extract_platforms_members(object, 'way') then return end
if extract_parking(object, 'way') then return end
if extract_highways(object, 'way') then return end
extract_pois(object, 'way')
Expand Down
48 changes: 34 additions & 14 deletions pipeline/stop_places/lua/platforms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,42 @@ local extract_conditions = {
}
}

-- Create tables

local tables = {
-- Create table that contains all platforms
local platforms_table = osm2pgsql.define_table({
name = "platforms",
ids = {
type = 'any',
id_column = 'osm_id',
type_column = 'osm_type'
},
columns = {
{ column = 'IFOPT', type = 'text', not_null = true },
{ column = 'tags', type = 'jsonb', not_null = true },
{ column = 'geom', type = 'geometry', not_null = true, projection = 4326 }
}
})
platforms_table = osm2pgsql.define_table({
name = "platforms",
ids = {
type = 'any',
id_column = 'osm_id',
type_column = 'osm_type'
},
columns = {
{ column = 'IFOPT', type = 'text', not_null = true },
{ column = 'tags', type = 'jsonb', not_null = true },
{ column = 'geom', type = 'geometry', not_null = true, projection = 4326 }
}
}),

-- Create table that contains the mapping of the public_transport area to its members
platforms_members_ref = osm2pgsql.define_relation_table("platforms_members_ref", {
{ column = 'member_id', type = 'BIGINT' },
{ column = 'osm_type', type = 'text', sql_type = 'CHAR(1)' }
})
}


function extract_platforms(object, osm_type)
return extract_by_conditions_to_table(object, osm_type, extract_conditions, platforms_table)
local is_platform = extract_by_conditions_to_table(object, osm_type, extract_conditions, tables.platforms_table)
if is_platform and osm_type == 'relation' then
-- Go through all members and store them in a separate reference table
for _, member in ipairs(object.members) do
tables.platforms_members_ref:add_row({
member_id = member.ref,
osm_type = member.type:upper()
})
end
end
return is_platform
end
28 changes: 28 additions & 0 deletions pipeline/stop_places/lua/platforms_members.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'utils'

local extract_conditions = {
{
['railway'] = {
'platform_edge'
}
}
}

-- Create table that contains members of platforms
local platforms_members_table = osm2pgsql.define_table({
name = "platforms_members",
ids = {
type = 'any',
id_column = 'osm_id',
type_column = 'osm_type'
},
columns = {
{ column = 'tags', type = 'jsonb', not_null = true },
{ column = 'geom', type = 'geometry', not_null = true, projection = 4326 }
}
})


function extract_platforms_members(object, osm_type)
return extract_by_conditions_to_table(object, osm_type, extract_conditions, platforms_members_table)
end

0 comments on commit c944e25

Please sign in to comment.