Skip to content

Commit

Permalink
SRS: patch getOGRAttrValue(DATUM) to return value strings for wgs_198…
Browse files Browse the repository at this point in the history
…4 and nad_1983
  • Loading branch information
gwaldron committed Jul 3, 2024
1 parent 0623cac commit e994c6d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/osgEarth/SpatialReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<double>( getOGRAttrValue( handle, "UNIT", 1, true ), 1.0 );
Expand Down

0 comments on commit e994c6d

Please sign in to comment.