62 static const uint16_t max_query_size = 512;
66 postgis_initialize_cache(fcinfo);
68 if (SPI_OK_CONNECT != SPI_connect ())
70 elog(NOTICE,
"getSRSbySRID: could not connect to SPI manager");
78 "SELECT auth_name||':'||auth_srid \
79 FROM %s WHERE srid='%d'",
80 postgis_spatial_ref_sys(),
85 "SELECT 'urn:ogc:def:crs:'||auth_name||'::'||auth_srid \
86 FROM %s WHERE srid='%d'",
87 postgis_spatial_ref_sys(),
90 err = SPI_exec(query, 1);
93 elog(NOTICE,
"getSRSbySRID: error executing query %d", err);
99 if (SPI_processed <= 0)
106 srs = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
116 size = strlen(srs)+1;
117 srscopy = SPI_palloc(size);
118 memcpy(srscopy, srs, size);