[GRASS-SVN] r33055 - grass/trunk/general/g.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 25 06:12:13 EDT 2008


Author: pkelly
Date: 2008-08-25 06:12:12 -0400 (Mon, 25 Aug 2008)
New Revision: 33055

Modified:
   grass/trunk/general/g.proj/g.proj.html
   grass/trunk/general/g.proj/input.c
   grass/trunk/general/g.proj/local_proto.h
   grass/trunk/general/g.proj/main.c
   grass/trunk/general/g.proj/output.c
Log:
Compile with reduced functionality if HAVE_OGR not defined.
Update documentation to reflect removal of interactivity.
Allow only one output format at a time.


Modified: grass/trunk/general/g.proj/g.proj.html
===================================================================
--- grass/trunk/general/g.proj/g.proj.html	2008-08-25 00:24:22 UTC (rev 33054)
+++ grass/trunk/general/g.proj/g.proj.html	2008-08-25 10:12:12 UTC (rev 33055)
@@ -2,13 +2,18 @@
 
 <P><em>g.proj</em> provides a means of converting a co-ordinate system
 description (i.e. projection information) between various formats.
-It requires <A HREF="http://www.gdal.org/ogr/">OGR</A> to compile. The basic
-functionality of the module is to report the projection information for the
-current location, either in conventional GRASS (-p flag) or PROJ.4 (-j flag) 
-format.</P>
+If compiled without <A HREF="http://www.gdal.org/ogr/">OGR</A> present, the 
+functionality is limited to:
+<ul>
+<li>Reporting the projection information for the current location, 
+either in conventional GRASS (-p flag) or PROJ.4 (-j flag) format</li>
+<li>Reporting and modifying the datum transformation parameters for
+the current location</li>
+</ul>
+</P>
 
-<P>Projection information may also be output in the Well-Known Text (WKT) 
-format popularised
+<P>When compiled with OGR, functionality is increased and allows output of 
+the projection information in the Well-Known Text (WKT) format popularised 
 by proprietary GIS. In addition, if one of the parameters <em>georef</em>, 
 <em>wkt</em>, <em>proj4</em> or <em>epsg</em> is specified, rather than the 
 projection information being read from the current location it is imported 
@@ -54,8 +59,7 @@
 DEFAULT_WIND) based on the imported information. If the <em>location</em> 
 parameter is specified in addition to -c, then a new location will be created. 
 Otherwise the projection information files in the current location will be
-overwritten. The program will warn before doing this only if command-line
-interactive mode (<em>-i</em> flag) is selected.</P>
+overwritten. The program will <strong>not</strong> warn before doing this.</P>
 
 <P>The final mode of operation of g.proj is to report on the datum
 information and datum transformation parameters associated with the
@@ -77,14 +81,11 @@
 <strong>Any other number less than or equal to the number of parameter sets
 available for this datum:</strong> Choose this parameter set and add it to the
 co-ordinate system description.<br>
-If the module is being used from the command-line through an interactive
-terminal, the <em>-i</em> flag can be specified to enable interactive
-selection of the parameter set, and the value of <em>datumtrans</em> (if 
-specified) is ignored.<br>
 If the <em>-t</em> flag is specified, the module will attempt to change the
 datum transformation parameters using one of the above two methods 
 <strong>even if</strong> a valid parameter set is already specified in the 
-input co-ordinate system.</P>
+input co-ordinate system. This can be useful to change the datum information
+for an existing location.</P>
 
 <P>Output is simply based on the input projection information. g.proj does 
 <strong>not</strong> attempt to verify that the co-ordinate system thus 
@@ -155,18 +156,17 @@
 
 <p>
 Create a new location with the same co-ordinate system as the current
-location:<br>
+location, but forcing a change to datum transformation parameter set no. 1:<br>
 
 <div class="code"><pre>
-g.proj -c location=newloc
+g.proj -c location=newloc -t datumtrans=1
 </pre></div>
 
 <p>
-Interactively change/update the datum transformation parameters for the
-current location:<br>
+List the possible datum transformation parameters for the current location:<br>
 
 <div class="code"><pre>
-g.proj -itc
+g.proj -t datumtrans=-1
 </pre></div>
 
 <p>

Modified: grass/trunk/general/g.proj/input.c
===================================================================
--- grass/trunk/general/g.proj/input.c	2008-08-25 00:24:22 UTC (rev 33054)
+++ grass/trunk/general/g.proj/input.c	2008-08-25 10:12:12 UTC (rev 33055)
@@ -22,15 +22,22 @@
 #include <grass/gis.h>
 #include <grass/gprojects.h>
 #include <grass/glocale.h>
-#include <gdal.h>
-#include <ogr_api.h>
-#include <cpl_csv.h>
+#include <grass/config.h>
 
+#ifdef HAVE_OGR
+#  include <gdal.h>
+#  include <ogr_api.h>
+#  include <cpl_csv.h>
+#endif
+
 #include "local_proto.h"
 
 static void set_default_region(void);
+
+#ifdef HAVE_OGR
 static void set_gdal_region(GDALDatasetH);
 static void set_ogr_region(OGRLayerH);
+#endif
 
 /**
  * \brief Read projection and region information from current location
@@ -50,6 +57,8 @@
     return;
 }
 
+#ifdef HAVE_OGR
+
 /**
  * \brief Read projection information in WKT format from stdin or a file
  * 
@@ -254,6 +263,7 @@
     return ret;
 
 }
+#endif /* HAVE_OGR */
 
 /**
  * \brief Populates global cellhd with "default" region settings
@@ -283,6 +293,8 @@
     return;
 }
 
+#ifdef HAVE_OGR
+
 /**
  * \brief Populates global cellhd with region settings based on 
  *        georeferencing information in a GDAL dataset
@@ -365,3 +377,4 @@
 
     return;
 }
+#endif /* HAVE_OGR */

Modified: grass/trunk/general/g.proj/local_proto.h
===================================================================
--- grass/trunk/general/g.proj/local_proto.h	2008-08-25 00:24:22 UTC (rev 33054)
+++ grass/trunk/general/g.proj/local_proto.h	2008-08-25 10:12:12 UTC (rev 33055)
@@ -1,3 +1,5 @@
+#include <grass/config.h>
+
 extern struct Key_Value *projinfo, *projunits;
 extern struct Cell_head cellhd;
 
@@ -3,14 +5,18 @@
 /* input.c */
 void input_currloc(void);
+#ifdef HAVE_OGR
 int input_wkt(char *);
 int input_proj4(char *);
 int input_epsg(int);
 int input_georef(char *);
+#endif
 
 /* output.c */
 void print_projinfo(void);
 void print_datuminfo(void);
 void print_proj4(int);
+#ifdef HAVE_OGR
 void print_wkt(int, int);
+#endif
 void create_location(char *);
 

Modified: grass/trunk/general/g.proj/main.c
===================================================================
--- grass/trunk/general/g.proj/main.c	2008-08-25 00:24:22 UTC (rev 33054)
+++ grass/trunk/general/g.proj/main.c	2008-08-25 10:12:12 UTC (rev 33055)
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/config.h>
 
 #include "local_proto.h"
 
@@ -44,7 +45,7 @@
 				 * GDAL or OGR                              */
     struct GModule *module;
 
-    int importformats;
+    int formats;
 
     G_set_program_name(argv[0]);
     G_no_gisinit();		/* We don't call G_gisinit() here because it validates the
@@ -54,9 +55,13 @@
     module = G_define_module();
     module->keywords = _("general");
     module->description =
+#ifdef HAVE_OGR
 	_("Converts co-ordinate system descriptions (i.e. projection "
 	  "information) between various formats (including GRASS format). "
 	  "Can also be used to create GRASS locations.");
+#else
+	_("Prints and manipulates GRASS projection information files.");
+#endif
 
     printinfo = G_define_flag();
     printinfo->key = 'p';
@@ -76,6 +81,17 @@
     printproj4->description =
 	_("Print projection information in PROJ.4 format");
 
+    dontprettify = G_define_flag();
+    dontprettify->key = 'f';
+    dontprettify->guisection = "Printed_Output";
+    dontprettify->description =
+	_("Print 'flat' output with no linebreaks (applies to "
+#ifdef HAVE_OGR
+	  "WKT and "
+#endif
+	  "PROJ.4 output)");
+
+#ifdef HAVE_OGR
     printwkt = G_define_flag();
     printwkt->key = 'w';
     printwkt->guisection = "Printed_Output";
@@ -87,13 +103,6 @@
     esristyle->description =
 	_("Use ESRI-style format (applies to WKT output only)");
 
-    dontprettify = G_define_flag();
-    dontprettify->key = 'f';
-    dontprettify->guisection = "Printed_Output";
-    dontprettify->description =
-	_("Print 'flat' output with no linebreaks (applies to WKT and "
-	  "PROJ.4 output)");
-
     ingeo = G_define_option();
     ingeo->key = "georef";
     ingeo->type = TYPE_STRING;
@@ -127,6 +136,7 @@
     inepsg->options = "1-1000000";
     inepsg->guisection = "Input";
     inepsg->description = _("EPSG projection code");
+#endif
 
     dtrans = G_define_option();
     dtrans->key = "datumtrans";
@@ -166,25 +176,25 @@
 
     /* Initialisation & Validation */
 
