PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ srs_tuple_from_entry()

static Datum srs_tuple_from_entry ( const struct srs_entry entry,
TupleDesc  tuple_desc 
)
static

Definition at line 342 of file postgis/lwgeom_transform.c.

343 {
344  HeapTuple tuple;
345  Datum tuple_data[7] = {0, 0, 0, 0, 0, 0, 0};
346  bool tuple_null[7] = {true, true, true, true, true, true, true};
347  PJ_CONTEXT * ctx = NULL;
348  const char * const empty_options[2] = {NULL};
349  const char * const wkt_options[2] = {"MULTILINE=NO", NULL};
350  const char * srtext;
351  const char * proj4text;
352  const char * srname;
353  double w_lon, s_lat, e_lon, n_lat;
354  int ok;
355 
356  PJ *obj = proj_create_from_database(ctx,
357  text_to_cstring(entry->auth_name),
358  text_to_cstring(entry->auth_code),
359  PJ_CATEGORY_CRS, 0, empty_options);
360 
361  if (!obj)
362  return (Datum) 0;
363 
364  srtext = proj_as_wkt(ctx, obj, PJ_WKT1_GDAL, wkt_options);
365  proj4text = proj_as_proj_string(ctx, obj, PJ_PROJ_4, empty_options);
366  srname = proj_get_name(obj);
367  ok = proj_get_area_of_use(ctx, obj, &w_lon, &s_lat, &e_lon, &n_lat, NULL);
368 
369  if (entry->auth_name) {
370  tuple_data[0] = PointerGetDatum(entry->auth_name);
371  tuple_null[0] = false;
372  }
373 
374  if (entry->auth_code) {
375  tuple_data[1] = PointerGetDatum(entry->auth_code);
376  tuple_null[1] = false;
377  }
378 
379  if (srname) {
380  tuple_data[2] = PointerGetDatum(cstring_to_text(srname));
381  tuple_null[2] = false;
382  }
383 
384  if (srtext) {
385  tuple_data[3] = PointerGetDatum(cstring_to_text(srtext));
386  tuple_null[3] = false;
387  }
388 
389  if (proj4text) {
390  tuple_data[4] = PointerGetDatum(cstring_to_text(proj4text));
391  tuple_null[4] = false;
392  }
393 
394  if (ok) {
395  LWPOINT *p_sw = lwpoint_make2d(4326, w_lon, s_lat);
396  LWPOINT *p_ne = lwpoint_make2d(4326, e_lon, n_lat);
397  GSERIALIZED *g_sw = geometry_serialize((LWGEOM*)p_sw);
398  GSERIALIZED *g_ne = geometry_serialize((LWGEOM*)p_ne);
399  tuple_data[5] = PointerGetDatum(g_sw);
400  tuple_null[5] = false;
401  tuple_data[6] = PointerGetDatum(g_ne);
402  tuple_null[6] = false;
403  }
404 
405  tuple = heap_form_tuple(tuple_desc, tuple_data, tuple_null);
406  proj_destroy(obj);
407 
408  return HeapTupleGetDatum(tuple);
409 }
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
Definition: lwpoint.c:163
text * auth_name
text * auth_code

References srs_entry::auth_code, srs_entry::auth_name, and lwpoint_make2d().

Referenced by postgis_srs_entry(), postgis_srs_entry_all(), and postgis_srs_search().

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