36 #define QUAD_EARTH_RADIUS_METRES 6372797.6
49 double min_dist = 0.0;
50 bool have_min =
false;
59 double dist = pointwise_distance(*a_iter, *b_iter);
63 }
else if (dist < min_dist) {
73 const char* b_ptr,
size_t b_len)
const
75 if (a.
empty() || b_len == 0) {
78 double min_dist = 0.0;
79 bool have_min =
false;
81 const char * b_end = b_ptr + b_len;
82 while (b_ptr != b_end) {
88 double dist = pointwise_distance(*a_iter, b);
92 }
else if (dist < min_dist) {
113 double lata = a.
latitude * (M_PI / 180.0);
114 double latb = b.
latitude * (M_PI / 180.0);
116 double latdiff = lata - latb;
119 double sin_half_lat = sin(latdiff / 2);
120 double sin_half_long = sin(longdiff / 2);
121 double h = sin_half_lat * sin_half_lat +
122 sin_half_long * sin_half_long * cos(lata) * cos(latb);
127 return 2 *
radius * asin(sqrt(h));
139 return "Xapian::GreatCircleMetric";
151 const char * p = s.data();
152 const char * end = p + s.size();
LatLongMetric * unserialise(const std::string &serialised) const
Create object given string serialisation returned by serialise().
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 serialise() const
Serialise object parameters into a string.
std::string name() const
Return the full name of the metric.
GreatCircleMetric()
Construct a GreatCircleMetric.
double radius
The radius of the sphere in metres.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
An iterator across the values in a LatLongCoords object.
A sequence of latitude-longitude coordinates.
LatLongCoordsIterator begin() const
Get a begin iterator for the coordinates.
LatLongCoordsIterator end() const
Get an end iterator for the coordinates.
bool empty() const
Return true if and only if there are no coordinates in the container.
Base class for calculating distances between two lat/long coordinates.
double operator()(const LatLongCoords &a, const LatLongCoords &b) const
Return the distance between two coordinate lists, in metres.
virtual ~LatLongMetric()
Destructor.
Indicates a problem communicating with a remote database.
Hierarchy of classes which Xapian can throw as exceptions.
Geospatial search support routines.
#define QUAD_EARTH_RADIUS_METRES
Quadratic mean radius of the Earth in metres.
The Xapian namespace contains public interfaces for the Xapian library.
std::string serialise_double(double v)
Serialise a double to a string.
double unserialise_double(const char **p, const char *end)
Unserialise a double serialised by serialise_double.
functions to serialise and unserialise a double
A latitude-longitude coordinate.
void unserialise(const std::string &serialised)
Unserialise a string and set this object to its coordinate.
double latitude
A latitude, as decimal degrees.
double longitude
A longitude, as decimal degrees.