141 static const int16_t max_query_size = 512;
143 Oid argtypes[] = {CSTRINGOID};
144 Datum values[] = {CStringGetDatum(srs)};
147 postgis_initialize_cache(fcinfo);
152 "regexp_matches($1::text, E'([a-z]+):([0-9]+)', 'gi') AS re "
153 "WHERE re[1] ILIKE auth_name AND int4(re[2]) = auth_srid",
154 postgis_spatial_ref_sys());
158 if (SPI_OK_CONNECT != SPI_connect())
160 elog(NOTICE,
"getSRIDbySRS: could not connect to SPI manager");
164 err = SPI_execute_with_args(query, 1, argtypes, values, NULL,
true, 1);
167 elog(NOTICE,
"getSRIDbySRS: error executing query %d", err);
173 if (SPI_processed <= 0)
179 "regexp_matches($1::text, E'urn:ogc:def:crs:([a-z]+):.*:([0-9]+)', 'gi') AS re "
180 "WHERE re[1] ILIKE auth_name AND int4(re[2]) = auth_srid",
181 postgis_spatial_ref_sys());
183 err = SPI_execute_with_args(query, 1, argtypes, values, NULL,
true, 1);
186 elog(NOTICE,
"getSRIDbySRS: error executing query %d", err);
191 if (SPI_processed <= 0)
198 srid = atoi(SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1));