PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ postgis_srs_codes()

Datum postgis_srs_codes ( PG_FUNCTION_ARGS  )

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

644 {
645  FuncCallContext *funcctx;
646  MemoryContext oldcontext;
647  struct srs_data *state;
648  Datum result;
649  text* auth_name = PG_GETARG_TEXT_P(0);
650  text* auth_code;
651 
652  /*
653  * On the first call, fill in the state with all
654  * of the auth_name/auth_srid pairings in the
655  * proj database. Then the per-call routine is just
656  * one isolated call per pair.
657  */
658  if (SRF_IS_FIRSTCALL())
659  {
660  /*
661  * Only a subset of supported proj types actually
662  * show up in spatial_ref_sys
663  */
664  funcctx = SRF_FIRSTCALL_INIT();
665  oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
666  state = srs_state_init();
667  srs_state_codes(text_to_cstring(auth_name), state);
668  funcctx->user_fctx = state;
669  MemoryContextSwitchTo(oldcontext);
670  }
671 
672  /* Stuff done on every call of the function */
673  funcctx = SRF_PERCALL_SETUP();
674  state = funcctx->user_fctx;
675 
676  /* Exit when we've read all entries */
677  if (!state->num_entries || state->current_entry == state->num_entries)
678  {
679  SRF_RETURN_DONE(funcctx);
680  }
681 
682  /* Read the code for this entry */
683  auth_code = state->entries[state->current_entry++].auth_code;
684  result = PointerGetDatum(auth_code);
685 
686  /* We are returning setof(text) */
687  if (result)
688  SRF_RETURN_NEXT(funcctx, result);
689 
690  /* Stop if lookup fails drastically */
691  SRF_RETURN_DONE(funcctx);
692  SRF_RETURN_DONE(funcctx);
693 }
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)
struct srs_entry * entries
text * auth_code

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

Here is the call graph for this function: