PostGIS  3.4.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 329 of file postgis/lwgeom_transform.c.

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