27 #define MULTIPLY_LOOP(x,y,c,m) \ 29 for (i = 0; i < c; ++i) {\ 35 #define DIVIDE_LOOP(x,y,c,m) \ 37 for (i = 0; i < c; ++i) {\ 43 static double METERS_in = 1.0, METERS_out = 1.0;
46 #if PROJ_VERSION_MAJOR >= 6 47 int get_pj_area(
const struct pj_info *iproj,
double *xmin,
double *xmax,
48 double *ymin,
double *ymax)
65 const char *projstr =
NULL;
73 if (proj_get_type(iproj->
pj) == PJ_TYPE_BOUND_CRS) {
76 source_crs = proj_get_source_crs(
NULL, iproj->
pj);
78 projstr = proj_as_proj_string(
NULL, source_crs, PJ_PROJ_5,
NULL);
82 proj_destroy(source_crs);
86 projstr = proj_as_proj_string(
NULL, iproj->
pj, PJ_PROJ_5,
NULL);
100 G_debug(1,
"get_pj_area() tproj.def: %s", tproj.
def);
101 tproj.
pj = proj_create(PJ_DEFAULT_CTX, tproj.
def);
107 proj_destroy(tproj.
pj);
111 projstr = proj_as_proj_string(
NULL, tproj.
pj, PJ_PROJ_5,
NULL);
112 if (projstr ==
NULL) {
116 proj_destroy(tproj.
pj);
121 G_debug(1,
"proj_create() projstr '%s'", projstr);
126 estep = (window.
east - window.
west) / 21.;
128 for (i = 0; i < 20; i++) {
129 x[i] = window.
west + estep * (i + 1);
132 x[i + 20] = window.
west + estep * (i + 1);
133 y[i + 20] = window.
south;
135 x[i + 40] = window.
west;
136 y[i + 40] = window.
south + nstep * (i + 1);
138 x[i + 60] = window.
east;
139 y[i + 60] = window.
south + nstep * (i + 1);
142 y[80] = window.
north;
144 y[81] = window.
south;
146 y[82] = window.
north;
148 y[83] = window.
south;
149 x[84] = (window.
west + window.
east) / 2.;
154 proj_destroy(tproj.
pj);
157 *xmin = *xmax = x[84];
158 *ymin = *ymax = y[84];
159 for (i = 0; i < 84; i++) {
174 if (*xmin < -180 && *xmax < 180 && *xmin + 360 > *xmax) {
178 else if (*xmax > 180 && *xmin > -180 && *xmax - 360 < *xmin) {
185 G_debug(1,
"input window east: %.8f", window.
east);
186 G_debug(1,
"input window west: %.8f", window.
west);
188 G_debug(1,
"transformed xmin: %.8f", *xmin);
189 G_debug(1,
"transformed xmax: %.8f", *xmax);
190 G_debug(1,
"transformed ymin: %.8f", *ymin);
191 G_debug(1,
"transformed ymax: %.8f", *ymax);
196 if (fabs(*xmin) > 180) {
197 G_warning(
_(
"Invalid west longitude %g"), *xmin);
200 if (fabs(*xmax) > 180) {
201 G_warning(
_(
"Invalid east longitude %g"), *xmax);
204 if (fabs(*ymin) > 90) {
205 G_warning(
_(
"Invalid south latitude %g"), *ymin);
208 if (fabs(*ymax) > 90) {
209 G_warning(
_(
"Invalid north latitude %g"), *ymax);
213 G_warning(
_(
"South %g is larger than north %g"), *ymin, *ymax);
217 G_debug(1,
"get_pj_area(): xmin %g, xmax %g, ymin %g, ymax %g",
218 *xmin, *xmax, *ymin, *ymax);
223 char *get_pj_type_string(PJ *
pj)
225 char *pj_type =
NULL;
227 switch (proj_get_type(pj)) {
228 case PJ_TYPE_UNKNOWN:
231 case PJ_TYPE_ELLIPSOID:
234 case PJ_TYPE_PRIME_MERIDIAN:
237 case PJ_TYPE_GEODETIC_REFERENCE_FRAME:
238 G_asprintf(&pj_type,
"geodetic reference frame");
240 case PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME:
241 G_asprintf(&pj_type,
"dynamic geodetic reference frame");
243 case PJ_TYPE_VERTICAL_REFERENCE_FRAME:
244 G_asprintf(&pj_type,
"vertical reference frame");
246 case PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME:
247 G_asprintf(&pj_type,
"dynamic vertical reference frame");
249 case PJ_TYPE_DATUM_ENSEMBLE:
256 case PJ_TYPE_GEODETIC_CRS:
259 case PJ_TYPE_GEOCENTRIC_CRS:
264 case PJ_TYPE_GEOGRAPHIC_CRS:
267 case PJ_TYPE_GEOGRAPHIC_2D_CRS:
270 case PJ_TYPE_GEOGRAPHIC_3D_CRS:
273 case PJ_TYPE_VERTICAL_CRS:
276 case PJ_TYPE_PROJECTED_CRS:
279 case PJ_TYPE_COMPOUND_CRS:
282 case PJ_TYPE_TEMPORAL_CRS:
285 case PJ_TYPE_ENGINEERING_CRS:
288 case PJ_TYPE_BOUND_CRS:
291 case PJ_TYPE_OTHER_CRS:
294 case PJ_TYPE_CONVERSION:
297 case PJ_TYPE_TRANSFORMATION:
300 case PJ_TYPE_CONCATENATED_OPERATION:
301 G_asprintf(&pj_type,
"concatenated operation");
303 case PJ_TYPE_OTHER_COORDINATE_OPERATION:
304 G_asprintf(&pj_type,
"other coordinate operation");
315 PJ *get_pj_object(
const struct pj_info *in_gpj,
char **in_defstr)
324 in_pj = proj_create(PJ_DEFAULT_CTX, in_gpj->
srid);
333 ((
struct pj_info *)in_gpj)->meters = 1;
336 if (!in_pj && in_gpj->
wkt) {
337 G_debug(1,
"Trying WKT '%s' ...", in_gpj->
wkt);
338 in_pj = proj_create(PJ_DEFAULT_CTX, in_gpj->
wkt);
347 ((
struct pj_info *)in_gpj)->meters = 1;
350 if (!in_pj && in_gpj->
pj) {
351 in_pj = proj_clone(PJ_DEFAULT_CTX, in_gpj->
pj);
353 if (*in_defstr && !**in_defstr)
374 if (proj_get_type(in_pj) == PJ_TYPE_BOUND_CRS) {
378 source_crs = proj_get_source_crs(
NULL, in_pj);
381 if (*in_defstr && !**in_defstr)
431 const struct pj_info *info_out,
441 #if PROJ_VERSION_MAJOR >= 6 448 info_trans->
zone = 0;
449 sprintf(info_trans->
proj,
"pipeline");
452 if (info_trans->
def) {
457 if (!info_in->
pj || !info_in->
proj[0] ||
458 !info_out->
pj || !info_out->
proj[0]) {
459 G_warning(
_(
"A custom pipeline requires input and output projection info"));
466 info_trans->
pj = proj_create(PJ_DEFAULT_CTX, info_trans->
def);
467 if (info_trans->
pj ==
NULL) {
468 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
472 projstr = proj_as_proj_string(
NULL, info_trans->
pj, PJ_PROJ_5,
NULL);
473 if (projstr ==
NULL) {
474 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
486 if (strstr(info_trans->
def,
"axisswap")) {
487 G_warning(
_(
"The transformation pipeline contains an '%s' step. " 488 "Remove this step if easting and northing are swapped in the output."),
492 G_debug(1,
"proj_create() pipeline: %s", info_trans->
def);
497 ((
struct pj_info *)info_in)->meters = 1;
498 ((
struct pj_info *)info_out)->meters = 1;
503 else if (info_out->
pj ==
NULL) {
504 const char *projstr =
NULL;
509 G_debug(1,
"ll equivalent definition: %s", indef);
514 G_asprintf(&(info_trans->
def),
"+proj=pipeline +step +inv %s",
516 info_trans->
pj = proj_create(PJ_DEFAULT_CTX, info_trans->
def);
517 if (info_trans->
pj ==
NULL) {
518 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
523 projstr = proj_as_proj_string(
NULL, info_trans->
pj, PJ_PROJ_5,
NULL);
524 if (projstr ==
NULL) {
525 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
533 else if (info_in->
def && info_out->
pj && info_out->
def) {
535 char *insrid =
NULL, *outsrid =
NULL;
537 PJ_OBJ_LIST *op_list;
538 PJ_OPERATION_FACTORY_CONTEXT *operation_ctx;
539 PJ_AREA *pj_area =
NULL;
540 double xmin, xmax, ymin, ymax;
541 int op_count = 0, op_count_area = 0;
547 if (get_pj_area(info_in, &xmin, &xmax, &ymin, &ymax)) {
548 pj_area = proj_area_create();
549 proj_area_set_bbox(pj_area, xmin, ymin, xmax, ymax);
552 G_warning(
_(
"Unable to determine area of interest for '%s'"), info_in->
def);
557 G_debug(1,
"source proj string: %s", info_in->
def);
558 G_debug(1,
"source type: %s", get_pj_type_string(info_in->
pj));
562 if (strncmp(info_in->
srid,
"epsg", 4) == 0) {
565 ((
struct pj_info *)info_in)->srid = insrid;
570 in_pj = get_pj_object(info_in, &indef);
571 if (in_pj ==
NULL || indef ==
NULL) {
572 G_warning(
_(
"Input CRS not available for '%s'"), info_in->
def);
576 G_debug(1,
"Input CRS definition: %s", indef);
578 G_debug(1,
"target proj string: %s", info_out->
def);
579 G_debug(1,
"target type: %s", get_pj_type_string(info_out->
pj));
582 if (info_out->
srid) {
583 if (strncmp(info_out->
srid,
"epsg", 4) == 0) {
586 ((
struct pj_info *)info_out)->srid = outsrid;
591 out_pj = get_pj_object(info_out, &outdef);
592 if (out_pj ==
NULL || outdef ==
NULL) {
593 G_warning(
_(
"Output CRS not available for '%s'"), info_out->
def);
597 G_debug(1,
"Output CRS definition: %s", outdef);
601 operation_ctx = proj_create_operation_factory_context(PJ_DEFAULT_CTX,
NULL);
608 op_list = proj_create_operations(PJ_DEFAULT_CTX,
612 proj_operation_factory_context_destroy(operation_ctx);
616 op_count = proj_list_get_count(op_list);
621 for (i = 0; i < op_count; i++) {
622 const char *area_of_use, *projstr;
627 op = proj_list_get(PJ_DEFAULT_CTX, op_list, i);
628 op_norm = proj_normalize_for_visualization(PJ_DEFAULT_CTX, op);
631 G_warning(
_(
"proj_normalize_for_visualization() failed for operation %d"),
639 pj_info = proj_pj_info(op);
640 proj_get_area_of_use(
NULL, op, &w, &s, &e, &n, &area_of_use);
643 if (pj_info.description) {
645 pj_info.description);
652 if (pj_info.accuracy > 0) {
657 #if PROJ_VERSION_NUM >= 6020000 658 const char *str = proj_get_remarks(op);
663 str = proj_get_scope(op);
670 projstr = proj_as_proj_string(
NULL, op,
690 proj_list_destroy(op_list);
698 operation_ctx = proj_create_operation_factory_context(PJ_DEFAULT_CTX,
NULL);
699 proj_operation_factory_context_set_area_of_interest(PJ_DEFAULT_CTX,
703 proj_operation_factory_context_set_spatial_criterion(PJ_DEFAULT_CTX,
705 PROJ_SPATIAL_CRITERION_STRICT_CONTAINMENT);
706 proj_operation_factory_context_set_grid_availability_use(PJ_DEFAULT_CTX,
708 PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID);
717 op_list = proj_create_operations(PJ_DEFAULT_CTX,
721 proj_operation_factory_context_destroy(operation_ctx);
724 op_count_area = proj_list_get_count(op_list);
725 if (op_count_area == 0) {
729 else if (op_count_area == 1) {
730 info_trans->
pj = proj_list_get(PJ_DEFAULT_CTX, op_list, 0);
736 info_trans->
pj = proj_list_get(PJ_DEFAULT_CTX, op_list, 0);
739 proj_list_destroy(op_list);
765 proj_destroy(out_pj);
767 if (info_trans->
pj) {
771 G_debug(1,
"proj_create_crs_to_crs() succeeded with PROJ%d",
774 projstr = proj_as_proj_string(
NULL, info_trans->
pj,
785 pj_norm = proj_normalize_for_visualization(PJ_DEFAULT_CTX, info_trans->
pj);
788 G_warning(
_(
"proj_normalize_for_visualization() failed for '%s'"),
792 projstr = proj_as_proj_string(
NULL, pj_norm,
794 if (projstr && *projstr) {
795 proj_destroy(info_trans->
pj);
796 info_trans->
pj = pj_norm;
800 proj_destroy(pj_norm);
801 G_warning(
_(
"No PROJ definition for normalized version of '%s'"),
810 proj_destroy(info_trans->
pj);
816 proj_area_destroy(pj_area);
825 if (info_trans->
pj ==
NULL) {
826 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
833 info_trans->
zone = 0;
834 sprintf(info_trans->
proj,
"pipeline");
837 if (info_trans->
def) {
839 info_trans->
pj = proj_create(PJ_DEFAULT_CTX, info_trans->
def);
840 if (info_trans->
pj ==
NULL) {
841 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
848 else if (info_out->
pj ==
NULL) {
849 G_asprintf(&(info_trans->
def),
"+proj=pipeline +step +inv %s",
851 info_trans->
pj = proj_create(PJ_DEFAULT_CTX, info_trans->
def);
852 if (info_trans->
pj ==
NULL) {
853 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
858 else if (info_in->
def && info_out->
pj && info_out->
def) {
860 char *insrid =
NULL, *outsrid =
NULL;
864 if (strncmp(info_in->
srid,
"EPSG", 4) == 0)
870 if (info_out->
pj && info_out->
srid) {
871 if (strncmp(info_out->
srid,
"EPSG", 4) == 0)
879 if (insrid && outsrid) {
883 G_asprintf(&(info_trans->
def),
"+proj=pipeline +step +inv +init=%s +step +init=%s",
887 info_trans->
pj = proj_create_crs_to_crs(PJ_DEFAULT_CTX,
893 if (info_trans->
pj) {
894 G_debug(1,
"proj_create_crs_to_crs() succeeded with PROJ5");
920 G_asprintf(&(info_trans->
def),
"+proj=pipeline +step +inv %s +step %s",
923 info_trans->
pj = proj_create(PJ_DEFAULT_CTX, info_trans->
def);
932 if (info_trans->
pj ==
NULL) {
933 G_warning(
_(
"proj_create() failed for '%s'"), info_trans->
def);
940 if (info_out->
pj ==
NULL) {
942 G_warning(
_(
"Unable to create latlong equivalent for '%s'"),
981 const struct pj_info *info_out,
982 const struct pj_info *info_trans,
int dir,
983 double *
x,
double *y,
double *z)
989 int in_is_ll, out_is_ll, in_deg2rad, out_rad2deg;
995 if (info_trans->
pj ==
NULL)
998 in_deg2rad = out_rad2deg = 1;
1001 METERS_in = info_in->
meters;
1002 in_is_ll = !strncmp(info_in->
proj,
"ll", 2);
1003 #if PROJ_VERSION_MAJOR >= 6 1007 if (in_is_ll && proj_angular_input(info_trans->
pj, dir) == 0) {
1012 METERS_out = info_out->
meters;
1013 out_is_ll = !strncmp(info_out->
proj,
"ll", 2);
1014 #if PROJ_VERSION_MAJOR >= 6 1018 if (out_is_ll && proj_angular_output(info_trans->
pj, dir) == 0) {
1030 METERS_out = info_in->
meters;
1031 out_is_ll = !strncmp(info_in->
proj,
"ll", 2);
1032 #if PROJ_VERSION_MAJOR >= 6 1036 if (out_is_ll && proj_angular_output(info_trans->
pj, dir) == 0) {
1041 METERS_in = info_out->
meters;
1042 in_is_ll = !strncmp(info_out->
proj,
"ll", 2);
1043 #if PROJ_VERSION_MAJOR >= 6 1047 if (in_is_ll && proj_angular_input(info_trans->
pj, dir) == 0) {
1076 c.xyzt.x = *x * METERS_in;
1077 c.xyzt.y = *y * METERS_in;
1084 G_debug(1,
"c.xyzt.x: %g", c.xyzt.x);
1085 G_debug(1,
"c.xyzt.y: %g", c.xyzt.y);
1086 G_debug(1,
"c.xyzt.z: %g", c.xyzt.z);
1089 c = proj_trans(info_trans->
pj, dir, c);
1090 ok = proj_errno(info_trans->
pj);
1093 G_warning(
_(
"proj_trans() failed: %s"), proj_errno_string(ok));
1114 *x = c.xyzt.x / METERS_out;
1115 *y = c.xyzt.y / METERS_out;
1123 const struct pj_info *p_in, *p_out;
1125 if (info_out ==
NULL)
1128 if (dir == PJ_FWD) {
1137 METERS_in = p_in->
meters;
1138 METERS_out = p_out->
meters;
1143 if (strncmp(p_in->
proj,
"ll", 2) == 0) {
1152 ok = pj_transform(p_in->
pj, p_out->
pj, 1, 0, &u, &v, &h);
1155 G_warning(
_(
"pj_transform() failed: %s"), pj_strerrno(ok));
1159 if (strncmp(p_out->
proj,
"ll", 2) == 0) {
1164 *x = u / METERS_out;
1165 *y = v / METERS_out;
1201 const struct pj_info *info_out,
1202 const struct pj_info *info_trans,
int dir,
1203 double *
x,
double *y,
double *z,
int n)
1211 int in_is_ll, out_is_ll, in_deg2rad, out_rad2deg;
1214 if (info_trans->
pj ==
NULL)
1217 in_deg2rad = out_rad2deg = 1;
1218 if (dir == PJ_FWD) {
1220 METERS_in = info_in->
meters;
1221 in_is_ll = !strncmp(info_in->
proj,
"ll", 2);
1222 #if PROJ_VERSION_MAJOR >= 6 1226 if (in_is_ll && proj_angular_input(info_trans->
pj, dir) == 0) {
1231 METERS_out = info_out->
meters;
1232 out_is_ll = !strncmp(info_out->
proj,
"ll", 2);
1233 #if PROJ_VERSION_MAJOR >= 6 1237 if (out_is_ll && proj_angular_output(info_trans->
pj, dir) == 0) {
1249 METERS_out = info_in->
meters;
1250 out_is_ll = !strncmp(info_in->
proj,
"ll", 2);
1251 #if PROJ_VERSION_MAJOR >= 6 1255 if (out_is_ll && proj_angular_output(info_trans->
pj, dir) == 0) {
1260 METERS_in = info_out->
meters;
1261 in_is_ll = !strncmp(info_out->
proj,
"ll", 2);
1262 #if PROJ_VERSION_MAJOR >= 6 1266 if (in_is_ll && proj_angular_input(info_trans->
pj, dir) == 0) {
1280 for (i = 0; i < n; i++)
1295 for (i = 0; i < n; i++) {
1306 c = proj_trans(info_trans->
pj, dir, c);
1307 if ((ok = proj_errno(info_trans->
pj)) < 0)
1321 for (i = 0; i < n; i++) {
1332 c = proj_trans(info_trans->
pj, dir, c);
1333 if ((ok = proj_errno(info_trans->
pj)) < 0)
1337 x[i] = c.xy.x / METERS_out;
1338 y[i] = c.xy.y / METERS_out;
1345 for (i = 0; i < n; i++) {
1347 c.xyzt.x = x[i] * METERS_in;
1348 c.xyzt.y = y[i] * METERS_in;
1350 c = proj_trans(info_trans->
pj, dir, c);
1351 if ((ok = proj_errno(info_trans->
pj)) < 0)
1365 for (i = 0; i < n; i++) {
1367 c.xyzt.x = x[i] * METERS_in;
1368 c.xyzt.y = y[i] * METERS_in;
1370 c = proj_trans(info_trans->
pj, dir, c);
1371 if ((ok = proj_errno(info_trans->
pj)) < 0)
1374 x[i] = c.xy.x / METERS_out;
1375 y[i] = c.xy.y / METERS_out;
1383 G_warning(
_(
"proj_trans() failed: %s"), proj_errno_string(ok));
1387 const struct pj_info *p_in, *p_out;
1389 if (dir == PJ_FWD) {
1398 METERS_in = p_in->
meters;
1399 METERS_out = p_out->
meters;
1404 for (i = 0; i < n; ++i)
1408 if (strncmp(p_in->
proj,
"ll", 2) == 0) {
1409 if (strncmp(p_out->
proj,
"ll", 2) == 0) {
1411 ok = pj_transform(info_in->
pj, info_out->
pj, n, 1, x, y, z);
1416 ok = pj_transform(info_in->
pj, info_out->
pj, n, 1, x, y, z);
1421 if (strncmp(p_out->
proj,
"ll", 2) == 0) {
1423 ok = pj_transform(info_in->
pj, info_out->
pj, n, 1, x, y, z);
1428 ok = pj_transform(info_in->
pj, info_out->
pj, n, 1, x, y, z);
1436 G_warning(
_(
"pj_transform() failed: %s"), pj_strerrno(ok));
1475 METERS_in = info_in->
meters;
1476 METERS_out = info_out->
meters;
1478 if (strncmp(info_in->
proj,
"ll", 2) == 0) {
1484 c = proj_trans(info_trans.
pj, PJ_FWD, c);
1485 ok = proj_errno(info_trans.
pj);
1487 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1494 *x = c.xy.x / METERS_out;
1495 *y = c.xy.y / METERS_out;
1500 c.xyzt.x = *x * METERS_in;
1501 c.xyzt.y = *y * METERS_in;
1504 c = proj_trans(info_trans.
pj, PJ_FWD, c);
1505 ok = proj_errno(info_trans.
pj);
1507 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1514 *x = c.xy.x / METERS_out;
1515 *y = c.xy.y / METERS_out;
1518 proj_destroy(info_trans.
pj);
1527 METERS_in = info_in->
meters;
1528 METERS_out = info_out->
meters;
1530 if (strncmp(info_in->
proj,
"ll", 2) == 0) {
1531 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1534 ok = pj_transform(info_in->
pj, info_out->
pj, 1, 0, &u, &v, &h);
1541 ok = pj_transform(info_in->
pj, info_out->
pj, 1, 0, &u, &v, &h);
1542 *x = u / METERS_out;
1543 *y = v / METERS_out;
1547 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1550 ok = pj_transform(info_in->
pj, info_out->
pj, 1, 0, &u, &v, &h);
1557 ok = pj_transform(info_in->
pj, info_out->
pj, 1, 0, &u, &v, &h);
1558 *x = u / METERS_out;
1559 *y = v / METERS_out;
1563 G_warning(
_(
"pj_transform() failed: %s"), pj_strerrno(ok));
1606 METERS_in = info_in->
meters;
1607 METERS_out = info_out->
meters;
1612 for (i = 0; i <
count; ++i)
1617 if (strncmp(info_in->
proj,
"ll", 2) == 0) {
1619 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1620 for (i = 0; i <
count; i++) {
1625 c = proj_trans(info_trans.
pj, PJ_FWD, c);
1626 if ((ok = proj_errno(info_trans.
pj)) < 0)
1634 for (i = 0; i <
count; i++) {
1639 c = proj_trans(info_trans.
pj, PJ_FWD, c);
1640 if ((ok = proj_errno(info_trans.
pj)) < 0)
1643 x[i] = c.xy.x / METERS_out;
1644 y[i] = c.xy.y / METERS_out;
1650 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1651 for (i = 0; i <
count; i++) {
1653 c.xyzt.x = x[i] * METERS_in;
1654 c.xyzt.y = y[i] * METERS_in;
1656 c = proj_trans(info_trans.
pj, PJ_FWD, c);
1657 if ((ok = proj_errno(info_trans.
pj)) < 0)
1665 for (i = 0; i <
count; i++) {
1667 c.xyzt.x = x[i] * METERS_in;
1668 c.xyzt.y = y[i] * METERS_in;
1670 c = proj_trans(info_trans.
pj, PJ_FWD, c);
1671 if ((ok = proj_errno(info_trans.
pj)) < 0)
1674 x[i] = c.xy.x / METERS_out;
1675 y[i] = c.xy.y / METERS_out;
1681 proj_destroy(info_trans.
pj);
1687 METERS_in = info_in->
meters;
1688 METERS_out = info_out->
meters;
1693 for (i = 0; i <
count; ++i)
1697 if (strncmp(info_in->
proj,
"ll", 2) == 0) {
1698 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1700 ok = pj_transform(info_in->
pj, info_out->
pj, count, 1, x, y, h);
1705 ok = pj_transform(info_in->
pj, info_out->
pj, count, 1, x, y, h);
1710 if (strncmp(info_out->
proj,
"ll", 2) == 0) {
1712 ok = pj_transform(info_in->
pj, info_out->
pj, count, 1, x, y, h);
1717 ok = pj_transform(info_in->
pj, info_out->
pj, count, 1, x, y, h);
1725 G_warning(
_(
"pj_transform() failed: %s"), pj_strerrno(ok));
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int pj_do_transform(int count, double *x, double *y, double *h, const struct pj_info *info_in, const struct pj_info *info_out)
Re-project an array of points between two co-ordinate systems with optional ellipsoidal height conver...
void void void G_important_message(const char *,...) __attribute__((format(printf
int pj_do_proj(double *x, double *y, const struct pj_info *info_in, const struct pj_info *info_out)
Re-project a point between two co-ordinate systems.
2D/3D raster map header (used also for region)
double west
Extent coordinates (west)
int GPJ_init_transform(const struct pj_info *info_in, const struct pj_info *info_out, struct pj_info *info_trans)
Create a PROJ transformation object to transform coordinates from an input SRS to an output SRS...
int GPJ_get_equivalent_latlong(struct pj_info *, struct pj_info *)
void G_free(void *)
Free allocated memory.
#define DIVIDE_LOOP(x, y, c, m)
int GPJ_transform_array(const struct pj_info *info_in, const struct pj_info *info_out, const struct pj_info *info_trans, int dir, double *x, double *y, double *z, int n)
Re-project an array of points between two co-ordinate systems using a transformation object prepared ...
double north
Extent coordinates (north)
double south
Extent coordinates (south)
char * G_store_lower(const char *)
Copy string to allocated memory and convert copied string to lower case.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
#define MULTIPLY_LOOP(x, y, c, m)
int GPJ_transform(const struct pj_info *info_in, const struct pj_info *info_out, const struct pj_info *info_trans, int dir, double *x, double *y, double *z)
Re-project a point between two co-ordinate systems using a transformation object prepared with GPJ_pr...
void G_warning(const char *,...) __attribute__((format(printf
double east
Extent coordinates (east)
char * G_store_upper(const char *)
Copy string to allocated memory and convert copied string to upper case.
char * G_store(const char *)
Copy string to allocated memory.
int G_asprintf(char **, const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf