Browse Source

r.sunmask: use new PROJ 5+ API if available

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72433 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 7 years ago
parent
commit
449a535f9a
1 changed files with 8 additions and 2 deletions
  1. 8 2
      raster/r.sunmask/g_solposition.c

+ 8 - 2
raster/r.sunmask/g_solposition.c

@@ -56,7 +56,9 @@ long calc_solar_position(double longitude, double latitude, double timezone,
     long retval;		/* to capture S_solpos return codes */
     struct Key_Value *in_proj_info, *in_unit_info;	/* projection information of input map */
     struct pj_info iproj;	/* input map proj parameters  */
+#ifndef HAVE_PROJ_H
     struct pj_info oproj;	/* output map proj parameters  */
+#endif
     extern struct Cell_head window;
     int inside;
 
@@ -113,17 +115,21 @@ long calc_solar_position(double longitude, double latitude, double timezone,
 	G_debug(1, "IN coord: longitude: %f, latitude: %f", longitude,
 		latitude);
 	/* see src/include/projects.h, struct PJconsts */
-	
+#ifndef HAVE_PROJ_H
 	/* set output projection to lat/long for solpos */
 	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
 	/* XX do the transform 
 	 *               outx        outy    in_info  out_info */
+#ifdef HAVE_PROJ_H
+	if (GPJ_do_proj_ll(&longitude, &latitude, &iproj, PJ_INV) < 0) {
+#else
 	if (pj_do_proj(&longitude, &latitude, &iproj, &oproj) < 0) {
+#endif
 	    G_fatal_error(_("Error in pj_do_proj (projection of input coordinate pair)"));
 	}