libosmscout  0.1
osmscout::GeoCoord Class Referencefinal

#include <GeoCoord.h>

Public Types

using GeoCoordBuffer = std::array< std::byte, 7 >
 

Public Member Functions

GeoCoord Add (const Bearing &bearing, const Distance &distance) const
 Get coordinate of position + course and distance. More...
 
void EncodeToBuffer (GeoCoordBuffer &buffer) const
 Encode the coordinate value into a buffer - as it would be done by FileScanner/FileWriter classes. More...
 
 GeoCoord ()=default
 The default constructor creates an uninitialized instance (for performance reasons). More...
 
 GeoCoord (const GeoCoord &other)=default
 
 GeoCoord (double lat, double lon)
 Initialize the coordinate with the given latitude and longitude values. More...
 
std::string GetDisplayText () const
 Return a string representation of the coordinate value in a human readable format. More...
 
Distance GetDistance (const GeoCoord &target) const
 Get distance between two coordinates. More...
 
Id GetHash () const
 Encode the coordinate value into a number (the number has hash character). More...
 
Id GetId () const
 Returns a fast calculable unique id for the coordinate. More...
 
double GetLat () const
 Return the latitude value of the coordinate. More...
 
double GetLon () const
 Return the latitude value of the coordinate. More...
 
bool IsEqual (const GeoCoord &other) const
 Return true if both coordinates are equal (using == operator) More...
 
bool IsValid () const
 Return true if latitude is in range <-90,+90> and longitude in range <-180,+180> More...
 
bool operator!= (const GeoCoord &other) const
 Return true if coordinates are not equal. More...
 
Distance operator- (const GeoCoord &other) const
 
bool operator< (const GeoCoord &other) const
 
std::ostream & operator<< (std::ostream &stream) const
 
GeoCoordoperator= (const GeoCoord &other)=default
 Assign the value of other. More...
 
bool operator== (const GeoCoord &other) const
 Return true if both coordinates are equals (using == operator) More...
 
void Set (double lat, double lon)
 Assign a new latitude and longitude value to the coordinate. More...
 

Static Public Member Functions

static bool Parse (const std::string &text, GeoCoord &coord)
 Parse a textual representation of a geo coordinate from a string to an GeoCoord instance. More...
 

Static Public Attributes

static constexpr int MaxLatitude = 90
 
static constexpr int MaxLongitude = 180
 
static constexpr int MinLatitude = -90
 
static constexpr int MinLongitude = -180
 

Detailed Description

Anonymous geographic coordinate.

Member Typedef Documentation

◆ GeoCoordBuffer

using osmscout::GeoCoord::GeoCoordBuffer = std::array<std::byte,7>

Constructor & Destructor Documentation

◆ GeoCoord() [1/3]

osmscout::GeoCoord::GeoCoord ( )
default

The default constructor creates an uninitialized instance (for performance reasons).

◆ GeoCoord() [2/3]

osmscout::GeoCoord::GeoCoord ( const GeoCoord other)
default

◆ GeoCoord() [3/3]

osmscout::GeoCoord::GeoCoord ( double  lat,
double  lon 
)
inline

Initialize the coordinate with the given latitude and longitude values.

Member Function Documentation

◆ Add()

GeoCoord osmscout::GeoCoord::Add ( const Bearing bearing,
const Distance distance 
) const

Get coordinate of position + course and distance.

Parameters
bearingTarget course in degree
distanceTarget distance
Returns
Target coordinates
Note
The difference in height between the two points is neglected.

References osmscout::Distance::AsMeter(), and osmscout::GetEllipsoidalDistance().

◆ EncodeToBuffer()

void osmscout::GeoCoord::EncodeToBuffer ( GeoCoordBuffer buffer) const
inline

Encode the coordinate value into a buffer - as it would be done by FileScanner/FileWriter classes.

The coord will be encoded with the maximum resolution (of the library), Coords with the same buffer value thus will in effect equal.

References osmscout::latConversionFactor, and osmscout::lonConversionFactor.

◆ GetDisplayText()

std::string osmscout::GeoCoord::GetDisplayText ( ) const

Return a string representation of the coordinate value in a human readable format.

References GetLat(), and GetLon().

Referenced by osmscout::GeoBox::GetDisplayText(), osmscout::SRTM::GetHeightAtLocation(), osmscout::LocationInfoModel::onLocationDescription(), and osmscout::LocationListModel::setPattern().

◆ GetDistance()

Distance osmscout::GeoCoord::GetDistance ( const GeoCoord target) const

