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