diff --git a/flex-config/style/amenity.lua b/flex-config/style/amenity.lua index f54fb2b..d4aa775 100644 --- a/flex-config/style/amenity.lua +++ b/flex-config/style/amenity.lua @@ -7,18 +7,18 @@ tables.amenity_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text' }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text' }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -27,18 +27,18 @@ tables.amenity_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text' }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text' }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'geom', type = 'linestring', projection = srid, not_null = true}, } }) @@ -48,18 +48,18 @@ tables.amenity_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'area', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text' }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text' }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -124,7 +124,7 @@ function amenity_process_node(object) local wheelchair = object.tags.wheelchair local wheelchair_desc = get_wheelchair_desc(object.tags) - tables.amenity_point:add_row({ + tables.amenity_point:insert({ osm_type = osm_types['osm_type'], osm_subtype = osm_types['osm_subtype'], name = name, @@ -136,7 +136,7 @@ function amenity_process_node(object) address = address, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -165,7 +165,7 @@ function amenity_process_way(object) local wheelchair_desc = get_wheelchair_desc(object.tags) if object.is_closed then - tables.amenity_polygon:add_row({ + tables.amenity_polygon:insert({ osm_type = osm_types['osm_type'], osm_subtype = osm_types['osm_subtype'], name = name, @@ -177,10 +177,10 @@ function amenity_process_way(object) address = address, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.amenity_line:add_row({ + tables.amenity_line:insert({ osm_type = osm_types['osm_type'], osm_subtype = osm_types['osm_subtype'], name = name, @@ -192,7 +192,7 @@ function amenity_process_way(object) address = address, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -215,7 +215,7 @@ function amenity_process_relation(object) local wheelchair = object.tags.wheelchair local wheelchair_desc = get_wheelchair_desc(object.tags) - tables.amenity_polygon:add_row({ + tables.amenity_polygon:insert({ osm_type = osm_types['osm_type'], osm_subtype = osm_types['osm_subtype'], name = name, @@ -227,7 +227,7 @@ function amenity_process_relation(object) address = address, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'area' } + geom = object:as_multipolygon() }) end diff --git a/flex-config/style/building.lua b/flex-config/style/building.lua index 3032586..f005590 100644 --- a/flex-config/style/building.lua +++ b/flex-config/style/building.lua @@ -8,21 +8,21 @@ tables.building_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text' , not_null = true}, - { column = 'osm_subtype', type = 'text'}, - { column = 'name', type = 'text' }, - { column = 'levels', type = 'int'}, + { column = 'osm_type', type = 'text' , not_null = true}, + { column = 'osm_subtype', type = 'text'}, + { column = 'name', type = 'text' }, + { column = 'levels', type = 'int'}, { column = 'height', sql_type = 'numeric'}, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, { column = 'operator', type = 'text'}, - { column = 'geom', type = 'point', projection = srid}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -32,21 +32,21 @@ tables.building_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text' , not_null = true}, - { column = 'osm_subtype', type = 'text'}, - { column = 'name', type = 'text' }, - { column = 'levels', type = 'int'}, - { column = 'height', sql_type = 'numeric'}, + { column = 'osm_type', type = 'text', not_null = true}, + { column = 'osm_subtype', type = 'text'}, + { column = 'name', type = 'text' }, + { column = 'levels', type = 'int'}, + { column = 'height', sql_type = 'numeric'}, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, { column = 'operator', type = 'text'}, - { column = 'geom', type = 'multipolygon', projection = srid}, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -148,7 +148,7 @@ function building_process_node(object) local height = parse_to_meters(object.tags['height']) local operator = object.tags.operator - tables.building_point:add_row({ + tables.building_point:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -163,7 +163,7 @@ function building_process_node(object) levels = levels, height = height, operator = operator, - geom = { create = 'point' } + geom = object:as_point() }) @@ -197,7 +197,7 @@ function building_process_way(object) local height = parse_to_meters(object.tags['height']) local operator = object.tags.operator - tables.building_polygon:add_row({ + tables.building_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -212,7 +212,7 @@ function building_process_way(object) levels = levels, height = height, operator = operator, - geom = { create = 'area' } + geom = object:as_polygon() }) @@ -245,7 +245,7 @@ function building_process_relation(object) local operator = object.tags.operator if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then - tables.building_polygon:add_row({ + tables.building_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -260,7 +260,7 @@ function building_process_relation(object) levels = levels, height = height, operator = operator, - geom = { create = 'area' } + geom = object:as_multipolygon() }) end end diff --git a/flex-config/style/indoor.lua b/flex-config/style/indoor.lua index 074ddfa..f36f1d3 100644 --- a/flex-config/style/indoor.lua +++ b/flex-config/style/indoor.lua @@ -7,16 +7,16 @@ tables.indoor_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'layer', type = 'int', not_null = false }, - { column = 'level', type = 'text'}, - { column = 'room', type = 'text'}, - { column = 'entrance', type = 'text'}, - { column = 'door', type = 'text'}, - { column = 'capacity', type = 'text'}, - { column = 'highway', type = 'text'}, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'layer', type = 'int', not_null = false }, + { column = 'level', type = 'text'}, + { column = 'room', type = 'text'}, + { column = 'entrance', type = 'text'}, + { column = 'door', type = 'text'}, + { column = 'capacity', type = 'text'}, + { column = 'highway', type = 'text'}, + { column = 'geom', type = 'point' , projection = srid, not_null = true}, } }) @@ -26,16 +26,16 @@ tables.indoor_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'layer', type = 'int', not_null = false }, - { column = 'level', type = 'text'}, - { column = 'room', type = 'text'}, - { column = 'entrance', type = 'text'}, - { column = 'door', type = 'text'}, - { column = 'capacity', type = 'text'}, - { column = 'highway', type = 'text'}, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'layer', type = 'int', not_null = false }, + { column = 'level', type = 'text'}, + { column = 'room', type = 'text'}, + { column = 'entrance', type = 'text'}, + { column = 'door', type = 'text'}, + { column = 'capacity', type = 'text'}, + { column = 'highway', type = 'text'}, + { column = 'geom', type = 'linestring', projection = srid, not_null = true}, } }) @@ -45,16 +45,16 @@ tables.indoor_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'layer', type = 'int', not_null = false }, - { column = 'level', type = 'text'}, - { column = 'room', type = 'text'}, - { column = 'entrance', type = 'text'}, - { column = 'door', type = 'text'}, - { column = 'capacity', type = 'text'}, - { column = 'highway', type = 'text'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'layer', type = 'int', not_null = false }, + { column = 'level', type = 'text'}, + { column = 'room', type = 'text'}, + { column = 'entrance', type = 'text'}, + { column = 'door', type = 'text'}, + { column = 'capacity', type = 'text'}, + { column = 'highway', type = 'text'}, + { column = 'geom', type = 'multipolygon' , projection = srid, not_null = true}, } }) @@ -98,7 +98,7 @@ function indoor_process_node(object) local capacity = object.tags.capacity local highway = object.tags.highway - tables.indoor_point:add_row({ + tables.indoor_point:insert({ osm_type = osm_type, name = name, layer = layer, @@ -108,7 +108,7 @@ function indoor_process_node(object) door = door, capacity = capacity, highway = highway, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -119,7 +119,6 @@ function indoor_process_way(object) return end - local osm_type = get_osm_type(object) local name = get_name(object.tags) local layer = parse_layer_value(object.tags.layer) @@ -131,7 +130,7 @@ function indoor_process_way(object) local highway = object.tags.highway if object.is_closed then - tables.indoor_polygon:add_row({ + tables.indoor_polygon:insert({ osm_type = osm_type, name = name, layer = layer, @@ -141,10 +140,10 @@ function indoor_process_way(object) door = door, capacity = capacity, highway = highway, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.indoor_line:add_row({ + tables.indoor_line:insert({ osm_type = osm_type, name = name, layer = layer, @@ -154,7 +153,7 @@ function indoor_process_way(object) door = door, capacity = capacity, highway = highway, - geom = { create = 'line' } + geom = object:as_linestring() }) end diff --git a/flex-config/style/infrastructure.lua b/flex-config/style/infrastructure.lua index ae13f41..4428b56 100644 --- a/flex-config/style/infrastructure.lua +++ b/flex-config/style/infrastructure.lua @@ -20,14 +20,14 @@ tables.infrastructure_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text'}, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text'}, + { column = 'name', type = 'text' }, { column = 'ele', type = 'int' }, - { column = 'height', sql_type = 'numeric'}, + { column = 'height', sql_type = 'numeric'}, { column = 'operator', type = 'text'}, { column = 'material', type = 'text'}, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -36,14 +36,14 @@ tables.infrastructure_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text'}, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text'}, + { column = 'name', type = 'text' }, { column = 'ele', type = 'int' }, - { column = 'height', sql_type = 'numeric'}, + { column = 'height', sql_type = 'numeric'}, { column = 'operator', type = 'text'}, { column = 'material', type = 'text'}, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'geom', type = 'linestring', projection = srid, not_null = true}, } }) @@ -53,14 +53,14 @@ tables.infrastructure_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text'}, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text'}, + { column = 'name', type = 'text' }, { column = 'ele', type = 'int' }, - { column = 'height', sql_type = 'numeric'}, + { column = 'height', sql_type = 'numeric'}, { column = 'operator', type = 'text'}, { column = 'material', type = 'text'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -141,7 +141,7 @@ function infrastructure_process_node(object) local operator = object.tags.operator local material = object.tags.material - tables.infrastructure_point:add_row({ + tables.infrastructure_point:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -149,7 +149,7 @@ function infrastructure_process_node(object) height = height, operator = operator, material = material, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -174,7 +174,7 @@ function infrastructure_process_way(object) local material = object.tags.material if object.is_closed then - tables.infrastructure_polygon:add_row({ + tables.infrastructure_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -182,10 +182,10 @@ function infrastructure_process_way(object) height = height, operator = operator, material = material, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.infrastructure_line:add_row({ + tables.infrastructure_line:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -193,7 +193,7 @@ function infrastructure_process_way(object) height = height, operator = operator, material = material, - geom = { create = 'line' } + geom = object:as_linestring() }) end diff --git a/flex-config/style/landuse.lua b/flex-config/style/landuse.lua index 431418d..2392e75 100644 --- a/flex-config/style/landuse.lua +++ b/flex-config/style/landuse.lua @@ -8,9 +8,9 @@ tables.landuse_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text' , not_null = true}, - { column = 'name', type = 'text' }, - { column = 'geom', type = 'point', projection = srid}, + { column = 'osm_type', type = 'text' , not_null = true}, + { column = 'name', type = 'text' }, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -20,9 +20,9 @@ tables.landuse_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text' , not_null = true}, - { column = 'name', type = 'text' }, - { column = 'geom', type = 'multipolygon', projection = srid}, + { column = 'osm_type', type = 'text', not_null = true}, + { column = 'name', type = 'text' }, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -36,10 +36,10 @@ function landuse_process_node(object) local osm_type = object:grab_tag('landuse') local name = get_name(object.tags) - tables.landuse_point:add_row({ + tables.landuse_point:insert({ osm_type = osm_type, name = name, - geom = { create = 'point' } + geom = object:as_point() }) @@ -58,10 +58,10 @@ function landuse_process_way(object) local osm_type = object:grab_tag('landuse') local name = get_name(object.tags) - tables.landuse_polygon:add_row({ + tables.landuse_polygon:insert({ osm_type = osm_type, name = name, - geom = { create = 'area' } + geom = object:as_polygon() }) end @@ -76,17 +76,16 @@ function landuse_process_relation(object) local name = get_name(object.tags) if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then - tables.landuse_polygon:add_row({ + tables.landuse_polygon:insert({ osm_type = osm_type, name = name, - geom = { create = 'area' } + geom = object:as_multipolygon() }) end end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = landuse_process_node else local nested = osm2pgsql.process_node @@ -100,14 +99,12 @@ end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = landuse_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here landuse_process_way(object_copy) end end diff --git a/flex-config/style/leisure.lua b/flex-config/style/leisure.lua index 3dbc1a6..b7a2f69 100644 --- a/flex-config/style/leisure.lua +++ b/flex-config/style/leisure.lua @@ -8,9 +8,9 @@ tables.leisure_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text' , not_null = true}, - { column = 'name', type = 'text' }, - { column = 'geom', type = 'point', projection = srid}, + { column = 'osm_type', type = 'text', not_null = true}, + { column = 'name', type = 'text' }, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -20,14 +20,13 @@ tables.leisure_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text' , not_null = true}, - { column = 'name', type = 'text' }, - { column = 'geom', type = 'multipolygon', projection = srid}, + { column = 'osm_type', type = 'text' , not_null = true}, + { column = 'name', type = 'text' }, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) --- Change function name here function leisure_process_node(object) if not object.tags.leisure then return @@ -36,16 +35,15 @@ function leisure_process_node(object) local osm_type = object:grab_tag('leisure') local name = get_name(object.tags) - tables.leisure_point:add_row({ + tables.leisure_point:insert({ osm_type = osm_type, name = name, - geom = { create = 'point' } + geom = object:as_point() }) - end --- Change function name here + function leisure_process_way(object) if not object.tags.leisure then return @@ -55,43 +53,37 @@ function leisure_process_way(object) return end - -- Using grab_tag() removes from remaining key/value saved to Pg local osm_type = object:grab_tag('leisure') local name = get_name(object.tags) - tables.leisure_polygon:add_row({ + tables.leisure_polygon:insert({ osm_type = osm_type, name = name, - geom = { create = 'area' } + geom = object:as_polygon() }) - end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = leisure_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here leisure_process_node(object_copy) end end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = leisure_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here leisure_process_way(object_copy) end end diff --git a/flex-config/style/natural.lua b/flex-config/style/natural.lua index 5c266a1..b22a801 100644 --- a/flex-config/style/natural.lua +++ b/flex-config/style/natural.lua @@ -8,10 +8,10 @@ tables.natural_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'ele', type = 'int' }, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -21,10 +21,10 @@ tables.natural_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'ele', type = 'int' }, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'geom', type = 'linestring' , projection = srid, not_null = true}, } }) @@ -34,10 +34,10 @@ tables.natural_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'ele', type = 'int' }, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon' , projection = srid, not_null = true}, } }) @@ -67,11 +67,11 @@ function natural_process_node(object) local name = get_name(object.tags) local ele = parse_to_meters(object.tags.ele) - tables.natural_point:add_row({ + tables.natural_point:insert({ osm_type = osm_type, name = name, ele = ele, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -101,18 +101,18 @@ function natural_process_way(object) local ele = parse_to_meters(object.tags.ele) if object.is_closed then - tables.natural_polygon:add_row({ + tables.natural_polygon:insert({ osm_type = osm_type, name = name, ele = ele, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.natural_line:add_row({ + tables.natural_line:insert({ osm_type = osm_type, name = name, ele = ele, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -120,29 +120,24 @@ end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = natural_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here natural_process_node(object_copy) end end - if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = natural_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here natural_process_way(object_copy) end end diff --git a/flex-config/style/place.lua b/flex-config/style/place.lua index e5b5e37..2812816 100644 --- a/flex-config/style/place.lua +++ b/flex-config/style/place.lua @@ -8,11 +8,11 @@ tables.place_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'boundary', type = 'text' }, - { column = 'admin_level', type = 'int4' }, - { column = 'name', type = 'text' }, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'boundary', type = 'text' }, + { column = 'admin_level', type = 'int4' }, + { column = 'name', type = 'text' }, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -21,11 +21,11 @@ tables.place_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'boundary', type = 'text' }, - { column = 'admin_level', type = 'int4' }, - { column = 'name', type = 'text' }, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'boundary', type = 'text' }, + { column = 'admin_level', type = 'int4' }, + { column = 'name', type = 'text' }, + { column = 'geom', type = 'linestring', projection = srid, not_null = true}, } }) @@ -35,12 +35,12 @@ tables.place_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'area', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'boundary', type = 'text' }, - { column = 'admin_level', type = 'int4' }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'boundary', type = 'text' }, + { column = 'admin_level', type = 'int4' }, + { column = 'name', type = 'text' }, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -66,12 +66,12 @@ function place_process_node(object) local admin_level = parse_admin_level(object:grab_tag('admin_level')) local name = get_name(object.tags) - tables.place_point:add_row({ + tables.place_point:insert({ osm_type = osm_type, boundary = boundary, admin_level = admin_level, name = name, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -99,20 +99,20 @@ function place_process_way(object) local name = get_name(object.tags) if object.is_closed then - tables.place_polygon:add_row({ + tables.place_polygon:insert({ osm_type = osm_type, boundary = boundary, admin_level = admin_level, name = name, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.place_line:add_row({ + tables.place_line:insert({ osm_type = osm_type, boundary = boundary, admin_level = admin_level, name = name, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -141,28 +141,25 @@ function place_process_relation(object) local name = get_name(object.tags) local member_ids = osm2pgsql.way_member_ids(object) - tables.place_polygon:add_row({ + tables.place_polygon:insert({ osm_type = osm_type, boundary = boundary, admin_level = admin_level, name = name, member_ids = member_ids, - geom = { create = 'area' } + geom = object:as_multipolygon() }) end - if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = place_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here place_process_node(object_copy) end end @@ -170,28 +167,24 @@ end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = place_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here place_process_way(object_copy) end end if osm2pgsql.process_relation == nil then - -- Change function name here osm2pgsql.process_relation = place_process_relation else local nested = osm2pgsql.process_relation osm2pgsql.process_relation = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here place_process_relation(object_copy) end end diff --git a/flex-config/style/poi.lua b/flex-config/style/poi.lua index 39d679e..bfd360d 100644 --- a/flex-config/style/poi.lua +++ b/flex-config/style/poi.lua @@ -128,17 +128,17 @@ tables.poi_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'operator', type = 'text'}, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -148,17 +148,17 @@ tables.poi_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'operator', type = 'text'}, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'geom', type = 'linestring', projection = srid, not_null = true}, } }) @@ -167,18 +167,18 @@ tables.poi_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, { column = 'operator', type = 'text'}, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -220,7 +220,7 @@ function poi_process_node(object) local operator = object:grab_tag('operator') - tables.poi_point:add_row({ + tables.poi_point:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -231,7 +231,7 @@ function poi_process_node(object) postcode = postcode, address = address, operator = operator, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -256,13 +256,10 @@ function poi_process_way(object) return end - if (object.tags.man_made and not man_made_poi(object)) then return end - - -- Gets osm_type and osm_subtype local osm_types = get_osm_type_subtype(object) local name = get_name(object.tags) @@ -274,11 +271,9 @@ function poi_process_way(object) local address = get_address(object.tags) local operator = object:grab_tag('operator') - - if object.is_closed then - tables.poi_polygon:add_row({ + tables.poi_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -289,10 +284,10 @@ function poi_process_way(object) postcode = postcode, address = address, operator = operator, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.poi_line:add_row({ + tables.poi_line:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -303,7 +298,7 @@ function poi_process_way(object) postcode = postcode, address = address, operator = operator, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end @@ -349,7 +344,7 @@ function poi_process_relation(object) local member_ids = osm2pgsql.way_member_ids(object) if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then - tables.poi_polygon:add_row({ + tables.poi_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, name = name, @@ -361,7 +356,7 @@ function poi_process_relation(object) address = address, operator = operator, member_ids = member_ids, - geom = { create = 'area' } + geom = object:as_multipolygon() }) end @@ -369,42 +364,36 @@ end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = poi_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here poi_process_node(object_copy) end end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = poi_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here poi_process_way(object_copy) end end if osm2pgsql.process_relation == nil then - -- Change function name here osm2pgsql.process_relation = poi_process_relation else local nested = osm2pgsql.process_relation osm2pgsql.process_relation = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here poi_process_relation(object_copy) end end diff --git a/flex-config/style/public_transport.lua b/flex-config/style/public_transport.lua index e4be4ba..d2ac21b 100644 --- a/flex-config/style/public_transport.lua +++ b/flex-config/style/public_transport.lua @@ -7,22 +7,22 @@ tables.public_transport_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = false }, - { column = 'public_transport', type = 'text', not_null = true }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, - { column = 'operator', type = 'text' }, - { column = 'network', type = 'text' }, - { column = 'surface', type = 'text' }, - { column = 'bus', type = 'text' }, - { column = 'shelter', type = 'text' }, - { column = 'bench', type = 'text' }, - { column = 'lit', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = false }, + { column = 'public_transport', type = 'text', not_null = true }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, + { column = 'operator', type = 'text' }, + { column = 'network', type = 'text' }, + { column = 'surface', type = 'text' }, + { column = 'bus', type = 'text' }, + { column = 'shelter', type = 'text' }, + { column = 'bench', type = 'text' }, + { column = 'lit', type = 'text' }, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, - { column = 'geom', type = 'point', projection = srid } + { column = 'geom', type = 'point', projection = srid, not_null = true } } }) @@ -33,23 +33,23 @@ tables.public_transport_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = false }, - { column = 'public_transport', type = 'text', not_null = true }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, - { column = 'operator', type = 'text' }, - { column = 'network', type = 'text' }, - { column = 'surface', type = 'text' }, - { column = 'bus', type = 'text' }, - { column = 'shelter', type = 'text' }, - { column = 'bench', type = 'text' }, - { column = 'lit', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = false }, + { column = 'public_transport', type = 'text', not_null = true }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, + { column = 'operator', type = 'text' }, + { column = 'network', type = 'text' }, + { column = 'surface', type = 'text' }, + { column = 'bus', type = 'text' }, + { column = 'shelter', type = 'text' }, + { column = 'bench', type = 'text' }, + { column = 'lit', type = 'text' }, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multilinestring', projection = srid } + { column = 'geom', type = 'multilinestring', projection = srid, not_null = true } } }) @@ -59,23 +59,23 @@ tables.public_transport_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'area', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = false }, - { column = 'public_transport', type = 'text', not_null = true }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, - { column = 'operator', type = 'text' }, - { column = 'network', type = 'text' }, - { column = 'surface', type = 'text' }, - { column = 'bus', type = 'text' }, - { column = 'shelter', type = 'text' }, - { column = 'bench', type = 'text' }, - { column = 'lit', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = false }, + { column = 'public_transport', type = 'text', not_null = true }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, + { column = 'operator', type = 'text' }, + { column = 'network', type = 'text' }, + { column = 'surface', type = 'text' }, + { column = 'bus', type = 'text' }, + { column = 'shelter', type = 'text' }, + { column = 'bench', type = 'text' }, + { column = 'lit', type = 'text' }, { column = 'wheelchair', type = 'text'}, { column = 'wheelchair_desc', type = 'text'}, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multipolygon', projection = srid } + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true } } }) @@ -152,7 +152,7 @@ local function public_transport_process_node(object) local bench = object.tags.bench local lit = object.tags.lit - tables.public_transport_point:add_row({ + tables.public_transport_point:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, public_transport = public_transport, @@ -168,7 +168,7 @@ local function public_transport_process_node(object) lit = lit, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -202,10 +202,9 @@ local function public_transport_process_way(object) local bench = object.tags.bench local lit = object.tags.lit - -- temporarily discarding polygons if (object.tags.area == 'yes' or object.is_closed) then - tables.public_transport_polygon:add_row({ + tables.public_transport_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, public_transport = public_transport, @@ -221,10 +220,10 @@ local function public_transport_process_way(object) lit = lit, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.public_transport_line:add_row({ + tables.public_transport_line:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, public_transport = public_transport, @@ -240,7 +239,7 @@ local function public_transport_process_way(object) lit = lit, wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -276,7 +275,7 @@ function public_transport_process_relation(object) local lit = object.tags.lit if object.tags.type == 'multipolygon' then - tables.public_transport_polygon:add_row({ + tables.public_transport_polygon:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, public_transport = public_transport, @@ -293,10 +292,10 @@ function public_transport_process_relation(object) wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, member_ids = member_ids, - geom = { create = 'area' } + geom = object:as_multipolygon() }) else - tables.public_transport_line:add_row({ + tables.public_transport_line:insert({ osm_type = osm_types.osm_type, osm_subtype = osm_types.osm_subtype, public_transport = public_transport, @@ -313,7 +312,7 @@ function public_transport_process_relation(object) wheelchair = wheelchair, wheelchair_desc = wheelchair_desc, member_ids = member_ids, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end end @@ -321,28 +320,24 @@ end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = public_transport_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here public_transport_process_node(object_copy) end end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = public_transport_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here public_transport_process_way(object_copy) end end diff --git a/flex-config/style/road.lua b/flex-config/style/road.lua index 252de61..b28d8ad 100644 --- a/flex-config/style/road.lua +++ b/flex-config/style/road.lua @@ -7,16 +7,16 @@ tables.road_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, { column = 'maxspeed', type = 'int' }, - { column = 'oneway', type = 'direction' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'access', type = 'text' }, - { column = 'geom', type = 'point', projection = srid } + { column = 'oneway', type = 'direction' }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'access', type = 'text' }, + { column = 'geom', type = 'point', projection = srid, not_null = true } } }) @@ -27,21 +27,21 @@ tables.road_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, { column = 'maxspeed', type = 'int' }, - { column = 'oneway', type = 'direction' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'major', type = 'boolean', not_null = true}, - { column = 'route_foot', type = 'boolean' }, - { column = 'route_cycle', type = 'boolean' }, - { column = 'route_motor', type = 'boolean' }, - { column = 'access', type = 'text' }, + { column = 'oneway', type = 'direction' }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'major', type = 'boolean', not_null = true}, + { column = 'route_foot', type = 'boolean' }, + { column = 'route_cycle', type = 'boolean' }, + { column = 'route_motor', type = 'boolean' }, + { column = 'access', type = 'text' }, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multilinestring', projection = srid } + { column = 'geom', type = 'multilinestring', projection = srid, not_null = true } } }) @@ -51,20 +51,20 @@ tables.road_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, { column = 'maxspeed', type = 'int' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'major', type = 'boolean', not_null = true}, - { column = 'route_foot', type = 'boolean' }, - { column = 'route_cycle', type = 'boolean' }, - { column = 'route_motor', type = 'boolean' }, - { column = 'access', type = 'text' }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'major', type = 'boolean', not_null = true}, + { column = 'route_foot', type = 'boolean' }, + { column = 'route_cycle', type = 'boolean' }, + { column = 'route_motor', type = 'boolean' }, + { column = 'access', type = 'text' }, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multipolygon', projection = srid } + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true } } }) @@ -90,7 +90,7 @@ function road_process_node(object) local bridge = object.tags.bridge local access = object.tags.access - tables.road_point:add_row({ + tables.road_point:insert({ name = name, osm_type = osm_type, ref = ref, @@ -100,7 +100,7 @@ function road_process_node(object) tunnel = tunnel, bridge = bridge, access = access, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -133,7 +133,7 @@ function road_process_way(object) if object.tags.area == 'yes' or object.tags.indoor == 'room' then - tables.road_polygon:add_row({ + tables.road_polygon:insert({ name = name, osm_type = osm_type, ref = ref, @@ -146,10 +146,10 @@ function road_process_way(object) route_cycle = route_cycle, route_motor = route_motor, access = access, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.road_line:add_row({ + tables.road_line:insert({ name = name, osm_type = osm_type, ref = ref, @@ -163,7 +163,7 @@ function road_process_way(object) route_cycle = route_cycle, route_motor = route_motor, access = access, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -200,7 +200,7 @@ function road_process_relation(object) if object.tags.area == 'yes' or object.tags.indoor == 'room' then - tables.road_polygon:add_row({ + tables.road_polygon:insert({ name = name, osm_type = osm_type, ref = ref, @@ -214,10 +214,10 @@ function road_process_relation(object) route_motor = route_motor, access = access, member_ids = member_ids, - geom = { create = 'area' } + geom = object:as_multipolygon() }) else - tables.road_line:add_row({ + tables.road_line:insert({ name = name, osm_type = osm_type, ref = ref, @@ -232,7 +232,7 @@ function road_process_relation(object) route_motor = route_motor, access = access, member_ids = member_ids, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end @@ -240,28 +240,24 @@ end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = road_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here road_process_node(object_copy) end end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = road_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here road_process_way(object_copy) end end @@ -274,7 +270,6 @@ else osm2pgsql.process_relation = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here road_process_relation(object_copy) end diff --git a/flex-config/style/road_major.lua b/flex-config/style/road_major.lua index c8ec5f5..7c0d5e7 100644 --- a/flex-config/style/road_major.lua +++ b/flex-config/style/road_major.lua @@ -7,16 +7,16 @@ tables.road_major = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'ref', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'ref', type = 'text' }, { column = 'maxspeed', type = 'int' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'major', type = 'boolean', not_null = true}, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'major', type = 'boolean', not_null = true}, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multilinestring', projection = srid }, + { column = 'geom', type = 'multilinestring', projection = srid, not_null = true }, } }) @@ -42,7 +42,7 @@ function road_major_process_way(object) local tunnel = object:grab_tag('tunnel') local bridge = object:grab_tag('bridge') - tables.road_major:add_row({ + tables.road_major:insert({ name = name, osm_type = osm_type, ref = ref, @@ -51,7 +51,7 @@ function road_major_process_way(object) layer = layer, tunnel = tunnel, bridge = bridge, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -85,7 +85,7 @@ function road_major_process_relation(object) local bridge = object.tags.bridge local access = object.tags.access - tables.road_major:add_row({ + tables.road_major:insert({ name = name, osm_type = osm_type, ref = ref, @@ -95,11 +95,12 @@ function road_major_process_relation(object) tunnel = tunnel, bridge = bridge, member_ids = member_ids, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end + if osm2pgsql.process_way == nil then osm2pgsql.process_way = road_major_process_way else @@ -112,7 +113,6 @@ else end - if osm2pgsql.process_relation == nil then osm2pgsql.process_relation = road_major_process_relation else @@ -120,7 +120,6 @@ else osm2pgsql.process_relation = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here road_major_process_relation(object_copy) end diff --git a/flex-config/style/shop.lua b/flex-config/style/shop.lua index 6cb3453..03cb597 100644 --- a/flex-config/style/shop.lua +++ b/flex-config/style/shop.lua @@ -7,12 +7,12 @@ tables.shop_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, @@ -22,7 +22,7 @@ tables.shop_point = osm2pgsql.define_table({ { column = 'operator', type = 'text'}, { column = 'brand', type = 'text'}, { column = 'website', type = 'text'}, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'geom', type = 'point' , projection = srid, not_null = true }, } }) @@ -32,12 +32,12 @@ tables.shop_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, { column = 'housenumber', type = 'text'}, - { column = 'street', type = 'text' }, - { column = 'city', type = 'text' }, + { column = 'street', type = 'text' }, + { column = 'city', type = 'text' }, { column = 'state', type = 'text'}, { column = 'postcode', type = 'text'}, { column = 'address', type = 'text', not_null = true}, @@ -47,7 +47,7 @@ tables.shop_polygon = osm2pgsql.define_table({ { column = 'operator', type = 'text'}, { column = 'brand', type = 'text'}, { column = 'website', type = 'text'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon' , projection = srid, not_null = true}, } }) @@ -76,7 +76,7 @@ function shop_process_node(object) local osm_type = 'shop' local osm_subtype = object:grab_tag('shop') - tables.shop_point:add_row({ + tables.shop_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -91,7 +91,7 @@ function shop_process_node(object) operator = operator, brand = brand, website = website, - geom = { create = 'point' } + geom = object:as_point() }) -- This creates overlap between this layer and amenity layer @@ -109,7 +109,7 @@ function shop_process_node(object) local osm_type = 'amenity' local osm_subtype = object:grab_tag('amenity') - tables.shop_point:add_row({ + tables.shop_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -125,7 +125,7 @@ function shop_process_node(object) operator = operator, brand = brand, website = website, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -159,7 +159,7 @@ function shop_process_way(object) local osm_subtype = object:grab_tag('shop') if object.is_closed then - tables.shop_polygon:add_row({ + tables.shop_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -175,7 +175,7 @@ function shop_process_way(object) operator = operator, brand = brand, website = website, - geom = { create = 'area' } + geom = object:as_polygon() }) end @@ -195,7 +195,7 @@ function shop_process_way(object) local osm_subtype = object:grab_tag('amenity') if object.is_closed then - tables.shop_polygon:add_row({ + tables.shop_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -211,7 +211,7 @@ function shop_process_way(object) operator = operator, brand = brand, website = website, - geom = { create = 'area' } + geom = object:as_polygon() }) end end @@ -219,29 +219,24 @@ end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = shop_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here shop_process_node(object_copy) end end - if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = shop_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here shop_process_way(object_copy) end end diff --git a/flex-config/style/tags.lua b/flex-config/style/tags.lua index 221111d..e2a2394 100644 --- a/flex-config/style/tags.lua +++ b/flex-config/style/tags.lua @@ -47,45 +47,37 @@ function all_tags_process_relation(object) end - if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = all_tags_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here all_tags_process_node(object_copy) end end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = all_tags_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here all_tags_process_way(object_copy) end end - if osm2pgsql.process_relation == nil then - -- Change function name here osm2pgsql.process_relation = all_tags_process_relation else local nested = osm2pgsql.process_relation osm2pgsql.process_relation = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here all_tags_process_relation(object_copy) end end diff --git a/flex-config/style/traffic.lua b/flex-config/style/traffic.lua index 7d91c01..6df25d9 100644 --- a/flex-config/style/traffic.lua +++ b/flex-config/style/traffic.lua @@ -8,9 +8,9 @@ tables.traffic_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text' }, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text' }, + { column = 'geom', type = 'point', projection = srid, not_null = true }, } }) @@ -20,9 +20,9 @@ tables.traffic_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text' }, - { column = 'geom', type = 'linestring' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text' }, + { column = 'geom', type = 'linestring', projection = srid, not_null = true}, } }) @@ -32,14 +32,13 @@ tables.traffic_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text' }, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text' }, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) --- Change function name here function traffic_process_node(object) if not object.tags.highway and not object.tags.railway and not object.tags.barrier and not object.tags.traffic_calming and not @@ -61,17 +60,17 @@ function traffic_process_node(object) then local osm_type = object:grab_tag('highway') - tables.traffic_point:add_row({ + tables.traffic_point:insert({ osm_type = osm_type, - geom = { create = 'point' } + geom = object:as_point() }) elseif object.tags.railway == 'level_crossing' then local osm_type = 'crossing' - tables.traffic_point:add_row({ + tables.traffic_point:insert({ osm_type = osm_type, - geom = { create = 'point' } + geom = object:as_point() }) -- Beginning of traffic w/ subtypes @@ -79,20 +78,20 @@ function traffic_process_node(object) local osm_type = 'barrier' local osm_subtype = object:grab_tag('barrier') - tables.traffic_point:add_row({ + tables.traffic_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'point' } + geom = object:as_point() }) elseif object.tags.traffic_calming then local osm_type = 'traffic_calming' local osm_subtype = object:grab_tag('traffic_calming') - tables.traffic_point:add_row({ + tables.traffic_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'point' } + geom = object:as_point() }) elseif object.tags.amenity == 'fuel' @@ -101,10 +100,10 @@ function traffic_process_node(object) then local osm_type = 'amenity' local osm_subtype = object:grab_tag('amenity') - tables.traffic_point:add_row({ + tables.traffic_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'point' } + geom = object:as_point() }) @@ -113,9 +112,9 @@ function traffic_process_node(object) local osm_type = 'noexit' -- No meaningful subtype, only defined value is "yes" -- https://wiki.openstreetmap.org/wiki/Key:noexit - tables.traffic_point:add_row({ + tables.traffic_point:insert({ osm_type = osm_type, - geom = { create = 'point' } + object:as_point() }) else @@ -125,7 +124,6 @@ function traffic_process_node(object) end --- Change function name here function traffic_process_way(object) if not object.tags.highway and not object.tags.railway and not object.tags.barrier and not object.tags.traffic_calming and not @@ -148,14 +146,14 @@ function traffic_process_way(object) local osm_type = object:grab_tag('highway') if object.is_closed then - tables.traffic_polygon:add_row({ + tables.traffic_polygon:insert({ osm_type = osm_type, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.traffic_line:add_row({ + tables.traffic_line:insert({ osm_type = osm_type, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -163,14 +161,14 @@ function traffic_process_way(object) local osm_type = 'crossing' if object.is_closed then - tables.traffic_polygon:add_row({ + tables.traffic_polygon:insert({ osm_type = osm_type, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.traffic_line:add_row({ + tables.traffic_line:insert({ osm_type = osm_type, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -180,16 +178,16 @@ function traffic_process_way(object) local osm_subtype = object:grab_tag('barrier') if object.is_closed then - tables.traffic_polygon:add_row({ + tables.traffic_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.traffic_line:add_row({ + tables.traffic_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -198,16 +196,16 @@ function traffic_process_way(object) local osm_subtype = object:grab_tag('traffic_calming') if object.is_closed then - tables.traffic_polygon:add_row({ + tables.traffic_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.traffic_line:add_row({ + tables.traffic_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -219,20 +217,19 @@ function traffic_process_way(object) local osm_subtype = object:grab_tag('amenity') if object.is_closed then - tables.traffic_polygon:add_row({ + tables.traffic_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.traffic_line:add_row({ + tables.traffic_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, - geom = { create = 'line' } + geom = object:as_linestring() }) end - elseif object.tags.noexit then local osm_type = 'noexit' @@ -243,9 +240,9 @@ function traffic_process_way(object) -- noexit does not make sense for polygons return else - tables.traffic_line:add_row({ + tables.traffic_line:insert({ osm_type = osm_type, - geom = { create = 'line' } + geom = object:as_linestring() }) end diff --git a/flex-config/style/unitable.lua b/flex-config/style/unitable.lua index e092efa..fc89f09 100644 --- a/flex-config/style/unitable.lua +++ b/flex-config/style/unitable.lua @@ -20,8 +20,8 @@ local dtable = osm2pgsql.define_table{ -- "geom_type CHAR(1)" for the type of object: N(ode), W(way), R(relation) ids = { type = 'any', id_column = 'osm_id', type_column = 'geom_type' }, columns = { - { column = 'tags', type = 'jsonb' }, - { column = 'geom', type = 'geometry', projection = srid }, + { column = 'tags', type = 'jsonb' }, + { column = 'geom', type = 'geometry', projection = srid, not_null = true }, } } @@ -42,9 +42,9 @@ function unitable_process_node(object) if clean_tags(object.tags) then return end - dtable:add_row({ + dtable:insert({ tags = object.tags, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -53,9 +53,9 @@ function unitable_process_way(object) if clean_tags(object.tags) then return end - dtable:add_row({ + dtable:insert({ tags = object.tags, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -68,9 +68,9 @@ function unitable_process_relation(object) if (object.tags.type == 'multipolygon' or object.tags.type == 'boundary') then - dtable:add_row({ + dtable:insert({ tags = object.tags, - geom = { create = 'area' } + geom = object:as_multipolygon() }) elseif (object.tags.type == 'route' or object.tags.type == 'route_master' @@ -83,55 +83,46 @@ function unitable_process_relation(object) or object.tags.type == 'tunnel' ) then - dtable:add_row({ + dtable:insert({ tags = object.tags, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end - end - if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = unitable_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here unitable_process_node(object_copy) end end - if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = unitable_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here unitable_process_way(object_copy) end end if osm2pgsql.process_relation == nil then - -- Change function name here osm2pgsql.process_relation = unitable_process_relation else local nested = osm2pgsql.process_relation osm2pgsql.process_relation = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here unitable_process_relation(object_copy) end end diff --git a/flex-config/style/water.lua b/flex-config/style/water.lua index f570393..09e82a7 100644 --- a/flex-config/style/water.lua +++ b/flex-config/style/water.lua @@ -7,14 +7,14 @@ tables.water_point = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'node', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'boat', type = 'text' }, - { column = 'geom', type = 'point' , projection = srid}, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'boat', type = 'text' }, + { column = 'geom', type = 'point', projection = srid, not_null = true}, } }) @@ -24,15 +24,15 @@ tables.water_line = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'boat', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'boat', type = 'text' }, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multilinestring' , projection = srid}, + { column = 'geom', type = 'multilinestring', projection = srid, not_null = true}, } }) @@ -42,15 +42,15 @@ tables.water_polygon = osm2pgsql.define_table({ schema = schema_name, ids = { type = 'way', id_column = 'osm_id' }, columns = { - { column = 'osm_type', type = 'text', not_null = true }, - { column = 'osm_subtype', type = 'text', not_null = true }, - { column = 'name', type = 'text' }, - { column = 'layer', type = 'int', not_null = true }, - { column = 'tunnel', type = 'text' }, - { column = 'bridge', type = 'text' }, - { column = 'boat', type = 'text' }, + { column = 'osm_type', type = 'text', not_null = true }, + { column = 'osm_subtype', type = 'text', not_null = true }, + { column = 'name', type = 'text' }, + { column = 'layer', type = 'int', not_null = true }, + { column = 'tunnel', type = 'text' }, + { column = 'bridge', type = 'text' }, + { column = 'boat', type = 'text' }, { column = 'member_ids', type = 'jsonb'}, - { column = 'geom', type = 'multipolygon' , projection = srid}, + { column = 'geom', type = 'multipolygon', projection = srid, not_null = true}, } }) @@ -79,7 +79,7 @@ function water_process_node(object) local bridge = object:grab_tag('bridge') local boat = object:grab_tag('boat') - tables.water_point:add_row({ + tables.water_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -87,7 +87,7 @@ function water_process_node(object) tunnel = tunnel, bridge = bridge, boat = boat, - geom = { create = 'point' } + geom = object:as_point() }) elseif object.tags.waterway then @@ -99,7 +99,7 @@ function water_process_node(object) local bridge = object:grab_tag('bridge') local boat = object:grab_tag('boat') - tables.water_point:add_row({ + tables.water_point:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -107,7 +107,7 @@ function water_process_node(object) tunnel = tunnel, bridge = bridge, boat = boat, - geom = { create = 'point' } + geom = object:as_point() }) end @@ -141,7 +141,7 @@ function water_process_way(object) local boat = object:grab_tag('boat') if object.is_closed then - tables.water_polygon:add_row({ + tables.water_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -149,10 +149,10 @@ function water_process_way(object) tunnel = tunnel, bridge = bridge, boat = boat, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.water_line:add_row({ + tables.water_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -160,7 +160,7 @@ function water_process_way(object) tunnel = tunnel, bridge = bridge, boat = boat, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -174,7 +174,7 @@ function water_process_way(object) local boat = object:grab_tag('boat') if object.is_closed then - tables.water_polygon:add_row({ + tables.water_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -182,10 +182,10 @@ function water_process_way(object) tunnel = tunnel, bridge = bridge, boat = boat, - geom = { create = 'area' } + geom = object:as_polygon() }) else - tables.water_line:add_row({ + tables.water_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -193,7 +193,7 @@ function water_process_way(object) tunnel = tunnel, bridge = bridge, boat = boat, - geom = { create = 'line' } + geom = object:as_linestring() }) end @@ -229,7 +229,7 @@ function water_process_relation(object) local boat = object:grab_tag('boat') if object.tags.type == 'multipolygon' then - tables.water_polygon:add_row({ + tables.water_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -238,10 +238,10 @@ function water_process_relation(object) bridge = bridge, boat = boat, member_ids = member_ids, - geom = { create = 'area' } + geom = object:as_multipolygon() }) else - tables.water_line:add_row({ + tables.water_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -250,7 +250,7 @@ function water_process_relation(object) bridge = bridge, boat = boat, member_ids = member_ids, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end @@ -264,7 +264,7 @@ function water_process_relation(object) local boat = object:grab_tag('boat') if object.tags.type == 'multipolygon' then - tables.water_polygon:add_row({ + tables.water_polygon:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -273,10 +273,10 @@ function water_process_relation(object) bridge = bridge, boat = boat, member_ids = member_ids, - geom = { create = 'area' } + geom = object:as_multipolygon() }) else - tables.water_line:add_row({ + tables.water_line:insert({ osm_type = osm_type, osm_subtype = osm_subtype, name = name, @@ -285,7 +285,7 @@ function water_process_relation(object) bridge = bridge, boat = boat, member_ids = member_ids, - geom = { create = 'line' } + geom = object:as_multilinestring() }) end @@ -296,14 +296,12 @@ end if osm2pgsql.process_node == nil then - -- Change function name here osm2pgsql.process_node = water_process_node else local nested = osm2pgsql.process_node osm2pgsql.process_node = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here water_process_node(object_copy) end end @@ -311,14 +309,12 @@ end if osm2pgsql.process_way == nil then - -- Change function name here osm2pgsql.process_way = water_process_way else local nested = osm2pgsql.process_way osm2pgsql.process_way = function(object) local object_copy = deep_copy(object) nested(object) - -- Change function name here water_process_way(object_copy) end end