[GRASS-SVN] r43579 - grass/branches/releasebranch_6_4/raster/r.out.arc

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 21 08:54:51 EDT 2010


Author: neteler
Date: 2010-09-21 12:54:51 +0000 (Tue, 21 Sep 2010)
New Revision: 43579

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

Modified: grass/branches/releasebranch_6_4/raster/r.out.arc/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.out.arc/main.c	2010-09-21 12:53:31 UTC (rev 43578)
+++ grass/branches/releasebranch_6_4/raster/r.out.arc/main.c	2010-09-21 12:54:51 UTC (rev 43579)
@@ -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