forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattributes.lua
More file actions
81 lines (70 loc) · 2.59 KB
/
Copy pathattributes.lua
File metadata and controls
81 lines (70 loc) · 2.59 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
69
70
71
72
73
74
75
76
77
78
79
80
-- This config example file is released into the Public Domain.
-- This config shows how to access the attributes of OSM objects: the version,
-- changeset id, timestamp, user id and user name. For this to work the
-- command line option --extra-attributes/-x must be set, otherwise those
-- fields will be empty.
-- Set this to the projection you want to use
local srid = 4326
local tables = {}
tables.points = osm2pgsql.define_node_table('points', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'point', projection = srid },
{ column = 'version', type = 'int' },
{ column = 'changeset', type = 'int' },
-- There is no built-in type for timestamps in osm2pgsql. So we use the
-- PostgreSQL type "timestamp" and then have to convert our timestamps
-- to a valid text representation for that type.
{ column = 'created', sql_type = 'timestamp' },
{ column = 'uid', type = 'int' },
{ column = 'user', type = 'text' },
})
tables.lines = osm2pgsql.define_way_table('lines', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'linestring', projection = srid },
{ column = 'version', type = 'int' },
{ column = 'changeset', type = 'int' },
{ column = 'created', sql_type = 'timestamp' },
{ column = 'uid', type = 'int' },
{ column = 'user', type = 'text' },
})
tables.relations = osm2pgsql.define_relation_table('relations', {
{ column = 'tags', type = 'jsonb' },
{ column = 'version', type = 'int' },
{ column = 'changeset', type = 'int' },
{ column = 'created', sql_type = 'timestamp' },
{ column = 'uid', type = 'int' },
{ column = 'user', type = 'text' },
})
function osm2pgsql.process_node(object)
if next(object.tags) == nil then
return
end
tables.points:add_row({
tags = object.tags,
version = object.version,
changeset = object.changeset,
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
uid = object.uid,
user = object.user
})
end
function osm2pgsql.process_way(object)
tables.lines:add_row({
tags = object.tags,
version = object.version,
changeset = object.changeset,
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
uid = object.uid,
user = object.user
})
end
function osm2pgsql.process_relation(object)
tables.relations:add_row({
tags = object.tags,
version = object.version,
changeset = object.changeset,
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
uid = object.uid,
user = object.user
})
end