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;
310 virtual double pointwise_distance(
const LatLongCoord & a,
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;
380 virtual std::string serialise()
const = 0;
386 virtual LatLongMetric * unserialise(
const std::string & serialised)
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()),
The Xapian namespace contains public interfaces for the Xapian library.
double radius
The radius of the sphere in metres.
This class is used to access a database, or a group of databases.
bool empty() const
Return true if and only if there are no coordinates in the container.
LatLongCoords centre
Centre, to compute distance from.
LatLongCoords(const LatLongCoord &coord)
Construct a container holding one coordinate.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoords ¢re_, const LatLongMetric &metric_)
Construct a LatLongDistanceKeyMaker.
Compiler attribute macros.
std::vector< LatLongCoord > coords
The coordinates.
External sources of posting information.
bool operator!=(const ESetIterator &a, const ESetIterator &b)
Inequality test for ESetIterator objects.
double dist
Current distance from centre.
std::string sortable_serialise(double value)
Convert a floating point number to a string, preserving sort order.
DerefWrapper_< LatLongCoord > operator++(int)
Advance the iterator to the next position (postfix version).
Xapian::valueno slot
The value slot to read.
double miles_to_metres(double miles)
Convert from miles to metres.
#define XAPIAN_VISIBILITY_DEFAULT
std::vector< LatLongCoord >::const_iterator iter
The current position of the iterator.
Build key strings for MSet ordering or collapsing.
LatLongCoords centre
The centre point (or points) for distance calculation.
Posting source which returns a weight based on geospatial distance.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoord ¢re_)
Construct a LatLongDistanceKeyMaker.
LatLongCoordsIterator(std::vector< LatLongCoord >::const_iterator iter_)
Constructor used by LatLongCoords.
double max_range
Maximum range to allow. If set to 0, there is no maximum range.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoord ¢re_, const LatLongMetric &metric_)
Construct a LatLongDistanceKeyMaker.
LatLongCoordsIterator begin() const
Get a begin iterator for the coordinates.
A latitude-longitude coordinate.
#define XAPIAN_CONST_FUNCTION
A function which does not examine any values except its arguments and has no effects except its retur...
LatLongCoord()
Construct an uninitialised coordinate.
double metres_to_miles(double metres)
Convert from metres to miles.
LatLongCoords()
Construct an empty container.
std::string defkey
The default key to return, for documents with no value stored.
Define XAPIAN_VISIBILITY_* macros.
Registry for user subclasses.
std::input_iterator_tag iterator_category
double latitude
A latitude, as decimal degrees.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoords ¢re_)
Construct a LatLongDistanceKeyMaker.
Base class for calculating distances between two lat/long coordinates.
double operator()(const LatLongCoords &a, const std::string &b) const
Return the distance between two coordinate lists, in metres.
const LatLongMetric * metric
Metric to compute the distance with.
double k1
Constant used in weighting function.
A sequence of latitude-longitude coordinates.
A posting source which generates weights from a value slot.
KeyMaker subclass which sorts by distance from a latitude/longitude.
void append(const LatLongCoord &coord)
Append a coordinate to the end of the sequence.
const LatLongMetric * metric
The metric to use when calculating distances.
An iterator across the values in a LatLongCoords object.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoords ¢re_, const LatLongMetric &metric_, double defdistance)
Construct a LatLongDistanceKeyMaker.
unsigned valueno
The number for a value slot in a document.
double k2
Constant used in weighting function.
LatLongCoordsIterator()
Default constructor. Produces an uninitialised iterator.
LatLongCoordsIterator end() const
Get an end iterator for the coordinates.
Class for wrapping type returned by an input_iterator.
LatLongDistanceKeyMaker(Xapian::valueno slot_, const LatLongCoord ¢re_, const LatLongMetric &metric_, double defdistance)
Construct a LatLongDistanceKeyMaker.
const LatLongCoord & operator*() const
Get the LatLongCoord for the current position.
Calculate the great-circle distance between two coordinates on a sphere.
LatLongCoordsIterator & operator++()
Advance the iterator to the next position.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
bool operator==(const LatLongCoordsIterator &other) const
Equality test for LatLongCoordsIterator objects.
A handle representing a document in a Xapian database.
Virtual base class for key making functors.
size_t size() const
Get the number of coordinates in the container.
double longitude
A longitude, as decimal degrees.
parsing a user query string to build a Xapian::Query object