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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started