Isis Developer Reference
|
This class is used to find the overlaps between all the images in a list of serial numbers. More...
#include <ImageOverlapSet.h>
Public Member Functions | |
ImageOverlapSet (bool continueOnError=false, bool useThread=true) | |
Create FindImageOverlaps object. | |
virtual | ~ImageOverlapSet () |
Delete this object. | |
void | FindImageOverlaps (SerialNumberList &boundaries) |
Create polygons of overlap from the images specified in the serial number list. | |
void | FindImageOverlaps (std::vector< QString > sns, std::vector< geos::geom::MultiPolygon * > polygons) |
This is a strict pthread implementation of this class' multi-threading! | |
void | FindImageOverlaps (SerialNumberList &boundaries, QString outputFile) |
This method calculates image overlaps given a SerialNumberList and writes it to the filename specified by outputFile. | |
void | ReadImageOverlaps (const QString &filename) |
Create polygons of overlap from the file specified. | |
void | WriteImageOverlaps (const QString &filename) |
Write polygons of overlap to the file specified. | |
int | Size () |
Returns the total number of latitude and longitude overlaps. | |
const ImageOverlap * | operator[] (int index) |
Returns the images which overlap at a given loverlap. | |
std::vector< ImageOverlap * > | operator[] (QString serialNumber) |
Return the overlaps that have a specific serial number. | |
const std::vector< PvlGroup > & | Errors () |
Return the a list of errors encountered. | |
Protected Member Functions | |
void | FindAllOverlaps (SerialNumberList *snlist=NULL) |
Find the overlaps between all the existing ImageOverlap Objects. | |
void | AddSerialNumbers (ImageOverlap *to, ImageOverlap *from) |
Add the serial numbers from the second overlap to the first. | |
Protected Attributes | |
std::vector< PvlGroup > | p_errorLog |
This is a list of detailed* errors including all known information. | |
This class is used to find the overlaps between all the images in a list of serial numbers.
The overlaps are created in (Lon,Lat) coordinates of geos::geom::MultiPolygons. Each overlap has an associated list of serial numbers which are contained in that overlap.
Isis::ImageOverlapSet::ImageOverlapSet | ( | bool | continueOnError = false, |
bool | useThread = true ) |
Create FindImageOverlaps object.
Create an empty FindImageOverlaps object.
continueOnError | Whether or not this class throws exceptions in addition to logging errors. |
|
virtual |
Delete this object.
Delete the FindImageOverlaps object. The stored ImageOverlaps will be deleted as well.
References Size().
|
protected |
Add the serial numbers from the second overlap to the first.
Note: Need to check for existence of a SN before adding it
to | The object to receive the new serial numbers |
from | The object to copy the serial numbers from |
Referenced by FindAllOverlaps().
|
inline |
Return the a list of errors encountered.
References p_errorLog.
|
protected |
Find the overlaps between all the existing ImageOverlap Objects.
snlist | The serialnumber list relating to the overlaps described by the current known ImageOverlap objects or NULL |
References AddSerialNumbers(), Isis::PolygonTools::Despike(), Isis::PolygonTools::Difference(), Isis::PolygonTools::Equal(), Isis::globalFactory, Isis::PolygonTools::Intersect(), Isis::PolygonTools::MakeMultiPolygon(), and Isis::Progress::SetText().
Referenced by FindImageOverlaps(), and FindImageOverlaps().
void Isis::ImageOverlapSet::FindImageOverlaps | ( | SerialNumberList & | sns | ) |
Create polygons of overlap from the images specified in the serial number list.
All polygons created by this class will be deleted when it is destroyed, so callers should not delete the polygons returned by various members.
sns | The serial number list to use when finding overlaps |
References _FILEINFO_, Isis::Cube::close(), Isis::PolygonTools::Despike(), FindAllOverlaps(), Isis::PolygonTools::MakeMultiPolygon(), Isis::Cube::open(), Isis::IException::Programmer, and Isis::Cube::readFootprint().
Referenced by FindImageOverlaps().
void Isis::ImageOverlapSet::FindImageOverlaps | ( | SerialNumberList & | boundaries, |
QString | outputFile ) |
This method calculates image overlaps given a SerialNumberList and writes it to the filename specified by outputFile.
This method is internally optimized and multi-threaded: the overlaps will NOT persist in memory after this method is called. This object will be reset to its initial state when this is called, and it is invalid to call this method if you have called other methods first.
This method is internally multi-threaded and more efficient than the others for calculating overlaps.
boundaries | The files to find overlaps between |
outputFile | The output ImageOverlapSet file |
References _FILEINFO_, FindImageOverlaps(), Isis::IException::Programmer, and WriteImageOverlaps().
void Isis::ImageOverlapSet::FindImageOverlaps | ( | std::vector< QString > | sns, |
std::vector< geos::geom::MultiPolygon * > | polygons ) |
This is a strict pthread implementation of this class' multi-threading!
void ImageOverlapSet::FindImageOverlaps(SerialNumberList &boundaries, QString outputFile) {
Do a common sense programmer check, this should be empty before we start if (!p_lonLatOverlaps.empty()) { string msg = "FindImageOverlaps(SerialNumberList&,QString) may not be called on an ImageOverlapSet " \ "which already contains overlaps."; throw iException::Message(iException::Programmer, msg, FILEINFO); }
p_writtenSoFar = 0; p_calculatedSoFar = -1;
This will enable using mutexes in the method calls where necessary. p_threadedCalculate = true;
We need to pass a this pointer to the thread AND the serial number list in order to have it calculate properly. Build the void* to pass in. void *data[] = {this, &boundaries};
This is the thread that will be calculating the overlaps. Our current thread will be the one writing to the output file so synchronization at exit is not an issue. pthread_t calculateThread;
Enter the initialization phase: don't try to write until the other thread says initialization is done by unlocking this mutex. pthread_mutex_lock(&initDataMutex);
Create the other thread - it will initialize variables (the ImageOverlap list), unlock the initDataMutex, and proceed to calculate. After each polygon is calculated the calculating mutex will also be unlocked in order to allow I/O if possible. When done calculatedSoFar == p_lonLatOverlaps.size() and the calculating mutex is unlocked. pthread_create(&calculateThread, NULL, FindImageOverlapsThreadStart, &data);
this will let us pass when initialization is done pthread_mutex_lock(&initDataMutex);
Final unlock of the initialization mutex - we locked it to get into this code pthread_mutex_unlock(&initDataMutex);
While our exit condition is not true, call WriteImageOverlaps with the filename. The WriteImageOverlaps call will block if it is waiting on calculations. while(p_calculatedSoFar != (int)p_lonLatOverlaps.size()) { WriteImageOverlaps(outputFile); }
Wait for the calculation thread to actually exit, this has more than likely already occurred. void *result; pthread_join(calculateThread, &result);
re-initialize object to original state p_lonLatOverlaps.clear(); p_writtenSoFar = 0; p_calculatedSoFar = -1; p_threadedCalculate = false; } This is the method that is called when a thread is spawned by FindImageOverlaps(...). It simply calls FindImageOverlaps with a SerialNumberList and exits.
data | An array of the form {ImageOverlapSet* instance, SerialNumberList *snlist) |
void *ImageOverlapSet::FindImageOverlapsThreadStart(void *data) { ImageOverlapSet *instance = (ImageOverlapSet *) ((void**)data)[0]; SerialNumberList *snlist = (SerialNumberList *)((void**)data)[1]; instance->FindImageOverlaps( *snlist ); pthread_exit(NULL); } Create polygons of overlap from the polygons specified. The serial numbers and the polygons are assumed to be parallel arrays. The original polygons passed as arguments are copied, so the ownership of the originals remains with the caller.
sns | The serial number list to use when finding overlaps |
polygons | The polygons which are to be used when finding overlaps |
References _FILEINFO_, FindAllOverlaps(), and Isis::IException::Programmer.
|
inline |
Returns the images which overlap at a given loverlap.
index | The index of the overlap |
std::vector< ImageOverlap * > Isis::ImageOverlapSet::operator[] | ( | QString | serialNumber | ) |
Return the overlaps that have a specific serial number.
Search the existing ImageOverlap objects for all that have the serial numbers associated with them. Note: This could be costly when many overlaps exist.
serialNumber | The serial number to be search for in all existing ImageOverlaps |
void Isis::ImageOverlapSet::ReadImageOverlaps | ( | const QString & | filename | ) |
Create polygons of overlap from the file specified.
filename | The file to read the image overlaps from |
References _FILEINFO_, Isis::FileName::expanded(), and Isis::IException::Unknown.
Referenced by Isis::InterestOperator::Operate().
|
inline |
Returns the total number of latitude and longitude overlaps.
Referenced by Isis::InterestOperator::FindOverlap(), and ~ImageOverlapSet().
void Isis::ImageOverlapSet::WriteImageOverlaps | ( | const QString & | filename | ) |
Write polygons of overlap to the file specified.
filename | The file to write the image overlaps to |
References _FILEINFO_, Isis::FileName::expanded(), Isis::IException::Io, and Isis::IException::User.
Referenced by FindImageOverlaps().
|
protected |
This is a list of detailed* errors including all known information.
Referenced by Errors().