File: iceland.lua

package info (click to toggle)
osm2pgsql 2.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,772 kB
  • sloc: cpp: 60,940; python: 1,115; ansic: 763; sh: 25; makefile: 14
file content (32 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download | duplicates (2)
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
-- This config example file is released into the Public Domain.

-- This file shows how to use a locator with a bounding box to import only
-- the data for a region. In this case only highways in Iceland are imported
-- even if you run this on the full planet file.

local iceland = osm2pgsql.define_locator({ name = 'iceland' })

iceland:add_bbox('IS', -25.0, 62.0, -12.0, 68.0)

local highways = osm2pgsql.define_way_table('highways', {
    { column = 'hwtype', type = 'text', not_null = true },
    { column = 'name', type = 'text' },
    { column = 'ref', type = 'text' },
    { column = 'geom', type = 'linestring', not_null = true },
})

function osm2pgsql.process_way(object)
    local t = object.tags
    if t.highway then
        local geom = object:as_linestring()
        local region = iceland:first_intersecting(geom)
        if region then
            highways:insert({
                hwtype = t.highway,
                name = t.name,
                ref = t.ref,
                geom = geom,
            })
        end
    end
end