PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ postgis_srs_entry_all()

Datum postgis_srs_entry_all ( PG_FUNCTION_ARGS  )

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

572 {
573  FuncCallContext *funcctx;
574  MemoryContext oldcontext;
575  struct srs_data *state;
576  Datum result;
577 
578  /*
579  * On the first call, fill in the state with all
580  * of the auth_name/auth_srid pairings in the
581  * proj database. Then the per-call routine is just
582  * one isolated call per pair.
583  */
584  if (SRF_IS_FIRSTCALL())
585  {
586  funcctx = SRF_FIRSTCALL_INIT();
587  oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
588 
589  /*
590  * Could read all authorities from database, but includes
591  * authorities (IGN, OGC) that use non-integral values in
592  * auth_srid. So hand-coded list for now.
593  */
594  state = srs_state_init();
595  srs_state_codes("EPSG", state);
596  srs_state_codes("ESRI", state);
597  srs_state_codes("IAU_2015", state);
598 
599  /*
600  * Read the TupleDesc from the FunctionCallInfo. The SQL definition
601  * of the function must have the right number of fields and types
602  * to match up to this C code.
603  */
604  if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE)
605  {
606  ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
607  errmsg("%s called with incompatible return type", __func__)));
608  }
609 
610  BlessTupleDesc(funcctx->tuple_desc);
611  funcctx->user_fctx = state;
612  MemoryContextSwitchTo(oldcontext);
613  }
614 
615  /* Stuff done on every call of the function */
616  funcctx = SRF_PERCALL_SETUP();
617  state = funcctx->user_fctx;
618 
619  /* Exit when we've read all entries */
620  if (!state->num_entries || state->current_entry == state->num_entries)
621  {
622  SRF_RETURN_DONE(funcctx);
623  }
624 
625  /* Lookup the srtext/proj4text for this entry */
627  state->entries + state->current_entry++,
628  funcctx->tuple_desc);
629 
630  if (result)
631  SRF_RETURN_NEXT(funcctx, result);
632 
633  /* Stop if lookup fails drastically */
634  SRF_RETURN_DONE(funcctx);
635 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
static struct srs_data * srs_state_init()
static void srs_state_codes(const char *auth_name, struct srs_data *state)
static Datum srs_tuple_from_entry(const struct srs_entry *entry, TupleDesc tuple_desc)
struct srs_entry * entries

References srs_data::current_entry, srs_data::entries, srs_data::num_entries, result, srs_state_codes(), srs_state_init(), and srs_tuple_from_entry().

Here is the call graph for this function: