Skip to content

Commit

Permalink
Add Bicycle Parking Data Set (FixMyBerlin/atlas-geo#70)
Browse files Browse the repository at this point in the history
This PR adds two data sets containing entries of bicycle parking
infrastructure. One contains point geometries of bicycle parking and the
other contains mostly parking areas which are mapped as areas. The point
data set also includes the entries of the second data set where the
respective point corresponds to the centroid of the mapped area.

Capacity values get processed s.t. the `capacity` tag only contains the
number of "normal" bicycle parking spots and not the total parking spots
e.g. `capacity = capacity - capacity:cargo_bikes`. Apart from that we
copy only the tags described on the [OSM Wiki - Bicycle
Parking](https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dbicycle_parking)
page.

[Related
Ticket](FixMyBerlin/private-issues#1094)
  • Loading branch information
rush42 authored Nov 7, 2023
2 parents 08d78e5 + 7d27f5a commit ad31f92
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
96 changes: 96 additions & 0 deletions atlas-geo/atlas-geo/app/process/bicycleParking/bicycleParking.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package.path = package.path .. ";/app/process/helper/?.lua;/app/process/shared/?.lua"
require("CopyTags")
require("Metadata")

local nodeTable = osm2pgsql.define_table({
name = 'bicycleParking-points',
ids = { type = 'any', id_column = 'osm_id', type_column = 'osm_type' },
columns = {
{ column = 'tags', type = 'jsonb' },
{ column = 'meta', type = 'jsonb' },
{ column = 'geom', type = 'point' },
}
})

local areaTable = osm2pgsql.define_table({
name = 'bicycleParking-areas',
ids = { type = 'any', id_column = 'osm_id', type_column = 'osm_type' },
columns = {
{ column = 'tags', type = 'jsonb' },
{ column = 'meta', type = 'jsonb' },
{ column = 'geom', type = 'polygon' },
}
})

function ExitProcessing(object)
if object.tags.amenity ~= 'bicycle_parking' then
return true
end
end

local function capacityNormalization(tags)
local capacities = { capacity = tonumber(tags.capacity) }
if capacities.capacity == nil then return capacities end
for key, val in pairs(tags) do
if osm2pgsql.has_prefix(key, "capacity") then
val = tonumber(val)
if val ~= nil then
capacities.capacity = capacities.capacity - val
end
capacities[key] = val
end
end
for k, v in pairs(capacities) do
if v == 0 then
capacities[k] = nil
end
end
return capacities
end

local function processTags(tags)
-- this is the list of tags found in the wiki: https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dbicycle_parking
-- also https://wiki.openstreetmap.org/wiki/Berlin/Verkehrswende/Fahrradparkpl%C3%A4tze
local tags_cc = { "area", "operator", "operator:type", "covered", "indoor", "access", "cargo_bike", "capacity",
"capacity:cargo_bike", "fee", "lit", "surface", "bicycle_parking", "mapillary", "maxstay", "surveillance",
"bicycle_parking:count", "bicycle_parking:position", "traffic_sign" }
local processedTags = capacityNormalization(tags)
CopyTags(processedTags, tags, tags_cc, "osm_")

local checkDateTag = "check_date"
if tags[checkDateTag] then
processedTags.age = AgeInDays(ParseDate(tags[checkDateTag]))
end
return processedTags
end

function osm2pgsql.process_node(object)
if ExitProcessing(object) then return end
local tags = processTags(object.tags)

nodeTable:insert({
tags = tags,
meta = Metadata(object),
geom = object:as_point()
})
end

function osm2pgsql.process_way(object)
if ExitProcessing(object) then return end
local tags = processTags(object.tags)
local meta = Metadata(object)

-- convert bicycle parking mapped as lines or areas to points by taking the centroid
nodeTable:insert({
tags = tags,
meta = meta,
geom = object:as_polygon():centroid(),
})

if not object.is_closed then return end
areaTable:insert({
tags = tags,
meta = meta,
geom = object:as_polygon(),
})
end
2 changes: 2 additions & 0 deletions atlas-geo/atlas-geo/app/run-4-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ echo "Reminder: The 'bikelanes' table is available only after Postprocessing fin
run_lua "roads_bikelanes/roads_bikelanes"
run_psql "roads_bikelanes/bikelanes/bikelanes"

run_lua "bicycleParking/bicycleParking"

run_lua "legacy_bikelanes/bikelanesPresence"
run_lua "legacy_surfaceQuality/surfaceQuality"
run_lua "legacy_roadClassification/roadClassification"
Expand Down

0 comments on commit ad31f92

Please sign in to comment.