[GRASS-SVN] r36430 - grass/branches/develbranch_6/raster/r.out.arc

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 20 05:51:32 EDT 2009


Author: neteler
Date: 2009-03-20 05:51:32 -0400 (Fri, 20 Mar 2009)
New Revision: 36430

Modified:
   grass/branches/develbranch_6/raster/r.out.arc/main.c
Log:
flag added to refer to cell center in header

Modified: grass/branches/develbranch_6/raster/r.out.arc/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.out.arc/main.c	2009-03-20 09:43:27 UTC (rev 36429)
+++ grass/branches/develbranch_6/raster/r.out.arc/main.c	2009-03-20 09:51:32 UTC (rev 36430)
@@ -51,6 +51,7 @@
     {
 	struct Flag *noheader;
 	struct Flag *singleline;
+	struct Flag *ccenter;
     } flag;
 
     G_gisinit(argv[0]);
@@ -93,6 +94,12 @@
     flag.singleline->description =
 	_("List one entry per line instead of full row");
 
+    /* use cell center in header instead of cell corner */
+    flag.ccenter = G_define_flag();
+    flag.ccenter->key = 'c';
+    flag.ccenter->description =
+	_("Use cell center reference in header instead of cell corner");
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -141,20 +148,27 @@
 	G_get_window(&region);
 	fprintf(fp, "ncols %d\n", region.cols);
 	fprintf(fp, "nrows %d\n", region.rows);
+	cellsize = fabs(region.east - region.west) / region.cols;
 
-	if (G_projection() != 3) {	/* Is Projection != LL (3) */
-	    G_format_easting(region.west, buf, region.proj);
-	    fprintf(fp, "xllcorner %s\n", buf);
-	    G_format_northing(region.south, buf, region.proj);
-	    fprintf(fp, "yllcorner %s\n", buf);
+	if (G_projection() != PROJECTION_LL) {	/* Is Projection != LL (3) */
+	    if (!flag.ccenter->answer) {
+		G_format_easting(region.west, buf, region.proj);
+		fprintf(fp, "xllcorner %s\n", buf);
+		G_format_northing(region.south, buf, region.proj);
+		fprintf(fp, "yllcorner %s\n", buf);
+	    }
+	    else {
+		G_format_easting(region.west + cellsize / 2., buf, region.proj);
+		fprintf(fp, "xllcenter %s\n", buf);
+		G_format_northing(region.south + cellsize / 2., buf, region.proj);
+		fprintf(fp, "yllcenter %s\n", buf);
+	    }
 	}
 	else {			/* yes, lat/long */
-
 	    fprintf(fp, "xllcorner %f\n", region.west);
 	    fprintf(fp, "yllcorner %f\n", region.south);
 	}
 
-	cellsize = fabs(region.east - region.west) / region.cols;
 	fprintf(fp, "cellsize %f\n", cellsize);
 	fprintf(fp, "NODATA_value %s\n", null_str);
     }



More information about the grass-commit mailing list