68 double coorddist = metric(coord1, coord2);
278 TEST((c1 < c2) ^ (c2 < c1));
280 TEST(!(c2 < c3) && !(c3 < c2));
284 TEST((c3 < c4) ^ (c4 < c3));
290 TEST(!(c1 < c4 || c4 < c1));
291 const char * ptr = s1.data();
292 const char * end = ptr + s1.size();
343 double d1 = m1(c1, c2);
350 double d2 = m2(c1, c2);
361 double d3 = (*m3)(c1, c2);
383 double d1 = m1(c1, c2);
384 double dl1 = m1(cl1, cl2);
386 double d1_str = m1(cl1, c2_str);
410 std::string k1 = keymaker(doc1);
411 std::string k2 = keymaker(doc2);
412 std::string k3 = keymaker(doc3);
413 std::string k4 = keymaker(doc4);
419 std::string k3b = keymaker2(doc3);
420 std::string k4b = keymaker2(doc4);
DEFINE_TESTCASE(latlongpostingsource1, backend &&!remote &&!inmemory)
Test behaviour of the LatLongDistancePostingSource.
static void builddb_coords1(Xapian::WritableDatabase &db, const string &)
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
This class is used to access a database, or a group of databases.
A handle representing a document in a Xapian database.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
Calculate the great-circle distance between two coordinates on a sphere.
std::string serialise() const
Serialise object parameters into a string.
std::string name() const
Return the full name of the metric.
An iterator across the values in a LatLongCoords object.
A sequence of latitude-longitude coordinates.
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.
std::string serialise() const
Return a serialised form of the coordinate list.
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::string get_description() const
Return a string describing this object.
KeyMaker subclass which sorts by distance from a latitude/longitude.
Posting source which returns a weight based on geospatial distance.
void init(const Database &db_)
Set this PostingSource to the start of the list of postings.
void next(double min_wt)
Advance the current position to the next matching document.
double get_weight() const
Return the weight contribution for the current document.
Base class for calculating distances between two lat/long coordinates.
virtual LatLongMetric * unserialise(const std::string &serialised) const =0
Create object given string serialisation returned by serialise().
Registry for user subclasses.
const Xapian::LatLongMetric * get_lat_long_metric(const std::string &name) const
Get a lat-long metric given a name.
bool at_end() const
Return true if the current position is past the last entry in this list.
Xapian::docid get_docid() const
Return the current docid.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
The Xapian namespace contains public interfaces for the Xapian library.
A latitude-longitude coordinate.
void unserialise(const std::string &serialised)
Unserialise a string and set this object to its coordinate.
std::string get_description() const
Return a string describing this object.
double latitude
A latitude, as decimal degrees.
double longitude
A longitude, as decimal degrees.
std::string serialise() const
Return a serialised representation of the coordinate.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
a generic test suite engine
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
#define TEST(a)
Test a condition, without an additional explanation for failure.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
Xapian-specific test helper functions and macros.
Public interfaces for the Xapian library.