In my cpp code I'm iterating over four geotiff images and want to extract their geotiepoints (coordinates) in a pair with the image number as first and the geotiepoints as second. Next, I want to push them into a global vector of type pair for later use. That's my current code:
//Global Variable
std::vector <std::pair<short, double*>> GeoTPWithNr;
//for each file in directory
void GetGeoTiePoints(TIFF* tif)
{
unsigned short count;
double* Geotiepoints;
std::pair<short, double*>TiepointsWithNumber;
TiepointsWithNumber.first = filenumber;
TIFFGetField(tif, TIFFTAG_GEOTIEPOINTS, &count, &Geotiepoints)
TiepointsWithNumber.second = Geotiepoints;
GeoTPWithNr.push_back(TiepointsWithNumber);
std::cout << GeoTPWithNr[0].second[3] << std::endl;
std::cout << GeoTPWithNr[0].second[4] << std::endl;
}
To test the code I want to print the tiepoints of the vector at position 0. What I expect are four times the tiepoint values. When I ran the code first time it worked and I got the following result:
However, every time I run my code I get different result, eventhough I didn't change anything in my code.
When I print the values of my pair, before I push it into the vector, I always get the correct results. Thus, it seems there is a problem when trying to push the pair into the vector or retrieving the values from the vector.
Where is the problem? I guess it has something to do with how the results are written into the vector. Does anyone have an idea on how to solve this issue?
Thanks and best wishes