Skip to content

Commit

Permalink
Updated ossimImageElevationDatabase code to write an elev_cell_map.kwl
Browse files Browse the repository at this point in the history
on first load for pointWithin(...) calls.
  • Loading branch information
David Burken committed May 25, 2021
1 parent 1d67c75 commit 0099831
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 48 deletions.
21 changes: 21 additions & 0 deletions include/ossim/base/ossimGrect.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,27 @@ class OSSIM_DLL ossimGrect
double latSpacingInDegrees,
double lonSpacingInDegrees,
bool clipToGeographicBounds = true)const;

/**
* @brief Get the rect as a string.
*
* Output format is two ossimGpts separated by a comma:
* (ul),(lr)
* ( 30.0, -90.0, 0.0, WGE ),( 29.0, -89.0, 0.0, WGE )
* ( lat, lon, hgt, datum),( lat, lon, hgt, datum),
*/
std::string toString(ossim_uint32 precision=15) const;

/**
* Initializes this rect from string.
*
* Expected input string format:
* (ul),(lr)
* ( 30.0, -90.0, 0.0, WGE ),( 29.0, -89.0, 0.0, WGE )
* ( lat, lon, hgt, datum),( lat, lon, hgt, datum)
*/
bool toRect(const std::string& s);

private:
ossimGpt theUlCorner; // Contains max height as well
ossimGpt theLrCorner; // Contains min height as well
Expand Down
23 changes: 17 additions & 6 deletions include/ossim/elevation/ossimImageElevationDatabase.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
//----------------------------------------------------------------------------
//---
//
// File: ossimImageElevationDatabase.h
//
// License: MIT
// License: MIT
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: David Burken
//
// Description: See description for class below.
//
//----------------------------------------------------------------------------
//---
// $Id$

#ifndef ossimImageElevationDatabase_HEADER
Expand All @@ -23,6 +21,7 @@
#include <ossim/base/ossimGrect.h>
#include <ossim/base/ossimRefPtr.h>
#include <ossim/base/ossimRtti.h>
#include <iosfwd>
#include <map>

class ossimString;
Expand Down Expand Up @@ -179,12 +178,18 @@ class OSSIM_DLL ossimImageElevationDatabase :

ossimImageElevationFileEntry(const ossimImageElevationFileEntry& copy_this);

void saveState( ossimKeywordlist& kwl, const std::string& prefix ) const;

bool loadState(const ossimKeywordlist& kwl, const std::string& prefix );

/** file name */
ossimFilename m_file;

/** Bounding rectangle in decimal degrees. */
ossimGrect m_rect;
ossimDpt m_nominalGSD; // post spacing at center

// post spacing at center
// ossimDpt m_nominalGSD;

/** True if in ossimElevationCellDatabase::m_cacheMap. */
bool m_loadedFlag;
Expand All @@ -196,6 +201,12 @@ class OSSIM_DLL ossimImageElevationDatabase :
*/
void loadFileMap();

/**
* @brief Initializes m_entryMap with all loadable files from
* m_connectionString.
*/
bool loadMapFromKwl();

/** Hidden from use copy constructor */
ossimImageElevationDatabase(const ossimImageElevationDatabase& copy_this);

Expand Down
8 changes: 3 additions & 5 deletions include/ossim/elevation/ossimImageElevationHandler.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
//----------------------------------------------------------------------------
//---
//
// File: ossimImageElevationHandler.h
//
// License: MIT
// License: MIT
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: David Burken
//
// Description: See description for class below.
//
//----------------------------------------------------------------------------
//---
// $Id$

#ifndef ossimImageElevationHandler_HEADER
Expand Down
40 changes: 40 additions & 0 deletions src/base/ossimGrect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,43 @@ void ossimGrect::expandToInclude(const ossimGrect& rect)
expandToInclude(rect.ul());
expandToInclude(rect.lr());
}

std::string ossimGrect::toString(ossim_uint32 precision) const
{
std::string result = theUlCorner.toString( precision ).string();
result += ",";
result += theLrCorner.toString( precision ).string();
return result;
}

bool ossimGrect::toRect(const std::string& s)
{
bool result = false;

// String example: (41,-105,0,WGE),(40,-104,0,WGE)

// Get the upper left:
std::string ss = ",(";
std::string::size_type found = s.find(ss);
if ( found != std::string::npos )
{
// cout << "s.substr( 0, found ): " << s.substr( 0, found ) << "\n";
theUlCorner.toPoint( s.substr( 0, found ) );

// Get the lower right:
ss = "),";
std::string::size_type found = s.find(ss);
if ( found != std::string::npos )
{
if ( found+2 < s.size() )
{
// cout << "s.substr( found+2, s.size()-(found+2) ): "
// << s.substr( found+2, s.size()-(found+2) ) << "\n";
theLrCorner.toPoint( s.substr(found+2, s.size()-(found+2)) );
result = true;
}
}
}

return result;
}
13 changes: 7 additions & 6 deletions src/elevation/ossimElevationDatabaseFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,29 @@ ossimElevationDatabaseFactory* ossimElevationDatabaseFactory::instance()
return m_instance;
}

ossimElevationDatabase* ossimElevationDatabaseFactory::createDatabase(const ossimString& typeName)const
ossimElevationDatabase* ossimElevationDatabaseFactory::createDatabase(
const ossimString& typeName )const
{
if((typeName == STATIC_TYPE_NAME(ossimDtedElevationDatabase)) ||
(typeName == "dted")||
(typeName == "dted_directory"))

{
return new ossimDtedElevationDatabase();
}
else if((typeName == STATIC_TYPE_NAME(ossimSrtmElevationDatabase)) ||
(typeName == "srtm")||
(typeName == "srtm_directory"))

{
return new ossimSrtmElevationDatabase();
}
else if((typeName == STATIC_TYPE_NAME(ossimGeneralRasterElevationDatabase)) ||
(typeName == "general_raster")||
(typeName == "general_raster_directory"))

{
return new ossimGeneralRasterElevationDatabase();
}
else if( (typeName == "ossimImageElevationDatabase") ||
(typeName == "image_directory"))

(typeName == "image_directory"))
{
return new ossimImageElevationDatabase();
}
Expand Down Expand Up @@ -87,6 +84,10 @@ ossimElevationDatabase* ossimElevationDatabaseFactory::open(const ossimString& c
if (result->open(connectionString))
break;

result = new ossimImageElevationDatabase;
if (result->open(connectionString))
break;

// This method will only open individual image files for use as dems. It will not utilize the
// file walker to search over directories:
ossimFilename filename (connectionString);
Expand Down
Loading

0 comments on commit 0099831

Please sign in to comment.