-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathosm2pgsql-flex.lua
More file actions
66 lines (61 loc) · 1.63 KB
/
osm2pgsql-flex.lua
File metadata and controls
66 lines (61 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local nodes = osm2pgsql.define_table({
name = 'nodes',
ids = { type = 'node', id_column = 'node_id' },
columns = {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'point', projection = 4326, not_null = true },
}
})
local ways = osm2pgsql.define_table({
name = 'ways',
ids = { type = 'way', id_column = 'way_id' },
columns = {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'geometry', projection = 4326, not_null = true },
}
})
local relations = osm2pgsql.define_table({
name = 'relations',
ids = { type = 'relation', id_column = 'relation_id' },
columns = {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'geometry', projection = 4326 },
}
})
function osm2pgsql.process_node(object)
if next(object.tags) == nil then
return
end
nodes:insert({
tags = object.tags,
geom = object:as_point()
})
end
function osm2pgsql.process_way(object)
if next(object.tags) == nil then
return
end
if object.is_closed then
ways:insert({
tags = object.tags,
geom = object:as_polygon()
})
else
ways:insert({
tags = object.tags,
geom = object:as_linestring()
})
end
end
function osm2pgsql.process_relation(object)
if next(object.tags) == nil then
return
end
local rtype = object.tags.type
if rtype == 'multipolygon' or rtype == 'boundary' then
relations:insert({
tags = object.tags,
geom = object:as_multipolygon()
})
end
end