xapian-core  1.4.21
Classes | Functions
GeoEncode Namespace Reference

Classes

class  DecoderWithBoundingBox
 A class for decoding coordinates within a bounding box. More...
 

Functions

bool encode (double lat, double lon, std::string &result)
 Encode a coordinate and append it to a string. More...
 
void decode (const char *value, size_t len, double &lat_ref, double &lon_ref)
 Decode a coordinate from a buffer. More...
 
static void decode (const std::string &value, double &lat_ref, double &lon_ref)
 Decode a coordinate from a string. More...
 

Function Documentation

◆ decode() [1/2]

void GeoEncode::decode ( const char *  value,
size_t  len,
double &  lat_ref,
double &  lon_ref 
)

Decode a coordinate from a buffer.

Parameters
valueA pointer to the start of the buffer to decode.
lenThe length of the buffer in bytes. The buffer must be at least 2 bytes long (this constraint is not checked).
lat_refA reference to a value to return the latitude in.
lon_refA reference to a value to return the longitude in.
Returns
The decoded coordinate.

No errors will be returned; any junk at the end of the value (ie, after the first 6 bytes) will be ignored, and it is possible for invalid inputs to result in out-of-range longitudes.

Definition at line 135 of file geoencode.cc.

Referenced by decode(), GeoEncode::DecoderWithBoundingBox::decode(), and Xapian::LatLongCoord::unserialise().

◆ decode() [2/2]

static void GeoEncode::decode ( const std::string &  value,
double &  lat_ref,
double &  lon_ref 
)
inlinestatic

Decode a coordinate from a string.

Parameters
valueThe string to decode. This must be at least 2 bytes long (this constraint is not checked).
lat_refA reference to a value to return the latitude in.
lon_refA reference to a value to return the longitude in.
Returns
The decoded coordinate.

No errors will be returned; any junk at the end of the value (ie, after the first 6 bytes) will be ignored, and it is possible for invalid inputs to result in out-of-range longitudes.

Definition at line 80 of file geoencode.h.

References decode().

◆ encode()

bool GeoEncode::encode ( double  lat,
double  lon,
std::string &  result 
)

Encode a coordinate and append it to a string.

Parameters
latThe latitude coordinate in degrees (ranging from -90 to +90)
lonThe longitude coordinate in degrees (any range is valid - longitudes will be wrapped). Note that decoding will return longitudes in the range 0 <= value < 360.
resultThe string to append the result to.
Returns
true if the encoding was successful, false if there was an error. If there was an error, the result value will be unmodified. The only cause of error is out-of-range latitudes. If there was no error, the string will have been extended by 6 bytes.

Definition at line 73 of file geoencode.cc.

References DegreesMinutesSeconds::degrees, DegreesMinutesSeconds::minutes, rare, DegreesMinutesSeconds::sec16ths, and DegreesMinutesSeconds::seconds.

Referenced by Xapian::BitWriter::encode_interpolative(), Xapian::LatLongCoord::serialise(), and Xapian::LatLongCoords::serialise().