Skip to content

Commit

Permalink
build osm2pgsql from source (#112)
Browse files Browse the repository at this point in the history
* build osm2pgsql from source

* checkout tag so we know what we're getting

* updating osm2pgsql command
  • Loading branch information
tgrigsby-sc authored Feb 4, 2022
1 parent 0ede406 commit a675c97
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/pre-commit.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
Expand Down
19 changes: 17 additions & 2 deletions import/import_planet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export PGUSER='%(db_user)s'
FLAT_NODES_BUCKET='%(flat_nodes_bucket)s'
FLAT_NODES_KEY='%(flat_nodes_key)s'
export AWS_DEFAULT_REGION='%(aws_region)s'
export OSM2PGSQL='/usr/bin/osm2pgsql'
export OSM2PGSQL='/usr/local/bin/osm2pgsql'
VECTOR_DATASOURCE_VERSION='%(vector_datasource_version)s'

# we don't want the STATUS file moving around while we change working directories, especially if
Expand Down Expand Up @@ -71,6 +71,21 @@ sudo DEBIAN_FRONTEND=noninteractive apt update
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y -q
sudo DEBIAN_FRONTEND=noninteractive apt install -y -q make g++ git awscli build-essential autoconf libtool pkg-config python-dev python3-pip python3-virtualenv python-pil libxml2-dev libxslt-dev unzip postgis osm2pgsql

# make osm2pgsql from source
if [[ ! -f "${OSM2PGSQL}" ]]; then
git clone git://github.com/openstreetmap/osm2pgsql.git
cd osm2pgsql
git checkout tags/1.5.1
sudo DEBIAN_FRONTEND=noninteractive sudo apt install -y -q 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 pandoc
mkdir build && cd build
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF
make
sudo make install
cd ../..
fi

# if there's no planet, then download it
if [[ ! -f "planet/${PLANET_FILE}" ]]; then
echo "downloading planet" > $STATUS
Expand Down Expand Up @@ -112,7 +127,7 @@ ntuples=`psql -t -c "select sum(n_live_tup) from pg_stat_user_tables where relna
if [[ $ntuples -eq 0 ]]; then
# no existing data => run osm2pgsql!
echo "running osm2pgsql" > $STATUS
(cd vector-datasource && $OSM2PGSQL --slim --hstore-all -C 61440 -S osm2pgsql.style -d "$PGDATABASE" -U "$PGUSER" -H "$PGHOST" --flat-nodes ../flat.nodes --number-processes 16 "../planet/${PLANET_FILE}")
(cd vector-datasource && $OSM2PGSQL --slim --hstore-all -C 61440 -S osm2pgsql.lua -O flex -d "$PGDATABASE" -U "$PGUSER" -H "$PGHOST" --flat-nodes ../flat.nodes --number-processes 16 "../planet/${PLANET_FILE}")
fi

# if flat nodes file already exists in S3, don't upload it again
Expand Down

0 comments on commit a675c97

Please sign in to comment.