470{
472 const int32_t srid_to = 4326;
474 PJ_TYPE types[1] = {PJ_TYPE_PROJECTED_CRS};
475 PROJ_CRS_INFO **crs_list_ptr, **crs_list;
476 int crs_count;
477 PJ_CONTEXT *ctx = NULL;
478
479 PROJ_CRS_LIST_PARAMETERS *params = proj_get_crs_list_parameters_create();
480 params->types = types;
481 params->typesCount = 1;
482 params->crs_area_of_use_contains_bbox = true;
483 params->bbox_valid = true;
484 params->allow_deprecated = false;
485
486#if POSTGIS_PROJ_VERSION >= 80100
487 params->celestial_body_name = "Earth";
488#endif
489
490 if (srid_from != srid_to)
491 {
493 if (lwproj_lookup(srid_from, srid_to, &pj) ==
LW_FAILURE)
494 elog(ERROR, "%s: Lookup of SRID %u => %u transform failed",
495 __func__, srid_from, srid_to);
496
498 }
499
500 params->west_lon_degree = gbox.
xmin;
501 params->south_lat_degree = gbox.
ymin;
502 params->east_lon_degree = gbox.
xmax;
503 params->north_lat_degree = gbox.
ymax;
504
505 crs_list = crs_list_ptr = proj_get_crs_info_list_from_database(
506 ctx, auth_name, params, &crs_count);
507
508
509
510 while (crs_list && *crs_list)
511 {
512
513 PROJ_CRS_INFO *crs = *crs_list++;
514
515
516 double area;
517 double height = crs->north_lat_degree - crs->south_lat_degree;
518 double width = crs->east_lon_degree - crs->west_lon_degree;
519 if (width < 0.0)
520 width = 360 - (crs->west_lon_degree - crs->east_lon_degree);
521 area = width * height;
522
523
525
526
531 }
532
533
535
536 proj_crs_info_list_destroy(crs_list_ptr);
537 proj_get_crs_list_parameters_destroy(params);
538}
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
int box3d_transform(GBOX *box, LWPROJ *pj)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
static void srs_state_memcheck(struct srs_data *state)
static int srs_entry_cmp(const void *a, const void *b)
struct srs_entry * entries