Skip to content

Commit

Permalink
Check node lat lon not NaN or infinite
Browse files Browse the repository at this point in the history
  • Loading branch information
Woazboat committed Nov 22, 2023
1 parent 1cefa94 commit 7d058d5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/cgimap/api06/changeset_upload/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <iostream>
#include <optional>
#include <cmath>

namespace api06 {

Expand Down Expand Up @@ -52,12 +53,16 @@ class Node : public OSMObject {
void set_lat(double lat) {
if (lat < -90 || lat > 90)
throw xml_error("Latitude outside of valid range");
else if (!std::isfinite(lat))
throw xml_error("Latitude not a valid finite number");
m_lat = lat;
}

void set_lon(double lon) {
if (lon < -180 || lon > 180)
throw xml_error("Longitude outside of valid range");
else if (!std::isfinite(lon))
throw xml_error("Longitude not a valid finite number");
m_lon = lon;
}

Expand Down

0 comments on commit 7d058d5

Please sign in to comment.