Remove osm2pgsql
This commit is contained in:
parent
761908a987
commit
0a18cda691
41
Dockerfile
41
Dockerfile
|
@ -1,44 +1,5 @@
|
|||
# This dockerfile is for the API + Frontend production image
|
||||
|
||||
#############################################
|
||||
# Build osm2pgsql AS builder
|
||||
#############################################
|
||||
|
||||
# This image should be the same as final one, because of the lib versions
|
||||
FROM python:3.9.7-bullseye as osm2pgsql-builder
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Europe/Berlin
|
||||
ENV OSM2PGSQL_VERSION=1.5.1
|
||||
|
||||
# Dependencies
|
||||
RUN apt-get update &&\
|
||||
apt-get install -y \
|
||||
make \
|
||||
cmake \
|
||||
g++ \
|
||||
libboost-dev \
|
||||
libboost-system-dev \
|
||||
libboost-filesystem-dev \
|
||||
libexpat1-dev \
|
||||
zlib1g-dev \
|
||||
libbz2-dev \
|
||||
libpq-dev \
|
||||
libproj-dev \
|
||||
lua5.3 \
|
||||
liblua5.3-dev \
|
||||
git &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Clone & Build
|
||||
RUN git clone --branch $OSM2PGSQL_VERSION https://github.com/openstreetmap/osm2pgsql.git &&\
|
||||
cd osm2pgsql/ &&\
|
||||
mkdir build &&\
|
||||
cd build &&\
|
||||
cmake .. &&\
|
||||
make -j4 &&\
|
||||
make install
|
||||
|
||||
#############################################
|
||||
# Build the frontend AS builder
|
||||
#############################################
|
||||
|
@ -94,10 +55,8 @@ ADD api/tools /opt/obs/api/tools/
|
|||
RUN pip install -e /opt/obs/api/
|
||||
|
||||
ADD roads_import.lua /opt/obs/api/tools
|
||||
ADD osm2pgsql.sh /opt/obs/api/tools
|
||||
|
||||
COPY --from=frontend-builder /opt/obs/frontend/build /opt/obs/frontend/build
|
||||
COPY --from=osm2pgsql-builder /usr/local/bin/osm2pgsql /usr/local/bin/osm2pgsql
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ You should see smth. like:
|
|||
|
||||
When you click on *My Tracks*, you should see it on a map.
|
||||
|
||||
#### Configre the map position
|
||||
#### Configure the map position
|
||||
|
||||
Open the tab *Map** an zoom to the desired position. The URL contains the corresponding GPS position,
|
||||
for example:
|
||||
|
@ -318,10 +318,6 @@ docker-compose restart portal
|
|||
The tab *Map* should be the selected map section now.
|
||||
When you uploaded some tracks, you map should show a colors overlay on the streets.
|
||||
|
||||
#### Verify osm2pgsql
|
||||
|
||||
If you zoom in the tab *Map* at the imported region/city, you should see dark grey lines on the streets.
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
### Logs
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
osm2pgsql --create --hstore --style tools/roads_import.lua -O flex -d postgresql://$OBS_POSTGRES_USER:$OBS_POSTGRES_PASSWORD@$OBS_POSTGRES_HOST/$OBS_POSTGRES_DB /pbf/*.osm.pbf
|
||||
|
161
roads_import.lua
161
roads_import.lua
|
@ -1,161 +0,0 @@
|
|||
--
|
||||
-- To use this file, see
|
||||
-- https://mygisnotes.wordpress.com/2015/10/09/openstreepmap-import-data-into-a-postgis-database-and-incrementally-update-it/
|
||||
-- for general instructions:
|
||||
-- 1. Download PBF
|
||||
-- 2. Convert and filter to your needs
|
||||
-- 3. Run the import like this:
|
||||
--
|
||||
-- osm2pgsql --create --hstore --style roads_import.lua -O flex \
|
||||
-- --proj 32629 -H localhost -d obs -U obs -W \
|
||||
-- YOUR_FILE.o5m
|
||||
|
||||
local function contains(table, val)
|
||||
for i=1,#table do
|
||||
if table[i] == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local HIGHWAY_TYPES = {
|
||||
"trunk",
|
||||
"primary",
|
||||
"secondary",
|
||||
"tertiary",
|
||||
"unclassified",
|
||||
"residential",
|
||||
"trunk_link",
|
||||
"primary_link",
|
||||
"secondary_link",
|
||||
"tertiary_link",
|
||||
"living_street",
|
||||
"service",
|
||||
"track",
|
||||
"road",
|
||||
}
|
||||
local ZONE_TYPES = {
|
||||
"urban",
|
||||
"rural",
|
||||
"motorway",
|
||||
}
|
||||
local URBAN_TYPES = {
|
||||
"residential",
|
||||
"living_street",
|
||||
"road",
|
||||
}
|
||||
local MOTORWAY_TYPES = {
|
||||
"motorway",
|
||||
"motorway_link",
|
||||
}
|
||||
|
||||
local ADMIN_LEVEL_MIN = 2
|
||||
local ADMIN_LEVEL_MAX = 8
|
||||
|
||||
local ONEWAY_YES = {"yes", "true", "1"}
|
||||
local ONEWAY_REVERSE = {"reverse", "-1"}
|
||||
|
||||
local roads = osm2pgsql.define_way_table('road', {
|
||||
{ column = 'zone', type = 'text', sql_type="zone_type" },
|
||||
{ column = 'directionality', type = 'int' },
|
||||
{ column = 'name', type = 'text' },
|
||||
{ column = 'geometry', type = 'linestring' },
|
||||
{ column = 'oneway', type = 'bool' },
|
||||
})
|
||||
|
||||
local minspeed_rural = 60
|
||||
|
||||
local regions = osm2pgsql.define_relation_table('region', {
|
||||
{ column = 'name', type = 'text' },
|
||||
{ column = 'geometry', type = 'geometry' },
|
||||
{ column = 'admin_level', type = 'int' },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
})
|
||||
|
||||
function osm2pgsql.process_way(object)
|
||||
if object.tags.highway and contains(HIGHWAY_TYPES, object.tags.highway) then
|
||||
local tags = object.tags
|
||||
local zone = nil
|
||||
|
||||
if tags["zone:traffic"] then
|
||||
zone = tags["zone:traffic"]
|
||||
|
||||
if zone == "DE:urban" then
|
||||
zone = "urban"
|
||||
elseif zone == "DE:rural" then
|
||||
zone = "rural"
|
||||
elseif zone == "DE:motorway" then
|
||||
zone = "motorway"
|
||||
elseif string.match(zone, "rural") then
|
||||
zone = "rural"
|
||||
elseif string.match(zone, "urban") then
|
||||
zone = "urban"
|
||||
elseif string.match(zone, "motorway") then
|
||||
zone = "motorway"
|
||||
elseif string.match(zone, "30") then
|
||||
zone = "urban"
|
||||
else
|
||||
zone = "urban"
|
||||
end
|
||||
end
|
||||
if not tags["zone:traffic"] then
|
||||
if contains(URBAN_TYPES, tags.highway) then
|
||||
zone = "urban"
|
||||
elseif contains(MOTORWAY_TYPES, tags.highway) then
|
||||
zone = "motorway"
|
||||
elseif (tags.maxspeed) and (tonumber(string.match(tags.maxspeed, '[%d]*'))) and tonumber(string.match(tags.maxspeed, '[%d]*')) > minspeed_rural then
|
||||
zone = "rural"
|
||||
elseif (tags["maxspeed:forward"]) and (tonumber(string.match(tags["maxspeed:forward"], '[%d]*'))) and tonumber(string.match(tags["maxspeed:forward"], '[%d]*')) > minspeed_rural then
|
||||
zone = "rural"
|
||||
elseif (tags["maxspeed:backward"]) and (tonumber(string.match(tags["maxspeed:backward"], '[%d]*'))) and tonumber(string.match(tags["maxspeed:backward"], '[%d]*')) > minspeed_rural then
|
||||
zone = "rural"
|
||||
elseif tags['source:maxspeed'] and string.match(tags['source:maxspeed'], "rural") then
|
||||
zone = "rural"
|
||||
elseif tags['source:maxspeed'] and string.match(tags['source:maxspeed'], "urban") then
|
||||
zone = "urban"
|
||||
else
|
||||
-- we can't figure it out
|
||||
zone = "urban"
|
||||
end
|
||||
end
|
||||
|
||||
local directionality = 0
|
||||
local oneway = tags.oneway
|
||||
|
||||
-- See https://wiki.openstreetmap.org/wiki/Key:oneway section "Implied oneway restriction"
|
||||
if contains(ONEWAY_YES, tags.oneway) or tags.junction == "roundabout" or zone == "motorway" then
|
||||
directionality = 1
|
||||
oneway = true
|
||||
elseif contains(ONEWAY_REVERSE, tags.oneway) then
|
||||
directionality = -1
|
||||
oneway = true
|
||||
end
|
||||
|
||||
roads:add_row({
|
||||
geom = { create = 'linear' },
|
||||
name = tags.name,
|
||||
zone = zone,
|
||||
directionality = directionality,
|
||||
oneway = oneway,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function osm2pgsql.process_relation(object)
|
||||
local admin_level = tonumber(object.tags.admin_level)
|
||||
if object.tags.boundary == "administrative" and admin_level and admin_level >= ADMIN_LEVEL_MIN and admin_level <= ADMIN_LEVEL_MAX then
|
||||
regions:add_row({
|
||||
geometry = { create = 'area' },
|
||||
name = object.tags.name,
|
||||
admin_level = admin_level,
|
||||
tags = object.tags,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function osm2pgsql.select_relation_members(relation)
|
||||
if relation.tags.type == 'route' then
|
||||
return { ways = osm2pgsql.way_member_ids(relation) }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue