Skip to content

Commit

Permalink
Fix in calculation of UTM zone number
Browse files Browse the repository at this point in the history
  • Loading branch information
mentaljam committed Jul 8, 2015
1 parent 178379b commit c349639
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Current:
- REMOVE: Removed setUTM()
- NEW: warp() options:
- useUTM - build output raster in UTM projection
- zerosAsND - set no data value to zero
- zerosAsND - set no data value to zero
- FIX: calculation of UTM zone number
13 changes: 9 additions & 4 deletions src/msuproj-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ int main(int argc, char *argv[])

if (srcFile.empty() || gcpFile.empty())
{
printf("ERROR: input and output not specified\n"
printf("ERROR: input files are not specified\n"
"print \"-h\" for help\n");
return 1;
}

if (dstFile.empty())
dstFile = srcFile + string(".tif");

retCode code;

code = msuObj.setSRC(srcFile.c_str());
Expand All @@ -86,6 +83,14 @@ int main(int argc, char *argv[])
return code;
}

if (dstFile.empty())
{
dstFile = srcFile;
if (useUTM)
dstFile += "_" + string(msuObj.getUTM());
dstFile += ".tif";
}

msuObj.setDST(dstFile.c_str());

printf("Processing warp operation");
Expand Down
6 changes: 4 additions & 2 deletions src/msuproj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ const msumr::retCode msumr::msugeo::readGCP(const char *file)
gcpXStep = srcXSize / gcpXSize + 1;
gcpYStep = srcYSize / gcpYSize + 1;

zone = (int)((gcps[(int)(gcpSize / 2)].lon + 180) / 6) + 1;
hemisphere = (gcps[(int)(gcpSize / 2)].lat > 0);
zone = ((int)(((gcps[0].lon + gcps[gcpXSize - 1].lon +
gcps[gcpSize - gcpXSize].lon + gcps[gcpSize - 1].lon) / 4 + 180) / 6) + 1);
hemisphere = ((gcps[0].lat + gcps[gcpXSize - 1].lat +
gcps[gcpSize - gcpXSize].lat + gcps[gcpSize - 1].lat) / 4 > 0);

return success;
}
Expand Down

0 comments on commit c349639

Please sign in to comment.