PostGIS  3.7.0dev-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 339 of file postgis/lwgeom_transform.c.

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