Get distance between two coordinates.

Parameters
targetTarget coordinate to measure distance
Returns
Point to point distance to target coordinates
Note
The difference in height between the two points is neglected.

References osmscout::GetEllipsoidalDistance().

◆ GetHash()

Id osmscout::GeoCoord::GetHash ( ) const
inline

Encode the coordinate value into a number (the number has hash character).

References osmscout::latConversionFactor, and osmscout::lonConversionFactor.

◆ GetId()

Id osmscout::GeoCoord::GetId ( ) const

Returns a fast calculable unique id for the coordinate.

Coordinates with have the same latitude and longitude value in the supported resolution wil have the same id.

The id does not have any semantics regarding sorting. Coordinates with close ids do not need to be close in location.

References osmscout::latConversionFactor, and osmscout::lonConversionFactor.

◆ GetLat()

double osmscout::GeoCoord::GetLat ( ) const
inline

Return the latitude value of the coordinate.

Referenced by osmscout::AreaSorter(), osmscout::GeoBox::BoxByCenterAndRadius(), osmscout::CalculateDistancePointToLineSegment(), osmscout::MapObjectInfoModel::data(), osmscout::NearPOIModel::data(), osmscout::LocationListModel::data(), osmscout::LocationDescriptionService::DescribeLocationByWay(), osmscout::DistanceToSegment(), osmscout::MapPainter::DrawHillShading(), osmscout::FindPathIntersections(), osmscout::Projection::BatchTransformer::GeoToPixel(), osmscout::TileProjection::GeoToPixel(), osmscout::MercatorProjection::GeoToPixel(), osmscout::GeoBox::GetBottomRight(), osmscout::GeoBox::GetCenter(), osmscout::SimpleRoutingService::GetClosestRoutableNode(), GetDisplayText(), osmscout::GetEllipsoidalDistance(), osmscout::GeoBox::GetHeight(), osmscout::SRTM::GetHeightAtLocation(), osmscout::SRTM::GetHeightInBoundingBox(), osmscout::Point::GetId(), osmscout::Point::GetLat(), osmscout::LocationEntry::getLat(), osmscout::RouteStep::getLat(), osmscout::GeoBox::GetMaxLat(), osmscout::GeoBox::GetMinLat(), osmscout::OSMTileId::GetOSMTile(), osmscout::getSegDistSq(), osmscout::GetSphericalBearingFinal(), osmscout::GetSphericalBearingInitial(), osmscout::GetSphericalDistance(), osmscout::GetSunriseSunset(), osmscout::CoverageIndex::GetTile(), osmscout::TileId::GetTile(), osmscout::GeoBox::GetTopLeft(), osmscout::MapWidget::hoverMoveEvent(), osmscout::GeoBox::Include(), osmscout::GeoBox::Includes(), osmscout::GeoBox::Intersects(), osmscout::MercatorProjection::IsValidFor(), osmscout::TileProjection::IsValidFor(), osmscout::MercatorProjection::Move(), osmscout::MoveHandler::moveNow(), osmscout::MapWidget::onIconFound(), osmscout::NavigationModel::onPositionEstimate(), osmscout::NavigationModel::onRerouteRequest(), osmscout::MapPainterOpenGL::OnTranslation(), osmscout::pointToPolygonDist(), osmscout::FileScanner::Read(), osmscout::GeoBox::Set(), osmscout::MercatorProjection::Set(), osmscout::TileProjection::SetInternal(), osmscout::SunriseSunset::setLongitude(), and osmscout::FileWriter::WriteCoord().

◆ GetLon()

double osmscout::GeoCoord::GetLon ( ) const
inline

Return the latitude value of the coordinate.

