PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ proj_cs_get_simplecs()

static PJ * proj_cs_get_simplecs ( const PJ *  pj_crs)
static

Definition at line 215 of file liblwgeom/lwgeom_transform.c.

216{
217 PJ *pj_sub = NULL;
218 if (proj_get_type(pj_crs) == PJ_TYPE_COMPOUND_CRS)
219 {
220 /* Sub-CRS[0] is the horizontal component */
221 pj_sub = proj_crs_get_sub_crs(NULL, pj_crs, 0);
222 if (!pj_sub)
223 lwerror("%s: proj_crs_get_sub_crs(0) returned NULL", __func__);
224 }
225 else if (proj_get_type(pj_crs) == PJ_TYPE_BOUND_CRS)
226 {
227 pj_sub = proj_get_source_crs(NULL, pj_crs);
228 if (!pj_sub)
229 lwerror("%s: proj_get_source_crs returned NULL", __func__);
230 }
231 else
232 {
233 /* If this works, we have a CS so we can return */
234 pj_sub = proj_crs_get_coordinate_system(NULL, pj_crs);
235 if (pj_sub)
236 return pj_sub;
237 }
238
239 /* Only sub-components of the Compound or Bound CRS's get here */
240 /* If we failed to get sub-components, or we failed to extract */
241 /* a CS from a generic CRS, then this is another case we don't */
242 /* handle */
243 if (!pj_sub)
244 lwerror("%s: %s", __func__, proj_errno_string(proj_context_errno(NULL)));
245
246 /* If the components are usable, we can extract the CS and return */
247 int pj_type = proj_get_type(pj_sub);
248 if (pj_type == PJ_TYPE_GEOGRAPHIC_2D_CRS || pj_type == PJ_TYPE_PROJECTED_CRS)
249 {
250 PJ *pj_2d = proj_crs_get_coordinate_system(NULL, pj_sub);
251 proj_destroy(pj_sub);
252 return pj_2d;
253 }
254
255 /* If the components are *themselves* Bound/Compound, we can recurse */
256 if (pj_type == PJ_TYPE_COMPOUND_CRS || pj_type == PJ_TYPE_BOUND_CRS)
257 return proj_cs_get_simplecs(pj_sub);
258
259 /* This is a case we don't know how to handle */
260 lwerror("%s: un-handled CRS sub-type: %s", __func__, pj_type);
261 return NULL;
262}
static PJ * proj_cs_get_simplecs(const PJ *pj_crs)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190

References lwerror(), and proj_cs_get_simplecs().

Referenced by proj_crs_is_swapped(), and proj_cs_get_simplecs().

Here is the call graph for this function:
Here is the caller graph for this function: