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
|
//
// Test Suite for C-API GEOSRelateBoundaryNodeRule
#include <tut/tut.hpp>
// geos
#include <geos_c.h>
#include "capi_test_utils.h"
namespace tut {
//
// Test Group
//
// Common data used in test cases.
struct test_capigeosrelateboundarynoderule_data : public capitest::utility {
char* pat_;
test_capigeosrelateboundarynoderule_data() : pat_(nullptr)
{}
~test_capigeosrelateboundarynoderule_data()
{
GEOSFree(pat_);
}
};
typedef test_group<test_capigeosrelateboundarynoderule_data> group;
typedef group::object object;
group test_capigeosrelateboundarynoderule_group("capi::GEOSRelateBoundaryNodeRule");
//
// Test Cases
//
// Closed line touching open line on endpoint with OGC rule
template<>
template<>
void object::test<1>
()
{
geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_OGC);
ensure_equals(std::string(pat_), std::string("F01FFF102"));
}
// Closed line touching open line on endpoint with MOD2 rule
template<>
template<>
void object::test<2>
()
{
geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_MOD2);
ensure_equals(std::string(pat_), std::string("F01FFF102"));
}
// Closed line touching open line on endpoint with ENDPOINT rule
template<>
template<>
void object::test<3>
()
{
geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
GEOSRELATE_BNR_ENDPOINT);
ensure_equals(std::string(pat_), std::string("FF1F0F102"));
}
// Noded multiline touching line on node , MOD2 rule
template<>
template<>
void object::test<4>
()
{
geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
GEOSRELATE_BNR_MOD2);
ensure_equals(std::string(pat_), std::string("F01FF0102"));
}
// Noded multiline touching line on node , ENDPOINT rule
template<>
template<>
void object::test<5>
()
{
geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
GEOSRELATE_BNR_ENDPOINT);
ensure_equals(std::string(pat_), std::string("FF1F00102"));
}
// Noded multiline touching line on node , MULTIVALENT ENDPOINT rule
// NOTE: the single line has no boundary !
template<>
template<>
void object::test<6>
()
{
geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
GEOSRELATE_BNR_MULTIVALENT_ENDPOINT);
ensure_equals(std::string(pat_), std::string("FF10FF1F2"));
}
// Noded multiline touching line on node , MONOVALENT ENDPOINT rule
template<>
template<>
void object::test<7>
()
{
geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
ensure_equals(std::string(pat_), std::string("F01FF0102"));
}
// Invalid/unknown rule
template<>
template<>
void object::test<8>
()
{
geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, 5);
ensure(nullptr == pat_);
}
} // namespace tut
|