PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ postgis_srs_entry_all()

Datum postgis_srs_entry_all ( PG_FUNCTION_ARGS  )

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

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