libosmscout 0.1
|
Collection of classes and methods related to low level geometric stuff. More...
Classes | |
class | osmscout::CoordBuffer |
Buffer structure for Vertex2D data. More... | |
class | osmscout::CoordBufferRange |
Hold a reference to a range of data within a CoordBuffer. More... | |
class | osmscout::GeoBox |
Anonymous geographic rectangular bounding box. More... | |
class | osmscout::GeoCoord |
Anonymous geographic coordinate. More... | |
class | osmscout::Path |
A path is defined by the way to be used and the node id of a node on this way which is the target to reach. More... | |
struct | osmscout::PathIntersection |
Information about intersection of two paths. More... | |
struct | osmscout::Pixel |
Representation of a pixel on a display or a plane. More... | |
class | osmscout::Point |
A point is a identifiable (has an id) geo-coordinate. More... | |
class | osmscout::Projection |
The Projection class is an abstract base class for multiple projection implementations. More... | |
class | osmscout::ScreenBox |
Anonymous screen rectangular bounding box. More... | |
class | osmscout::TransBuffer |
Temporary stateful buffer for holding results of transformation of polygon from geo coords to display coords. More... | |
struct | osmscout::TransPoint |
Entry in the TransBuffer structure. More... | |
class | osmscout::TransPolygon |
Class to allows transformation of geometric primitives form geo coordinate to display coordinates using the passed Projection instance. More... | |
class | osmscout::Vertex2D |
Two dimensional coordinate (floating point values, negative coordinates possible). More... | |
class | osmscout::Vertex3D |
Three dimensional coordinate (floating point values, negative coordinates possible). More... | |
Functions | |
double | osmscout::AngleDiff (double a, double b) |
compute difference of two angles | |
template<typename N > | |
bool | osmscout::AreaIsCCW (const std::vector< N > &edges) |
Returns true, if the polygon is counter clock wise (CCW) | |
template<typename N > | |
bool | osmscout::AreaIsClockwise (const std::vector< N > &edges) |
Returns true, if the closed polygon with the given nodes is oriented clockwise. | |
template<typename N > | |
bool | osmscout::AreaIsSimple (const std::vector< std::pair< N, N > > &edges, const std::vector< bool > &edgeStartsNewPoly) |
Returns true, if the handed polygons are simple (aka not complex). | |
template<typename N > | |
bool | osmscout::AreaIsSimple (std::vector< N > points) |
Returns true, if the handed polygon is simple (aka not complex). | |
template<typename N > | |
bool | osmscout::AreaIsValid (std::vector< N > &outerPoints, std::vector< std::vector< N > > &innerPoints) |
double | osmscout::DegToRad (double deg) |
double | osmscout::Det (double x1, double y1, double x2, double y2) |
Calculates the determinant of the line between the given points. | |
double | osmscout::DistanceToSegment (double px, double py, double p1x, double p1y, double p2x, double p2y, double &r, double &qx, double &qy) |
Return the distance of the point (px,py) to the segment [(p1x,p1y),(p2x,p2y)], r the abscissa on the line of (qx,qy) the orthogonal projected point from (px,py). | |
template<typename N > | |
bool | osmscout::FindIntersection (const std::vector< N > &way, size_t &i, size_t &j) |
Find next intersection on way (with itself) from node index i. | |
template<typename N > | |
void | osmscout::FindPathIntersections (const std::vector< N > &aPath, const std::vector< N > &bPath, bool aClosed, bool bClosed, std::vector< PathIntersection > &intersections, size_t aStartIndex=0, size_t bStartIndex=0) |
Find all intersections between aPath and bPath from node index aStartIndex and bStartIndex. | |
template<class InputIt > | |
void | osmscout::GetBoundingBox (const InputIt first, const InputIt last, GeoBox &boundingBox) |
Calculate the bounding box of the (non empty) range of geo coords. | |
template<typename N > | |
GeoBox | osmscout::GetBoundingBox (const std::vector< N > &nodes) |
Calculate the bounding box of the (non empty) vector of geo coords. | |
template<typename N > | |
void | osmscout::GetBoundingBox (const std::vector< N > &nodes, GeoBox &boundingBox) |
Calculate the bounding box of the (non empty) vector of geo coords. | |
GeoBox | osmscout::GetBoundingBox (const std::vector< Point > &nodes) |
Calculate the bounding box of the (non empty) vector of geo coords. | |
void | osmscout::GetBoundingBox (const std::vector< Point > &nodes, GeoBox &boundingBox) |
Calculate the bounding box of the (non empty) vector of geo coords. | |
double | osmscout::GetDistanceInLonDegrees (const Distance &d, double latitude=0) |
Distance | osmscout::GetEllipsoidalDistance (const GeoCoord &a, const GeoCoord &b) |
Calculates the ellipsoidal (WGS-84) distance between the two given points on the ellipsoid. | |
GeoCoord | osmscout::GetEllipsoidalDistance (const GeoCoord &position, const Bearing &bearing, const Distance &distance) |
Given a starting point and a bearing and a distance calculates the coordinates of the resulting point in the (WGS-84) ellipsoid. | |
Distance | osmscout::GetEllipsoidalDistance (double aLon, double aLat, double bLon, double bLat) |
Calculates the ellipsoidal (WGS-84) distance between the two given points on the ellipsoid. | |
void | osmscout::GetEllipsoidalDistance (double lat1, double lon1, const Bearing &bearing, const Distance &distance, double &lat2, double &lon2) |
Given a starting point and a bearing and a distance calculates the coordinates of the resulting point in the (WGS-84) ellipsoid. | |
template<typename N , typename I > | |
bool | osmscout::GetLineIntersection (const N &a1, const N &a2, const N &b1, const N &b2, I &intersection) |
Returns true, if the lines defined by the given coordinates intersect. | |
template<typename N > | |
bool | osmscout::GetLineIntersectionPixel (const N &a1, const N &a2, const N &b1, const N &b2, N &intersection) |
Returns true, if the lines defined by the given coordinates intersect. | |
template<typename N , typename M > | |
int | osmscout::GetRelationOfPointToArea (const N &point, const std::vector< M > &nodes) |
Gives information about the position of the point in relation to the area. | |
Bearing | osmscout::GetSphericalBearingFinal (const GeoCoord &a, const GeoCoord &b) |
Calculates the final bearing for a line from one coordinate two the other coordinate on a sphere. | |
Bearing | osmscout::GetSphericalBearingInitial (const GeoCoord &a, const GeoCoord &b) |
Calculates the initial bearing for a line from one coordinate to the other coordinate on a sphere. | |
Distance | osmscout::GetSphericalDistance (const GeoCoord &a, const GeoCoord &b) |
Calculates the spherical distance between the two given points on the sphere. | |
template<typename N , typename M > | |
bool | osmscout::IsAreaAtLeastPartlyInArea (const std::vector< N > &a, const std::vector< M > &b) |
Return true, if at least one point of area a in within area b. | |
template<typename N , typename M > | |
bool | osmscout::IsAreaAtLeastPartlyInArea (const std::vector< N > &a, const std::vector< M > &b, const GeoBox &aBox, const GeoBox &bBox) |
Return true, if at least one point of area a in within area b. | |
template<typename N , typename M > | |
bool | osmscout::IsAreaCompletelyInArea (const std::vector< N > &a, const std::vector< M > &b) |
Return true, if area a is completely in area b. | |
template<typename N , typename M > | |
bool | osmscout::IsAreaSubOfArea (const std::vector< N > &a, const std::vector< M > &b) |
Assumes that the given areas do not intersect. | |
template<typename N , typename M > | |
bool | osmscout::IsAreaSubOfAreaOrSame (const std::vector< N > &a, const std::vector< M > &b) |
Assumes that the given areas do not intersect. | |
template<typename N , typename M > | |
bool | osmscout::IsAreaSubOfAreaQuorum (const std::vector< N > &a, const std::vector< M > &b) |
Assumes that the given areas do not intersect. | |
template<typename N , typename M > | |
bool | osmscout::IsCoordInArea (const N &point, const std::vector< M > &nodes) |
Returns true, if point in area. | |
template<typename N > | |
bool | osmscout::LinesIntersect (const N &a1, const N &a2, const N &b1, const N &b2) |
Returns true, if the lines defined by the given coordinates intersect. | |
void | osmscout::Normalize (double x, double y, double &nx, double &ny) |
Normalize vector [x,y], result is set to [nx,ny]. | |
double | osmscout::NormalizeRelativeAngle (double angle) |
Normalizes the given angle (in degrees) to be in the interval [-180.0 - 180.0]. | |
double | osmscout::RadToDeg (double rad) |
void | osmscout::ScanConvertLine (int x1, int y1, int x2, int y2, std::vector< ScanCell > &cells) |
Does a scan conversion for a line between the given coordinates. | |
Collection of classes and methods related to low level geometric stuff.
|
inline |
compute difference of two angles
a | angle in radians in range - M_PI .. + M_PI |
b | angle in radians in range - M_PI .. + M_PI |
Referenced by osmscout::LabelPath::TestAngleVariance().
bool osmscout::AreaIsCCW | ( | const std::vector< N > & | edges | ) |
Returns true, if the polygon is counter clock wise (CCW)
Referenced by osmscout::AreaIsValid().
bool osmscout::AreaIsClockwise | ( | const std::vector< N > & | edges | ) |
Returns true, if the closed polygon with the given nodes is oriented clockwise.
It is assumed, that the polygon is valid. Validity is not checked.
See http://en.wikipedia.org/wiki/Curve_orientation.
Referenced by osmscout::PolygonMerger::AddPolygon().
bool osmscout::AreaIsSimple | ( | const std::vector< std::pair< N, N > > & | edges, |
const std::vector< bool > & | edgeStartsNewPoly | ||
) |
Returns true, if the handed polygons are simple (aka not complex).
This method supports passing multiple closed polygons and checks all of them.
Currently it is checked, that the line segments that make up the polygon, only meet at their end points.
References osmscout::LinesIntersect().
bool osmscout::AreaIsSimple | ( | std::vector< N > | points | ) |
Returns true, if the handed polygon is simple (aka not complex).
Currently the following checks are done:
References osmscout::LinesIntersect().
Referenced by osmscout::AreaIsValid().
bool osmscout::AreaIsValid | ( | std::vector< N > & | outerPoints, |
std::vector< std::vector< N > > & | innerPoints | ||
) |
outerPoints | |
innerPoints |
References osmscout::AreaIsCCW(), and osmscout::AreaIsSimple().
|
inline |
deg | angle in degrees |
Referenced by osmscout::GetSphericalDistance().
|
inline |
Calculates the determinant of the line between the given points.
Referenced by osmscout::CoordBuffer::GenerateParallelWay().
|
extern |
Return the distance of the point (px,py) to the segment [(p1x,p1y),(p2x,p2y)], r the abscissa on the line of (qx,qy) the orthogonal projected point from (px,py).
return the minimum distance from the point p to the line segment [p1,p2] this could be the distance from p to p1 or to p2 if q the orthogonal projection of p on the line supporting the segment is outside [p1,p2] r is the abscissa of q on the line, 0 <= r <= 1 if q is between p1 and p2.
0 <= r <= 1 if q is between p1 and p2.
Referenced by osmscout::Navigation< NodeDescriptionTmpl >::ClosestPointOnRoute(), osmscout::LocationDescriptionService::DescribeLocationByWay(), osmscout::DistanceToSegment(), osmscout::DistanceToSegment(), osmscout::DistanceToSegment(), and osmscout::SimpleRoutingService::GetClosestRoutableNode().
bool osmscout::FindIntersection | ( | const std::vector< N > & | way, |
size_t & | i, | ||
size_t & | j | ||
) |
Find next intersection on way (with itself) from node index i.
Return true if some intersection was found (way is not simple), i and j indexes are setup to start possition of intesections lines.
References osmscout::ComputeSegmentBoxes(), osmscout::LinesIntersect(), and osmscout::GeoBox::Set().
Referenced by osmscout::EnsureSimple().
void osmscout::FindPathIntersections | ( | const std::vector< N > & | aPath, |
const std::vector< N > & | bPath, | ||
bool | aClosed, | ||
bool | bClosed, | ||
std::vector< PathIntersection > & | intersections, | ||
size_t | aStartIndex = 0 , |
||
size_t | bStartIndex = 0 |
||
) |
Find all intersections between aPath and bPath from node index aStartIndex and bStartIndex.
Intersections are added to intersections vector.
References osmscout::PathIntersection::aDistanceSquare, osmscout::PathIntersection::aIndex, osmscout::PathIntersection::bDistanceSquare, osmscout::PathIntersection::bIndex, osmscout::ComputeSegmentBoxes(), osmscout::DistanceSquare(), osmscout::GeoCoord::GetLat(), osmscout::GetLineIntersection(), osmscout::GeoCoord::GetLon(), osmscout::GetSegmentBoundingBox(), osmscout::GeoBox::Intersects(), osmscout::PathIntersection::orientation, osmscout::PathIntersection::point, and osmscout::GeoBox::Set().
void osmscout::GetBoundingBox | ( | const InputIt | first, |
const InputIt | last, | ||
GeoBox & | boundingBox | ||
) |
Calculate the bounding box of the (non empty) range of geo coords.
[first,last) | range of geo coords |
resulting | bounding box |
References osmscout::GeoBox::Set().
Referenced by osmscout::OverlayObject::boundingBoxInternal(), osmscout::Area::Ring::GetBoundingBox(), osmscout::Way::GetBoundingBox(), osmscout::Area::Intersects(), osmscout::Way::Intersects(), osmscout::IsAreaAtLeastPartlyInArea(), osmscout::PolygonCenter(), and osmscout::FileScanner::Read().
GeoBox osmscout::GetBoundingBox | ( | const std::vector< N > & | nodes | ) |
Calculate the bounding box of the (non empty) vector of geo coords.
nodes | The geo coordinates |
References osmscout::GeoBox::Include().
void osmscout::GetBoundingBox | ( | const std::vector< N > & | nodes, |
GeoBox & | boundingBox | ||
) |
Calculate the bounding box of the (non empty) vector of geo coords.
nodes | The geo coordinates |
bounding | box to fill |
References osmscout::GeoBox::Include(), and osmscout::GeoBox::Invalidate().
Calculate the bounding box of the (non empty) vector of geo coords.
nodes | The geo coordinates |
References osmscout::GeoBox::Include().
Calculate the bounding box of the (non empty) vector of geo coords.
nodes | The geo coordinates |
bounding | box to fill |
References osmscout::GeoBox::Include(), and osmscout::GeoBox::Invalidate().
|
extern |
d | distance |
latitude | where degrees are computed. Function is not defined on poles (+90, -90), it may leads to division by zero error. |
References osmscout::Distance::AsMeter().
Calculates the ellipsoidal (WGS-84) distance between the two given points on the ellipsoid.
References osmscout::GetEllipsoidalDistance(), osmscout::GeoCoord::GetLat(), and osmscout::GeoCoord::GetLon().
|
extern |
Given a starting point and a bearing and a distance calculates the coordinates of the resulting point in the (WGS-84) ellipsoid.
References bearing, osmscout::GetEllipsoidalDistance(), osmscout::GeoCoord::GetLat(), and osmscout::GeoCoord::GetLon().
|
extern |
Calculates the ellipsoidal (WGS-84) distance between the two given points on the ellipsoid.
Calculating Vincenty's inverse for getting the ellipsoidal distance of two points on earth.
References lambda, and osmscout::sincos().
Referenced by osmscout::GeoCoord::Add(), osmscout::GeoBox::BoxByCenterAndRadius(), osmscout::LocationDescriptionService::DescribeLocationByCrossing(), osmscout::LocationInfoModel::distance(), osmscout::ElevationService< DataLoader >::ElevationProfile(), osmscout::RouteDescriptionBuilder::GenerateNextRouteInstruction(), osmscout::SimpleRoutingService::GetClosestRoutableNode(), osmscout::GeoCoord::GetDistance(), osmscout::GetEllipsoidalDistance(), osmscout::GetEllipsoidalDistance(), osmscout::Database::LoadAreasInArea(), osmscout::Database::LoadAreasInRadius(), osmscout::Database::LoadNodesInArea(), osmscout::Database::LoadNodesInRadius(), osmscout::Database::LoadWaysInArea(), osmscout::Database::LoadWaysInRadius(), osmscout::PositionAgent::Process(), osmscout::RouteStateAgent::Process(), osmscout::SpeedAgent::Process(), osmscout::VoiceInstructionAgent::Process(), osmscout::RoutePostprocessor::DistanceAndTimePostprocessor::Process(), osmscout::MapWidget::recenter(), and osmscout::MapWidget::showLocation().
|
extern |
Given a starting point and a bearing and a distance calculates the coordinates of the resulting point in the (WGS-84) ellipsoid.
References osmscout::Distance::As(), osmscout::Bearing::AsRadians(), bearing, and lambda.
bool osmscout::GetLineIntersection | ( | const N & | a1, |
const N & | a2, | ||
const N & | b1, | ||
const N & | b2, | ||
I & | intersection | ||
) |
Returns true, if the lines defined by the given coordinates intersect.
Returns the intersection.
References osmscout::GeoBox::Includes().
Referenced by osmscout::ElevationService< DataLoader >::ElevationProfile(), osmscout::FindPathIntersections(), and osmscout::GetGridPoints().
bool osmscout::GetLineIntersectionPixel | ( | const N & | a1, |
const N & | a2, | ||
const N & | b1, | ||
const N & | b2, | ||
N & | intersection | ||
) |
Returns true, if the lines defined by the given coordinates intersect.
Returns the intersection.
|
inline |
Gives information about the position of the point in relation to the area.
If -1 returned, the point is outside the area, if 0, the point is on the area boundary, 1 the point is within the area.
Referenced by osmscout::IsAreaAtLeastPartlyInArea(), osmscout::IsAreaCompletelyInArea(), osmscout::IsAreaSubOfArea(), osmscout::IsAreaSubOfAreaOrSame(), and osmscout::IsAreaSubOfAreaQuorum().
Calculates the final bearing for a line from one coordinate two the other coordinate on a sphere.
Taken the path from A to B over a sphere return the bearing at the destination point B.
References bearing, osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::Bearing::Radians(), and osmscout::sincos().
Referenced by osmscout::RoutePostprocessor::DirectionPostprocessor::Process().
Calculates the initial bearing for a line from one coordinate to the other coordinate on a sphere.
References bearing, osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::Bearing::Radians(), and osmscout::sincos().
Referenced by osmscout::LocationInfoModel::bearing(), osmscout::NearPOIModel::data(), osmscout::LocationListModel::data(), osmscout::LocationDescriptionService::DescribeLocationByCrossing(), osmscout::BearingAgent::Process(), osmscout::PositionAgent::Process(), osmscout::RouteStateAgent::Process(), osmscout::RoutePostprocessor::DirectionPostprocessor::Process(), and osmscout::AbstractRoutingService< RoutingState >::RestrictInitialUTurn().
Calculates the spherical distance between the two given points on the sphere.
Calculating basic cost for the A* algorithm based on the spherical distance of two points on earth.
References osmscout::DegToRad(), osmscout::GeoCoord::GetLat(), and osmscout::GeoCoord::GetLon().
Referenced by osmscout::AbstractRoutingService< RoutingState >::CalculateRoute(), osmscout::NearPOIModel::data(), osmscout::LocationListModel::data(), osmscout::LocationDescriptionService::DescribeLocationByWay(), osmscout::LocationEntry::distanceTo(), osmscout::AbstractRoutingService< RoutingState >::GetRNode(), osmscout::SimpleRoutingService::GetRoutableNode(), osmscout::NearPOIModel::onLookupResult(), osmscout::ArrivalEstimateAgent::Process(), osmscout::BearingAgent::Process(), osmscout::DataAgent< DataLoader >::Process(), osmscout::PositionAgent::Process(), osmscout::VehicleFollowHandler::vehiclePosition(), and osmscout::AbstractRoutingService< RoutingState >::WalkPaths().
|
inline |
Return true, if at least one point of area a in within area b.
References osmscout::GetBoundingBox(), and osmscout::IsAreaAtLeastPartlyInArea().
|
inline |
Return true, if at least one point of area a in within area b.
References osmscout::GetRelationOfPointToArea(), osmscout::GeoBox::Includes(), and osmscout::GeoBox::Intersects().
Referenced by osmscout::IsAreaAtLeastPartlyInArea().
|
inline |
Return true, if area a is completely in area b.
References osmscout::GetRelationOfPointToArea().
|
inline |
Assumes that the given areas do not intersect.
Returns true, of area a is within b (because at least one point of area a is in b), else (at least one point of area a is outside area b) false
References osmscout::GetRelationOfPointToArea().
|
inline |
Assumes that the given areas do not intersect.
Returns true, of area a is within b or the same as b. This version uses some heuristic based on the assumption that areas are either in another area or not - but there may be some smaller errors due to areas slightly overlapping.
References osmscout::GetRelationOfPointToArea().
|
inline |
Assumes that the given areas do not intersect.
Returns true, of area a is within b. This version uses some heuristic based on the assumption that areas are either in another area or not - but there may be some smaller errors due to areas slightly overlapping.
References osmscout::GetRelationOfPointToArea().
|
inline |
Returns true, if point in area.
http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm
Returns true, if point in on the area border or within the area.
See http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
Referenced by osmscout::Database::LoadAreasInArea(), and osmscout::Database::LoadAreasInRadius().
bool osmscout::LinesIntersect | ( | const N & | a1, |
const N & | a2, | ||
const N & | b1, | ||
const N & | b2 | ||
) |
Returns true, if the lines defined by the given coordinates intersect.
References osmscout::GeoBox::Includes().
Referenced by osmscout::AreaIsSimple(), osmscout::AreaIsSimple(), and osmscout::FindIntersection().
|
inline |
Normalize vector [x,y], result is set to [nx,ny].
When vector length is zero, nx,ny are unchanged.
Referenced by osmscout::CoordBuffer::GenerateParallelWay().
|
extern |
Normalizes the given angle (in degrees) to be in the interval [-180.0 - 180.0].
Referenced by osmscout::RoutePostprocessor::DirectionPostprocessor::Process().
|
inline |
rad | angle in radians |
void osmscout::ScanConvertLine | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
std::vector< ScanCell > & | cells | ||
) |
Does a scan conversion for a line between the given coordinates.
This functions does a scan conversion of a line with the given start and end points.
This problem is equal to the following problem: Assuming an index that works by referencing lines by linking them to all cells in a cell grid that contain or are crossed by the line. Which cells does the line cross?
The given vector for the result data is not cleared on start, to allow multiple calls to this method with different line segments.
The algorithm of Bresenham is used together with some checks for special cases.