[GRASS-SVN] r33841 - grass-addons/gipe/i.latlong

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 12 04:50:48 EDT 2008


Author: ychemin
Date: 2008-10-12 04:50:48 -0400 (Sun, 12 Oct 2008)
New Revision: 33841

Modified:
   grass-addons/gipe/i.latlong/i.latlong.html
   grass-addons/gipe/i.latlong/main.c
Log:
Prepared i.latlong for main SVN

Modified: grass-addons/gipe/i.latlong/i.latlong.html
===================================================================
--- grass-addons/gipe/i.latlong/i.latlong.html	2008-10-12 08:32:46 UTC (rev 33840)
+++ grass-addons/gipe/i.latlong/i.latlong.html	2008-10-12 08:50:48 UTC (rev 33841)
@@ -7,7 +7,7 @@
 The proj <A HREF="http://www.remotesensing.org/proj/">website</A>.
 
 <H2>TODO</H2>
-Datum corrected reprojection is not implemented.
+Datum transform is not implemented, the same datum is taken as output.
 
 <H2>SEE ALSO</H2>
 

Modified: grass-addons/gipe/i.latlong/main.c
===================================================================
--- grass-addons/gipe/i.latlong/main.c	2008-10-12 08:32:46 UTC (rev 33840)
+++ grass-addons/gipe/i.latlong/main.c	2008-10-12 08:50:48 UTC (rev 33841)
@@ -1,4 +1,3 @@
-
 /****************************************************************************
  *
  * MODULE:       i.latlong
@@ -23,43 +22,41 @@
 int main(int argc, char *argv[]) 
 {
     struct Cell_head cellhd;	/*region+header info */
-    char *mapset;		/*mapset name */
     int nrows, ncols;
     int row, col;
     int not_ll = 0;		/*if proj is not lat/long, it will be 1. */
+
     struct GModule *module;
     struct Option *input1, *output1;
     struct Flag *flag1;
     struct History history;	/*metadata */
     struct pj_info iproj;
     struct pj_info oproj;
+    struct Key_Value *in_proj_info, *in_unit_info;
 
-	/************************************/ 
-    char *name;			/*input raster name */
+    /************************************/ 
     char *result1;		/*output raster name */
     
     int infd;
     int outfd1;
     char *in;
-    int i = 0, j = 0;
-    double xp, yp;
     double xmin, ymin;
     double xmax, ymax;
     double stepx, stepy;
     double latitude, longitude;
     void *inrast;
     DCELL * outrast1;
-    RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
-    RASTER_MAP_TYPE data_type_inrast;
+    DCELL d;
 
-	/************************************/ 
-	G_gisinit(argv[0]);
+    /************************************/ 
+    G_gisinit(argv[0]);
+
     module = G_define_module();
-    module->keywords = _("longitude, projection");
-    module->description = _("creates a longitude map");
+    module->keywords = _("imagery, latitude, longitude, projection");
+    module->description = _("creates a latitude/longitude map");
     
-	/* Define the different options */ 
-	input1 = G_define_standard_option(G_OPT_R_INPUT);
+    /* Define the different options */ 
+    input1 = G_define_standard_option(G_OPT_R_INPUT);
     input1->description = _("Name of the input map");
 
     output1 = G_define_standard_option(G_OPT_R_OUTPUT);
@@ -67,28 +64,23 @@
     
     flag1 = G_define_flag();
     flag1->key = 'l';
-    flag1->description = _("Loongitude output");
+    flag1->description = _("Longitude output");
 
-	/********************/ 
-	if (G_parser(argc, argv))
+    /********************/ 
+    if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
     in = input1->answer;
     result1 = output1->answer;
 
-	/***************************************************/ 
-	mapset = G_find_cell2(in, "");
-    if (mapset == NULL) {
-	G_fatal_error(_("cell file [%s] not found"), in);
-    }
-    data_type_inrast = G_raster_map_type(in, mapset);
-    if ((infd = G_open_cell_old(in, mapset)) < 0)
+    /***************************************************/ 
+    if ((infd = G_open_cell_old(in, "")) < 0)
 	G_fatal_error(_("Cannot open cell file [%s]"), in);
-    if (G_get_cellhd(in, mapset, &cellhd) < 0)
+    if (G_get_cellhd(in, "", &cellhd) < 0)
 	G_fatal_error(_("Cannot read file header of [%s])"), in);
-    inrast = G_allocate_raster_buf(data_type_inrast);
+    inrast = G_allocate_d_raster_buf();
     
-	/***************************************************/ 
+    /***************************************************/ 
     stepx = cellhd.ew_res;
     stepy = cellhd.ns_res;
     xmin = cellhd.west;
@@ -98,12 +90,11 @@
     nrows = G_window_rows();
     ncols = G_window_cols();
     
-	/*Shamelessly stolen from r.sun !!!!    */ 
-	/* Set up parameters for projection to lat/long if necessary */ 
+    /*Stolen from r.sun */ 
+    /* Set up parameters for projection to lat/long if necessary */ 
     if ((G_projection() != PROJECTION_LL)) 
     {
 	not_ll = 1;
-	struct Key_Value *in_proj_info, *in_unit_info;
 
 	if ((in_proj_info = G_get_projinfo()) == NULL)
 	    G_fatal_error(_("Can't get projection info of current location"));
@@ -120,43 +111,34 @@
 	sprintf(oproj.proj, "ll");
 	if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
 	    G_fatal_error(_("Unable to set up lat/long projection parameters"));
-    }				/* End of stolen from r.sun :P */
+    }	/* End of stolen from r.sun */
 
-    outrast1 = G_allocate_raster_buf(data_type_output);
+    outrast1 = G_allocate_d_raster_buf();
 
-    if ((outfd1 = G_open_raster_new(result1, data_type_output)) < 0)
+    if ((outfd1 = G_open_raster_new(result1,DCELL_TYPE)) < 0)
 	G_fatal_error(_("Could not open <%s>"), result1);
 
     for (row = 0; row < nrows; row++)
     {
-	DCELL d;
-	DCELL d_lon;
-	DCELL d_lat;
 	G_percent(row, nrows, 2);
 
-	if (G_get_raster_row(infd, inrast, row, data_type_inrast) < 0)
+	if (G_get_d_raster_row(infd, inrast, row) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), in);
 
 	for (col = 0; col < ncols; col++)
         {
 	    latitude = ymax - (row * stepy);
 	    longitude = xmin + (col * stepx);
-	    if (not_ll) {
-		if (pj_do_proj(&longitude, &latitude, &iproj, &oproj) < 0) {
+	    if (not_ll) 
+		if (pj_do_proj(&longitude, &latitude, &iproj, &oproj) < 0) 
 		    G_fatal_error(_("Error in pj_do_proj"));
-		}
-	    }
-	    else {
-		
-		    /*Do nothing */ 
-	    }
             if(flag1->answer)
 	        d = longitude;
             else
 	        d = latitude;
 	    outrast1[col] = d;
 	}
-	if (G_put_raster_row(outfd1, outrast1, data_type_output) < 0)
+	if (G_put_d_raster_row(outfd1, outrast1) < 0)
 	    G_fatal_error(_("Cannot write to output raster file"));
     }
     G_free(inrast);



More information about the grass-commit mailing list