Skip to content

Commit c349639

Browse files
committed
Fix in calculation of UTM zone number
1 parent 178379b commit c349639

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGELOG.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ Current:
44
- REMOVE: Removed setUTM()
55
- NEW: warp() options:
66
- useUTM - build output raster in UTM projection
7-
- zerosAsND - set no data value to zero
7+
- zerosAsND - set no data value to zero
8+
- FIX: calculation of UTM zone number

src/msuproj-cli.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,11 @@ int main(int argc, char *argv[])
6262

6363
if (srcFile.empty() || gcpFile.empty())
6464
{
65-
printf("ERROR: input and output not specified\n"
65+
printf("ERROR: input files are not specified\n"
6666
"print \"-h\" for help\n");
6767
return 1;
6868
}
6969

70-
if (dstFile.empty())
71-
dstFile = srcFile + string(".tif");
72-
7370
retCode code;
7471

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

86+
if (dstFile.empty())
87+
{
88+
dstFile = srcFile;
89+
if (useUTM)
90+
dstFile += "_" + string(msuObj.getUTM());
91+
dstFile += ".tif";
92+
}
93+
8994
msuObj.setDST(dstFile.c_str());
9095

9196
printf("Processing warp operation");

src/msuproj.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ const msumr::retCode msumr::msugeo::readGCP(const char *file)
112112
gcpXStep = srcXSize / gcpXSize + 1;
113113
gcpYStep = srcYSize / gcpYSize + 1;
114114

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

118120
return success;
119121
}

0 commit comments

Comments
 (0)