Skip to content

Commit

Permalink
More code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Jan 22, 2025
1 parent e99b809 commit 5ab4c00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 43 deletions.
48 changes: 9 additions & 39 deletions tests/xmltester/XMLTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,6 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node)
gA = nullptr;
gB = nullptr;


//dump_to_stdout(node);

curr_case_desc.clear();
const tinyxml2::XMLNode* txt = node->FirstChildElement("desc");
if(txt) {
Expand All @@ -630,10 +627,6 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node)
curr_case_desc = trimBlanks(txt->Value());
}
}

//std::cerr << "Desc: " << curr_case_desc << std::endl;


try {
const tinyxml2::XMLNode* el = node->FirstChildElement("a");
geomAin = el->FirstChild()->Value();
Expand Down Expand Up @@ -1125,63 +1118,63 @@ void Test::executeOp(Geometry* gA, Geometry* gB)
checkResult( den.getResultGeometry().get() );
}
else if(opName == "intersects") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->intersects(gB));
}
else {
checkResult( gA->intersects(gB) );
}
}
else if(opName == "contains") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->contains(gB));
}
else {
checkResult( gA->contains(gB) );
}
}
else if(opName == "overlaps") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->overlaps(gB));
}
else {
checkResult( gA->overlaps(gB) );
}
}
else if(opName == "within") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->within(gB));
}
else {
checkResult( gA->within(gB) );
}
}
else if(opName == "touches") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->touches(gB));
}
else {
checkResult( gA->touches(gB) );
}
}
else if(opName == "crosses") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->crosses(gB));
}
else {
checkResult( gA->crosses(gB) );
}
}
else if(opName == "disjoint") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->disjoint(gB));
}
else {
checkResult( gA->disjoint(gB) );
}
}
else if(opName == "covers") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->covers(gB));
}
else {
Expand All @@ -1204,7 +1197,7 @@ void Test::executeOp(Geometry* gA, Geometry* gB)
checkResult( gA->equalsExact(gB));
}
else if(opName == "coveredby") {
if (tester.isUsePrepared()) {
if (tester.isPrepared()) {
checkResult( prepare(gA)->coveredBy(gB));
}
else {
Expand Down Expand Up @@ -1367,49 +1360,26 @@ void Test::executeOp(Geometry* gA, Geometry* gB)
throw std::runtime_error("malformed testcase: missing tolerated area difference in 'areatest' op");
}

if(verbose > 1) {
std::cerr << "Running intersection for areatest" << std::endl;
}
std::unique_ptr<Geometry> gI(gA->intersection(gB));

if(testValidOutput) {
validOut &= tester.testValid(gI.get(), "areatest intersection");
}

if(verbose > 1) {
std::cerr << "Running difference(A,B) for areatest" << std::endl;
}

std::unique_ptr<Geometry> gDab(gA->difference(gB));

if(testValidOutput) {
validOut &= tester.testValid(gI.get(), "areatest difference(a,b)");
}

if(verbose > 1) {
std::cerr << "Running difference(B,A) for areatest" << std::endl;
}

std::unique_ptr<Geometry> gDba(gB->difference(gA));

if(testValidOutput) {
validOut &= tester.testValid(gI.get(), "areatest difference(b,a)");
}

if(verbose > 1) {
std::cerr << "Running symdifference for areatest" << std::endl;
}

std::unique_ptr<Geometry> gSD(gA->symDifference(gB));

if(testValidOutput) {
validOut &= tester.testValid(gI.get(), "areatest symdifference");
}

if(verbose > 1) {
std::cerr << "Running union for areatest" << std::endl;
}

std::unique_ptr<Geometry> gU(gA->Union(gB));

double areaA = gA->getArea();
Expand Down
8 changes: 4 additions & 4 deletions tests/xmltester/XMLTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class XMLTester {

bool isTestValidOutput() { return testValidOutput; }

bool isUsePrepared() { return usePrepared; }
bool isPrepared() { return usePrepared; }

geom::GeometryFactory* getFactory() { return factory.get(); }

Expand Down Expand Up @@ -135,6 +135,9 @@ class XMLTester {

};

/*
Executes a single test in a XML test file.
*/
class Test {
private:
XMLTester& tester;
Expand All @@ -148,7 +151,6 @@ class Test {
std::string opSignature;

//TODO: make these functions on XMLTester?
int verbose;
bool testValidOutput;

bool isSuccess;
Expand All @@ -174,9 +176,7 @@ class Test {
isSuccess(false),
actual_result("NONE")
{
verbose = tester.isVerbose();
testValidOutput = tester.isTestValidOutput();
//usePrepared = tester.isUsePrepared();
}
bool run(const tinyxml2::XMLNode* node, Geometry* geomA, Geometry* geomB);

Expand Down

0 comments on commit 5ab4c00

Please sign in to comment.