Skip to content

Commit 4ff692f

Browse files
committed
Add optional options parameter to define_*_table() functions
This way users can keep using the simpler versions of the function in more cases.
1 parent 618b00d commit 4ff692f

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

docs/flex.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ following fields:
2828

2929
The following functions are defined:
3030

31-
* `osm2pgsql.define_node_table(name, columns)`: Define a node table.
32-
* `osm2pgsql.define_way_table(name, columns)`: Define a way table.
33-
* `osm2pgsql.define_relation_table(name, columns)`: Define a relation table.
34-
* `osm2pgsql.define_area_table(name, columns)`: Define an area table.
35-
* `osm2pgsql.define_table()`: Define a table. This is the more flexible
31+
* `osm2pgsql.define_node_table(name, columns[, options])`: Define a node table.
32+
* `osm2pgsql.define_way_table(name, columns[, options])`: Define a way table.
33+
* `osm2pgsql.define_relation_table(name, columns[, options])`: Define a relation
34+
table.
35+
* `osm2pgsql.define_area_table(name, columns[, options])`: Define an area table.
36+
* `osm2pgsql.define_table(options)`: Define a table. This is the more flexible
3637
function behind all the other `define_*_table()` functions. It gives you
3738
more control than the more convenient other functions.
3839
* `osm2pgsql.mark_way(id)`: Mark the OSM way with the specified id. This way

flex-config/with-schema.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
-- This configuration for the flex output shows how to define a table in
33
-- a PostgreSQL schema.
44

5-
local dtable = osm2pgsql.define_table{
6-
name = "data",
7-
schema = "myschema",
8-
ids = { type = 'way', id_column = 'way_id' },
9-
columns = {
5+
local dtable = osm2pgsql.define_way_table('data', {
106
{ column = 'attrs', type = 'hstore' },
117
{ column = 'tags', type = 'hstore' },
128
{ column = 'geom', type = 'geometry' },
13-
}
14-
}
9+
}, { schema = 'myschema' })
1510

1611
function osm2pgsql.process_way(object)
1712
dtable:add_row({

src/init.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55

66
local math = require('math')
77

8-
local _define_table_impl = function (_type, _name, _columns)
9-
return osm2pgsql.define_table{
10-
name = _name,
11-
ids = { type = _type, id_column = _type .. '_id' },
12-
columns = _columns,
13-
}
8+
local _define_table_impl = function(_type, _name, _columns, _options)
9+
_options = _options or {}
10+
_options.name = _name
11+
_options.ids = { type = _type, id_column = _type .. '_id' }
12+
_options.columns = _columns
13+
return osm2pgsql.define_table(_options)
1414
end
1515

16-
function osm2pgsql.define_node_table(_name, _columns)
17-
return _define_table_impl('node', _name, _columns)
16+
function osm2pgsql.define_node_table(_name, _columns, _options)
17+
return _define_table_impl('node', _name, _columns, _options)
1818
end
1919

20-
function osm2pgsql.define_way_table(_name, _columns)
21-
return _define_table_impl('way', _name, _columns)
20+
function osm2pgsql.define_way_table(_name, _columns, _options)
21+
return _define_table_impl('way', _name, _columns, _options)
2222
end
2323

24-
function osm2pgsql.define_relation_table(_name, _columns)
25-
return _define_table_impl('relation', _name, _columns)
24+
function osm2pgsql.define_relation_table(_name, _columns, _options)
25+
return _define_table_impl('relation', _name, _columns, _options)
2626
end
2727

28-
function osm2pgsql.define_area_table(_name, _columns)
29-
return _define_table_impl('area', _name, _columns)
28+
function osm2pgsql.define_area_table(_name, _columns, _options)
29+
return _define_table_impl('area', _name, _columns, _options)
3030
end
3131

3232
function osm2pgsql.mark_way(id)

0 commit comments

Comments
 (0)