xapian-core 2.0.0

Public Member Functions | List of all members
Xapian::GreatCircleMetric Class Reference

Calculate the great-circle distance between two coordinates on a sphere. More...

`#include <geospatial.h>`

Inheritance diagram for Xapian::GreatCircleMetric:
[legend]

## Public Member Functions
| GreatCircleMetric ()
| Construct a GreatCircleMetric.
| GreatCircleMetric (double radius_)
| Construct a GreatCircleMetric using a specified radius.
double | pointwise_distance (const LatLongCoord &a, const LatLongCoord &b) const
| Return the great-circle distance between points on the sphere.
LatLongMetric * | clone () const
| Clone the metric.
std::string | name () const
| Return the full name of the metric.
std::string | serialise () const
| Serialise object parameters into a string.
LatLongMetric * | unserialise (const std::string &serialised) const
| Create object given string serialisation returned by serialise().
Public Member Functions inherited from Xapian::LatLongMetric
virtual | ~LatLongMetric ()
| Destructor.
double | operator() (const LatLongCoords &a, const LatLongCoords &b) const
| Return the distance between two coordinate lists, in metres.
double | operator() (const LatLongCoords &a, std::string_view b) const
| Return the distance between two coordinate lists, in metres.
double | operator() (const LatLongCoords &a, const char *b_ptr, size_t b_len) const
| Return the distance between two coordinate lists, in metres.

## Detailed Description

Calculate the great-circle distance between two coordinates on a sphere.

Experimental - see https://xapian.org/docs/deprecation#experimental-features

This uses the haversine formula to calculate the distance. Note that this formula is subject to inaccuracy due to numerical errors for coordinates on the opposite side of the sphere.

See https://en.wikipedia.org/wiki/Haversine_formula

## Constructor & Destructor Documentation

## ◆ GreatCircleMetric() [1/2]

Xapian::GreatCircleMetric::GreatCircleMetric | ( |  | ) |

Construct a GreatCircleMetric.

The (quadratic mean) radius of the Earth will be used by this calculator.

## ◆ GreatCircleMetric() [2/2]

Xapian::GreatCircleMetric::GreatCircleMetric | ( | double | radius_ | ) |
| explicit

Construct a GreatCircleMetric using a specified radius.

This is useful for data sets in which the points are not on Earth (eg, a database of features on Mars).

Parameters

  radius_ | The radius of the sphere to use, in metres.

## Member Function Documentation

## ◆ clone()

LatLongMetric * Xapian::GreatCircleMetric::clone | ( |  | ) | const
| virtual

Clone the metric.

Implements Xapian::LatLongMetric.

## ◆ name()

std::string Xapian::GreatCircleMetric::name | ( |  | ) | const
| virtual

Return the full name of the metric.

This is used when serialising and unserialising metrics; for example, for performing remote searches.

If the subclass is in a C++ namespace, the namespace should be included in the name, using "::" as a separator. For example, for a LatLongMetric subclass called "FooLatLongMetric" in the "Xapian" namespace the result of this call should be "Xapian::FooLatLongMetric".

Implements Xapian::LatLongMetric.

## ◆ pointwise_distance()

double Xapian::GreatCircleMetric::pointwise_distance | ( | const LatLongCoord & | a,
|  | const LatLongCoord & | b ) const
| virtual

Return the great-circle distance between points on the sphere.

Implements Xapian::LatLongMetric.

## ◆ serialise()

std::string Xapian::GreatCircleMetric::serialise | ( |  | ) | const
| virtual

Serialise object parameters into a string.

The serialised parameters should represent the configuration of the metric.

Implements Xapian::LatLongMetric.

## ◆ unserialise()

LatLongMetric * Xapian::GreatCircleMetric::unserialise | ( | const std::string & | serialised | ) | const
| virtual

Create object given string serialisation returned by serialise().

Parameters

  serialised | A serialised instance of this LatLongMetric subclass.

Implements Xapian::LatLongMetric.

The documentation for this class was generated from the following file:

- xapian/geospatial.h