@@ -28,18 +28,18 @@ inline constexpr double kDefaultTolerance = 0.1; // meters
2828namespace detail {
2929
3030// Returns tan(latitude-at-lng3) on the great circle (lat1, 0) to (lat2, lng2).
31- inline double tan_lat_gc (double lat1, double lat2, double lng2, double lng3) noexcept {
31+ [[nodiscard]] inline double tan_lat_gc (double lat1, double lat2, double lng2, double lng3) noexcept {
3232 return (std::tan (lat1) * std::sin (lng2 - lng3) + std::tan (lat2) * std::sin (lng3)) / std::sin (lng2);
3333}
3434
3535// Returns mercator(latitude-at-lng3) on the Rhumb line (lat1, 0) to (lat2, lng2).
36- inline double mercator_lat_rhumb (double lat1, double lat2, double lng2, double lng3) noexcept {
36+ [[nodiscard]] inline double mercator_lat_rhumb (double lat1, double lat2, double lng2, double lng3) noexcept {
3737 return (mercator (lat1) * (lng2 - lng3) + mercator (lat2) * lng3) / lng2;
3838}
3939
4040// Computes whether the vertical segment (lat3, lng3) to South Pole intersects
4141// the segment (lat1, 0) to (lat2, lng2). Longitudes are offset so lng1 == 0.
42- inline bool intersects (double lat1, double lat2, double lng2, double lat3, double lng3, bool geodesic) noexcept {
42+ [[nodiscard]] inline bool intersects (double lat1, double lat2, double lng2, double lat3, double lng3, bool geodesic) noexcept {
4343 if ((lng3 >= 0 && lng3 >= lng2) || (lng3 < 0 && lng3 < lng2)) {
4444 return false ;
4545 }
@@ -66,7 +66,7 @@ inline bool intersects(double lat1, double lat2, double lng2, double lat3, doubl
6666
6767// Returns sin(initial bearing from (lat1,lng1) to (lat3,lng3) minus initial
6868// bearing from (lat1,lng1) to (lat2,lng2)).
69- inline double sin_delta_bearing (double lat1, double lng1, double lat2, double lng2, double lat3, double lng3) noexcept {
69+ [[nodiscard]] inline double sin_delta_bearing (double lat1, double lng1, double lat2, double lng2, double lat3, double lng3) noexcept {
7070 double sin_lat1 = std::sin (lat1);
7171 double cos_lat2 = std::cos (lat2);
7272 double cos_lat3 = std::cos (lat3);
@@ -82,7 +82,7 @@ inline double sin_delta_bearing(double lat1, double lng1, double lat2, double ln
8282 return denom <= 0 ? 1 : (a * d - b * c) / std::sqrt (denom);
8383}
8484
85- inline bool is_on_segment_gc (double lat1, double lng1, double lat2, double lng2, double lat3, double lng3, double hav_tolerance) noexcept {
85+ [[nodiscard]] inline bool is_on_segment_gc (double lat1, double lng1, double lat2, double lng2, double lat3, double lng3, double hav_tolerance) noexcept {
8686 double hav_dist13 = hav_distance (lat1, lat3, lng1 - lng3);
8787 if (hav_dist13 <= hav_tolerance) {
8888 return true ;
@@ -114,7 +114,7 @@ inline bool is_on_segment_gc(double lat1, double lng1, double lat2, double lng2,
114114
115115// Computes whether a given point lies on or near a polyline within a tolerance.
116116template <typename Path>
117- bool on_edge_or_path (const LatLng& point, const Path& poly, bool closed, bool geodesic, double tolerance_earth) {
117+ [[nodiscard]] bool on_edge_or_path (const LatLng& point, const Path& poly, bool closed, bool geodesic, double tolerance_earth) {
118118 std::size_t size = poly.size ();
119119 if (size == 0U ) {
120120 return false ;
@@ -187,7 +187,7 @@ bool on_edge_or_path(const LatLng& point, const Path& poly, bool closed, bool ge
187187 * the South Pole. Edges are great circle arcs if geodesic is true, rhumb lines otherwise.
188188 */
189189template <typename Path>
190- bool contains (const LatLng& point, const Path& polygon, bool geodesic = false ) {
190+ [[nodiscard]] bool contains (const LatLng& point, const Path& polygon, bool geodesic = false ) {
191191 std::size_t size = polygon.size ();
192192 if (size == 0 ) {
193193 return false ;
@@ -223,7 +223,7 @@ bool contains(const LatLng& point, const Path& polygon, bool geodesic = false) {
223223 * within a specified tolerance in meters. The polygon is implicitly closed.
224224 */
225225template <typename Path>
226- bool on_edge (const LatLng& point, const Path& polygon, bool geodesic = true , double tolerance = kDefaultTolerance ) {
226+ [[nodiscard]] bool on_edge (const LatLng& point, const Path& polygon, bool geodesic = true , double tolerance = kDefaultTolerance ) {
227227 return detail::on_edge_or_path (point, polygon, true , geodesic, tolerance);
228228}
229229
@@ -232,15 +232,15 @@ bool on_edge(const LatLng& point, const Path& polygon, bool geodesic = true, dou
232232 * specified tolerance in meters. The polyline is not closed.
233233 */
234234template <typename Path>
235- bool on_path (const LatLng& point, const Path& polyline, bool geodesic = true , double tolerance = kDefaultTolerance ) {
235+ [[nodiscard]] bool on_path (const LatLng& point, const Path& polyline, bool geodesic = true , double tolerance = kDefaultTolerance ) {
236236 return detail::on_edge_or_path (point, polyline, false , geodesic, tolerance);
237237}
238238
239239/* *
240240 * Computes the spherical distance between the point p and the line segment
241241 * (start, end), in meters.
242242 */
243- inline double distance_to_segment (const LatLng& p, const LatLng& start, const LatLng& end) noexcept {
243+ [[nodiscard]] inline double distance_to_segment (const LatLng& p, const LatLng& start, const LatLng& end) noexcept {
244244 if (start == end) {
245245 return distance_between (end, p);
246246 }
0 commit comments