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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
-- This config example file is released into the Public Domain.
-- This is a generic configuration that is a good starting point for
-- real-world projects. Data is split into tables according to geometry type
-- and most tags are stored in jsonb columns.
-- Set this to the projection you want to use
local srid = 3857
local tables = {}
tables.points = osm2pgsql.define_node_table('points', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'point', projection = srid, not_null = true },
})
tables.lines = osm2pgsql.define_way_table('lines', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'linestring', projection = srid, not_null = true },
})
tables.polygons = osm2pgsql.define_area_table('polygons', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'geometry', projection = srid, not_null = true },
})
tables.routes = osm2pgsql.define_relation_table('routes', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'multilinestring', projection = srid, not_null = true },
})
tables.boundaries = osm2pgsql.define_relation_table('boundaries', {
{ column = 'tags', type = 'jsonb' },
{ column = 'geom', type = 'multilinestring', projection = srid, not_null = true },
})
-- These tag keys are generally regarded as useless for most rendering. Most
-- of them are from imports or intended as internal information for mappers.
--
-- If a key ends in '*' it will match all keys with the specified prefix.
--
-- If you want some of these keys, perhaps for a debugging layer, just
-- delete the corresponding lines.
local delete_keys = {
-- "mapper" keys
'attribution',
'comment',
'created_by',
'fixme',
'note',
'note:*',
'odbl',
'odbl:note',
'source',
'source:*',
'source_ref',
-- "import" keys
-- Corine Land Cover (CLC) (Europe)
'CLC:*',
-- Geobase (CA)
'geobase:*',
-- CanVec (CA)
'canvec:*',
-- osak (DK)
'osak:*',
-- kms (DK)
'kms:*',
-- ngbe (ES)
-- See also note:es and source:file above
'ngbe:*',
-- Friuli Venezia Giulia (IT)
'it:fvg:*',
-- KSJ2 (JA)
-- See also note:ja and source_ref above
'KSJ2:*',
-- Yahoo/ALPS (JA)
'yh:*',
-- LINZ (NZ)
'LINZ2OSM:*',
'linz2osm:*',
'LINZ:*',
'ref:linz:*',
-- WroclawGIS (PL)
'WroclawGIS:*',
-- Naptan (UK)
'naptan:*',
-- TIGER (US)
'tiger:*',
-- GNIS (US)
'gnis:*',
-- National Hydrography Dataset (US)
'NHD:*',
'nhd:*',
-- mvdgis (Montevideo, UY)
'mvdgis:*',
-- EUROSHA (Various countries)
'project:eurosha_2012',
-- UrbIS (Brussels, BE)
'ref:UrbIS',
-- NHN (CA)
'accuracy:meters',
'sub_sea:type',
'waterway:type',
-- StatsCan (CA)
'statscan:rbuid',
-- RUIAN (CZ)
'ref:ruian:addr',
'ref:ruian',
'building:ruian:type',
-- DIBAVOD (CZ)
'dibavod:id',
-- UIR-ADR (CZ)
'uir_adr:ADRESA_KOD',
-- GST (DK)
'gst:feat_id',
-- Maa-amet (EE)
'maaamet:ETAK',
-- FANTOIR (FR)
'ref:FR:FANTOIR',
-- 3dshapes (NL)
'3dshapes:ggmodelk',
-- AND (NL)
'AND_nosr_r',
-- OPPDATERIN (NO)
'OPPDATERIN',
-- Various imports (PL)
'addr:city:simc',
'addr:street:sym_ul',
'building:usage:pl',
'building:use:pl',
-- TERYT (PL)
'teryt:simc',
-- RABA (SK)
'raba:id',
-- DCGIS (Washington DC, US)
'dcgis:gis_id',
-- Building Identification Number (New York, US)
'nycdoitt:bin',
-- Chicago Building Inport (US)
'chicago:building_id',
-- Louisville, Kentucky/Building Outlines Import (US)
'lojic:bgnum',
-- MassGIS (Massachusetts, US)
'massgis:way_id',
-- Los Angeles County building ID (US)
'lacounty:*',
-- Address import from Bundesamt für Eich- und Vermessungswesen (AT)
'at_bev:addr_date',
-- misc
'import',
'import_uuid',
'OBJTYPE',
'SK53_bulk:load',
'mml:class'
}
-- The osm2pgsql.make_clean_tags_func() function takes the list of keys
-- and key prefixes defined above and returns a function that can be used
-- to clean those tags out of a Lua table. The clean_tags function will
-- return true if it removed all tags from the table.
local clean_tags = osm2pgsql.make_clean_tags_func(delete_keys)
-- Helper function that looks at the tags and decides if this is possibly
-- an area.
local function has_area_tags(tags)
if tags.area == 'yes' then
return true
end
if tags.area == 'no' then
return false
end
return tags.aeroway
or tags.amenity
or tags.building
or tags.harbour
or tags.historic
or tags.landuse
or tags.leisure
or tags.man_made
or tags.military
or tags.natural
or tags.office
or tags.place
or tags.power
or tags.public_transport
or tags.shop
or tags.sport
or tags.tourism
or tags.water
or tags.waterway
or tags.wetland
or tags['abandoned:aeroway']
or tags['abandoned:amenity']
or tags['abandoned:building']
or tags['abandoned:landuse']
or tags['abandoned:power']
or tags['area:highway']
or tags['building:part']
end
function osm2pgsql.process_node(object)
if clean_tags(object.tags) then
return
end
tables.points:insert({
tags = object.tags,
geom = object:as_point()
})
end
function osm2pgsql.process_way(object)
if clean_tags(object.tags) then
return
end
if object.is_closed and has_area_tags(object.tags) then
tables.polygons:insert({
tags = object.tags,
geom = object:as_polygon()
})
else
tables.lines:insert({
tags = object.tags,
geom = object:as_linestring()
})
end
end
function osm2pgsql.process_relation(object)
local relation_type = object:grab_tag('type')
if clean_tags(object.tags) then
return
end
if relation_type == 'route' then
tables.routes:insert({
tags = object.tags,
geom = object:as_multilinestring()
})
return
end
if relation_type == 'boundary' or (relation_type == 'multipolygon' and object.tags.boundary) then
tables.boundaries:insert({
tags = object.tags,
geom = object:as_multilinestring():line_merge()
})
return
end
if relation_type == 'multipolygon' then
tables.polygons:insert({
tags = object.tags,
geom = object:as_multipolygon()
})
end
end
|