[GRASS-SVN] r72517 - grass/trunk/raster/r.sunhours
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 23 02:24:52 PDT 2018
Author: mmetz
Date: 2018-03-23 02:24:52 -0700 (Fri, 23 Mar 2018)
New Revision: 72517
Modified:
grass/trunk/raster/r.sunhours/main.c
Log:
r.sunhours: use new GRASS API for coordinate transformation
Modified: grass/trunk/raster/r.sunhours/main.c
===================================================================
--- grass/trunk/raster/r.sunhours/main.c 2018-03-23 09:24:39 UTC (rev 72516)
+++ grass/trunk/raster/r.sunhours/main.c 2018-03-23 09:24:52 UTC (rev 72517)
@@ -48,9 +48,8 @@
/* projection information of input map */
struct Key_Value *in_proj_info, *in_unit_info;
struct pj_info iproj; /* input map proj parameters */
-#ifndef HAVE_PROJ_H
struct pj_info oproj; /* output map proj parameters */
-#endif
+ struct pj_info tproj; /* transformation parameters */
char *elev_name, *azimuth_name, *sunhour_name;
int elev_fd, azimuth_fd, sunhour_fd;
double ha, ha_cos, s_gamma, s_elevation, s_azimuth;
@@ -224,14 +223,11 @@
G_free_key_value(in_proj_info);
G_free_key_value(in_unit_info);
-#ifndef HAVE_PROJ_H
- /* output projection to lat/long w/ same ellipsoid as input */
- 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 update lat/long projection parameters"));
-#endif
+
+ oproj.pj = NULL;
+
+ if (GPJ_init_transform(&iproj, &oproj, &tproj) < 0)
+ G_fatal_error(_("Unable to initialize coordinate transformation"));
}
/* always init pd */
@@ -294,8 +290,10 @@
north_ll = (window.north + window.south) / 2;
east_ll = (window.east + window.west) / 2;
if (do_reproj) {
- if (GPJ_do_proj_ll(&east_ll, &north_ll, &iproj, PJ_INV) < 0)
- G_fatal_error(_("Error in pj_do_proj (projection of input coordinate pair)"));
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD,
+ &east_ll, &north_ll, NULL) < 0)
+ G_fatal_error(_("Error in %s (projection of input coordinate pair)"),
+ "GPJ_transform()");
}
pd.timezone = east_ll / 15.;
pd.time_updated = 1;
@@ -388,8 +386,10 @@
if (do_reproj) {
north_ll = north;
- if (GPJ_do_proj_ll(&east_ll, &north_ll, &iproj, PJ_INV) < 0)
- G_fatal_error(_("Error in pj_do_proj (projection of input coordinate pair)"));
+ if (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD,
+ &east_ll, &north_ll, NULL) < 0)
+ G_fatal_error(_("Error in %s (projection of input coordinate pair)"),
+ "GPJ_transform()");
}
/* geocentric latitude */
More information about the grass-commit
mailing list