1 | /* |
2 | * Copyright 2016-2017 Uber Technologies, Inc. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | /** @file geoCoord.h |
17 | * @brief Geodetic (lat/lon) functions. |
18 | */ |
19 | |
20 | #ifndef GEOCOORD_H |
21 | #define GEOCOORD_H |
22 | |
23 | #include <stdbool.h> |
24 | #include <stdint.h> |
25 | #include <stdio.h> |
26 | #include "constants.h" |
27 | #include "h3api.h" |
28 | |
29 | /** epsilon of ~0.1mm in degrees */ |
30 | #define EPSILON_DEG .000000001 |
31 | /** epsilon of ~0.1mm in radians */ |
32 | #define EPSILON_RAD (EPSILON_DEG * M_PI_180) |
33 | |
34 | void setGeoDegs(GeoCoord* p, double latDegs, double lonDegs); |
35 | double constrainLat(double lat); |
36 | double constrainLng(double lng); |
37 | |
38 | bool geoAlmostEqual(const GeoCoord* p1, const GeoCoord* p2); |
39 | bool geoAlmostEqualThreshold(const GeoCoord* p1, const GeoCoord* p2, |
40 | double threshold); |
41 | |
42 | // Internal functions |
43 | |
44 | double _posAngleRads(double rads); |
45 | void _setGeoRads(GeoCoord* p, double latRads, double lonRads); |
46 | double _geoDistRads(const GeoCoord* p1, const GeoCoord* p2); |
47 | double _geoDistKm(const GeoCoord* p1, const GeoCoord* p2); |
48 | double _geoAzimuthRads(const GeoCoord* p1, const GeoCoord* p2); |
49 | void _geoAzDistanceRads(const GeoCoord* p1, double az, double distance, |
50 | GeoCoord* p2); |
51 | |
52 | #endif |
53 | |