Referenced by osmscout::AreaSorter(), osmscout::GeoBox::BoxByCenterAndRadius(), osmscout::CalculateDistancePointToLineSegment(), osmscout::MapObjectInfoModel::data(), osmscout::NearPOIModel::data(), osmscout::LocationListModel::data(), osmscout::LocationDescriptionService::DescribeLocationByWay(), osmscout::DistanceToSegment(), osmscout::MapPainter::DrawHillShading(), osmscout::FindPathIntersections(), osmscout::Projection::BatchTransformer::GeoToPixel(), osmscout::TileProjection::GeoToPixel(), osmscout::MercatorProjection::GeoToPixel(), osmscout::GeoBox::GetBottomRight(), osmscout::GeoBox::GetCenter(), osmscout::SimpleRoutingService::GetClosestRoutableNode(), GetDisplayText(), osmscout::GetEllipsoidalDistance(), osmscout::SRTM::GetHeightAtLocation(), osmscout::SRTM::GetHeightInBoundingBox(), osmscout::Point::GetId(), osmscout::Point::GetLon(), osmscout::LocationEntry::getLon(), osmscout::RouteStep::getLon(), osmscout::GeoBox::GetMaxLon(), osmscout::GeoBox::GetMinLon(), osmscout::OSMTileId::GetOSMTile(), osmscout::getSegDistSq(), osmscout::GetSphericalBearingFinal(), osmscout::GetSphericalBearingInitial(), osmscout::GetSphericalDistance(), osmscout::GetSunriseSunset(), osmscout::CoverageIndex::GetTile(), osmscout::TileId::GetTile(), osmscout::GeoBox::GetTopLeft(), osmscout::GeoBox::GetWidth(), osmscout::MapWidget::hoverMoveEvent(), osmscout::GeoBox::Include(), osmscout::GeoBox::Includes(), osmscout::GeoBox::Intersects(), osmscout::MercatorProjection::IsValidFor(), osmscout::TileProjection::IsValidFor(), osmscout::MercatorProjection::Move(), osmscout::MoveHandler::moveNow(), osmscout::MapWidget::onIconFound(), osmscout::NavigationModel::onPositionEstimate(), osmscout::NavigationModel::onRerouteRequest(), osmscout::MapPainterOpenGL::OnTranslation(), osmscout::MercatorProjection::PixelToGeo(), osmscout::pointToPolygonDist(), osmscout::FileScanner::Read(), osmscout::GeoBox::Set(), osmscout::SunriseSunset::setLatitude(), and osmscout::FileWriter::WriteCoord().

◆ IsEqual()

bool osmscout::GeoCoord::IsEqual ( const GeoCoord other) const
inline

Return true if both coordinates are equal (using == operator)

◆ IsValid()

bool osmscout::GeoCoord::IsValid ( ) const
inline

Return true if latitude is in range <-90,+90> and longitude in range <-180,+180>

Referenced by Parse().

◆ operator!=()

bool osmscout::GeoCoord::operator!= ( const GeoCoord other) const
inline

Return true if coordinates are not equal.

◆ operator-()

Distance osmscout::GeoCoord::operator- ( const GeoCoord other) const
inline

◆ operator<()

bool osmscout::GeoCoord::operator< ( const GeoCoord other) const
inline

◆ operator<<()

std::ostream& osmscout::GeoCoord::operator<< ( std::ostream &  stream) const
inline

◆ operator=()

GeoCoord& osmscout::GeoCoord::operator= ( const GeoCoord other)
default

Assign the value of other.

◆ operator==()

bool osmscout::GeoCoord::operator== ( const GeoCoord other) const
inline

Return true if both coordinates are equals (using == operator)

◆ Parse()

bool osmscout::GeoCoord::Parse ( const std::string &  text,
GeoCoord coord 
)
static

Parse a textual representation of a geo coordinate from a string to an GeoCoord instance.

The text should follow the following expression:

[+|-|N|S] <coordinate> [N|S] [+|-|W|E] <coordinate> [W|E]

coordinate may have one of these formats: DDD[.DDDDD] DD°[D[.DDD]'[D[.DDD]"]] DD°[D[.DDD]

The means:

  • You first define the latitude, then the longitude value
  • You can define with half you mean by either prefixing or postfixing the actual number with a hint
  • The hint can either be a sign ('-' or '+') or a direction ('N' and 'S' for latitude, 'E' or 'W' for longitude).

Possibly in future more variants will be supported. It is guaranteed that the result of GetDisplayText() is successfully parsed.

Parameters
textText containing the textual representation
coordThe resulting coordinate, if the text was correctly parsed
Returns
true, if the text was correctly parsed, else false

References osmscout::EatWhitespace(), IsValid(), osmscout::ScanCoordinate(), and Set().

Referenced by osmscout::LocationListModel::setPattern().

◆ Set()

Member Data Documentation

◆ MaxLatitude

constexpr int osmscout::GeoCoord::MaxLatitude = 90
staticconstexpr

◆ MaxLongitude

constexpr int osmscout::GeoCoord::MaxLongitude = 180
staticconstexpr

◆ MinLatitude

constexpr int osmscout::GeoCoord::MinLatitude = -90
staticconstexpr

◆ MinLongitude

constexpr int osmscout::GeoCoord::MinLongitude = -180
staticconstexpr

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