[GRASS-SVN] r72452 - grass/trunk/display/d.grid
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Mar 20 16:28:47 PDT 2018
Author: mmetz
Date: 2018-03-20 16:28:47 -0700 (Tue, 20 Mar 2018)
New Revision: 72452
Modified:
grass/trunk/display/d.grid/local_proto.h
grass/trunk/display/d.grid/plot.c
Log:
d.grid: adjust PROJ 5 usage
Modified: grass/trunk/display/d.grid/local_proto.h
===================================================================
--- grass/trunk/display/d.grid/local_proto.h 2018-03-20 22:56:47 UTC (rev 72451)
+++ grass/trunk/display/d.grid/local_proto.h 2018-03-20 23:28:47 UTC (rev 72452)
@@ -11,9 +11,9 @@
int, int, double, int, int);
void init_proj(struct pj_info *, struct pj_info *, int);
void get_ll_bounds(double *, double *, double *, double *, struct Cell_head,
- struct pj_info, struct pj_info);
+ struct pj_info, struct pj_info, int);
void check_coords(double, double, double *, double *, int, struct Cell_head,
- struct pj_info, struct pj_info);
+ struct pj_info, struct pj_info, int);
float get_heading(double, double);
/* plotborder.c */
Modified: grass/trunk/display/d.grid/plot.c
===================================================================
--- grass/trunk/display/d.grid/plot.c 2018-03-20 22:56:47 UTC (rev 72451)
+++ grass/trunk/display/d.grid/plot.c 2018-03-20 23:28:47 UTC (rev 72452)
@@ -263,7 +263,7 @@
/* get lat long min max */
/* probably need something like boardwalk ?? */
- get_ll_bounds(&west, &east, &south, &north, window, info_in, info_out);
+ get_ll_bounds(&west, &east, &south, &north, window, info_in, info_out, wgs84);
G_debug(3, "REGION BOUNDS N=%f S=%f E=%f W=%f", north, south, east, west);
@@ -283,15 +283,26 @@
n1 = n2 = g;
e1 = west + (ll * ((east - west) / SEGS));
e2 = e1 + ((east - west) / SEGS);
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&e1, &n1, &info_out, PJ_FWD) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&e1, &n1, &info_in, &info_out) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&e1, &n1, &info_in, &info_out) < 0)
G_fatal_error(_("Error in pj_do_proj"));
+#endif
- check_coords(e1, n1, &lon, &lat, 1, window, info_in, info_out);
+ check_coords(e1, n1, &lon, &lat, 1, window, info_in, info_out, wgs84);
e1 = lon;
n1 = lat;
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e2, &n2, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e2, &n2, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -302,7 +313,7 @@
if (pj_do_proj(&e2, &n2, &info_in, &info_out) < 0)
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e2, n2, &lon, &lat, 1, window, info_in, info_out);
+ check_coords(e2, n2, &lon, &lat, 1, window, info_in, info_out, wgs84);
e2 = lon;
n2 = lat;
if (start_coord == -9999.) {
@@ -342,7 +353,7 @@
*/
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e1, &n1, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e1, &n1, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -354,12 +365,12 @@
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e1, n1, &lon, &lat, 2, window, info_in, info_out);
+ check_coords(e1, n1, &lon, &lat, 2, window, info_in, info_out, wgs84);
e1 = lon;
n1 = lat;
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e2, &n2, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e2, &n2, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -371,7 +382,7 @@
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e2, n2, &lon, &lat, 2, window, info_in, info_out);
+ check_coords(e2, n2, &lon, &lat, 2, window, info_in, info_out, wgs84);
e2 = lon;
n2 = lat;
@@ -436,7 +447,7 @@
/* get lat long min max */
/* probably need something like boardwalk ?? */
- get_ll_bounds(&west, &east, &south, &north, window, info_in, info_out);
+ get_ll_bounds(&west, &east, &south, &north, window, info_in, info_out, wgs84);
G_debug(3, "REGION BOUNDS N=%f S=%f E=%f W=%f", north, south, east, west);
@@ -457,7 +468,7 @@
e2 = e1 + ((east - west) / SEGS);
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e1, &n1, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e1, &n1, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -469,12 +480,12 @@
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e1, n1, &lon, &lat, 1, window, info_in, info_out);
+ check_coords(e1, n1, &lon, &lat, 1, window, info_in, info_out, wgs84);
e1 = lon;
n1 = lat;
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e2, &n2, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e2, &n2, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -486,7 +497,7 @@
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e2, n2, &lon, &lat, 1, window, info_in, info_out);
+ check_coords(e2, n2, &lon, &lat, 1, window, info_in, info_out, wgs84);
e2 = lon;
n2 = lat;
if (start_coord == -9999.) {
@@ -537,7 +548,7 @@
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e1, &n1, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e1, &n1, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -549,12 +560,12 @@
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e1, n1, &lon, &lat, 2, window, info_in, info_out);
+ check_coords(e1, n1, &lon, &lat, 2, window, info_in, info_out, wgs84);
e1 = lon;
n1 = lat;
#ifdef HAVE_PROJ_H
if (!wgs84) {
- if (GPJ_do_proj_ll(&e2, &n2, &info_in, PJ_INV) < 0)
+ if (GPJ_do_proj_ll(&e2, &n2, &info_out, PJ_FWD) < 0)
G_fatal_error(_("Error in pj_do_proj"));
}
else {
@@ -566,7 +577,7 @@
G_fatal_error(_("Error in pj_do_proj"));
#endif
- check_coords(e2, n2, &lon, &lat, 2, window, info_in, info_out);
+ check_coords(e2, n2, &lon, &lat, 2, window, info_in, info_out, wgs84);
e2 = lon;
n2 = lat;
@@ -683,7 +694,7 @@
********************************************************/
void get_ll_bounds(double *w, double *e, double *s, double *n,
struct Cell_head window,
- struct pj_info info_in, struct pj_info info_out)
+ struct pj_info info_in, struct pj_info info_out, int wgs84)
{
double east, west, north, south;
double e1, w1, n1, s1;
@@ -711,8 +722,19 @@
for (ew = window.west; ew <= window.east; ew += ew_res) {
e1 = ew;
n1 = window.north;
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&e1, &n1, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&e1, &n1, &info_out, &info_in) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&e1, &n1, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj"));
+#endif
if (!first) {
north = n1;
first = 1;
@@ -727,8 +749,19 @@
for (ew = window.west; ew <= window.east; ew += ew_res) {
e1 = ew;
s1 = window.south;
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&e1, &s1, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&e1, &s1, &info_out, &info_in) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&e1, &s1, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj"));
+#endif
if (!first) {
south = s1;
first = 1;
@@ -744,8 +777,19 @@
for (ns = window.south; ns <= window.north; ns += ns_res) {
e1 = window.east;
n1 = ns;
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&e1, &n1, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&e1, &n1, &info_out, &info_in) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&e1, &n1, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj"));
+#endif
if (!first) {
east = e1;
first = 1;
@@ -761,8 +805,19 @@
for (ns = window.south; ns <= window.north; ns += ns_res) {
w1 = window.west;
n1 = ns;
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&w1, &n1, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&w1, &n1, &info_out, &info_in) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&w1, &n1, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj"));
+#endif
if (!first) {
west = w1;
first = 1;
@@ -792,7 +847,8 @@
double *lat,
int par,
struct Cell_head w,
- struct pj_info info_in, struct pj_info info_out)
+ struct pj_info info_in, struct pj_info info_out,
+ int wgs84)
{
double x, y;
int proj = 0;
@@ -819,18 +875,51 @@
if (proj) {
/* convert original coords to ll */
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&e, &n, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&e, &n, &info_in, &info_out) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&e, &n, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj1"));
+#endif
if (par == 1) {
/* lines of latitude -- const. northing */
/* convert correct UTM to ll */
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&x, &y, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&x, &y, &info_out, &info_in) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&x, &y, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj2"));
+#endif
/* convert new ll back to coords */
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&x, &n, &info_out, PJ_FWD) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&x, &n, &info_in, &info_out) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&x, &n, &info_in, &info_out) < 0)
G_fatal_error(_("Error in pj_do_proj3"));
+#endif
*lat = n;
*lon = x;
}
@@ -837,12 +926,34 @@
if (par == 2) {
/* lines of longitude -- const. easting */
/* convert correct UTM to ll */
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&x, &y, &info_out, PJ_INV) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&x, &y, &info_out, &info_in) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&x, &y, &info_out, &info_in) < 0)
G_fatal_error(_("Error in pj_do_proj5"));
+#endif
/* convert new ll back to coords */
+#ifdef HAVE_PROJ_H
+ if (!wgs84) {
+ if (GPJ_do_proj_ll(&e, &n, &info_out, PJ_FWD) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ else {
+ if (pj_do_proj(&e, &n, &info_in, &info_out) < 0)
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+#else
if (pj_do_proj(&e, &y, &info_in, &info_out) < 0)
G_fatal_error(_("Error in pj_do_proj6"));
+#endif
*lat = y;
*lon = e;
}
More information about the grass-commit
mailing list