Commit 7c31be67 authored by mjg226's avatar mjg226
Browse files

Debugged for windows compilation.

- added default constructor to CA::Point class, as MSVC complained.
- add two functions to the HexAsciiGrid class, as these are needed by DLL or comparison program, not fully implemented yet
    void addAsciiGrid(AsciiGrid<T>& grid2, bool print = false); which adds the data of one grid into another using geo-cordinates
    Errors compareAsciiGrid(AsciiGrid<T>& grid2, T tolerance = 0.0, bool print = false); which compares the difference between two grids, likey this will be the same as for square grids.
- minor debug of mapping real value to arrays of length two, for some reason MSVC didn't like this so replaced with Points which hold the two values.
parent cc06dea1
......@@ -61,6 +61,10 @@ namespace CA {
public:
//default constructor, sets to zero's
Point();
//! Create a point in the grid.
//! \param x The X position.
//! \param y The Y position.
......@@ -142,7 +146,11 @@ namespace CA {
/// ----- Inline implementation ----- ///
inline Point::Point() :
_x(0), _y(0), _coo()
{
}
inline Point::Point(Unsigned x, Unsigned y):
_x(x), _y(y), _coo()
......
......@@ -225,6 +225,92 @@ namespace CA {
}
//------------------------------------------------------------------------------------------------------------------------------
//! Add another ascii gri dof data to this grid of data
inline void addAsciiGrid(AsciiGrid<T>& grid2, bool print = false) {
// find how many cells between bottom left of each terrain.
int colsDiff = 0;
int rowsDiff = 0;
if (print)
std::cout << "BLAH" << std::endl;
// TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEEDS IMPLMENTING FOR HEX GRIDS
}
//------------------------------------------------------------------------------------------------------------------------------
//#######################################################################################################################################
//########################################### comparitor functions ########################################################
//#######################################################################################################################################
//--------------------------------------------------------------------------------------------------------------
//! Compare the RMSE of two ascii grids, and return the errors
//! if the same cell from either grid is no data, then no comparison is made
//! note this object is considered the observation (truth) to compare to the other simulation.
inline Errors compareAsciiGrid(AsciiGrid<T>& grid2, T tolerance = 0.0, bool print = false)
{
//
//double result = 0.0;
//int count = 0;
// TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEEDS IMPLMENTING FOR HEX GRIDS
// note needs checking for cell size usuage?!.............
// erros structure used, to reduce multiple loops
Errors result;
result.RMSE = 0.0;
result.RMSE_wet_both = 0.0;
result.RMSE_wet_either = 0.0;
result.meanError = 0.0;
result.meanError_wet_both = 0.0;
result.meanError_wet_either = 0.0;
result.accuracy = 0.0;
result.sensitivity = 0.0;
result.precision = 0.0;
result.precentage = 0.0;
result.nashSutcliffe = 0.0;
result.truePositive = 0;
result.falsePositive = 0;
result.trueNegative = 0;
result.falseNegative = 0;
result.thisWettedCount = 0;
result.thatWettedCount = 0;
result.combinedWettedCount = 0;
result.allDataCells = 0;
result.eitherWetted = 0;
// for nash sutcliffe we need the mean of the observed (truth), i.e. this ascii grids data
double meanObserved = 0.0;
double nashSumSquaredErrors = 0.0;
double nashSumDataVariance = 0.0;
// do a check for size mismatch here.
// due to geo-cor-ordinates, we must check only the region that overlaps
// TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEEDS IMPLMENTING FOR HEX GRIDS
return result;
}// end of compareAsciiGridHeader
//--------------------------------------------------------------------------------------------------------------
};// end of class
......@@ -244,6 +330,8 @@ namespace CA {
template<typename T>
const std::string HexAsciiGrid<T>::file_extension = ".hasc";
}// end of namespace
......
......@@ -58,7 +58,9 @@ namespace CA {
inline Point Point::create(const Grid& grid, Real x_coo, Real y_coo)
{
std::map<Real, std::array<Unsigned, 2> > centroids;
// windows doesn't like the use of the array inside the map for some reason, adapting code
//std::map<Real, std::array<Unsigned, 2> > centroids;
std::map<Real, Point> centroids;
Coo param(x_coo, y_coo);
Unsigned x,y;
Unsigned x_principal = static_cast<Unsigned>( std::floor( (x_coo - grid.xCoo())/(grid.length()*3/2) ) );
......@@ -66,22 +68,28 @@ namespace CA {
Coo c1(x_principal * (grid.length()*3/2), y_principal * grid.distance());
if(!(x_principal % 2)) c1.setY(c1.y() + grid.distance() / 2);
centroids[c1.distanceTo(param)] = {x_principal, y_principal};
//centroids[c1.distanceTo(param)] = {x_principal, y_principal};
centroids[c1.distanceTo(param)] = Point( x_principal, y_principal );
Coo c2(x_principal * (grid.length()*3/2), (y_principal - 1) * grid.distance());
if(!(x_principal % 2)) c2.setY(c2.y() + grid.distance() / 2);
centroids[c2.distanceTo(param)] = {x_principal, y_principal - 1};
//centroids[c2.distanceTo(param)] = {x_principal, y_principal - 1};
centroids[c2.distanceTo(param)] = Point( x_principal, y_principal - 1 );
Coo c3((x_principal - 1) * (grid.length()*3/2), (y_principal - 1) * grid.distance());
if(!((x_principal - 1) % 2)) c3.setY(c3.y() + grid.distance() / 2);
centroids[c3.distanceTo(param)] = {x_principal - 1, y_principal - 1};
//centroids[c3.distanceTo(param)] = {x_principal - 1, y_principal - 1};
centroids[c3.distanceTo(param)] = Point( x_principal - 1, y_principal - 1 );
Coo c4((x_principal - 1) * (grid.length()*3/2), y_principal * grid.distance());
if(!((x_principal - 1) % 2)) c4.setY(c4.y() + grid.distance() / 2);
centroids[c4.distanceTo(param)] = {x_principal - 1, y_principal};
//centroids[c4.distanceTo(param)] = {x_principal - 1, y_principal};
centroids[c4.distanceTo(param)] = Point( x_principal - 1, y_principal );
x = centroids.begin()->second[0];
y = centroids.begin()->second[1];
//x = centroids.begin()->second[0];
x = centroids.begin()->second.x();
//y = centroids.begin()->second[1];
y = centroids.begin()->second.y();
/// Y is inverted
/// Y cannot be zero!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment