Skip to content

Commit 165065e

Browse files
authored
Merge pull request #1496 from joto/flex-config
Flex config
2 parents 17ddb99 + ab49944 commit 165065e

File tree

9 files changed

+34
-31
lines changed

9 files changed

+34
-31
lines changed

flex-config/attributes.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local srid = 4326
1111
local tables = {}
1212

1313
tables.points = osm2pgsql.define_node_table('points', {
14-
{ column = 'tags', type = 'hstore' },
14+
{ column = 'tags', type = 'jsonb' },
1515
{ column = 'geom', type = 'point', projection = srid },
1616
{ column = 'version', type = 'int' },
1717
{ column = 'changeset', type = 'int' },
@@ -21,7 +21,7 @@ tables.points = osm2pgsql.define_node_table('points', {
2121
})
2222

2323
tables.lines = osm2pgsql.define_way_table('lines', {
24-
{ column = 'tags', type = 'hstore' },
24+
{ column = 'tags', type = 'jsonb' },
2525
{ column = 'geom', type = 'linestring', projection = srid },
2626
{ column = 'version', type = 'int' },
2727
{ column = 'changeset', type = 'int' },
@@ -31,7 +31,7 @@ tables.lines = osm2pgsql.define_way_table('lines', {
3131
})
3232

3333
tables.relations = osm2pgsql.define_relation_table('relations', {
34-
{ column = 'tags', type = 'hstore' },
34+
{ column = 'tags', type = 'jsonb' },
3535
{ column = 'version', type = 'int' },
3636
{ column = 'changeset', type = 'int' },
3737
{ column = 'created', type = 'timestamp' },
@@ -48,7 +48,7 @@ function osm2pgsql.process_node(object)
4848
tags = object.tags,
4949
version = object.version,
5050
changeset = object.changeset,
51-
created = os.date('!%Y-%m-%dT%TZ', object.timestamp),
51+
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
5252
uid = object.uid,
5353
user = object.user
5454
})
@@ -59,7 +59,7 @@ function osm2pgsql.process_way(object)
5959
tags = object.tags,
6060
version = object.version,
6161
changeset = object.changeset,
62-
created = os.date('!%Y-%m-%dT%TZ', object.timestamp),
62+
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
6363
uid = object.uid,
6464
user = object.user
6565
})
@@ -70,7 +70,7 @@ function osm2pgsql.process_relation(object)
7070
tags = object.tags,
7171
version = object.version,
7272
changeset = object.changeset,
73-
created = os.date('!%Y-%m-%dT%TZ', object.timestamp),
73+
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
7474
uid = object.uid,
7575
user = object.user
7676
})

flex-config/data-types.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- This config example file is released into the Public Domain.
22

3-
-- This is a very simple Lua config for the Flex Backend not intended for
3+
-- This is a very simple Lua config for the Flex output not intended for
44
-- real-world use. Look at and understand "simple.lua" first, before looking
55
-- at this file. This file demonstrates some column data type options.
66

