PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ postgis_srs_codes()

Datum postgis_srs_codes ( PG_FUNCTION_ARGS  )

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

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