diff --git a/src/geom-from-osm.cpp b/src/geom-from-osm.cpp index f53920fe6..a273399c9 100644 --- a/src/geom-from-osm.cpp +++ b/src/geom-from-osm.cpp @@ -202,6 +202,9 @@ void create_collection(geometry_t *geom, if (line.size() >= 2U) { collection.add_geometry(std::move(item)); } + if (line.size() == 1) { + collection.add_geometry(geometry_t{std::move(line[0])}); + } } } diff --git a/tests/bdd/flex/geometry-collection.feature b/tests/bdd/flex/geometry-collection.feature index 525c33758..81fcb0220 100644 --- a/tests/bdd/flex/geometry-collection.feature +++ b/tests/bdd/flex/geometry-collection.feature @@ -54,7 +54,7 @@ Feature: Create geometry collections from relations | 10 | And the OSM data """ - w20 Nn10 + w20 Nn11 r30 Tname=foo Mn11@ r31 Tname=bar Mw20@ r32 Tname=baz Mw21@ @@ -62,8 +62,25 @@ Feature: Create geometry collections from relations When running osm2pgsql flex Then table osm2pgsql_test_collection contains exactly - | osm_id | name | ST_GeometryType(geom) | - | 30 | foo | NULL | - | 31 | bar | NULL | - | 32 | baz | NULL | + | osm_id | name | geom | + | 30 | foo | NULL | + | 31 | bar | NULL | + | 32 | baz | NULL | + + Scenario: Point entry generated for broken way lines + Given the grid + | 10 | + And the OSM data + """ + w20 Nn10 + w21 Nn10,n10 + r30 Tname=w20 Mw20@ + r31 Tname=w21 Mw21@ + """ + When running osm2pgsql flex + + Then table osm2pgsql_test_collection contains exactly + | osm_id | name | ST_NumGeometries(geom) | ST_AsText(ST_GeometryN(geom, 1)) | + | 30 | w20 | 1 | 10 | + | 31 | w21 | 1 | 10 | diff --git a/tests/test-geom-collections.cpp b/tests/test-geom-collections.cpp index 8cc2f9684..35c2d5380 100644 --- a/tests/test-geom-collections.cpp +++ b/tests/test-geom-collections.cpp @@ -81,3 +81,17 @@ TEST_CASE("create_collection from no OSM data returns null geometry", "[NoDB]") REQUIRE(geometry_type(geom) == "NULL"); REQUIRE(num_geometries(geom) == 0); } + +TEST_CASE("create_collection from OSM data with single-node way", "[NoDB]") +{ + test_buffer_t buffer; + buffer.add_way("w20 Nn1x1y1"); + + auto const geom = geom::create_collection(buffer.buffer()); + + REQUIRE(geometry_type(geom) == "GEOMETRYCOLLECTION"); + REQUIRE(num_geometries(geom) == 1); + + auto const &c = geom.get(); + REQUIRE(c[0] == geom::geometry_t{geom::point_t{1, 1}}); +}