Question: Help with GIS class C++: I need to fix findParcelName function so that it reads a point object and tells me if that object is

Help with GIS class C++:

I need to fix findParcelName function so that it reads a point object and tells me if that object is inside the polygon or not. I added the text file you need to read in order to complete these tests at the bottom. I pass the first section of the test case but not the second or third one.

TEST CASE:

TEST_CASE("Testing container (GIS) operations") { GIS taxMap; SECTION("Check file availability") { //I PASS THIS TEST REQUIRE(!taxMap.readFile("zzzzz.zzzz")); REQUIRE(taxMap.readFile("simple-polygons.txt")); }

SECTION("Check point that isn't inside any of the polygons") { //I FAILED THIS TEST taxMap.readFile("simple-polygons.txt"); CHECK("Not Found" == taxMap.findParcelName(Point(-1, -1))); }

SECTION("Check for point inside polygon") { //I FAILED THIS TEST taxMap.readFile("simple-polygons.txt"); CHECK("squareParcel" == taxMap.findParcelName(Point(1, 1))); CHECK("wideRectangleParcel" == taxMap.findParcelName(Point(5, 4))); } }

GIS Class Code:

class GIS{ public: GIS(){ }

~GIS(){cout<<"memory release"<

string findParcelName(Point point); bool readFile(string fileName); private: string fileName; };

bool GIS::readFile(string fileName){ ifstream file; file.open(fileName); //checks if file exist if(file){ file.close(); return true; } return false; }

string GIS::findParcelName(Point point){ //THERE IS ISSUES WITH findParcelName FUNCTION ifstream file; Polygon Poly; file.open("Employee.txt",ios::in); file.seekg(0); while(file){ file.read((char*)&Poly,sizeof(Poly));

if(Poly.contains(point)==true){ file.close(); return Poly.GetName(); } } file.close(); return "Not Found"; }

simple-polygons.txt:

squareParcel 0 0 0 2 2 2 2 0 wideRectangleParcel 0 2 0 4 6 4 6 2

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!