Skip to content

Commit 3ae740f

Browse files
committed
First commit
0 parents  commit 3ae740f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+6097
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
t-rex-config.toml

.luacheckrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--
2+
-- Configuration for luacheck
3+
--
4+
5+
unused_args = false
6+
unused_secondaries = false
7+
8+
stds.osm2pgsql = {
9+
read_globals = {
10+
osm2pgsql = {
11+
fields = {
12+
process_node = {
13+
read_only = false
14+
},
15+
process_way = {
16+
read_only = false
17+
},
18+
process_relation = {
19+
read_only = false
20+
},
21+
select_relation_members = {
22+
read_only = false
23+
},
24+
process_gen = {
25+
read_only = false
26+
},
27+
},
28+
other_fields = true,
29+
}
30+
}
31+
}
32+
33+
std = 'min+osm2pgsql'
34+

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
2+
# Osm2pgsql Themepark
3+
4+
https://osm2pgsql.org/themepark/
5+
6+
THIS IS BETA SOFTWARE. EVERYTHING IN HERE IS SUBJECT TO CHANGE.
7+
8+
This is a framework for creating [osm2pgsql](https://osm2pgsql.org/)
9+
configurations assembled from many building blocks. Some of those blocks are
10+
provided in this repository, others you can add yourself. This way you don't
11+
have to start with a new configuration from scratch every time you build and
12+
style a new map. Instead you take those existing blocks that suit your needs
13+
and add new ones for those things that make your map special.
14+
15+
This framework makes use of the [flex
16+
output](https://osm2pgsql.org/doc/manual.html#the-flex-output) and it needs at
17+
least version 1.9.2 of osm2pgsql. See [the osm2pgsql installation
18+
documentation](https://osm2pgsql.org/doc/install.html) for how to install
19+
osm2pgsql.
20+
21+
When running osm2pgsql you'll always need the command line parameters `-O flex
22+
-S CONFIG.lua`. `CONFIG.lua` is the configuration file you are writing that
23+
makes use of this framework. Some example config files are provided in the
24+
`config` directory. Read the [User
25+
Manual](https://osm2pgsql.org/themepark/users-manual.html) for instructions on
26+
how to create one yourself.
27+
28+
## Plugins
29+
30+
The framework has support for plugins adding some functionality. They are in
31+
the `lua/themepark/plugins` directory.
32+
33+
Available plugins are:
34+
* `taginfo`: For creating [Taginfo project files]().
35+
* `tilekiln`: For creating a config file for the
36+
[Tilekiln](https://github.com/pnorman/tilekiln) tile server.
37+
* `t-rex`: For creating a config file for the
38+
[T-Rex](https://t-rex.tileserver.ch/) tile server.
39+
40+
## Themes
41+
42+
Themes provide building blocks for map data transformations. They usually
43+
contain some common code plus several *topics*; each topic usually provides the
44+
code to create one or more database tables which can then be used as a basis
45+
for a map layer.
46+
47+
You can write your own themes and topics, read the [Authors
48+
Manual](https://osm2pgsql.org/themepark/authors-manual.html) for details.
49+
50+
Several themes are available in this repository to get you going and support
51+
some common use cases.
52+
53+
### Theme `basic`
54+
55+
This theme contains some basic layers for testing and debugging. It can
56+
also be used as a jumping-off point for your own theme creation.
57+
58+
[More...](themes/basic/README.md)
59+
60+
### Theme `core`
61+
62+
The topics in this theme are not meant to be used on their own, but they
63+
provide common transformations which can be used with other themes and
64+
topics. This includes functionality for handling *names*.
65+
66+
[More...](themes/core/README.md)
67+
68+
### Theme `experimental`
69+
70+
These are some experimental layers. Use at your own risk.
71+
72+
[More...](themes/experimental/README.md)
73+
74+
### Theme `external`
75+
76+
This theme contains some layers not generated directly from OSM data but
77+
created from external sources, specifically data that can be downloaded from
78+
https://osmdata.openstreetmap.de/ .
79+
80+
[More...](themes/external/README.md)
81+
82+
### Theme `shortbread_v1`
83+
84+
Implements the [Shortbread (v1.0)
85+
schema](https://shortbread-tiles.org/schema/1.0). Data for low zoom levels
86+
are not generated.
87+
88+
[More...](themes/shortbread_v1/README.md)
89+
90+
### Theme `shortbread_v1_gen`
91+
92+
Implements the [Shortbread (v1.0)
93+
schema](https://shortbread-tiles.org/schema/1.0) with automated
94+
generalization for low zoom levels. This needs the experimental `osm2pgsql-gen`
95+
command provided with newer osm2pgsql versions.
96+
97+
[More...](themes/shortbread_v1_gen/README.md)
98+
99+
## License
100+
101+
Copyright 2023 Jochen Topf <[email protected]>
102+
103+
Licensed under the Apache License, Version 2.0 (the "License");
104+
you may not use this file except in compliance with the License.
105+
You may obtain a copy of the License at
106+
107+
https://www.apache.org/licenses/LICENSE-2.0
108+
109+
Unless required by applicable law or agreed to in writing, software
110+
distributed under the License is distributed on an "AS IS" BASIS,
111+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112+
See the License for the specific language governing permissions and
113+
limitations under the License.
114+
115+
## Author
116+
117+
This framework is written and maintained by Jochen Topf ([email protected]).
118+

bin/check-lua-scripts.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
#
3+
# Uses luacheck to check all Lua files
4+
#
5+
# Needs: https://github.com/mpeterv/luacheck (Debian package: lua-check)
6+
#
7+
8+
luacheck \
9+
lua/themepark.lua \
10+
lua/themepark/*.lua \
11+
lua/themepark/*/*.lua \
12+
config/*.lua \
13+
themes/*/*.lua \
14+
themes/*/topics/*.lua
15+

config/experimental.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
-- ---------------------------------------------------------------------------
2+
--
3+
-- Example config for experimental topics
4+
--
5+
-- Configuration for the osm2pgsql Themepark framework
6+
--
7+
-- ---------------------------------------------------------------------------
8+
9+
local themepark = require('themepark')
10+
11+
themepark.debug = false
12+
13+
-- ---------------------------------------------------------------------------
14+
15+
themepark:set_option('debug', 'debug') -- Add JSONB column `debug` with debug infos in debug mode
16+
themepark:set_option('tags', 'all_tags') -- Add JSONB column `tags` with original OSM tags in debug mode
17+
18+
-- ---------------------------------------------------------------------------
19+
20+
-- themepark:add_topic('core/clean-tags')
21+
22+
-- themepark:add_topic('core/name-single', { column = 'name' })
23+
-- themepark:add_topic('core/name-list', { keys = {'name', 'name:de', 'name:en'} })
24+
25+
themepark:add_topic('core/name-with-fallback', {
26+
keys = {
27+
name = { 'name', 'name:en', 'name:de' },
28+
name_de = { 'name:de', 'name', 'name:en' },
29+
name_en = { 'name:en', 'name', 'name:de' },
30+
}
31+
})
32+
33+
--themepark:add_topic('experimental/builtup')
34+
--themepark:add_topic('experimental/places')
35+
--themepark:add_topic('experimental/rivers')
36+
37+
themepark:add_topic('core/elevation')
38+
themepark:add_topic('experimental/information')
39+
themepark:add_topic('experimental/viewpoints')
40+
41+
-- ---------------------------------------------------------------------------
42+
43+
themepark:plugin('t-rex'):write_config('t-rex-config.toml', {})
44+
45+
-- ---------------------------------------------------------------------------

config/generic.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- ---------------------------------------------------------------------------
2+
--
3+
-- Example config for basic/generic topics
4+
--
5+
-- Configuration for the osm2pgsql Themepark framework
6+
--
7+
-- ---------------------------------------------------------------------------
8+
9+
local themepark = require('themepark')
10+
11+
themepark.debug = false
12+
13+
-- ---------------------------------------------------------------------------
14+
15+
themepark:add_topic('core/clean-tags')
16+
17+
themepark:add_topic('basic/generic-points')
18+
themepark:add_topic('basic/generic-lines')
19+
themepark:add_topic('basic/generic-polygons')
20+
themepark:add_topic('basic/generic-boundaries')
21+
themepark:add_topic('basic/generic-routes')
22+
23+
-- ---------------------------------------------------------------------------

config/nwr.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- ---------------------------------------------------------------------------
2+
--
3+
-- Example config for basic/nwr topic
4+
--
5+
-- Configuration for the osm2pgsql Themepark framework
6+
--
7+
-- ---------------------------------------------------------------------------
8+
9+
local themepark = require('themepark')
10+
11+
themepark.debug = false
12+
13+
-- ---------------------------------------------------------------------------
14+
15+
themepark:add_topic('core/clean-tags')
16+
17+
themepark:add_topic('basic/nwr')
18+
19+
-- ---------------------------------------------------------------------------

config/shortbread.lua

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- ---------------------------------------------------------------------------
2+
--
3+
-- Shortbread theme
4+
--
5+
-- Configuration for the osm2pgsql Themepark framework
6+
--
7+
-- ---------------------------------------------------------------------------
8+
9+
local themepark = require('themepark')
10+
11+
themepark.debug = false
12+
13+
-- Add JSONB column `tags` with original OSM tags in debug mode
14+
themepark:set_option('tags', 'all_tags')
15+
16+
-- ---------------------------------------------------------------------------
17+
18+
-- themepark:add_topic('core/name-single', { column = 'name' })
19+
-- themepark:add_topic('core/name-list', { keys = {'name', 'name:de', 'name:en'} })
20+
21+
themepark:add_topic('core/name-with-fallback', {
22+
keys = {
23+
name = { 'name', 'name:en', 'name:de' },
24+
name_de = { 'name:de', 'name', 'name:en' },
25+
name_en = { 'name:en', 'name', 'name:de' },
26+
}
27+
})
28+
29+
themepark:add_topic('core/layer')
30+
31+
themepark:add_topic('external/oceans', { name = 'ocean' })
32+
33+
themepark:add_topic('shortbread_v1/aerialways')
34+
themepark:add_topic('shortbread_v1/boundaries')
35+
themepark:add_topic('shortbread_v1/boundary_labels')
36+
themepark:add_topic('shortbread_v1/bridges')
37+
themepark:add_topic('shortbread_v1/buildings')
38+
themepark:add_topic('shortbread_v1/dams')
39+
themepark:add_topic('shortbread_v1/ferries')
40+
themepark:add_topic('shortbread_v1/land')
41+
themepark:add_topic('shortbread_v1/piers')
42+
themepark:add_topic('shortbread_v1/places')
43+
themepark:add_topic('shortbread_v1/pois')
44+
themepark:add_topic('shortbread_v1/public_transport')
45+
themepark:add_topic('shortbread_v1/sites')
46+
themepark:add_topic('shortbread_v1/streets')
47+
themepark:add_topic('shortbread_v1/water')
48+
49+
-- Must be after "pois" layer, because as per Shortbread spec addresses that
50+
-- are already in "pois" should not be in the "addresses" layer.
51+
themepark:add_topic('shortbread_v1/addresses')
52+
53+
-- ---------------------------------------------------------------------------
54+
55+
if osm2pgsql.mode == 'create' then
56+
themepark:plugin('t-rex'):write_config('t-rex-config.toml', {
57+
tileset = 'osm',
58+
})
59+
60+
-- themepark:plugin('tilekiln'):write_config('tk')
61+
62+
-- themepark:plugin('taginfo'):write_config('taginfo-shortbread', {
63+
-- project = { name = 'shortbread' }
64+
-- })
65+
end
66+
67+
-- ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)