67 double coorddist = metric(coord1, coord2);
277 TEST((c1 < c2) ^ (c2 < c1));
279 TEST(!(c2 < c3) && !(c3 < c2));
283 TEST((c3 < c4) ^ (c4 < c3));
289 TEST(!(c1 < c4 || c4 < c1));
290 const char * ptr = s1.data();
291 const char * end = ptr + s1.size();
342 double d1 = m1(c1, c2);
349 double d2 = m2(c1, c2);
360 double d3 = (*m3)(c1, c2);
382 double d1 = m1(c1, c2);
383 double dl1 = m1(cl1, cl2);
385 double d1_str = m1(cl1, c2_str);
409 std::string k1 = keymaker(doc1);
410 std::string k2 = keymaker(doc2);
411 std::string k3 = keymaker(doc3);
412 std::string k4 = keymaker(doc4);
418 std::string k3b = keymaker2(doc3);
419 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
An indexed database of documents.
Class representing a document.
void add_value(Xapian::valueno slot, std::string_view value)
Add a value to a slot in this document.
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 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.
void reset(const Database &db_, Xapian::doccount shard_index)
Set this PostingSource to the start of the list of postings.
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(std::string_view 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 &doc)
Add a document to the database.
The Xapian namespace contains public interfaces for the Xapian library.
A latitude-longitude coordinate.
std::string get_description() const
Return a string describing this object.
void unserialise(std::string_view 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.
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.