PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ postgis_srs_entry_all()

Datum postgis_srs_entry_all ( PG_FUNCTION_ARGS  )

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

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