Skip to content

Commit 444bbeb

Browse files
committed
Switch flex config files from hstore to jsonb
The jsonb data type is built into PostgreSQL, no hstore extension is needed. It is more flexible and there are more functions to extract data from it.
1 parent 189fcbb commit 444bbeb

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

flex-config/attributes.lua

Lines changed: 3 additions & 3 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' },

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- your database (created with something like `CREATE SCHEMA myschema;`).
88

99
local dtable = osm2pgsql.define_way_table('data', {
10-
{ column = 'tags', type = 'hstore' },
10+
{ column = 'tags', type = 'jsonb' },
1111
{ column = 'geom', type = 'geometry' },
1212
}, { schema = 'myschema' })
1313

0 commit comments

Comments
 (0)