xapian-core  1.4.22
Xapian::GreatCircleMetric Class Reference

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

`#include <geospatial.h>`

Inheritance diagram for Xapian::GreatCircleMetric:

## Public Member Functions

GreatCircleMetric ()
Construct a GreatCircleMetric. More...

Construct a GreatCircleMetric using a specified radius. More...

double pointwise_distance (const LatLongCoord &a, const LatLongCoord &b) const
Return the great-circle distance between points on the sphere. More...

LatLongMetricclone () const
Clone the metric. More...

std::string name () const
Return the full name of the metric. More...

std::string serialise () const
Serialise object parameters into a string. More...

LatLongMetricunserialise (const std::string &serialised) const
Create object given string serialisation returned by serialise(). More...

Public Member Functions inherited from Xapian::LatLongMetric
virtual ~LatLongMetric ()
Destructor.

virtual double pointwise_distance (const LatLongCoord &a, const LatLongCoord &b) const =0
Return the distance between two coordinates, in metres. More...

double operator() (const LatLongCoords &a, const LatLongCoords &b) const
Return the distance between two coordinate lists, in metres. More...

double operator() (const LatLongCoords &a, const std::string &b) const
Return the distance between two coordinate lists, in metres. More...

double operator() (const LatLongCoords &a, const char *b_ptr, size_t b_len) const
Return the distance between two coordinate lists, in metres. More...

virtual LatLongMetricclone () const =0
Clone the metric. More...

virtual std::string name () const =0
Return the full name of the metric. More...

virtual std::string serialise () const =0
Serialise object parameters into a string. More...

virtual LatLongMetricunserialise (const std::string &serialised) const =0
Create object given string serialisation returned by serialise(). More...

## 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.

## ◆ 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]

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

## ◆ 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: