KOSMIndoorMap

geomath.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef OSM_GEOMATH_H
8 #define OSM_GEOMATH_H
9 
10 #include "kosm_export.h"
11 
12 #include "datatypes.h"
13 
14 #include <cmath>
15 
16 namespace OSM {
17 
18 /** Degree to radian conversion. */
19 constexpr inline double degToRad(double deg)
20 {
21  return deg / 180.0 * M_PI;
22 }
23 /** Radian to degree conversion. */
24 constexpr inline double radToDeg(double rad)
25 {
26  return rad / M_PI * 180.0;
27 }
28 
29 /** Distance between two coordinates. */
30 KOSM_EXPORT double distance(double lat1, double lon1, double lat2, double lon2);
31 
32 /** Distance between @p coord1 and @p coord2 in meter. */
33 KOSM_EXPORT double distance(Coordinate coord1, Coordinate coord2);
34 
35 /** Distance in meters between a line segment defined by @p l1 and @p l2 to a point @p p. */
36 double distance(Coordinate l1, Coordinate l2, Coordinate p);
37 
38 /** Distance between the given polygon and coordinate, in meter. */
39 KOSM_EXPORT double distance(const std::vector<const OSM::Node*> &path, Coordinate coord);
40 
41 }
42 
43 #endif // OSM_GEOMATH_H
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
Definition: datatypes.h:37
constexpr double degToRad(double deg)
Degree to radian conversion.
Definition: geomath.h:19
constexpr double radToDeg(double rad)
Radian to degree conversion.
Definition: geomath.h:24
KOSM_EXPORT double distance(double lat1, double lon1, double lat2, double lon2)
Distance between two coordinates.
Definition: geomath.cpp:17
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.