libosmscout  1.1.1
Classes | Functions
Geometric helper
Collaboration diagram for Geometric helper:

Classes

class  osmscout::CLASS_FINAL< DataLoader >
 
struct  osmscout::PathIntersection
 
class  osmscout::Projection
 
struct  osmscout::TransPoint
 

Functions

double osmscout::DegToRad (double deg)
 
double osmscout::RadToDeg (double rad)
 
double osmscout::AngleDiff (double a, double b)
 
template<typename N >
void osmscout::GetBoundingBox (const std::vector< N > &nodes, double &minLon, double &maxLon, double &minLat, double &maxLat)
 
template<class InputIt >
void osmscout::GetBoundingBox (const InputIt first, const InputIt last, GeoBox &boundingBox)
 
template<typename N >
void osmscout::GetBoundingBox (const std::vector< N > &nodes, GeoBox &boundingBox)
 
template<typename N >
bool osmscout::LinesIntersect (const N &a1, const N &a2, const N &b1, const N &b2)
 
template<typename N , typename I >
bool osmscout::GetLineIntersection (const N &a1, const N &a2, const N &b1, const N &b2, I &intersection)
 
template<typename N >
bool osmscout::GetLineIntersectionPixel (const N &a1, const N &a2, const N &b1, const N &b2, N &intersection)
 
template<typename N , typename M >
bool osmscout::IsCoordInArea (const N &point, const std::vector< M > &nodes)
 
template<typename N , typename M >
int osmscout::GetRelationOfPointToArea (const N &point, const std::vector< M > &nodes)
 
template<typename N , typename M >
bool osmscout::IsAreaCompletelyInArea (const std::vector< N > &a, const std::vector< M > &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)
 
template<typename N , typename M >
bool osmscout::IsAreaAtLeastPartlyInArea (const std::vector< N > &a, const std::vector< M > &b)
 
template<typename N , typename M >
bool osmscout::IsAreaSubOfArea (const std::vector< N > &a, const std::vector< M > &b)
 
template<typename N , typename M >
bool osmscout::IsAreaSubOfAreaQuorum (const std::vector< N > &a, const std::vector< M > &b)
 
template<typename N , typename M >
bool osmscout::IsAreaSubOfAreaOrSame (const std::vector< N > &a, const std::vector< M > &b)
 
template<typename N >
bool osmscout::AreaIsSimple (std::vector< N > points)
 
template<typename N >
bool osmscout::AreaIsSimple (const std::vector< std::pair< N, N > > &edges, const std::vector< bool > &edgeStartsNewPoly)
 
template<typename N >
bool osmscout::AreaIsCCW (const std::vector< N > &edges)
 
template<typename N >
bool osmscout::AreaIsValid (std::vector< N > &outerPoints, std::vector< std::vector< N > > &innerPoints)
 
void osmscout::Normalize (double x, double y, double &nx, double &ny)
 
double osmscout::Det (double x1, double y1, double x2, double y2)
 
template<typename N >
bool osmscout::AreaIsClockwise (const std::vector< N > &edges)
 
OSMSCOUT_API Distance osmscout::GetSphericalDistance (const GeoCoord &a, const GeoCoord &b)
 
OSMSCOUT_API Distance osmscout::GetEllipsoidalDistance (double aLon, double aLat, double bLon, double bLat)
 
OSMSCOUT_API Distance osmscout::GetEllipsoidalDistance (const GeoCoord &a, const GeoCoord &b)
 
OSMSCOUT_API void osmscout::GetEllipsoidalDistance (double lat1, double lon1, const Bearing &bearing, const Distance &distance, double &lat2, double &lon2)
 
OSMSCOUT_API GeoCoord osmscout::GetEllipsoidalDistance (const GeoCoord &position, const Bearing &bearing, const Distance &distance)
 
OSMSCOUT_API Bearing osmscout::GetSphericalBearingInitial (const GeoCoord &a, const GeoCoord &b)
 
OSMSCOUT_API Bearing osmscout::GetSphericalBearingFinal (const GeoCoord &a, const GeoCoord &b)
 
OSMSCOUT_API double osmscout::GetDistanceInLonDegrees (const Distance &d, double latitude=0)
 
OSMSCOUT_API double osmscout::NormalizeRelativeAngle (double angle)
 
void OSMSCOUT_API osmscout::ScanConvertLine (int x1, int y1, int x2, int y2, std::vector< ScanCell > &cells)
 
OSMSCOUT_API double osmscout::DistanceToSegment (double px, double py, double p1x, double p1y, double p2x, double p2y, double &r, double &qx, double &qy)
 
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)
 
template<typename N >
bool osmscout::FindIntersection (const std::vector< N > &way, size_t &i, size_t &j)
 

Detailed Description

Collection of classes and methods releated to low level geometric stuff.

Function Documentation

◆ AngleDiff()

double osmscout::AngleDiff ( double  a,
double  b 
)
inline

compute difference of two angles

Parameters
aangle in radians in range - M_PI .. + M_PI
bangle in radians in range - M_PI .. + M_PI
Returns
angle in radians in range 0 .. M_PI

◆ AreaIsCCW()

template<typename N >
bool osmscout::AreaIsCCW ( const std::vector< N > &  edges)

Returns true, if the polygon is counter clock wise (CCW)

◆ AreaIsClockwise()

template<typename N >
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.

◆ AreaIsSimple() [1/2]

template<typename N >
bool osmscout::AreaIsSimple ( std::vector< N >  points)

Returns true, if the handed polygon is simple (aka not complex).

Currently the following checks are done:

  • Polygon has at least 3 points
  • Assure that the line segments that make up the polygon only meet at their end points.

◆ AreaIsSimple() [2/2]

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

◆ AreaIsValid()

template<typename N >
bool osmscout::AreaIsValid ( std::vector< N > &  outerPoints,
std::vector< std::vector< N > > &  innerPoints 
)
Parameters
outerPoints
innerPoints
Returns

◆ DegToRad()

double osmscout::DegToRad ( double  deg)
inline
Parameters
degangl ein degrees
Returns
angle in radians

◆ Det()

double osmscout::Det ( double  x1,
double  y1,
double  x2,
double  y2 
)
inline

Calculates the determinant of the line between the given points.

◆ DistanceToSegment()

OSMSCOUT_API 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). 0 <= r <= 1 if q is between p1 and p2.

◆ FindIntersection()

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. Return true if some intersection was found (way is not simple), i and j indexes are setup to start possition of intesections lines.

◆ FindPathIntersections()

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. Intersections are added to intersections vector.

◆ GetBoundingBox() [1/3]

template<typename N >
void osmscout::GetBoundingBox ( const std::vector< N > &  nodes,
double &  minLon,
double &  maxLon,
double &  minLat,
double &  maxLat 
)

Calculate the bounding box of the (non empty) vector of geo coords

Parameters
nodesThe geo coordinates
minLon
maxLon
minLat
maxLat

◆ GetBoundingBox() [2/3]

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

Parameters
[first,last)range of geo coords
minLon
maxLon
minLat
maxLat

◆ GetBoundingBox() [3/3]

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

Parameters
nodesThe geo coordinates
minLon
maxLon
minLat
maxLat

◆ GetDistanceInLonDegrees()

OSMSCOUT_API double osmscout::GetDistanceInLonDegrees ( const Distance &  d,
double  latitude = 0 
)
Parameters
ddistance
latitudewhere degrees are computed. Function is not defined on poles (+90, -90), it may leads to division by zero error.
Returns
longitude degrees corresponding to distance

◆ GetEllipsoidalDistance() [1/4]

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

◆ GetEllipsoidalDistance() [2/4]

OSMSCOUT_API Distance osmscout::GetEllipsoidalDistance ( const GeoCoord &  a,
const GeoCoord &  b 
)

Calculates the ellipsoidal (WGS-84) distance between the two given points on the ellipsoid.

◆ GetEllipsoidalDistance() [3/4]

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

◆ GetEllipsoidalDistance() [4/4]

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

◆ GetLineIntersection()

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. Returns the intersection.

◆ GetLineIntersectionPixel()

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. Returns the intersection.

◆ GetRelationOfPointToArea()

template<typename N , typename M >
int osmscout::GetRelationOfPointToArea ( const N &  point,
const std::vector< M > &  nodes 
)
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.

◆ GetSphericalBearingFinal()

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

◆ GetSphericalBearingInitial()

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

◆ GetSphericalDistance()

OSMSCOUT_API Distance osmscout::GetSphericalDistance ( const GeoCoord &  a,
const GeoCoord &  b 
)

Calculates the spherical distance between the two given points on the sphere.

◆ IsAreaAtLeastPartlyInArea() [1/2]

template<typename N , typename M >
bool osmscout::IsAreaAtLeastPartlyInArea ( const std::vector< N > &  a,
const std::vector< M > &  b,
const GeoBox &  aBox,
const GeoBox &  bBox 
)
inline

Return true, if at least one point of area a in within area b

◆ IsAreaAtLeastPartlyInArea() [2/2]

template<typename N , typename M >
bool osmscout::IsAreaAtLeastPartlyInArea ( const std::vector< N > &  a,
const std::vector< M > &  b 
)
inline

Return true, if at least one point of area a in within area b

◆ IsAreaCompletelyInArea()

template<typename N , typename M >
bool osmscout::IsAreaCompletelyInArea ( const std::vector< N > &  a,
const std::vector< M > &  b 
)
inline

Return true, if area a is completely in area b

◆ IsAreaSubOfArea()

template<typename N , typename M >
bool osmscout::IsAreaSubOfArea ( const std::vector< N > &  a,
const std::vector< M > &  b 
)
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

◆ IsAreaSubOfAreaOrSame()

template<typename N , typename M >
bool osmscout::IsAreaSubOfAreaOrSame ( const std::vector< N > &  a,
const std::vector< M > &  b 
)
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.

◆ IsAreaSubOfAreaQuorum()

template<typename N , typename M >
bool osmscout::IsAreaSubOfAreaQuorum ( const std::vector< N > &  a,
const std::vector< M > &  b 
)
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.

◆ IsCoordInArea()

template<typename N , typename M >
bool osmscout::IsCoordInArea ( const N &  point,
const std::vector< M > &  nodes 
)
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

◆ LinesIntersect()

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.

◆ Normalize()

void osmscout::Normalize ( double  x,
double  y,
double &  nx,
double &  ny 
)
inline

Normalize vector [x,y], result is set to [nx,ny]. When vector length is zero, nx,ny are unchanged.

◆ NormalizeRelativeAngle()

OSMSCOUT_API double osmscout::NormalizeRelativeAngle ( double  angle)

Normalizes the given angle (in degrees) to be in the interval [-180.0 - 180.0]

◆ RadToDeg()

double osmscout::RadToDeg ( double  rad)
inline
Parameters
radangle in radians
Returns
angle in degrees

◆ ScanConvertLine()

void OSMSCOUT_API 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.