PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ gserialized_gist_geog_distance()

Datum gserialized_gist_geog_distance ( PG_FUNCTION_ARGS  )

Definition at line 1349 of file gserialized_gist_nd.c.

References distance(), gidx_distance(), gserialized_gist_distance(), LW_FAILURE, PG_FUNCTION_INFO_V1(), and WGS84_RADIUS.

Referenced by gserialized_gist_same().

1350 {
1351  GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1352  Datum query_datum = PG_GETARG_DATUM(1);
1353  StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1354 #if POSTGIS_PGSQL_VERSION >= 95
1355  bool *recheck = (bool *) PG_GETARG_POINTER(4);
1356 #endif
1357  char query_box_mem[GIDX_MAX_SIZE];
1358  GIDX *query_box = (GIDX*)query_box_mem;
1359  GIDX *entry_box;
1360  double distance;
1361 
1362  POSTGIS_DEBUGF(3, "[GIST] '%s' function called", __func__);
1363 
1364  /* We are using '13' as the gist geography distance <-> strategy number */
1365  if ( strategy != 13 )
1366  {
1367  elog(ERROR, "unrecognized strategy number: %d", strategy);
1368  PG_RETURN_FLOAT8(FLT_MAX);
1369  }
1370 
1371  /* Null box should never make this far. */
1372  if ( gserialized_datum_get_gidx_p(query_datum, query_box) == LW_FAILURE )
1373  {
1374  POSTGIS_DEBUG(2, "[GIST] null query_gbox_index!");
1375  PG_RETURN_FLOAT8(FLT_MAX);
1376  }
1377 
1378 #if POSTGIS_PGSQL_VERSION >= 95
1379  /* When we hit leaf nodes, it's time to turn on recheck */
1380  if (GIST_LEAF(entry))
1381  {
1382  *recheck = true;
1383  }
1384 #endif
1385 
1386  /* Get the entry box */
1387  entry_box = (GIDX*)DatumGetPointer(entry->key);
1388 
1389  /* Return distances from key-based tests should always be */
1390  /* the minimum possible distance, box-to-box */
1391  /* We scale up to "world units" so that the box-to-box distances */
1392  /* compare reasonably with the over-the-spheroid distances that */
1393  /* the recheck process will turn up */
1394  distance = WGS84_RADIUS * gidx_distance(entry_box, query_box, 0);
1395  POSTGIS_DEBUGF(2, "[GIST] '%s' got distance %g", __func__, distance);
1396 
1397  PG_RETURN_FLOAT8(distance);
1398 }
#define WGS84_RADIUS
Definition: liblwgeom.h:130
#define LW_FAILURE
Definition: liblwgeom.h:78
static double gidx_distance(const GIDX *a, const GIDX *b, int m_is_time)
Calculate the box->box distance.
Datum distance(PG_FUNCTION_ARGS)
Here is the call graph for this function:
Here is the caller graph for this function: