xapian-core  1.4.26
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.
 
 LatLongCoord (double latitude_, double longitude_)
 Construct a coordinate.
 
void unserialise (const std::string &serialised)
 Unserialise a string and set this object to its coordinate.
 
void unserialise (const char **ptr, const char *end)
 Unserialise a buffer and set this object to its coordinate.
 
std::string serialise () const
 Return a serialised representation of the coordinate.
 
bool operator< (const LatLongCoord &other) const
 Compare with another LatLongCoord.
 
std::string get_description () const
 Return a string describing this object.
 

Public Attributes

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

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.

Constructor & Destructor Documentation

◆ LatLongCoord()

Xapian::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.

Member Function Documentation

◆ 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.

References latitude, and longitude.

◆ unserialise() [1/2]

void Xapian::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.

◆ unserialise() [2/2]

void Xapian::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.

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.

Referenced by operator<().

◆ 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.

Referenced by operator<().


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