forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturning-circles.lua
More file actions
69 lines (62 loc) · 2.25 KB
/
turning-circles.lua
File metadata and controls
69 lines (62 loc) · 2.25 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
67
68
-- This config example file is released into the Public Domain.
-- Create a table with turning circles that can be styled in sync with the
-- highway they are on.
local turning_circles = osm2pgsql.define_table({
name = 'turning_circles',
ids = { type = 'node', id_column = 'node_id', cache = true },
columns = {
{ column = 'geom', type = 'point', not_null = true },
}
})
local highways = osm2pgsql.define_table({
name = 'highways',
ids = { type = 'way', id_column = 'way_id' },
columns = {
{ column = 'htype', type = 'text', not_null = true },
{ column = 'geom', type = 'linestring', not_null = true },
}
})
-- This table will contain entries for all node/way combinations where the way
-- is tagged as "highway" and the node is tagged as "highway=turning_circle".
-- The "htype" column contains the highway type, the "geom" the geometry of
-- the node. This can be used, for instance, to draw the point in a style that
-- fits with the style of the highway.
--
-- Note that you might have multiple entries for the same node in this table
-- if it is in several ways. In that case you might have to decide at rendering
-- time which of them to render.
local highway_ends = osm2pgsql.define_table({
name = 'highway_ends',
ids = { type = 'way', id_column = 'way_id' },
columns = {
{ column = 'htype', type = 'text', not_null = true },
{ column = 'node_id', type = 'int8', not_null = true },
{ column = 'geom', type = 'point', not_null = true },
}
})
function osm2pgsql.process_node(object)
if object.tags.highway == 'turning_circle' then
-- This insert will add the entry to the id cache later read with
-- in_id_cache().
turning_circles:insert({
geom = object:as_point(),
})
end
end
function osm2pgsql.process_way(object)
local t = object.tags.highway
if t then
highways:insert({
htype = t,
geom = object:as_linestring(),
})
local c = turning_circles:in_id_cache(object.nodes)
for _, n in ipairs(c) do
highway_ends:insert({
htype = t,
node_id = object.nodes[n],
geom = object:as_point(n),
})
end
end
end