Skip to content

Commit

Permalink
libgproj: Use SRID for PJ object creation when possible (#2394)
Browse files Browse the repository at this point in the history
* Use SRID for PJ creation

* Use proj_get_source_crs()

* Tabs to spaces
  • Loading branch information
HuidaeCho committed Jan 10, 2023
1 parent d657c9a commit 76d27ff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/proj/get_proj.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ int pj_get_kv(struct pj_info *info, const struct Key_Value *in_proj_keys,

if (perr)
G_fatal_error("PROJ 5 error %d", perr);

if (proj_get_type(pj) == PJ_TYPE_BOUND_CRS) {
PJ *source_crs = proj_get_source_crs(pjc, pj);
if (source_crs) {
proj_destroy(pj);
pj = source_crs;
}
}
#endif

info->pj = pj;
Expand Down Expand Up @@ -417,6 +425,14 @@ int pj_get_string(struct pj_info *info, char *str)
proj_errno_string(proj_context_errno(pjc)));
return -1;
}

if (proj_get_type(pj) == PJ_TYPE_BOUND_CRS) {
PJ *source_crs = proj_get_source_crs(pjc, pj);
if (source_crs) {
proj_destroy(pj);
pj = source_crs;
}
}
#else
/* Set finder function for locating datum conversion tables PK */
pj_set_finder(FINDERFUNC);
Expand Down

0 comments on commit 76d27ff

Please sign in to comment.