[GRASS-SVN] r72428 - grass/trunk/display/d.where

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 20 11:48:30 PDT 2018


Author: mmetz
Date: 2018-03-20 11:48:30 -0700 (Tue, 20 Mar 2018)
New Revision: 72428

Modified:
   grass/trunk/display/d.where/local_proto.h
   grass/trunk/display/d.where/main.c
   grass/trunk/display/d.where/where.c
Log:
d.where: use new PROJ 5+ API if available

Modified: grass/trunk/display/d.where/local_proto.h
===================================================================
--- grass/trunk/display/d.where/local_proto.h	2018-03-20 18:47:54 UTC (rev 72427)
+++ grass/trunk/display/d.where/local_proto.h	2018-03-20 18:48:30 UTC (rev 72428)
@@ -1,2 +1,2 @@
 /* where.c */
-int where_am_i(char **, FILE *, int, int, int);
+int where_am_i(char **, FILE *, int, int, int, int);

Modified: grass/trunk/display/d.where/main.c
===================================================================
--- grass/trunk/display/d.where/main.c	2018-03-20 18:47:54 UTC (rev 72427)
+++ grass/trunk/display/d.where/main.c	2018-03-20 18:48:30 UTC (rev 72428)
@@ -112,7 +112,9 @@
 	if (pj_get_kv(&iproj, in_proj_info, in_unit_info) < 0)
 	    G_fatal_error(_("Can't get projection key values of current location"));
 
-
+#ifdef HAVE_PROJ_H
+	if (wgs84->answer) {
+#else
 	if (!wgs84->answer) {
 	    /* Set output to same ellipsoid as input if we're not looking
 	     * for the WGS84 values */
@@ -121,6 +123,7 @@
 
 	}
 	else {
+#endif
 	    struct Key_Value *out_proj_info, *out_unit_info;
 
 	    out_proj_info = G_create_key_value();
@@ -170,7 +173,8 @@
 
     D_setup(0);
 
-    where_am_i(coords->answers, fp, have_spheroid, decimal->answer, dcoord->answer);
+    where_am_i(coords->answers, fp, have_spheroid, decimal->answer,
+               dcoord->answer, wgs84->answer);
     
     D_close_driver();
 

Modified: grass/trunk/display/d.where/where.c
===================================================================
--- grass/trunk/display/d.where/where.c	2018-03-20 18:47:54 UTC (rev 72427)
+++ grass/trunk/display/d.where/where.c	2018-03-20 18:48:30 UTC (rev 72428)
@@ -7,7 +7,8 @@
 
 extern struct pj_info iproj, oproj;
 
-int where_am_i(char **coords, FILE *fp, int have_spheroid, int decimal, int dcoord)
+int where_am_i(char **coords, FILE *fp, int have_spheroid, int decimal,
+               int dcoord, int wgs84)
 {
     char buf1[50], buf2[50];
     int screen_x, screen_y;
@@ -57,8 +58,19 @@
 	    double lat = north;
 	    double lon = east;
 
-	    if (pj_do_proj(&lon, &lat, &iproj, &oproj) < 0)
-		G_fatal_error("Error in pj_do_proj()");
+#ifdef HAVE_PROJ_H
+	    if (!wgs84) {
+		if (GPJ_do_proj_ll(&lon, &lat, &iproj, PJ_INV) < 0)
+		    G_fatal_error(_("Error in pj_do_proj"));
+	    }
+	    else {
+		if (pj_do_proj(&lon, &lat, &iproj, &oproj) < 0)
+		    G_fatal_error(_("Error in pj_do_proj"));
+	    }
+#else
+            if (pj_do_proj(&lon, &lat, &iproj, &oproj) < 0)
+                G_fatal_error(_("Error in pj_do_proj"));
+#endif
 
 	    if (decimal) {
 		G_format_easting(lon, buf1, 0);



More information about the grass-commit mailing list