forked from libgeos/geos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GEOSOrientPolygons (libgeos#818)
* Add GEOSOrientPolygons Fixes libgeos#779 Co-authored-by: Joris Van den Bossche <[email protected]>
- Loading branch information
1 parent
cbe7a6c
commit 4c3bd72
Showing
9 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// Test Suite for C-API GEOSOrientationPolygons | ||
|
||
#include <tut/tut.hpp> | ||
// geos | ||
#include <geos_c.h> | ||
// std | ||
#include <string> | ||
#include <cstdarg> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <memory> | ||
|
||
#include "capi_test_utils.h" | ||
|
||
namespace tut { | ||
// | ||
// Test Group | ||
// | ||
|
||
// Common data used in test cases. | ||
struct test_capigeosorientpolygons_data : public capitest::utility {}; | ||
|
||
typedef test_group<test_capigeosorientpolygons_data> group; | ||
typedef group::object object; | ||
|
||
group test_capigeosorientpolygons_group("capi::GEOSOrientPolygons"); | ||
|
||
// empty polygon is passed through | ||
template<> | ||
template<> | ||
void object::test<1>() | ||
{ | ||
geom1_ = GEOSGeomFromWKT("POLYGON EMPTY"); | ||
ensure_equals(GEOSOrientPolygons(geom1_, 1), 0); | ||
|
||
ensure_equals(toWKT(geom1_), "POLYGON EMPTY"); | ||
} | ||
|
||
// hole orientation is opposite to shell | ||
template<> | ||
template<> | ||
void object::test<2>() | ||
{ | ||
geom1_ = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 0), 0); | ||
ensure_equals(toWKT(geom1_), "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 1), 0); | ||
ensure_equals(toWKT(geom1_), "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))"); | ||
} | ||
|
||
// all polygons in collection are processed | ||
template<> | ||
template<> | ||
void object::test<3>() | ||
{ | ||
geom1_ = GEOSGeomFromWKT("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((100 100, 200 100, 200 200, 100 100)))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 0), 0); | ||
ensure_equals(toWKT(geom1_), "MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((100 100, 200 100, 200 200, 100 100)))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 1), 0); | ||
ensure_equals(toWKT(geom1_), "MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((100 100, 200 200, 200 100, 100 100)))"); | ||
} | ||
|
||
// polygons in collection are oriented, closed linestring unchanged | ||
template<> | ||
template<> | ||
void object::test<4>() | ||
{ | ||
geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), LINESTRING (100 100, 200 100, 200 200, 100 100))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 1), 0); | ||
ensure_equals(toWKT(geom1_), "GEOMETRYCOLLECTION (POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), LINESTRING (100 100, 200 100, 200 200, 100 100))"); | ||
} | ||
|
||
// nested collection handled correctly | ||
template<> | ||
template<> | ||
void object::test<5>() | ||
{ | ||
geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)))))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 0), 0); | ||
ensure_equals(toWKT(geom1_), "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)))))"); | ||
|
||
ensure_equals(GEOSOrientPolygons(geom1_, 1), 0); | ||
ensure_equals(toWKT(geom1_), "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0)))))"); | ||
} | ||
|
||
} // namespace tut | ||
|