# KOSMIndoorMap

geomath.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
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. */
20{
21 return deg / 180.0 * M_PI;
22}
23/** Radian to degree conversion. */
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