From e994c6d65ff3cf88a3199f453b891e3729cf7b5d Mon Sep 17 00:00:00 2001 From: Glenn Waldron Date: Wed, 3 Jul 2024 12:29:30 -0400 Subject: [PATCH] SRS: patch getOGRAttrValue(DATUM) to return value strings for wgs_1984 and nad_1983 --- src/osgEarth/SpatialReference.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/osgEarth/SpatialReference.cpp b/src/osgEarth/SpatialReference.cpp index 1a6e251734..63028d0aa2 100644 --- a/src/osgEarth/SpatialReference.cpp +++ b/src/osgEarth/SpatialReference.cpp @@ -202,7 +202,8 @@ SpatialReference::SpatialReference(const Key& key) : // common WGS84: else if( key.horizLower == "epsg:4326" || - key.horizLower == "wgs84") + key.horizLower == "wgs84" || + key.horizLower == "wgs_1984") { _setup.name = "WGS84"; _setup.type = INIT_PROJ; @@ -336,10 +337,7 @@ SpatialReference::getLocal() const error = OSRSetFromUserInput(local._handle, _setup.horiz.c_str()); } - if (error == OGRERR_NONE) - { - } - else + if (error != OGRERR_NONE) { OE_WARN << LC << "Failed to create SRS from \"" << _setup.horiz << "\"" << std::endl; OSRDestroySpatialReference(local._handle); @@ -1455,6 +1453,12 @@ SpatialReference::init() // Try to extract the horizontal datum _datum = getOGRAttrValue( handle, "DATUM", 0, true ); + // Fix bad return values.. + if (_datum == "wgs_1984" || _datum == "WGS_1984") + _datum = "WGS84"; + else if (_datum == "nad_1983" || _datum == "NAD_1983") + _datum = "NAD83"; + // Extract the base units: std::string units_name = getOGRAttrValue( handle, "UNIT", 0, true ); double unitMultiplier = osgEarth::Util::as( getOGRAttrValue( handle, "UNIT", 1, true ), 1.0 );