-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathextract.lua
More file actions
66 lines (51 loc) · 1.5 KB
/
extract.lua
File metadata and controls
66 lines (51 loc) · 1.5 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
-- ---------------------------------------------------------------------------
--
-- Theme: core
-- Topic: extract
--
-- ---------------------------------------------------------------------------
local themepark, theme, cfg = ...
-- ---------------------------------------------------------------------------
local locator
if cfg.locator == nil then
locator = osm2pgsql.define_locator({
name = 'themepark-core-extract-' .. math.random(100000000)
})
else
locator = cfg.locator
end
if cfg.bbox ~= nil then
local b = cfg.bbox
locator:add_bbox('inside', b[1], b[2], b[3], b[4])
end
-- ---------------------------------------------------------------------------
themepark:add_proc('node', function(object)
if not locator:first_intersecting(object:as_point()) then
return 'stop'
end
end)
themepark:add_proc('way', function(object)
local geom
if object.is_closed then
geom = object:as_polygon()
end
if geom == nil or geom:is_null() then
geom = object:as_linestring()
end
if not locator:first_intersecting(geom) then
return 'stop'
end
end)
themepark:add_proc('relation', function(object)
local geom = object:as_multipolygon()
if geom:is_null() then
geom = object:as_geometrycollection()
end
if geom:is_null() then
return 'stop'
end
if not locator:first_intersecting(geom) then
return 'stop'
end
end)
-- ---------------------------------------------------------------------------