24 #ifndef XAPIAN_INCLUDED_GEOSPATIAL_H
25 #define XAPIAN_INCLUDED_GEOSPATIAL_H
27 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
28 # error Never use <xapian/geospatial.h> directly; include <xapian.h> instead.
56 return 1609.344 * miles;
69 return metres * (1.0 / 1609.344);
126 void unserialise(
const std::string & serialised);
139 void unserialise(
const char ** ptr,
const char * end);
143 std::string serialise()
const;
152 if (latitude < other.
latitude)
return true;
153 if (latitude > other.
latitude)
return false;
158 std::string get_description()
const;
170 std::vector<LatLongCoord>::const_iterator
iter;
201 return iter == other.
iter;
250 return coords.size();
256 return coords.empty();
262 coords.push_back(coord);
271 coords.push_back(coord);
282 void unserialise(
const std::string & serialised);
286 std::string serialise()
const;
289 std::string get_description()
const;
339 return (*
this)(a, b.data(), b.
size());
358 const char * b_ptr,
size_t b_len)
const;
373 virtual std::string
name()
const = 0;
427 std::string
name()
const;
428 std::string serialise()
const;
429 LatLongMetric * unserialise(
const std::string & serialised)
const;
475 void calc_distance();
499 double max_range_ = 0.0,
516 double max_range_ = 0.0,
521 void next(
double min_wt);
525 double get_weight()
const;
527 std::string
name()
const;
528 std::string serialise()
const;
530 unserialise_with_registry(
const std::string &serialised,
534 std::string get_description()
const;
580 metric(metric_.clone()),
599 metric(metric_.clone()),
635 metric(metric_.clone()),
655 metric(metric_.clone()),
Compiler attribute macros.
#define XAPIAN_CONST_FUNCTION
A function which does not examine any values except its arguments and has no effects except its retur...
This class is used to access a database, or a group of databases.
A handle representing a document in a Xapian database.
Calculate the great-circle distance between two coordinates on a sphere.
double radius
The radius of the sphere in metres.
Virtual base class for key making functors.
An iterator across the values in a LatLongCoords object.
bool operator==(const LatLongCoordsIterator &other) const
Equality test for LatLongCoordsIterator objects.
const LatLongCoord & operator*() const
Get the LatLongCoord for the current position.
std::vector< LatLongCoord >::const_iterator iter
The current position of the iterator.
std::input_iterator_tag iterator_category
DerefWrapper_< LatLongCoord > operator++(int)
Advance the iterator to the next position (postfix version).
LatLongCoordsIterator()
Default constructor. Produces an uninitialised iterator.
LatLongCoordsIterator & operator++()
Advance the iterator to the next position.
LatLongCoordsIterator(std::vector< LatLongCoord >::const_iterator iter_)
Constructor used by LatLongCoords.
A sequence of latitude-longitude coordinates.
LatLongCoords(const LatLongCoord &coord)
Construct a container holding one coordinate.
LatLongCoords()
Construct an empty container.
size_t size() const
Get the number of coordinates in the container.
LatLongCoordsIterator begin() const
Get a begin iterator for the coordinates.
void append(const LatLongCoord &coord)
Append a coordinate to the end of the sequence.
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.
std::vector< LatLongCoord > coords
The coordinates.
KeyMaker subclass which sorts by distance from a latitude/longitude.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoords ¢re_, const LatLongMetric &metric_, double defdistance)
Construct a LatLongDistanceKeyMaker.
LatLongCoords centre
The centre point (or points) for distance calculation.
std::string defkey
The default key to return, for documents with no value stored.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoords ¢re_)
Construct a LatLongDistanceKeyMaker.
Xapian::valueno slot
The value slot to read.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoord ¢re_, const LatLongMetric &metric_, double defdistance)
Construct a LatLongDistanceKeyMaker.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoords ¢re_, const LatLongMetric &metric_)
Construct a LatLongDistanceKeyMaker.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoord ¢re_)
Construct a LatLongDistanceKeyMaker.
const LatLongMetric * metric
The metric to use when calculating distances.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoord ¢re_, const LatLongMetric &metric_)
Construct a LatLongDistanceKeyMaker.
Posting source which returns a weight based on geospatial distance.
double k1
Constant used in weighting function.
double k2
Constant used in weighting function.
double dist
Current distance from centre.
double max_range
Maximum range to allow. If set to 0, there is no maximum range.
LatLongCoords centre
Centre, to compute distance from.
const LatLongMetric * metric
Metric to compute the distance with.
Base class for calculating distances between two lat/long coordinates.
virtual double pointwise_distance(const LatLongCoord &a, const LatLongCoord &b) const =0
Return the distance between two coordinates, in metres.
virtual LatLongMetric * unserialise(const std::string &serialised) const =0
Create object given string serialisation returned by serialise().
virtual std::string serialise() const =0
Serialise object parameters into a string.
double operator()(const LatLongCoords &a, const std::string &b) const
Return the distance between two coordinate lists, in metres.
virtual LatLongMetric * clone() const =0
Clone the metric.
virtual std::string name() const =0
Return the full name of the metric.
Registry for user subclasses.
A posting source which generates weights from a value slot.
Class for wrapping type returned by an input_iterator.
Build key strings for MSet ordering or collapsing.
The Xapian namespace contains public interfaces for the Xapian library.
std::string sortable_serialise(double value)
Convert a floating point number to a string, preserving sort order.
unsigned valueno
The number for a value slot in a document.
double metres_to_miles(double metres)
Convert from metres to miles.
double miles_to_metres(double miles)
Convert from miles to metres.
bool operator!=(const ESetIterator &a, const ESetIterator &b)
Inequality test for ESetIterator objects.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
External sources of posting information.
parsing a user query string to build a Xapian::Query object
A latitude-longitude coordinate.
LatLongCoord()
Construct an uninitialised coordinate.
double latitude
A latitude, as decimal degrees.
double longitude
A longitude, as decimal degrees.
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT