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