1 #include "ProcessGroundPolygons.h" 5 #include "geos/geom/CoordinateSequence.h" 6 #include "geos/geom/CoordinateArraySequence.h" 7 #include "geos/geom/LineString.h" 8 #include "geos/geosAlgorithm.h" 19 ProcessGroundPolygons::ProcessGroundPolygons() {
34 void ProcessGroundPolygons::Rasterize(std::vector<double> &lat,
35 std::vector<double> &lon,
36 std::vector<double> &values) {
42 for (
unsigned int i = 0; i < lon.size() - 1; i++) {
43 if (fabs(lon[i] - lon[i+1]) > 180.0) {
51 geos::geom::CoordinateSequence *pts =
new geos::geom::CoordinateArraySequence();
52 for (
unsigned int i = 0; i < lat.size(); i++) {
53 pts->add(geos::geom::Coordinate(lon[i], lat[i]));
55 pts->add(geos::geom::Coordinate(lon[0], lat[0]));
57 geos::geom::Polygon *crossingPoly = Isis::globalFactory.createPolygon(
58 globalFactory.createLinearRing(pts), NULL);
60 geos::geom::MultiPolygon *splitPoly = NULL;
62 splitPoly = PolygonTools::SplitPolygonOn360(crossingPoly);
72 if (splitPoly != NULL) {
74 for (
unsigned int g = 0; g < splitPoly->getNumGeometries(); ++g) {
75 const geos::geom::Polygon *poly =
76 dynamic_cast<const geos::geom::Polygon *
>(splitPoly->getGeometryN(g));
78 geos::geom::CoordinateSequence *llcoords = poly->getExteriorRing()->getCoordinates();
82 std::vector<double> tlat;
83 std::vector<double> tlon;
84 for (
unsigned int cord = 0; cord < llcoords->getSize() - 1; ++cord) {
85 tlon.push_back(llcoords->getAt(cord).x);
86 tlat.push_back(llcoords->getAt(cord).y);
90 ProcessPolygons::Rasterize(p_samples, p_lines, values);
97 ProcessPolygons::Rasterize(p_samples, p_lines, values);
112 void ProcessGroundPolygons::Rasterize(std::vector<double> &lat,
113 std::vector<double> &lon,
114 int &band,
double &value) {
117 ProcessPolygons::Rasterize(p_samples, p_lines, band, value);
128 void ProcessGroundPolygons::Convert(std::vector<double> &lat,
129 std::vector<double> &lon) {
134 for (
unsigned int i = 0; i < lat.size(); i++) {
135 if (p_groundMap->SetUniversalGround(lat[i], lon[i])) {
136 p_samples.push_back(p_groundMap->Sample());
137 p_lines.push_back(p_groundMap->Line());
150 void ProcessGroundPolygons::EndProcess() {
152 if(p_groundMap != NULL) {
156 ProcessPolygons::EndProcess();
166 void ProcessGroundPolygons::Finalize() {
168 if(p_groundMap != NULL) {
172 ProcessPolygons::Finalize();
183 void ProcessGroundPolygons::AppendOutputCube(QString &cubeStr,
184 const QString &avgFileName,
185 const QString &countFileName) {
187 Cube cube(cubeStr,
"r");
189 ProcessPolygons::AppendOutputCube(avgFileName, countFileName);
203 void ProcessGroundPolygons::SetStatCubes(
const QString &avgFileName,
204 const QString &countFileName,
214 int nBands = this->InputCubes[0]->bandCount();
215 int nLines = this->InputCubes[0]->lineCount();
216 int nSamples = this->InputCubes[0]->sampleCount();
218 this->Process::SetOutputCube(avgFileName, outAtts, nSamples, nLines, nBands);
219 this->Process::SetOutputCube(countFileName, outAtts, nSamples, nLines, nBands);
238 void ProcessGroundPolygons::SetStatCubes(
const QString ¶meter,
242 Application::GetUserInterface().GetFileName(parameter);
244 Application::GetUserInterface().GetOutputAttribute(parameter);
247 QString path = file.
path();
249 QString countString = path +
"/" + filename +
"-count-";
251 SetStatCubes(avgString, countString, atts, cube);
263 void ProcessGroundPolygons::SetStatCubes(
const QString ¶meter,
267 Application::GetUserInterface().GetFileName(parameter);
269 Application::GetUserInterface().GetOutputAttribute(parameter);
272 QString path = file.
path();
274 QString countString = path +
"/" + filename +
"-count-";
276 SetStatCubes(avgString, countString, atts, map, bands);
295 void ProcessGroundPolygons::SetStatCubes(
const QString &avgFileName,
296 const QString &countFileName,
301 Projection *proj = ProjectionFactory::CreateForCube(map, samples, lines,
304 this->ProcessPolygons::SetStatCubes(avgFileName, countFileName, atts,
305 samples, lines, bands);
314 OutputCubes[0]->putGroup(group);
315 OutputCubes[1]->putGroup(group);
320 OutputCubes[0]->putGroup(alpha);
321 OutputCubes[1]->putGroup(alpha);
QString path() const
Returns the path of the file name.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
File name manipulation and expansion.
Namespace for the standard library.
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
This algorithm is designed for applications that jump around between a couple of spots in the cube wi...
Base class for Map Projections.
Contains multiple PvlContainers.
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
Manipulate and parse attributes of output cube filenames.
Container for cube-like labels.
QString baseName() const
Returns the name of the file without the path and without extensions.
Namespace for ISIS/Bullet specific routines.
IO Handler for Isis Cubes.