+#ifdef HAVE_OGR
     /* -e implies -w */
     if (esristyle->answer && !printwkt->answer)
 	printwkt->answer = 1;
 
-    projinfo = NULL;
-    projunits = NULL;
-
-    importformats = ((ingeo->answer ? 1 : 0) + (inwkt->answer ? 1 : 0) +
-		     (inproj4->answer ? 1 : 0) + (inepsg->answer ? 1 : 0));
-    if (importformats > 1)
+    formats = ((ingeo->answer ? 1 : 0) + (inwkt->answer ? 1 : 0) +
+	       (inproj4->answer ? 1 : 0) + (inepsg->answer ? 1 : 0));
+    if (formats > 1)
 	G_fatal_error(_("Only one of '%s', '%s', '%s' or '%s' options may be specified"),
 		      ingeo->key, inwkt->key, inproj4->key, inepsg->key);
 
     /* Input */
     /* We can only have one input source, hence if..else construct */
 
-    if (importformats == 0)
+    if (formats == 0)
+#endif
 	/* Input is projection of current location */
 	input_currloc();
+#ifdef HAVE_OGR
     else if (inwkt->answer)
 	/* Input in WKT format */
 	input_wkt(inwkt->answer);
@@ -197,8 +207,8 @@
     else
 	/* Input from georeferenced file */
 	input_georef(ingeo->answer);
+#endif
 
-
     /* Consistency Check */
 
     if ((cellhd.proj != PROJECTION_XY)
@@ -210,23 +220,39 @@
 
 
     /* Output */
-    /* We can output the same information in multiple formats if
-     * necessary, hence multiple if statements */
+    /* Only allow one output format at a time, to reduce confusion */
+    formats = ((printinfo->answer ? 1 : 0) + (datuminfo->answer ? 1 : 0) +
+	       (printproj4->answer ? 1 : 0) +
+#ifdef HAVE_OGR
+	       (printwkt->answer ? 1 : 0) +
+#endif
+	       (create->answer ? 1 : 0));
+    if (formats > 1)
+	G_fatal_error(_("Only one of -%c, -%c, -%c"
+#ifdef HAVE_OGR
+			", -%c"
+#endif
+			" or -%c flags may be specified"),
+		      printinfo->key, datuminfo->key, printproj4->key,
+#ifdef HAVE_OGR
+		      printwkt->key,
+#endif
+		      create->key);
 
     if (printinfo->answer)
 	print_projinfo();
-
-    if (datuminfo->answer)
+    else if (datuminfo->answer)
 	print_datuminfo();
-
-    if (printproj4->answer)
+    else if (printproj4->answer)
 	print_proj4(dontprettify->answer);
-
-    if (printwkt->answer)
+#ifdef HAVE_OGR
+    else if (printwkt->answer)
 	print_wkt(esristyle->answer, dontprettify->answer);
-
-    if (create->answer)
+#endif
+    else if (create->answer)
 	create_location(location->answer);
+    else
+	G_warning(_("No output! Please specify an output option."));
 
 
     /* Tidy Up */

Modified: grass/trunk/general/g.proj/output.c
===================================================================
--- grass/trunk/general/g.proj/output.c	2008-08-25 00:24:22 UTC (rev 33054)
+++ grass/trunk/general/g.proj/output.c	2008-08-25 10:12:12 UTC (rev 33055)
@@ -20,6 +20,7 @@
 #include <grass/gis.h>
 #include <grass/gprojects.h>
 #include <grass/glocale.h>
+#include <grass/config.h>
 
 #include "local_proto.h"
 
@@ -124,6 +125,7 @@
     return;
 }
 
+#ifdef HAVE_OGR
 void print_wkt(int esristyle, int dontprettify)
 {
     char *outwkt;
@@ -142,6 +144,7 @@
 
     return;
 }
+#endif
 
 void create_location(char *location)
 {



More information about the grass-commit mailing list