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
|
Feature: Handling of multiple geometries
Background:
Given the 1.0 grid
| 13 | 12 | | 17 | 16 |
| 10 | 11 | | 14 | 15 |
And the OSM data
"""
w20 Tnatural=water,name=poly Nn10,n11,n12,n13,n10
w21 Nn10,n11,n12,n13,n10
w22 Nn14,n15,n16,n17,n14
r30 Ttype=multipolygon,natural=water,name=poly Mw21@outer
r31 Ttype=multipolygon,natural=water,name=multi Mw21@outer,w22@outer
"""
Scenario: Use 'geometry' column for area (not splitting multipolygons)
Given the lua style
"""
local polygons = osm2pgsql.define_table{
name = 'osm2pgsql_test_polygon',
ids = { type = 'area', id_column = 'osm_id' },
columns = {
{ column = 'name', type = 'text' },
{ column = 'geom', type = 'geometry' }
}
}
function osm2pgsql.process_way(object)
polygons:insert({
name = object.tags.name,
geom = object:as_polygon()
})
end
function osm2pgsql.process_relation(object)
polygons:insert({
name = object.tags.name,
geom = object:as_multipolygon()
})
end
"""
When running osm2pgsql flex
Then table osm2pgsql_test_polygon contains exactly
| osm_id | ST_GeometryType(geom) |
| 20 | ST_Polygon |
| -30 | ST_Polygon |
| -31 | ST_MultiPolygon |
Scenario Outline: Use 'geometry'/'polygon' column for area (splitting multipolygons)
Given the lua style
"""
local polygons = osm2pgsql.define_table{
name = 'osm2pgsql_test_polygon',
ids = { type = 'area', id_column = 'osm_id' },
columns = {
{ column = 'name', type = 'text' },
{ column = 'geom', type = '<geometry_type>', projection = 4326 }
}
}
function osm2pgsql.process_way(object)
polygons:insert({
name = object.tags.name,
geom = object:as_polygon()
})
end
function osm2pgsql.process_relation(object)
for sgeom in object:as_multipolygon():geometries() do
polygons:insert({
name = object.tags.name,
geom = sgeom
})
end
end
"""
When running osm2pgsql flex
Then table osm2pgsql_test_polygon contains exactly
| osm_id | ST_GeometryType(geom) | ST_AsText(geom) |
| 20 | ST_Polygon | (10, 11, 12, 13, 10) |
| -30 | ST_Polygon | (10, 11, 12, 13, 10) |
| -31 | ST_Polygon | (10, 11, 12, 13, 10) |
| -31 | ST_Polygon | (14, 15, 16, 17, 14) |
Examples:
| geometry_type |
| geometry |
| polygon |
Scenario: Use 'multipolygon' column for area (not splitting multipolygons)
Given the lua style
"""
local polygons = osm2pgsql.define_table{
name = 'osm2pgsql_test_polygon',
ids = { type = 'area', id_column = 'osm_id' },
columns = {
{ column = 'name', type = 'text' },
{ column = 'geom', type = 'multipolygon' }
}
}
function osm2pgsql.process_way(object)
polygons:insert({
name = object.tags.name,
geom = object:as_polygon()
})
end
function osm2pgsql.process_relation(object)
polygons:insert({
name = object.tags.name,
geom = object:as_multipolygon()
})
end
"""
When running osm2pgsql flex
Then table osm2pgsql_test_polygon contains exactly
| osm_id | ST_GeometryType(geom) |
| 20 | ST_MultiPolygon |
| -30 | ST_MultiPolygon |
| -31 | ST_MultiPolygon |
Scenario: Use 'multipolygon' column for area (splitting multipolygons)
Given the lua style
"""
local polygons = osm2pgsql.define_table{
name = 'osm2pgsql_test_polygon',
ids = { type = 'area', id_column = 'osm_id' },
columns = {
{ column = 'name', type = 'text' },
{ column = 'geom', type = 'multipolygon' }
}
}
function osm2pgsql.process_way(object)
polygons:insert({
name = object.tags.name,
geom = object:as_polygon()
})
end
function osm2pgsql.process_relation(object)
for sgeom in object:as_multipolygon():geometries() do
polygons:insert({
name = object.tags.name,
geom = sgeom
})
end
end
"""
When running osm2pgsql flex
Then table osm2pgsql_test_polygon contains exactly
| osm_id | ST_GeometryType(geom) |
| 20 | ST_MultiPolygon |
| -30 | ST_MultiPolygon |
| -31 | ST_MultiPolygon |
| -31 | ST_MultiPolygon |
|