[GRASS-SVN] r72512 - grass/trunk/display/d.where
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 23 02:22:49 PDT 2018
Author: mmetz
Date: 2018-03-23 02:22:49 -0700 (Fri, 23 Mar 2018)
New Revision: 72512
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 GRASS API for coordinate transformation
Modified: grass/trunk/display/d.where/local_proto.h
===================================================================
--- grass/trunk/display/d.where/local_proto.h 2018-03-23 09:22:34 UTC (rev 72511)
+++ grass/trunk/display/d.where/local_proto.h 2018-03-23 09:22:49 UTC (rev 72512)
@@ -1,2 +1,2 @@
/* where.c */
-int where_am_i(char **, FILE *, int, int, int, int);
+int where_am_i(char **, FILE *, int, int, int);
Modified: grass/trunk/display/d.where/main.c
===================================================================
--- grass/trunk/display/d.where/main.c 2018-03-23 09:22:34 UTC (rev 72511)
+++ grass/trunk/display/d.where/main.c 2018-03-23 09:22:49 UTC (rev 72512)
@@ -26,7 +26,7 @@
#include "local_proto.h"
#include <grass/glocale.h>
-struct pj_info iproj, oproj;
+struct pj_info iproj, oproj, tproj;
int main(int argc, char **argv)
{
@@ -112,18 +112,7 @@
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 */
- if (GPJ_get_equivalent_latlong(&oproj, &iproj) < 0)
- G_fatal_error(_("Unable to set up lat/long projection parameters"));
-
- }
- else {
-#endif
struct Key_Value *out_proj_info, *out_unit_info;
out_proj_info = G_create_key_value();
@@ -151,10 +140,13 @@
G_free_key_value(out_proj_info);
G_free_key_value(out_unit_info);
}
+ /* else the latlong equivalent is generated by GPJ_init_transform() */
G_free_key_value(in_proj_info);
G_free_key_value(in_unit_info);
+ if (GPJ_init_transform(&iproj, &oproj, &tproj) < 0)
+ G_fatal_error(_("Unable to initialize coordinate transformation"));
}
if (file->answer) {
@@ -174,7 +166,7 @@
D_setup(0);
where_am_i(coords->answers, fp, have_spheroid, decimal->answer,
- dcoord->answer, wgs84->answer);
+ dcoord->answer);
D_close_driver();
Modified: grass/trunk/display/d.where/where.c
===================================================================
--- grass/trunk/display/d.where/where.c 2018-03-23 09:22:34 UTC (rev 72511)
+++ grass/trunk/display/d.where/where.c 2018-03-23 09:22:49 UTC (rev 72512)
@@ -5,10 +5,10 @@
#include <grass/display.h>
#include "local_proto.h"
-extern struct pj_info iproj, oproj;
+extern struct pj_info iproj, oproj, tproj;
int where_am_i(char **coords, FILE *fp, int have_spheroid, int decimal,
- int dcoord, int wgs84)
+ int dcoord)
{
char buf1[50], buf2[50];
int screen_x, screen_y;
@@ -58,19 +58,9 @@
double lat = north;
double lon = east;
-#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 (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD,
+ &lon, &lat, NULL) < 0)
+ G_fatal_error(_("Error in GPJ_transform()"));
if (decimal) {
G_format_easting(lon, buf1, 0);
More information about the grass-commit
mailing list