Skip to content

Commit 9b2b67b

Browse files
committed
Add recommended indexes for Carto style (thanks @souladm)
1 parent d7c2817 commit 9b2b67b

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ RUN chown -R postgres:postgres /var/lib/postgresql \
140140

141141
# Start running
142142
COPY run.sh /
143+
COPY indexes.sql /
143144
ENTRYPOINT ["/run.sh"]
144145
CMD []
145146

indexes.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- Extracted from https://github.com/gravitystorm/openstreetmap-carto
2+
-- Comes with a CC0 license
3+
4+
-- These are optional but suggested indexes for rendering OpenStreetMap Carto
5+
-- with a full planet database.
6+
-- This file is generated with scripts/indexes.py
7+
8+
CREATE INDEX planet_osm_roads_admin
9+
ON planet_osm_roads USING GIST (way)
10+
WHERE boundary = 'administrative';
11+
CREATE INDEX planet_osm_roads_roads_ref
12+
ON planet_osm_roads USING GIST (way)
13+
WHERE highway IS NOT NULL AND ref IS NOT NULL;
14+
CREATE INDEX planet_osm_roads_admin_low
15+
ON planet_osm_roads USING GIST (way)
16+
WHERE boundary = 'administrative' AND admin_level IN ('0', '1', '2', '3', '4');
17+
CREATE INDEX planet_osm_line_ferry
18+
ON planet_osm_line USING GIST (way)
19+
WHERE route = 'ferry';
20+
CREATE INDEX planet_osm_line_river
21+
ON planet_osm_line USING GIST (way)
22+
WHERE waterway = 'river';
23+
CREATE INDEX planet_osm_line_name
24+
ON planet_osm_line USING GIST (way)
25+
WHERE name IS NOT NULL;
26+
CREATE INDEX planet_osm_polygon_water
27+
ON planet_osm_polygon USING GIST (way)
28+
WHERE waterway IN ('dock', 'riverbank', 'canal')
29+
OR landuse IN ('reservoir', 'basin')
30+
OR "natural" IN ('water', 'glacier');
31+
CREATE INDEX planet_osm_polygon_nobuilding
32+
ON planet_osm_polygon USING GIST (way)
33+
WHERE building IS NULL;
34+
CREATE INDEX planet_osm_polygon_name
35+
ON planet_osm_polygon USING GIST (way)
36+
WHERE name IS NOT NULL;
37+
CREATE INDEX planet_osm_polygon_way_area_z10
38+
ON planet_osm_polygon USING GIST (way)
39+
WHERE way_area > 23300;
40+
CREATE INDEX planet_osm_polygon_military
41+
ON planet_osm_polygon USING GIST (way)
42+
WHERE (landuse = 'military' OR military = 'danger_area') AND building IS NULL;
43+
CREATE INDEX planet_osm_polygon_way_area_z6
44+
ON planet_osm_polygon USING GIST (way)
45+
WHERE way_area > 5980000;
46+
CREATE INDEX planet_osm_point_place
47+
ON planet_osm_point USING GIST (way)
48+
WHERE place IS NOT NULL AND name IS NOT NULL;

run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ if [ "$1" = "import" ]; then
3838

3939
# Import data
4040
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script /home/renderer/src/openstreetmap-carto/openstreetmap-carto.lua -C 2048 --number-processes ${THREADS:-4} -S /home/renderer/src/openstreetmap-carto/openstreetmap-carto.style /data.osm.pbf
41+
42+
# Create indexes
43+
sudo -u postgres psql -d gis -f indexes.sql
44+
4145
service postgresql stop
4246

4347
exit 0

0 commit comments

Comments
 (0)