-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bicycle Parking Data Set (FixMyBerlin/atlas-geo#70)
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
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
atlas-geo/atlas-geo/app/process/bicycleParking/bicycleParking.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters