Question: gis.cpp #include #include #include #include #include point.hpp #include polygon.hpp #include gis.hpp using namespace std; Gis::Gis(){ fileName = ; numPolygons = 0; polygons = new Polygon

gis.cpp

#include

#include

#include

#include

#include "point.hpp"

#include "polygon.hpp"

#include "gis.hpp"

using namespace std;

Gis::Gis(){

fileName = "";

numPolygons = 0;

polygons = new Polygon [numPolygons];

}

Gis::~Gis()

{

}

Gis::Gis(const Gis &other)

{

numPolygons = other.numPolygons;

for(int i = 0; i < numPolygons; i++)

{

polygons[i] = other.polygons[i];

}

}

Gis& Gis::operator=(const Gis &other)

{

numPolygons = other.numPolygons;

for(int i = 0; i < numPolygons; i++)

{

polygons[i] = other.polygons[i];

}

return *this;

}

bool Gis::readFile(string filename){

ifstream infile(filename);

if (!infile.is_open()){

cout << "File not found!" << endl;

return false;

}

else {

fileName = filename;

}

return true;

}

string Gis::findParcelName(Point pointForGis) {

for (int i = 0; i < numPolygons; i++) {

if(polygons[i].contains(pointForGis)) {

return polygons[i].GetName();

}

}

return "Not Found";

}

#include "../gis.hpp"

#include "catch/catch.hpp"

test-4-gis.cpp

TEST_CASE("Testing container (GIS) operations") {

GIS taxMap;

SECTION("Check file availability") {

REQUIRE(!taxMap.readFile("zzzzz.zzzz"));

REQUIRE(taxMap.readFile("simple-polygons.txt"));

}

SECTION("Check point that isn't inside any of the polygons") {

taxMap.readFile("simple-polygons.txt");

CHECK("Not Found" == taxMap.findParcelName(Point(-1, -1)));

}

SECTION("Check for point inside polygon") {

taxMap.readFile("simple-polygons.txt");

CHECK("squareParcel" == taxMap.findParcelName(Point(1, 1)));

CHECK("wideRectangleParcel" == taxMap.findParcelName(Point(5, 4)));

}

}

its allowing me to get to the test file but its giving me errors, I need help with how to get it to pass, espically how to read the file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!