Browse Source

Fixed bug when already lat/long input map

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45023 15284696-431f-4ddb-bdfa-cd5b030d7da7
Yann Chemin 14 years ago
parent
commit
8e145ffb25
1 changed files with 4 additions and 4 deletions
  1. 4 4
      imagery/i.latlong/main.c

+ 4 - 4
imagery/i.latlong/main.c

@@ -83,14 +83,14 @@ int main(int argc, char *argv[])
     inrast = Rast_allocate_d_buf();
     
     /***************************************************/ 
-    stepx = cellhd.ew_res;
-    stepy = cellhd.ns_res;
     xmin = cellhd.west;
     xmax = cellhd.east;
     ymin = cellhd.south;
     ymax = cellhd.north;
     nrows = Rast_window_rows();
     ncols = Rast_window_cols();
+    stepx = abs(xmax-xmin)*(double)ncols;
+    stepy = abs(ymax-ymin)*(double)nrows;
     
     /*Stolen from r.sun */ 
     /* Set up parameters for projection to lat/long if necessary */ 
@@ -127,8 +127,8 @@ int main(int argc, char *argv[])
 
 	for (col = 0; col < ncols; col++)
         {
-	    latitude = ymax - (row * stepy);
-	    longitude = xmin + (col * stepx);
+	    latitude = ymax - ((double)row * stepy);
+	    longitude = xmin + ((double)col * stepx);
 	    if (not_ll) 
 		if (pj_do_proj(&longitude, &latitude, &iproj, &oproj) < 0) 
 		    G_fatal_error(_("Error in pj_do_proj"));