KOSMIndoorMap

geomath.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
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
16namespace OSM {
17
18/** Degree to radian conversion. */
19[[nodiscard]] constexpr inline double degToRad(double deg)
20{
21 return deg / 180.0 * M_PI;
22}
23/** Radian to degree conversion. */
24[[nodiscard]] constexpr inline double radToDeg(double rad)
25{
26 return rad / M_PI * 180.0;
27}
28
29/** Distance between two coordinates. */
30[[nodiscard]] KOSM_EXPORT double distance(double lat1, double lon1, double lat2, double lon2);
31
32/** Distance between @p coord1 and @p coord2 in meter. */
33[[nodiscard]] 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[[nodiscard]] double distance(Coordinate l1, Coordinate l2, Coordinate p);
37
38/** Distance between the given polygon and coordinate, in meter. */
39[[nodiscard]] KOSM_EXPORT double distance(const std::vector<const OSM::Node*> &path, Coordinate coord);
40
41}
42
43#endif // OSM_GEOMATH_H
Low-level types and functions to work with raw OSM data as efficiently as possible.
KOSM_EXPORT double distance(double lat1, double lon1, double lat2, double lon2)
Distance between two coordinates.
Definition geomath.cpp:16
constexpr double radToDeg(double rad)
Radian to degree conversion.
Definition geomath.h:24
constexpr double degToRad(double deg)
Degree to radian conversion.
Definition geomath.h:19
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.