From 76540a211cb7bbc935825bf310b594d48383013a Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 13 Dec 2020 17:23:24 +0000 Subject: [PATCH] SGGeod: add static constructor of an invalid Geod Use this to allow explicitly initializing a value which isValid will return false for. --- simgear/math/SGGeod.hxx | 7 +++++++ simgear/math/SGGeodesy.cxx | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/simgear/math/SGGeod.hxx b/simgear/math/SGGeod.hxx index 89461db8..ca614e67 100644 --- a/simgear/math/SGGeod.hxx +++ b/simgear/math/SGGeod.hxx @@ -29,6 +29,13 @@ public: /// Default constructor, initializes the instance to lat = lon = elev = 0 SGGeod(void); + /** + return an SGGeod for which isValid() returns false. + This is necessaerby becuase for historical reasons, ther defaulrt constructor above initialsies to zero,zero,zero + which *is* + */ + static SGGeod invalid(); + /// Factory from angular values in radians and elevation is 0 static SGGeod fromRad(double lon, double lat); /// Factory from angular values in degrees and elevation is 0 diff --git a/simgear/math/SGGeodesy.cxx b/simgear/math/SGGeodesy.cxx index 6949a526..d7d5a0a5 100644 --- a/simgear/math/SGGeodesy.cxx +++ b/simgear/math/SGGeodesy.cxx @@ -663,3 +663,8 @@ SGGeodesy::radialIntersection(const SGGeod& a, double aRadial, result = SGGeod::fromGeoc(r); return true; } + +SGGeod SGGeod::invalid() +{ + return SGGeod::fromDeg(-999.9, -999.0); +}