@@ -19,7 +19,7 @@ local highways = osm2pgsql.define_way_table('highways', {
1919

2020
-- type "bool" is special, see below
2121
{ column = 'lit', type = 'bool' },
22-
{ column = 'tags', type = 'hstore' },
22+
{ column = 'tags', type = 'jsonb' }, -- also available: 'json', 'hstore'
2323

2424
-- an PostgreSQL array type, not specially handled by osm2pgsql, see below
2525
{ column = 'nodes', type = 'int8[]' },

flex-config/generic.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22

33
-- This is a generic configuration that is a good starting point for
44
-- real-world projects. Data is split into tables according to geometry type
5-
-- and most tags are stored in hstore columns.
5+
-- and most tags are stored in jsonb columns.
66

77
-- Set this to the projection you want to use
88
local srid = 3857
99

1010
local tables = {}
1111

1212
tables.points = osm2pgsql.define_node_table('points', {
13-
{ column = 'tags', type = 'hstore' },
13+
{ column = 'tags', type = 'jsonb' },
1414
{ column = 'geom', type = 'point', projection = srid },
1515
})
1616

1717
tables.lines = osm2pgsql.define_way_table('lines', {
18-
{ column = 'tags', type = 'hstore' },
18+
{ column = 'tags', type = 'jsonb' },
1919
{ column = 'geom', type = 'linestring', projection = srid },
2020
})
2121

2222
tables.polygons = osm2pgsql.define_area_table('polygons', {
23-
{ column = 'tags', type = 'hstore' },
23+
{ column = 'tags', type = 'jsonb' },
2424
{ column = 'geom', type = 'geometry', projection = srid },
2525
{ column = 'area', type = 'area' },
2626
})
2727

2828
tables.routes = osm2pgsql.define_relation_table('routes', {
29-
{ column = 'tags', type = 'hstore' },
29+
{ column = 'tags', type = 'jsonb' },
3030
{ column = 'geom', type = 'multilinestring', projection = srid },
3131
})
3232

3333
tables.boundaries = osm2pgsql.define_relation_table('boundaries', {
34-
{ column = 'tags', type = 'hstore' },
34+
{ column = 'tags', type = 'jsonb' },
3535
{ column = 'geom', type = 'multilinestring', projection = srid },
3636
})
3737

flex-config/geometries.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
-- This config example file is released into the Public Domain.
22

3-
-- This is a very simple Lua config for the Flex Backend not intended for
3+
-- This is a very simple Lua config for the Flex output not intended for
44
-- real-world use. Look at and understand "simple.lua" first, before looking
55
-- at this file. This file will show some options around geometry processing.
66
-- After you have understood this file, go on to "data-types.lua".
77

88
local tables = {}
99

1010
tables.pois = osm2pgsql.define_node_table('pois', {
11-
{ column = 'tags', type = 'hstore' },
11+
{ column = 'tags', type = 'jsonb' },
1212
-- Create a geometry column for point geometries. The geometry will be
1313
-- in web mercator, EPSG 3857.
1414
{ column = 'geom', type = 'point' },
1515
})
1616

1717
tables.ways = osm2pgsql.define_way_table('ways', {
18-
{ column = 'tags', type = 'hstore' },
18+
{ column = 'tags', type = 'jsonb' },
1919
-- Create a geometry column for linestring geometries. The geometry will
2020
-- be in latlong (WGS84), EPSG 4326.
2121
{ column = 'geom', type = 'linestring', projection = 4326 },
2222
})
2323

2424
tables.polygons = osm2pgsql.define_area_table('polygons', {
25-
{ column = 'tags', type = 'hstore' },
25+
{ column = 'tags', type = 'jsonb' },
2626
{ column = 'geom', type = 'geometry' },
2727
-- The 'area' type is used to store the calculated area of a polygon
2828
-- feature. This can be used in style sheets to only render larger polygons
@@ -34,7 +34,7 @@ tables.polygons = osm2pgsql.define_area_table('polygons', {
3434

3535
tables.boundaries = osm2pgsql.define_relation_table('boundaries', {
3636
{ column = 'type', type = 'text' },
37-
{ column = 'tags', type = 'hstore' },
37+
{ column = 'tags', type = 'jsonb' },
3838
-- Boundaries will be stitched together from relation members into long
3939
-- linestrings. This is a multilinestring column because sometimes the
4040
-- boundaries are not contiguous.

flex-config/route-relations.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
local tables = {}
1313

1414
tables.highways = osm2pgsql.define_way_table('highways', {
15-
{ column = 'tags', type = 'hstore' },
15+
{ column = 'tags', type = 'jsonb' },
1616
{ column = 'rel_refs', type = 'text' }, -- for the refs from the relations
1717
{ column = 'rel_ids', type = 'int8[]' }, -- array with integers (for relation IDs)
1818
{ column = 'geom', type = 'linestring' },
1919
})
2020

2121
-- Tables don't have to have a geometry column
2222
tables.routes = osm2pgsql.define_relation_table('routes', {
23-
{ column = 'tags', type = 'hstore' },
23+
{ column = 'tags', type = 'jsonb' },
2424
})
2525

2626
-- This will be used to store information about relations queryable by member

flex-config/simple.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- This config example file is released into the Public Domain.
22

3-
-- This is a very simple Lua config for the Flex Backend not intended for
3+
-- This is a very simple Lua config for the Flex output not intended for
44
-- real-world use. Use it do understand the basic principles of the
55
-- configuration. After reading and understanding this, have a look at
66
-- "geometries.lua".
@@ -24,7 +24,7 @@ local tables = {}
2424
-- "append" mode, osm2pgsql will automatically update this table using the node
2525
-- ids.
2626
tables.pois = osm2pgsql.define_node_table('pois', {
27-
{ column = 'tags', type = 'hstore' },
27+
{ column = 'tags', type = 'jsonb' },
2828
{ column = 'geom', type = 'point' }, -- will be something like `GEOMETRY(Point, 4326)` in SQL
2929
})
3030

@@ -40,7 +40,7 @@ tables.restaurants = osm2pgsql.define_node_table('restaurants', {
4040
-- contain a "way_id" column. When running in "append" mode, osm2pgsql will
4141
-- automatically update this table using the way ids.
4242
tables.ways = osm2pgsql.define_way_table('ways', {
43-
{ column = 'tags', type = 'hstore' },
43+
{ column = 'tags', type = 'jsonb' },
4444
{ column = 'geom', type = 'linestring' },
4545
})
4646

@@ -50,7 +50,7 @@ tables.ways = osm2pgsql.define_way_table('ways', {
5050
-- running in "append" mode, osm2pgsql will automatically update this table
5151
-- using the way/relation ids.
5252
tables.polygons = osm2pgsql.define_area_table('polygons', {
53-
{ column = 'tags', type = 'hstore' },
53+
{ column = 'tags', type = 'jsonb' },
5454
-- The type of the `geom` column is `geometry`, because we need to store
5555
-- polygons AND multipolygons
5656
{ column = 'geom', type = 'geometry' },
@@ -95,7 +95,7 @@ function osm2pgsql.process_node(object)
9595
})
9696
else
9797
tables.pois:add_row({
98-
-- We know `tags` is of type `hstore` so this will do the
98+
-- We know `tags` is of type `jsonb` so this will do the
9999
-- right thing.
100100
tags = object.tags
101101
})

flex-config/unitable.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ local dtable = osm2pgsql.define_table{
1212
-- "osm_type CHAR(1)" for the type of object: N(ode), W(way), R(relation)
1313
ids = { type = 'any', id_column = 'osm_id', type_column = 'osm_type' },
1414
columns = {
15-
{ column = 'attrs', type = 'hstore' },
16-
{ column = 'tags', type = 'hstore' },
15+
{ column = 'attrs', type = 'jsonb' },
16+
{ column = 'tags', type = 'jsonb' },
1717
{ column = 'geom', type = 'geometry' },
1818
}
1919
}

flex-config/with-schema.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
-- This configuration for the flex output shows how to define a table in
44
-- a PostgreSQL schema.
5+
--
6+
-- This config file expects that you have a schema called `myschema` in
7+
-- your database (created with something like `CREATE SCHEMA myschema;`).
58

69
local dtable = osm2pgsql.define_way_table('data', {
7-
{ column = 'tags', type = 'hstore' },
10+
{ column = 'tags', type = 'jsonb' },
811
{ column = 'geom', type = 'geometry' },
912
}, { schema = 'myschema' })
1013

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ if (HAVE_LUA)
9898
set_test(test-output-flex-way-relation-del)
9999

100100
set_test(test-output-flex-example-configs)
101-
set(FLEX_EXAMPLE_CONFIGS "compatible,data-types,generic,geometries,route-relations,simple,unitable")
102-
# places.lua not tested because it needs dkjson package
101+
set(FLEX_EXAMPLE_CONFIGS "attributes,compatible,data-types,generic,geometries,places,route-relations,simple,unitable")
102+
# with-schema.lua is not tested because it needs the schema created in the database
103103
set_tests_properties(test-output-flex-example-configs PROPERTIES ENVIRONMENT "EXAMPLE_FILES=${FLEX_EXAMPLE_CONFIGS}")
104104
endif()
105105

0 commit comments

Comments
 (0)