[GRASS-SVN] r72514 - grass/trunk/raster/r.horizon
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 23 02:24:07 PDT 2018
Author: mmetz
Date: 2018-03-23 02:24:07 -0700 (Fri, 23 Mar 2018)
New Revision: 72514
Modified:
grass/trunk/raster/r.horizon/main.c
Log:
r.horizon: use new GRASS API for coordinate transformation
Modified: grass/trunk/raster/r.horizon/main.c
===================================================================
--- grass/trunk/raster/r.horizon/main.c 2018-03-23 09:23:48 UTC (rev 72513)
+++ grass/trunk/raster/r.horizon/main.c 2018-03-23 09:24:07 UTC (rev 72514)
@@ -74,8 +74,7 @@
struct Cell_head cellhd;
struct Key_value *in_proj_info, *in_unit_info;
-struct pj_info iproj;
-struct pj_info oproj;
+struct pj_info iproj, oproj, tproj;
struct Cell_head new_cellhd;
double bufferZone = 0., ebufferZone = 0., wbufferZone = 0.,
@@ -540,16 +539,11 @@
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 parser - ******************************/
@@ -844,9 +838,9 @@
longitude = xp;
latitude = yp;
- if (GPJ_do_proj_ll(&longitude, &latitude, &iproj, PJ_INV) < 0) {
- G_fatal_error(_("Error in pj_do_proj"));
- }
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD,
+ &longitude, &latitude, NULL) < 0)
+ G_fatal_error(_("Error in %s"), "GPJ_transform()");
}
else { /* ll projection */
latitude = yp;
@@ -862,9 +856,9 @@
latitude = (latitude + delt_lat) * rad2deg;
longitude = (longitude + delt_lon) * rad2deg;
- if (GPJ_do_proj_ll(&longitude, &latitude, &iproj, PJ_FWD) < 0) {
- G_fatal_error(_("Error in pj_do_proj"));
- }
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_INV,
+ &longitude, &latitude, NULL) < 0)
+ G_fatal_error(_("Error in %s"), "GPJ_transform()");
delt_east = longitude - xp;
delt_nor = latitude - yp;
@@ -1198,12 +1192,10 @@
longitude = xp;
latitude = yp;
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD,
+ &longitude, &latitude, NULL) < 0)
+ G_fatal_error(_("Error in %s"), "GPJ_transform()");
- if ((G_projection() != PROJECTION_LL)) {
- if (GPJ_do_proj_ll(&longitude, &latitude, &iproj, PJ_INV) < 0)
- G_fatal_error("Error in pj_do_proj");
- }
-
latitude *= deg2rad;
longitude *= deg2rad;
@@ -1220,8 +1212,9 @@
longitude = (longitude + delt_lon) * rad2deg;
if ((G_projection() != PROJECTION_LL)) {
- if (GPJ_do_proj_ll(&longitude, &latitude, &iproj, PJ_FWD) < 0)
- G_fatal_error("Error in pj_do_proj");
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_INV,
+ &longitude, &latitude, NULL) < 0)
+ G_fatal_error(_("Error in %s"), "GPJ_transform()");
}
delt_east = longitude - xp;
More information about the grass-commit
mailing list