[GRASS5] r.in.gdal updates?

Markus Neteler neteler at itc.it
Fri Apr 18 06:04:30 EDT 2003


On Fri, Apr 18, 2003 at 12:15:57AM +0100, Glynn Clements wrote:
> 
> Markus Neteler wrote:
> 
> > PS: I have used cvs diff to create the file, hopefully in the right way.
> 
> Use either "diff -u" (unified) or "diff -c" (context).
> 
> Those formats include some context (lines before and after those being
> added/removed/modified), which makes them more robust. They are also
> easier to read.
> 
> Patches which use the default format are only safe to apply to the
> exact code which was used for creating them. Applying them to code
> which has changed in any way is unreliable (patching may fail
> unnecessarily) and risky (patching may appear to succeed but produce
> the wrong result).

Thanks for the recommendations! Again the patch, now unified.

Markus
-------------- next part --------------
@@ -553,6 +553,7 @@
     char msg[100];
     char outputReal[200], outputImg[200];
     char *nullFlags = NULL;
+    int (*raster_open_new_func)(char *, RASTER_MAP_TYPE) = G_open_raster_new;
 
 /* -------------------------------------------------------------------- */
 /*      Select a cell type for the new cell.                            */
@@ -567,19 +568,28 @@
         complex = FALSE;
         break;
 
-      case GDT_CInt16:
-      case GDT_CInt32:
-      case GDT_CFloat32:
-      case GDT_CFloat64:
-        data_type = FCELL_TYPE;
-        eGDT = GDT_CFloat32;
-        complex = TRUE;
-        break;	
+      case GDT_Byte:
+        data_type = CELL_TYPE;
+        eGDT = GDT_Int32;
+        complex = FALSE;
+        G_set_cell_format(0);
+        raster_open_new_func = G_open_raster_new_uncompressed;
+        break;
+
+      case GDT_Int16:
+      case GDT_UInt16:
+        data_type = CELL_TYPE;
+        eGDT = GDT_Int32;
+        complex = FALSE;
+        G_set_cell_format(1);
+        raster_open_new_func = G_open_raster_new_uncompressed;
+        break;
 
       default:
         data_type = CELL_TYPE;
         eGDT = GDT_Int32;
         complex = FALSE;
+	G_set_cell_format(3);
         break;
     }
     
@@ -592,7 +602,7 @@
     if( complex )
     {
         sprintf( outputReal, "%s.real", output);
-        cfR = G_open_raster_new((char *)outputReal, data_type);
+        cfR = (*raster_open_new_func)((char *)outputReal, data_type);
         if (cfR < 0)
 	{
             sprintf (msg, "unable to create raster map %s", outputReal);
@@ -601,7 +611,7 @@
 	}
         sprintf( outputImg, "%s.imaginary", output);
 
-        cfI = G_open_raster_new((char *)outputImg, data_type);
+        cfI = (*raster_open_new_func)((char *)outputImg, data_type);
         if (cfI < 0)
 	{
             sprintf (msg, "unable to create raster map %s", outputImg);
@@ -621,7 +631,7 @@
     }
     else
     {
-        cf = G_open_raster_new((char *)output, data_type);
+        cf = (*raster_open_new_func)((char *)output, data_type);
         if (cf < 0)
 	{
             sprintf (msg, "unable to create raster map %s", output);


More information about the grass-dev mailing list