[GRASS-SVN] r72515 - grass/trunk/raster/r.latlong
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 23 02:24:26 PDT 2018
Author: mmetz
Date: 2018-03-23 02:24:26 -0700 (Fri, 23 Mar 2018)
New Revision: 72515
Modified:
grass/trunk/raster/r.latlong/main.c
Log:
r.latlong: use new GRASS API for coordinate transformation
Modified: grass/trunk/raster/r.latlong/main.c
===================================================================
--- grass/trunk/raster/r.latlong/main.c 2018-03-23 09:24:07 UTC (rev 72514)
+++ grass/trunk/raster/r.latlong/main.c 2018-03-23 09:24:26 UTC (rev 72515)
@@ -31,10 +31,7 @@
struct Option *input1, *output1;
struct Flag *flag1;
struct History history; /*metadata */
- struct pj_info iproj;
-#ifndef HAVE_PROJ_H
- struct pj_info oproj;
-#endif
+ struct pj_info iproj, oproj, tproj;
struct Key_Value *in_proj_info, *in_unit_info;
/************************************/
@@ -106,14 +103,11 @@
G_fatal_error(_("Unable to get projection key values of current location"));
G_free_key_value(in_proj_info);
G_free_key_value(in_unit_info);
-#ifndef HAVE_PROJ_H
- /* Set output projection to latlong w/ same ellipsoid */
- oproj.zone = 0;
- oproj.meters = 1.;
- sprintf(oproj.proj, "ll");
- if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
- G_fatal_error(_("Unable to set up lat/long projection parameters"));
-#endif
+
+ oproj.pj = NULL;
+
+ if (GPJ_init_transform(&iproj, &oproj, &tproj) < 0)
+ G_fatal_error(_("Unable to initialize coordinate transformation"));
} /* End of stolen from r.sun */
outrast1 = Rast_allocate_d_buf();
@@ -130,10 +124,13 @@
{
latitude = ymax - ((double)row * stepy);
longitude = xmin + ((double)col * stepx);
- if (not_ll)
- if (GPJ_do_proj_ll(&longitude, &latitude, &iproj, PJ_INV) < 0)
- G_fatal_error(_("Error in pj_do_proj"));
- if(flag1->answer)
+ if (not_ll) {
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD,
+ &longitude, &latitude, NULL) < 0)
+ G_fatal_error(_("Error in %s (projection of input coordinate pair)"),
+ "GPJ_transform()");
+ }
+ if (flag1->answer)
d = longitude;
else
d = latitude;
More information about the grass-commit
mailing list