xapian-core  1.4.25
Public Member Functions | Public Attributes | List of all members
Xapian::LatLongCoord Struct Reference

A latitude-longitude coordinate. More...

#include <geospatial.h>

Public Member Functions

 LatLongCoord ()
 Construct an uninitialised coordinate. More...
 
 LatLongCoord (double latitude_, double longitude_)
 Construct a coordinate. More...
 
void unserialise (const std::string &serialised)
 Unserialise a string and set this object to its coordinate. More...
 
void unserialise (const char **ptr, const char *end)
 Unserialise a buffer and set this object to its coordinate. More...
 
std::string serialise () const
 Return a serialised representation of the coordinate. More...
 
bool operator< (const LatLongCoord &other) const
 Compare with another LatLongCoord. More...
 
std::string get_description () const
 Return a string describing this object. More...
 

Public Attributes

double latitude
 A latitude, as decimal degrees. More...
 
double longitude
 A longitude, as decimal degrees. More...
 

Detailed Description

A latitude-longitude coordinate.

Experimental - see https://xapian.org/docs/deprecation#experimental-features

Note that latitude-longitude coordinates are only precisely meaningful if the datum used to define them is specified. This class ignores this issue - it is up to the caller to ensure that the datum used for each coordinate in a system is consistent.

Definition at line 81 of file geospatial.h.

Constructor & Destructor Documentation

◆ LatLongCoord() [1/2]

Xapian::LatLongCoord::LatLongCoord ( )
inline

Construct an uninitialised coordinate.

Definition at line 102 of file geospatial.h.

◆ LatLongCoord() [2/2]

LatLongCoord::LatLongCoord ( double  latitude_,
double  longitude_ 
)

Construct a coordinate.

If the supplied longitude is out of the standard range, it will be normalised to the range 0 <= longitude < 360.

If you want to avoid the checks (for example, you know that your values are already in range), you can use the alternate constructor to construct an uninitialised coordinate, and then set the latitude and longitude directly.

Exceptions
InvalidArgumentErrorthe supplied latitude is out of range.

Definition at line 36 of file latlongcoord.cc.

References longitude.

Member Function Documentation

◆ get_description()

string LatLongCoord::get_description ( ) const

Return a string describing this object.

Definition at line 83 of file latlongcoord.cc.

References latitude, longitude, and Xapian::Internal::str().

Referenced by DEFINE_TESTCASE().

◆ operator<()

bool Xapian::LatLongCoord::operator< ( const LatLongCoord other) const
inline

Compare with another LatLongCoord.

This is mostly provided so that things like std::map<LatLongCoord> work

  • the ordering isn't particularly meaningful.

Definition at line 150 of file geospatial.h.

References latitude, and longitude.

◆ serialise()

string LatLongCoord::serialise ( ) const

Return a serialised representation of the coordinate.

Definition at line 75 of file latlongcoord.cc.

References GeoEncode::encode(), latitude, and longitude.

Referenced by builddb_coords1(), and DEFINE_TESTCASE().

◆ unserialise() [1/2]

void LatLongCoord::unserialise ( const std::string &  serialised)

Unserialise a string and set this object to its coordinate.

Parameters
serialisedthe string to unserialise the coordinate from.
Exceptions
Xapian::SerialisationErrorif the string does not contain a valid serialised latitude-longitude pair, or contains extra data at the end of it.

Definition at line 47 of file latlongcoord.cc.

Referenced by DEFINE_TESTCASE(), and Xapian::LatLongMetric::operator()().

◆ unserialise() [2/2]

void LatLongCoord::unserialise ( const char **  ptr,
const char *  end 
)

Unserialise a buffer and set this object to its coordinate.

The buffer may contain further data after that for the coordinate.

Parameters
ptrA pointer to the start of the string. This will be updated to point to the end of the data representing the coordinate.
endA pointer to the end of the string.
Exceptions
Xapian::SerialisationErrorif the string does not start with a valid serialised latitude-longitude pair.

Definition at line 58 of file latlongcoord.cc.

References GeoEncode::decode(), latitude, and longitude.

Member Data Documentation

◆ latitude

double Xapian::LatLongCoord::latitude

A latitude, as decimal degrees.

Should be in the range -90 <= latitude <= 90

Positive latitudes represent the northern hemisphere.

Definition at line 88 of file geospatial.h.

Referenced by DEFINE_TESTCASE(), get_description(), operator<(), Xapian::GreatCircleMetric::pointwise_distance(), serialise(), and unserialise().

◆ longitude

double Xapian::LatLongCoord::longitude

A longitude, as decimal degrees.

Will be wrapped around, so for example, -150 is equal to 210. When obtained from a serialised form, will be in the range 0 <= longitude < 360.

Longitudes increase as coordinates move eastwards.

Definition at line 98 of file geospatial.h.

Referenced by DEFINE_TESTCASE(), get_description(), LatLongCoord(), operator<(), Xapian::GreatCircleMetric::pointwise_distance(), serialise(), and unserialise().


The documentation for this struct was generated from the following files: