xapian-core
1.4.27
|
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... | |
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.
|
inline |
Construct an uninitialised coordinate.
Definition at line 102 of file geospatial.h.
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.
InvalidArgumentError | the supplied latitude is out of range. |
Definition at line 36 of file latlongcoord.cc.
References longitude.
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().
|
inline |
Compare with another LatLongCoord.
This is mostly provided so that things like std::map<LatLongCoord> work
Definition at line 150 of file geospatial.h.
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().
void LatLongCoord::unserialise | ( | const std::string & | serialised | ) |
Unserialise a string and set this object to its coordinate.
serialised | the string to unserialise the coordinate from. |
Xapian::SerialisationError | if 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()().
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.
ptr | A pointer to the start of the string. This will be updated to point to the end of the data representing the coordinate. |
end | A pointer to the end of the string. |
Xapian::SerialisationError | if 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.
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().
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().