xapian-core  1.4.25
Xapian::GreatCircleMetric Class Reference

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

`#include <geospatial.h>`

Inheritance diagram for Xapian::GreatCircleMetric:
Collaboration diagram for Xapian::GreatCircleMetric:

## Public Member Functions

GreatCircleMetric ()
Construct a GreatCircleMetric. More...

GreatCircleMetric (double radius_)
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. 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...

## Private Attributes

double radius
The radius of the sphere in metres. 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.

Definition at line 399 of file geospatial.h.

## ◆ GreatCircleMetric() [1/2]

 GreatCircleMetric::GreatCircleMetric ( )

Construct a GreatCircleMetric.

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

Definition at line 101 of file latlong_metrics.cc.

Referenced by clone(), and unserialise().

## ◆ GreatCircleMetric() [2/2]

 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.

Definition at line 105 of file latlong_metrics.cc.

## ◆ clone()

 LatLongMetric * GreatCircleMetric::clone ( ) const
virtual

Clone the metric.

Implements Xapian::LatLongMetric.

Definition at line 131 of file latlong_metrics.cc.

References GreatCircleMetric(), and radius.

## ◆ name()

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

Definition at line 137 of file latlong_metrics.cc.

Referenced by DEFINE_TESTCASE().

## ◆ pointwise_distance()

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

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

Implements Xapian::LatLongMetric.

Definition at line 110 of file latlong_metrics.cc.

References Xapian::LatLongCoord::latitude, Xapian::LatLongCoord::longitude, radius, and rare.

## ◆ serialise()

 string GreatCircleMetric::serialise ( ) const
virtual

Serialise object parameters into a string.

The serialised parameters should represent the configuration of the metric.

Implements Xapian::LatLongMetric.

Definition at line 143 of file latlong_metrics.cc.

References radius, and serialise_double().

Referenced by DEFINE_TESTCASE().

## ◆ unserialise()

 LatLongMetric * 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.

Definition at line 149 of file latlong_metrics.cc.

References GreatCircleMetric(), and unserialise_double().

## ◆ radius

 double Xapian::GreatCircleMetric::radius
private

The radius of the sphere in metres.

Definition at line 402 of file geospatial.h.

Referenced by clone(), pointwise_distance(), and serialise().

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