7#include "ProcessGroundPolygons.h"
11#include "geos/geom/CoordinateSequence.h"
12#include "geos/geom/LineString.h"
14#include "Application.h"
15#include "BoxcarCachingAlgorithm.h"
16#include "IException.h"
17#include "PolygonTools.h"
18#include "Projection.h"
23 ProcessGroundPolygons::ProcessGroundPolygons() {
39 std::vector<double> &lon,
40 std::vector<double> &values) {
46 for (
unsigned int i = 0; i < lon.size() - 1; i++) {
47 if (fabs(lon[i] - lon[i+1]) > 180.0) {
55 geos::geom::CoordinateSequence pts;
56 for (
unsigned int i = 0; i < lat.size(); i++) {
57 pts.add(geos::geom::Coordinate(lon[i], lat[i]));
59 pts.add(geos::geom::Coordinate(lon[0], lat[0]));
61 geos::geom::Polygon *crossingPoly = Isis::globalFactory->createPolygon(
62 globalFactory->createLinearRing(pts)).release();
64 geos::geom::MultiPolygon *splitPoly = NULL;
76 if (splitPoly != NULL) {
78 for (
unsigned int g = 0; g < splitPoly->getNumGeometries(); ++g) {
79 const geos::geom::Polygon *poly =
80 dynamic_cast<const geos::geom::Polygon *
>(splitPoly->getGeometryN(g));
82 geos::geom::CoordinateSequence *llcoords =
83 poly->getExteriorRing()->getCoordinates().release();
87 std::vector<double> tlat;
88 std::vector<double> tlon;
89 for (
unsigned int cord = 0; cord < llcoords->getSize() - 1; ++cord) {
90 tlon.push_back(llcoords->getAt(cord).x);
91 tlat.push_back(llcoords->getAt(cord).y);
118 std::vector<double> &lon,
119 int &band,
double &value) {
134 std::vector<double> &lon) {
139 for (
unsigned int i = 0; i < lat.size(); i++) {
141 p_samples.push_back(p_groundMap->
Sample());
142 p_lines.push_back(p_groundMap->
Line());
157 if(p_groundMap != NULL) {
173 if(p_groundMap != NULL) {
189 const QString &avgFileName,
190 const QString &countFileName) {
192 Cube cube(cubeStr,
"r");
209 const QString &countFileName,
219 int nBands = this->
InputCubes[0]->bandCount();
220 int nLines = this->
InputCubes[0]->lineCount();
221 int nSamples = this->
InputCubes[0]->sampleCount();
252 QString path = file.path();
253 QString filename = file.baseName();
254 QString countString = path +
"/" + filename +
"-count-";
277 QString path = file.path();
278 QString filename = file.baseName();
279 QString countString = path +
"/" + filename +
"-count-";
301 const QString &countFileName,
310 samples, lines, bands);
323 if (map.hasGroup(
"AlphaCube")) {
static UserInterface & GetUserInterface()
Returns the UserInterface object.
This algorithm is designed for applications that jump around between a couple of spots in the cube wi...
Manipulate and parse attributes of output cube filenames.
IO Handler for Isis Cubes.
File name manipulation and expansion.
void Convert(std::vector< double > &lat, std::vector< double > &lon)
Converts lat/long to line/sample using the universal ground map object.
void AppendOutputCube(QString &cube, const QString &avgFileName, const QString &countFileName="")
This gives the option to append to the cube.
void Finalize()
This method cleans up any open outputcube files and deletes the pointer to the universal ground map i...
void EndProcess()
This method cleans up any open outputcube files and deletes the pointer to the universal ground map i...
void SetStatCubes(const QString ¶meter, QString &cube)
This is a method that is called directly from the application.
void Rasterize(std::vector< double > &lat, std::vector< double > &lon, std::vector< double > &values)
This method gets called from the application with the lat/lon vertices of a polygon along with a vect...
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
virtual Isis::Cube * SetOutputCube(const QString ¶meter)
Allocates a user-specified output cube whose size matches the first input cube.
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
void ClearInputCubes()
Close owned input cubes from the list and clear the list.
Isis::Cube * AppendOutputCube(const QString &avgFileName, const QString &countFileName="")
This gives the option to append to the cube.
void Rasterize(std::vector< double > &samples, std::vector< double > &lines, std::vector< double > &values)
void SetStatCubes(const QString ¶meter, const int nsamps, const int nlines, int nbands=1)
void Finalize()
Cleans up by closing cubes and freeing memory for owned cubes.
static Isis::Projection * CreateForCube(Isis::Pvl &label, int &ns, int &nl, bool sizeMatch=true)
This method creates a map projection for a cube given a label.
Base class for Map Projections.
Contains multiple PvlContainers.
Container for cube-like labels.
@ Traverse
Search child objects.
double Sample() const
Returns the current line value of the camera model or projection.
double Line() const
Returns the current line value of the camera model or projection.
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.