You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create you database with osm2pgsql, using the script `geometries-alone.lua` in this folder.
10
+
### 1. View for a new, dedicated, updatable and complete DB
11
11
12
-
Example command :
12
+
This view is configured to be a true alternative to overpass, in the sense that there is no filtering on the elements included in the DB. They are all included in the DB with all their tags, whereas osm2pgsql is usually configured not to include tags or elements that are useless for generating tiles.
13
13
14
+
Warning : this wiew will not work on an existing osm2pgsql database (see below). It is specific for a database created with the lua script above and the `-s (--slim)` option.
15
+
16
+
Create you database with osm2pgsql, using the script `geometries-alone.lua` available in this folder.
-`-c -s -x`: create an updatable table including metadata
26
+
-`--flat-nodes FILE --middle-with-nodes`: use the file `FILE` to store nodes (to reduce the size of the DB), but nodes with tags are also stored in the database (so that filtering by tag will be possible on nodes)
27
+
-`-O flex -S geometries-alone.lua`: use flex output mode with specific `.lua` file
CREATE INDEX nodes_tags_idx ON planet_osm_nodes USING GIN (tags);
32
+
CREATE INDEX ways_tags_idx ON planet_osm_ways USING GIN (tags);
33
+
CREATE INDEX rels_tags_idx ON planet_osm_rels USING GIN (tags);
16
34
```
17
35
18
-
Warning : this backend will not work on a existing osm2pgsql database. it is specific for a database created with the lua script above and the `-s (--slim)` option.
36
+
Use `osm2pgsql-replication` to update the DB.
37
+
38
+
Sizing
39
+
- 57GB for France (29GB for middle tables (metadata+tags) + 2GB for tag index + 26GB for output tables (geometries))
19
40
20
41
If your database was created "outside" docker, you will have to modify `docker-compose.yaml` to:
21
42
- delete services `osm2pgsql` and `postgress`
22
43
- in service api : delete reference `depends on: -postgres` and set your `DATABASE_URL: postgres://user:pw@host:5432/database`
23
44
45
+
Explanation of the `.lua` script and principle of the DB structure:
46
+
-`-s` option creates `middle` tables which include all raw OSM elements (`planet_osm_nodes`, `planet_osm_ways`, `planet_osm_rels`) with all their tags. This view uses these 3 tables to get tags (no need to duplicate them in `output` tables), but we need to manually index them at the beginning.
47
+
-`-x` option add columns for metadata in these tables, and table `planet_osm_users` for usernames.
48
+
- so only the geometries are missing. The `.lua` script of the `flex output` creates 3 additionnal `output` tables: `nodes_geom`, `ways_geom` and `rels_geom` with the id and the geometry.
49
+
- I had to use tables by element type instead of geometry type (as usual for osm2pgsql) since the negative id used for relations in area type table is problematic for the join with the `planet_osm_rels` table which uses normal positive id (join is slow since indexing is not working).
50
+
- For a list of expected areas (as usual in osm2pgsql), the lua script creates polygon-like geometries (instead of line-like) and adds the area size in a 3rd column (it will be usefull to get areas).
51
+
52
+
### 2. View for an existing DB created for cartocss
53
+
54
+
not written yet
55
+
56
+
### 3. View for a simple static DB (without synchronisation)
- without the --slim option, only "output" tables are created (PREFIX_point PREFIX_line and PREFIX_polygon in the case of the deprecated pgsql output) and they contain elements filtered based on their tags (using list and parameters in .style file). These tables also contain the geometry.
4
-
- with --slim, 3 other "middle" tables containing ALL the raw OSM elements are created : _nodes, _ways, _rels
3
+
This view is specific for a new database created with flex output geometries-alone.lua
5
4
*/
6
5
7
-
/************** ABOUT GEOMETRY *****************/
8
-
/*
9
-
Underpass as Overpass uses SRID 4326 whereas osm2pgsql uses by default SRID 3857
10
-
To make Underpass works on your osm2pgsl database, you have to CREATE it with option --proj=4326 (for the case of deprecated pgsql output) or define that the tables will use SRID 4326 (for the case of the modern flex output)
11
-
If you want to deploy Underpass on an existing osm2pgsl database, you will have to modify both this backend and overpass_parser-rb, so that the parser transforms bbox and areas and others in SRID 3857 to allow comparison with the geom in your DB
12
-
*/
13
6
14
-
/************** ABOUT TAGS COLUMNS *****************/
7
+
/************** ABOUT TABLES *****************/
15
8
/*
16
-
- tags in "middle" tables _nodes, _ways, _rels are identical to the ones in OSM (they are "raw data" tables)
17
-
- but tags in "output" tables are always (slightly) different depending on the hstore options:
18
-
# With --hstore any tags without a column will be added to the hstore column.
19
-
# With --hstore-all all tags are added to the hstore column unless they appear in the style file with a delete flag
9
+
The flex output lua script creates:
10
+
- the 3 normal "middle" tables planet_osm_nodes, _ ways and _rels which include (all ans synchronised) OSM elements with (all) their tags and metadata. (tags need to be indexed after DB creation). And also _users table
11
+
- 3 additionnal "output" tables to store the geometries using SRID 4326 (to be compatible with overpass). 1 table per element type : nodes_geom, ways_geom and rels_geom
12
+
- the views join middle table (tags) with the corresponding output table (geometry) and also with users table (username)
20
13
*/
21
14
22
-
/************** ABOUT METADATA *****************/
23
-
/* adding metadata to the DB requires -x option */
24
-
/* without it, all the CAST(tags->...) will return NULL */
0 commit comments