Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
ec53591
Create Region table
opatut Mar 12, 2023
7e51976
Import regions from administrative boundaries
opatut Mar 12, 2023
78561d5
Add route to expose region stats
opatut Mar 12, 2023
bea4174
Do not generate roads and events for tiles at low zoom levels
opatut Mar 12, 2023
3a97b07
Add tile layer for regions with event count
opatut Mar 12, 2023
382db5a
Expose OBS map source for all zoom levels
opatut Mar 12, 2023
7ae4ebe
Show region stats on home page
opatut Mar 12, 2023
518bcd8
Show regions on map page, and move on-click info panel into a proper …
opatut Mar 12, 2023
e0070fc
Merge branch 'administrative-area-import' into next
opatut Mar 12, 2023
6d71b88
Translate region frontend
opatut Mar 12, 2023
215801f
Regions: Fix migration order
opatut Mar 12, 2023
78dca14
Fix naming of AUTO_RELOAD/AUTO_RESTART
opatut Sep 16, 2022
b9aaf23
Clean up sanic logging
opatut Sep 16, 2022
ed272b4
Use TTY in development docker to get line-buffered prints
opatut Sep 16, 2022
84ab957
fix cors by implementing it ourselves
opatut Sep 16, 2022
6c458a4
Raise maximum on track page limit
opatut Sep 16, 2022
56905fd
Install stream-zip
opatut Sep 26, 2022
5a78d7e
Parse device identifiers and create UserDevice entries in database
opatut Sep 16, 2022
cbab83e
Build awesome "My Tracks" table with filters and sorting
opatut Sep 22, 2022
4fe7d45
Bulk update operations on tracks
opatut Sep 22, 2022
141460c
Split settings page
opatut Nov 27, 2022
2c27a2c
Pin sqlalchemy better
opatut Mar 12, 2023
61b74e9
wip:Build devices page
opatut Mar 12, 2023
0d44560
Merge branch 'device-identifiers' into next
opatut Mar 12, 2023
665816c
Fix map size when sidebar is open
opatut Mar 12, 2023
fa29deb
Fix that bug sonarcloud is moaning about.
gluap Mar 12, 2023
b6cf59a
fix requirements.txt
gluap Mar 21, 2023
a7566fb
restrict to admin_level 6
gluap Mar 25, 2023
9882b20
update what can be updated without breaking stuff.
gluap Mar 25, 2023
df0466c
as discussed with paul: This makes the region lookup smooth.
gluap Mar 26, 2023
eda3bf2
Make menu stackable on mobile
boldt Mar 26, 2023
cf8358d
fix the road_usage issue dennis found.
gluap Mar 26, 2023
de8d371
Include device count in stats
opatut Mar 30, 2023
276a2dd
Remove HSTORE tags column from region table
opatut Mar 26, 2023
69d7f64
Add import_group columns for OSM data tables
opatut Mar 26, 2023
4c1c95e
Add chunk utility
opatut Mar 26, 2023
59f074c
New import pipeline with a PBF conversion step
opatut Mar 26, 2023
ac90d50
Remove lean mode
opatut Mar 26, 2023
c4cc4a9
Docs for new pipeline
opatut Mar 26, 2023
761908a
Move deployment readme to docs/
opatut Mar 26, 2023
0a18cda
Remove osm2pgsql
opatut Mar 26, 2023
e13bc75
Update Dockerfile
gluap Mar 28, 2023
39d90b3
Update 35e7f1768f9b_create_table_road.py
gluap Mar 28, 2023
dd912bc
`np.float` was a deprecated alias for the builtin `float`. To avoid t…
gluap Mar 28, 2023
8ce5816
enable importing and dumping also regions - in the same epsg geometry…
gluap Mar 29, 2023
10f6b0c
make sure we generate the right geometry column type and stay with th…
gluap Mar 29, 2023
6fb5dfe
Fix index names on geometry tables and add way_id/relation_id indexes
opatut Mar 30, 2023
0d9ddf4
Use logging in import_osm
opatut Mar 30, 2023
ce8054b
Use NUTS for region import, not OSM
opatut Mar 31, 2023
dd72ed7
Use ESPG 3857 for all geometry columns
opatut Apr 1, 2023
251be4a
Fix bearings on road info, and German words for those
opatut Apr 1, 2023
5108eb0
Update scripts to latest version to avoid version conflicts
gluap Apr 1, 2023
10fd028
exclude newest websockets versions that kill sanic.
gluap Apr 10, 2023
dc89db5
fix typo in column name...
gluap Apr 10, 2023
a66d965
fix downgrade step of event geometry transform.
gluap Apr 10, 2023
c359d94
the current version of region does not have that column - furthermore…
gluap Apr 10, 2023
56c9d2e
don't die if no argv is supplied.
gluap Apr 10, 2023
fb3e8bf
log10(0) is not defined - also: make region borders less intrusive fo…
gluap Apr 10, 2023
a946ea5
Add bulk downloading
gluap Apr 11, 2023
7e44f6d
implement comments from review; slow fade-in of events
gluap May 4, 2023
1c53230
chore: fix log import
opatut May 12, 2023
612a443
make the tar strip the common parts of the directory structure.
gluap May 12, 2023
dd2e995
generate proper filenames for bulk download, and use that as base fol…
opatut May 13, 2023
c249b16
Add semaphore to limit simultaneous requests to tile data
opatut May 13, 2023
d3fbb11
Fix export bounding box ESPG id
opatut May 13, 2023
a6811d4
Also add semaphore for exports
opatut May 13, 2023
7ff88ab
Add the possibility to export road usage (without temporal filtering)
gluap May 18, 2023
41ce56a
restore `.env` which was lost (probably due to gitignore)
gluap May 19, 2023
edc3c37
fix openid logout (wasn't working with old keycloak anyhow, but this …
gluap May 19, 2023
0766467
Merge branch 'next' into next-semaphore
gluap May 19, 2023
de029fa
Merge branch 'next-semaphore' into next-semaphore-with-road-usage
gluap May 19, 2023
e1763e0
chore: upgrade python in containers.
gluap May 19, 2023
d8e8d9a
Merge pull request #337 from openbikesensor/next-semaphore
gluap May 25, 2023
497e1b7
Add a first shot at upgrade documentation (WIP)
gluap May 25, 2023
da82303
implement reviewer comments
gluap May 29, 2023
b1cfd30
Merge pull request #341 from openbikesensor/next-semaphore-with-road-…
gluap May 29, 2023
0233045
import in chunks to avoid smaller systems chocking
gluap Jun 10, 2023
7dd6b68
fix percentage logging
gluap Jun 10, 2023
4a87489
documentation update after dancing the dance on obs.adfc-hessen.de
gluap Jun 10, 2023
1a1232f
up openmaptiles version (7.0 has been running on adfc-hessen for ages…
gluap Jun 10, 2023
4376509
fix issue when displaying mapdetails (newer numpy deprecates numpy.bo…
gluap Jun 10, 2023
c897412
Merge pull request #343 from openbikesensor/next-document-upgrade
gluap Jun 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.8.0

### Features

* Bulk actions on users owned tracks (reprocess, download, make private, make public, delete) (#269, #38)
* Easy sorting by device for "multi-device users" (e.g. group lending out OBSes)
* Region display at higher zoom levels to easily find interesting areas (#112)
* Export of road statistics on top of the already-existing event statistics (#341)

### Improvements

* Refactored database access to hopefully combat portal crashes (#337)
* New infrastructure for map imports that makes import of larger maps possible on small VMs (#334)
* Reference current postgres and postgis versions in docker-compose.yaml files (#286)
* Configurable terms-and-conditions link (#320)
* French translation by @cbiteau (#303)

### Bug Fixes

* Logout not working (#285)
* Duplicate road usage hashes (#335, #253)
* cannot import name .... (#338)

## 0.7.0

### Features
Expand Down
45 changes: 1 addition & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
#############################################
Expand All @@ -60,7 +21,7 @@ RUN npm run build
# Build the API and add the built frontend to it
#############################################

FROM python:3.9.7-bullseye
FROM python:3.11.3-bullseye

RUN apt-get update &&\
apt-get install -y \
Expand Down Expand Up @@ -93,11 +54,7 @@ ADD api/obs /opt/obs/api/obs/
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

Expand Down
69 changes: 8 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ git submodule update --init --recursive

## Production setup

There is a guide for a deployment based on docker in the
[deployment](deployment) folder. Lots of non-docker deployment strategy are
possible, but they are not "officially" supported, so please do not expect the
authors of the software to assist in troubleshooting.
There is a guide for a deployment based on docker at
[docs/production-deployment.md](docs/production-deployment.md). Lots of
non-docker deployment strategies are possible, but they are not "officially"
supported, so please do not expect the authors of the software to assist in
troubleshooting.

This is a rather complex application, and it is expected that you know the
basics of deploying a modern web application securely onto a production server.
Expand All @@ -52,7 +53,8 @@ Please note that you will always need to install your own reverse proxy that
terminates TLS for you and handles certificates. We do not support TLS directly
in the application, instead, please use this prefered method.

Upgrading and migrating is descrube
Upgrading and migrating is described in [UPGRADING.md](./UPGRADING.md) for each
version.

### Migrating (Production)

Expand All @@ -75,18 +77,6 @@ docker-compose run --rm api alembic upgrade head
docker-compose run --rm api tools/prepare_sql_tiles
```


docker-compose run --rm api alembic upgrade head

### Upgrading from v0.2 to v0.3

After v0.2 we switched the underlying technology of the API and the database.
We now have no more MongoDB, instead, everything has moved to the PostgreSQL
installation. For development setups, it is advised to just reset the whole
state (remove the `local` folder) and start fresh. For production upgrades,
please follow the relevant section in [`UPGRADING.md`](./UPGRADING.md).


## Development setup

We've moved the whole development setup into Docker to make it easy for
Expand All @@ -101,7 +91,6 @@ Then clone the repository as described above.

### Configure Keycloak


Login will not be possible until you configure the keycloak realm correctly. Boot your keycloak instance:

```bash
Expand Down Expand Up @@ -164,7 +153,7 @@ You will need to re-run this command after updates, to migrate the database and
(re-)create the functions in the SQL database that are used when generating
vector tiles.

You should also import OpenStreetMap data now, see below for instructions.
You should also [import OpenStreetMap data](docs/osm-import.md) now.

### Boot the application

Expand All @@ -190,48 +179,6 @@ docker-compose run --rm api alembic upgrade head
```


## Import OpenStreetMap data

**Hint:** This step may be skipped if you are using [Lean mode](./docs/lean-mode.md).

You need to import road information from OpenStreetMap for the portal to work.
This information is stored in your PostgreSQL database and used when processing
tracks (instead of querying the Overpass API), as well as for vector tile
generation. The process applies to both development and production setups. For
development, you should choose a small area for testing, such as your local
county or city, to keep the amount of data small. For production use you have
to import the whole region you are serving.

* Install `osm2pgsql`.
* Download the area(s) you would like to import from [GeoFabrik](https://download.geofabrik.de).
* Import each file like this:

```bash
osm2pgsql --create --hstore --style roads_import.lua -O flex \
-H localhost -d obs -U obs -W \
path/to/downloaded/myarea-latest.osm.pbf
```

You might need to adjust the host, database and username (`-H`, `-d`, `-U`) to
your setup, and also provide the correct password when queried. For the
development setup the password is `obs`. For production, you might need to
expose the containers port and/or create a TCP tunnel, for example with SSH,
such that you can run the import from your local host and write to the remote
database.

The import process should take a few seconds to minutes, depending on the area
size. A whole country might even take one or more hours. You should probably
not try to import `planet.osm.pbf`.

You can run the process multiple times, with the same or different area files,
to import or update the data. However, for this to work, the actual [command
line arguments](https://osm2pgsql.org/doc/manual.html#running-osm2pgsql) are a
bit different each time, including when first importing, and the disk space
required is much higher.

Refer to the documentation of `osm2pgsql` for assistance. We are using "flex
mode", the provided script `roads_import.lua` describes the transformations
and extractions to perform on the original data.

## Troubleshooting

Expand Down
33 changes: 28 additions & 5 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# Upgrading

This document describes the general steps to upgrade between major changes.
Simple migrations, e.g. for adding schema changes, are not documented
explicitly. Their general usage is described in the [README](./README.md) (for
development) and [deployment/README.md](deployment/README.md) (for production).
development) and [docs/production-deployment.md](docs/production-deployment.md) (for production).


## 0.8.0
Upgrade to `0.7.x` first. See below for details. Then follow these steps:

> **Warning** The update includes a reprocessing of tracks after import. Depending on the number of tracks this can take a few hours. The portal is reachable during that time but events disappear and incrementally reappear during reimport.

> **Info** With this version the import process for OpenStreetMap data has changed: the [new process](docs/osm-import.md) is easier on resources and finally permits to import a full country on a low-end VM.

- Do your [usual backup](docs/production-deployment.md)
- get the release in your source folder (``git pull; git checkout 0.8.0`` and update submodules ``git submodule update --recursive``)
- Rebuild images ``docker-compose build``
- Stop your portal and worker services ``docker-compose stop worker portal``
- run upgrade
```bash
docker-compose run --rm portal tools/upgrade.py
```
this automatically does the following
- Migration of database schema using alembic.
- Upgrade of SQL tile schema to new schema.
- Import the nuts-regions from the web into the database.
- Trigger a re-import of all tracks.
- Start your portal and worker services. ``docker-compose up -d worker portal``


## 0.7.0

Expand Down Expand Up @@ -57,7 +80,7 @@ You can, but do not have to, reimport all tracks. This will generate a GPX file
for each track and allow the users to download those. If a GPX file has not yet
been created, the download will fail. To reimport all tracks, log in to your
PostgreSQL database (instructions are in [README.md](./README.md) for
development and [deployment/README.md](./deployment/README.md) for production)
development and [docs/production-deployment.md](./docs/production-deployment.md) for production)
and run:

```sql
Expand All @@ -77,7 +100,7 @@ Make sure your worker is running to process the queue.
`POSTGRES_MAX_OVERFLOW`. Check the example config for sane default values.
* Re-run `tools/prepare_sql_tiles.py` again (see README)
* It has been made easier to import OSM data, check
[deployment/README.md](deployment/README.md) for the sections "Download
[docs/production-deployment.md](./docs/production-deployment.md) for the sections "Download
OpenStreetMap maps" and "Import OpenStreetMap data". You can now download
multiple .pbf files and then import them at once, using the docker image
built with the `Dockerfile`. Alternatively, you can choose to enable [lean
Expand Down Expand Up @@ -132,5 +155,5 @@ Make sure your worker is running to process the queue.
`export/users.json` into your realm, it will re-add all the users from the
old installation. You should delete the file and `export/` folder afterwards.
* Start `portal`.
* Consider configuring a worker service. See [deployment/README.md](deployment/README.md).
* Consider configuring a worker service. See [docs/production-deployment.md](./docs/production-deployment.md).

2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.7-bullseye
FROM python:3.11.3-bullseye

WORKDIR /opt/obs/api

Expand Down
5 changes: 3 additions & 2 deletions api/config.dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
PORT = 3000
DEBUG = True
VERBOSE = False
AUTO_RESTART = True
AUTO_RELOAD = True
SECRET = "!!!!!!!!!!!!CHANGE ME!!!!!!!!!!!!"
LEAN_MODE = False
POSTGRES_URL = "postgresql+asyncpg://obs:obs@postgres/obs"
POSTGRES_POOL_SIZE = 20
POSTGRES_MAX_OVERFLOW = 2 * POSTGRES_POOL_SIZE
Expand All @@ -30,5 +29,7 @@
"http://localhost:8880/", # for maputnik on 8880
"http://localhost:8888/", # for maputnik on 8888
]
TILE_SEMAPHORE_SIZE = 4
EXPORT_SEMAPHORE_SIZE = 4

# vim: set ft=python :
16 changes: 10 additions & 6 deletions api/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ PORT = 3000
# Extended log output, but slower
DEBUG = False
VERBOSE = DEBUG
AUTO_RESTART = DEBUG

# Turn on lean mode to simplify the setup. Lots of features will be
# unavailable, but you will not need to manage OpenStreetMap data. Please make
# sure to configure the OBS_FACE_CACHE_DIR correctly for lean mode.
LEAN_MODE = False
AUTO_RELOAD = DEBUG

# Required to encrypt or sign sessions, cookies, tokens, etc.
SECRET = "!!!<<<CHANGEME>>>!!!"
Expand Down Expand Up @@ -66,4 +61,13 @@ TILES_FILE = None
# default. Python list, or whitespace separated string.
ADDITIONAL_CORS_ORIGINS = None

# How many asynchronous requests may be sent to the database to generate tile
# information. Should be less than POSTGRES_POOL_SIZE to leave some connections
# to the other features of the API ;)
TILE_SEMAPHORE_SIZE = 4

# How many asynchronous requests may generate exported data simultaneously.
# Keep this small.
EXPORT_SEMAPHORE_SIZE = 1

# vim: set ft=python :
11 changes: 7 additions & 4 deletions api/migrations/versions/35e7f1768f9b_create_table_road.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ def upgrade():
op.create_table(
"road",
sa.Column(
"way_id", sa.BIGINT, autoincrement=True, primary_key=True, index=True
"way_id", sa.BIGINT, primary_key=True, index=True, autoincrement=False
),
sa.Column("zone", dbtype("zone_type")),
sa.Column("name", sa.String),
sa.Column("geometry", dbtype("GEOMETRY"), index=True),
sa.Column("name", sa.Text),
sa.Column("geometry", dbtype("geometry(LINESTRING,3857)")),
sa.Column("directionality", sa.Integer),
sa.Column("oenway", sa.Boolean),
sa.Column("oneway", sa.Boolean),
)
op.execute(
"CREATE INDEX road_geometry_idx ON road USING GIST (geometry) WITH (FILLFACTOR=100);"
)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""transform overtaking_event geometry to 3857

Revision ID: 587e69ecb466
Revises: f4b0f460254d
Create Date: 2023-04-01 14:30:49.927505

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "587e69ecb466"
down_revision = "f4b0f460254d"
branch_labels = None
depends_on = None


def upgrade():
op.execute("UPDATE overtaking_event SET geometry = ST_Transform(geometry, 3857);")
op.execute(
"ALTER TABLE overtaking_event ALTER COLUMN geometry TYPE geometry(POINT, 3857);"
)


def downgrade():
op.execute(
"ALTER TABLE overtaking_event ALTER COLUMN geometry TYPE geometry;"
)
op.execute("UPDATE overtaking_event SET geometry = ST_Transform(geometry, 4326);")
Loading