PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ postgis_srs_codes()

Datum postgis_srs_codes ( PG_FUNCTION_ARGS  )

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

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