xapian-core
1.4.27
|
Calculate the great-circle distance between two coordinates on a sphere. More...
#include <geospatial.h>
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... | |
LatLongMetric * | clone () 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... | |
LatLongMetric * | unserialise (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... | |
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
Definition at line 399 of file geospatial.h.
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().
|
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).
radius_ | The radius of the sphere to use, in metres. |
Definition at line 105 of file latlong_metrics.cc.
|
virtual |
Clone the metric.
Implements Xapian::LatLongMetric.
Definition at line 131 of file latlong_metrics.cc.
References GreatCircleMetric(), and radius.
|
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().
|
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.
|
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().
|
virtual |
Create object given string serialisation returned by serialise().
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().
|
private |
The radius of the sphere in metres.
Definition at line 402 of file geospatial.h.
Referenced by clone(), pointwise_distance(), and serialise().