Skip to content

Commit 52d2ba0

Browse files
acpaquetteamystamile-usgs
authored andcommitted
Gdal Projection Parsing Fixes (#5999)
* Allow for some tolerance in x/y resolution in projected geotiffs * Properly search proj axes for longitude direction * Added change log file
1 parent c1774d1 commit 52d2ba0

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

changes/5999.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allows for slightly unsquare pixels from projected GDAL products and fixes axes parsing for longitude direction.

isis/src/core/src/Pvl.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,21 @@ namespace Isis {
190190
projJson = projJson["base_crs"];
191191
}
192192

193-
std::string direction = projJson["coordinate_system"]["axis"][1]["direction"];
194-
if (direction == "east") {
195-
mappingGroup.addKeyword(PvlKeyword("LongitudeDirection", "PositiveEast"));
196-
}
197-
else if (direction == "west") {
198-
mappingGroup.addKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"));
199-
}
200-
else {
201-
QString msg = "Unknown direction [" + QString::fromStdString(direction) + "]";
202-
throw IException(IException::Programmer, msg, _FILEINFO_);
193+
nlohmann::json axes = projJson["coordinate_system"]["axis"];
194+
for (nlohmann::json axis : axes) {
195+
if (axis["name"] == "Longitude") {
196+
std::string direction = axis["direction"];
197+
if (direction == "east") {
198+
mappingGroup.addKeyword(PvlKeyword("LongitudeDirection", "PositiveEast"));
199+
}
200+
else if (direction == "west") {
201+
mappingGroup.addKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"));
202+
}
203+
else {
204+
QString msg = "Unknown direction [" + QString::fromStdString(direction) + "]";
205+
throw IException(IException::Programmer, msg, _FILEINFO_);
206+
}
207+
}
203208
}
204209

205210
if (oSRS.GetSemiMajor() == oSRS.GetSemiMinor()) {
@@ -215,7 +220,7 @@ namespace Isis {
215220
// Read the GeoTransform and get the elements we care about
216221
double *padfTransform = new double[6];
217222
dataset->GetGeoTransform(padfTransform);
218-
if (abs(padfTransform[1]) != abs(padfTransform[5])) {
223+
if ((abs(padfTransform[1]) - abs(padfTransform[5])) > 1e-2) {
219224
delete[] padfTransform;
220225
QString msg = "Vertical and horizontal resolution do not match";
221226
throw IException(IException::Io, msg, _FILEINFO_);

0 commit comments

Comments
 (0)