Skip to content

Implemented operator() in NoBinningObject class #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/decoders/BinningObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,75 @@ Matrix* BinningObject::operator()(PointsList& points) {
}i*/
return matrix;
}


NoBinningObject::NoBinningObject() {
}

NoBinningObject::~NoBinningObject() {

}

BinningObject* NoBinningObject::clone() const {
return new NoBinningObject();
}

Matrix* NoBinningObject::operator()(PointsList& points) {

static float default_float_fill_value = 9.96921e+36;

// make a new Matrix object
Matrix* ret = new Matrix();

ret->akimaEnabled();
ret->reserve(points.size());
ret->missing(default_float_fill_value);

// set column values (longitudes)
points.setToFirst();

double last_latitude = -360;

vector<double> &xValues = ret->columnsAxis();
while (points.more()) {
const UserPoint& current_point = points.current();
double current_lat = current_point.y();

if ( (last_latitude != -360) && (last_latitude != current_lat))
break;

last_latitude = current_lat;
xValues.push_back(current_point.x());
points.advance();
}

int columns = xValues.size();
int rows = points.size() / columns;

// set row (latitude) and data values
points.setToFirst();

int row = points.size() - columns;
int column = 0;

vector<double> &yValues = ret->rowsAxis();
while (points.more()) {
const UserPoint& current_point = points.current();
double current_value = current_point.value();

(*ret)[row + column] = current_value;

points.advance();
++column;

if (column == columns) {
row -= columns;
column = 0;
yValues.insert(yValues.begin(), current_point.y());
}
}

ret->setMapsAxis();

return ret;
}
9 changes: 5 additions & 4 deletions src/decoders/BinningObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BinningObject : public BinningObjectAttributes {

virtual BinningObject* clone() const { return new BinningObject(); }

Matrix* operator()(PointsList& points);
virtual Matrix* operator()(PointsList& points);


protected:
Expand Down Expand Up @@ -76,9 +76,10 @@ class BinningObject : public BinningObjectAttributes {

class NoBinningObject : public BinningObject {
public:
NoBinningObject() {}
~NoBinningObject() {}
BinningObject* clone() const { return new NoBinningObject(); }
NoBinningObject();
~NoBinningObject();
BinningObject* clone() const override;
Matrix* operator()(PointsList& points) override;
};


Expand Down