geoCoord.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2016-2020 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. #ifndef GEOCOORD_H
  20. #define GEOCOORD_H
  21. #include <stdbool.h>
  22. #include <stdint.h>
  23. #include <stdio.h>
  24. #include "constants.h"
  25. #include "h3api.h"
  26. /** epsilon of ~0.1mm in degrees */
  27. #define EPSILON_DEG .000000001
  28. /** epsilon of ~0.1mm in radians */
  29. #define EPSILON_RAD (EPSILON_DEG * M_PI_180)
  30. void setGeoDegs(GeoCoord* p, double latDegs, double lonDegs);
  31. double constrainLat(double lat);
  32. double constrainLng(double lng);
  33. bool geoAlmostEqual(const GeoCoord* p1, const GeoCoord* p2);
  34. bool geoAlmostEqualThreshold(const GeoCoord* p1, const GeoCoord* p2,
  35. double threshold);
  36. // Internal functions
  37. double _posAngleRads(double rads);
  38. void _setGeoRads(GeoCoord* p, double latRads, double lonRads);
  39. double _geoAzimuthRads(const GeoCoord* p1, const GeoCoord* p2);
  40. void _geoAzDistanceRads(const GeoCoord* p1, double az, double distance,
  41. GeoCoord* p2);
  42. #endif