LibCorr3D 2.2
All Classes Namespaces Files Functions
LibCorr3D.h
Go to the documentation of this file.
1//- ****************************************************************************
2//-
3//- Copyright 2009 Sandia Corporation. Under the terms of Contract
4//- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
5//- retains certain rights in this software.
6//-
7//- BSD Open Source License.
8//- All rights reserved.
9//-
10//- Redistribution and use in source and binary forms, with or without
11//- modification, are permitted provided that the following conditions are met:
12//-
13//- * Redistributions of source code must retain the above copyright notice,
14//- this list of conditions and the following disclaimer.
15//- * Redistributions in binary form must reproduce the above copyright
16//- notice, this list of conditions and the following disclaimer in the
17//- documentation and/or other materials provided with the distribution.
18//- * Neither the name of Sandia National Laboratories nor the names of its
19//- contributors may be used to endorse or promote products derived from
20//- this software without specific prior written permission.
21//-
22//- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23//- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24//- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25//- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26//- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27//- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28//- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29//- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30//- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31//- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32//- POSSIBILITY OF SUCH DAMAGE.
33//-
34//- ****************************************************************************
35
36#ifndef LIBCORR3D_OBJECT_H
37#define LIBCORR3D_OBJECT_H
38
39// **** _SYSTEM INCLUDES_ ******************************************************
40
41#include <iostream>
42#include <string>
43#include <fstream>
44#include <vector>
45#include <map>
46
47// use standard library objects
48using namespace std;
49
50// **** _LOCAL INCLUDES_ *******************************************************
51
52#include "CPPUtils.h"
53#include "GeoTessUtils.h"
54#include "GeoTessException.h"
55#include "GeoTessModel.h"
56#include "GeoTessPosition.h"
57#include "GeoTessOptimizationType.h"
58
59// **** _BEGIN GEOTESS NAMESPACE_ **********************************************
60
61namespace geotess
62{
63
64// **** _FORWARD REFERENCES_ ***************************************************
65
66class GeoTessPosition;
67class LibCorr3DModel;
68class GeoTessMetaData;
69class IFStreamBinary;
70class GeoTessInterpolatorType;
71
72// **** _CLASS DEFINITION_ *****************************************************
73
116class GEOTESS_EXP_IMP LibCorr3D
117{
118private:
119
123 double lc3dCurrIntrpVector[3];
124
129 double lc3dCurrIntrpRadius;
130
138 double lc3dCurrIntrpTime;
139
147 string lc3dGTRootPath;
148
154 string lc3dOldRootPath;
155
161 string lc3dGTRelGridPath;
162
168 string lc3dOldRelTessPath;
169
174 vector<string> lc3dModelFileName;
175
186 map<string, int> lc3dModelMap;
187
200 vector<LibCorr3DModel*> lc3dModelList;
201
208 map<string, GeoTessPosition*> lc3dPositionMap;
209
217 vector<GeoTessPosition*> lc3dPositionList;
218
222 int lc3dCurrErrCode;
223
227 string lc3dCurrErrMsg;
228
233 void checkPath(const string& fname, string& pth, string& relGrid);
234
241 GeoTessInterpolatorType const* geographicInterpolatorType;
242
249 GeoTessInterpolatorType const* radialInterpolatorType;
250
251public:
252
259 LibCorr3D(const string& rootPath);
260
269 LibCorr3D(const string& newRootPath, const string& oldRootPath);
270
283 LibCorr3D(const string& newRootPath, const string& newRelGridPath,
284 const string& oldRootPath, const string& oldRelGridPath);
285
289 virtual ~LibCorr3D();
290
294 static string getVersion() { return "1.2.8"; };
295
296 // version 1.2.5 2015-08-19
297 // Fixed a bug discovered at AFTAC, in method
298 // LibCorr3DModel::interpolate2DModelUncertainty
299 // that resulted in incorrect model uncertainty values
300 // when distance was out of range.
301 //
302 // version 1.2.4 2015-01-22
303 // Added getMemory() functions to GeoTess and Libcorr3D.
304 //
305 // version 1.2.2 2014-05-01
306 // Changes to GeoTessCPP to improve the performance of
307 // the natural neighbor algorithm. GeoTessCPP version
308 // is now 2.2.0. No changes to the LibCorr3D code.
309 //
310 // version 1,2,1 10/07/2013
311 // Fixed a bug where GeoTessPosition objects were not being deleted
312 // properly in LibCorr3d::removeModel(handle).
313 //
314 // version 1.1.0 11/21/2012:
315 // - multiple models can be supported by a single GeoTessPosition object.
316 // - can specify geographic and radial interpolators independently.
317 // - can specify interpolation location using unit vector and radius
318 // in addition to specification using lat, lon, depth.
319 // - can specify OptimizationType in loadModel() method
320
328 LONG_INT getMemory();
329
349 int loadModel(const string& fname, const GeoTessOptimizationType& optimizationType = GeoTessOptimizationType::SPEED)
350 {
351 // call the other loadModel() method with attributeFilter that is empty, which means
352 // it will be ignored and all attributes will be loaded.
353 vector<int> attributeFilter;
354 return loadModel(fname, attributeFilter, optimizationType);
355 }
356
381 int loadModel(const string& fname, vector<int>& attributeFilter,
382 const GeoTessOptimizationType& optimizationType = GeoTessOptimizationType::SPEED);
383
387 void removeModel(int handle);
388
394 {
395 return lc3dCurrIntrpVector;
396 }
397
403 {
404 return GeoTessUtils::getLatDegrees(lc3dCurrIntrpVector);
405 }
406
412 {
413 return GeoTessUtils::getLonDegrees(lc3dCurrIntrpVector);
414 }
415
421 {
422 return lc3dCurrIntrpRadius;
423 }
424
430 {
431 return GeoTessUtils::getEarthRadius(lc3dCurrIntrpVector)-lc3dCurrIntrpRadius;
432 }
433
439 {
440 return lc3dCurrIntrpTime;
441 }
442
450 {
451 ostringstream os;
452 os << fixed << setprecision(5);
453 os << setw(11) << getCurrentInterpolationLon();
454 os << " " << setw(10) << getCurrentInterpolationLat();
455 os << fixed << setprecision(3);
456 os << " " << setw(7) << getCurrentInterpolationDepth();
457 os << " " << setw(7) << getCurrentInterpolationTime();
458 return os.str();
459 }
460
472 LibCorr3D* setInterpolationLocation(double lon, double lat, double depth = 0.0, double time =
473 NA_VALUE)
474 {
475 if (lat < -90 || lat > 90)
476 {
477 ostringstream os;
478 os << fixed << setprecision(6);
479 os << endl << "ERROR in LibCorr3D::setInterpolationLocation" << endl
480 << "latitude (" << lat << ") is out of range" << endl;
481 throw GeoTessException(os, __FILE__, __LINE__, 109);
482 }
483
484 GeoTessUtils::getVectorDegrees(lat, lon, lc3dCurrIntrpVector);
485 lc3dCurrIntrpRadius = GeoTessUtils::getEarthRadius(lc3dCurrIntrpVector)-depth;
486 lc3dCurrIntrpTime = time;
487 return this;
488 }
489
502 LibCorr3D* setInterpolationLocation(double* unitVector, double radius = -1., double time =
503 NA_VALUE)
504 {
505 lc3dCurrIntrpVector[0] = unitVector[0];
506 lc3dCurrIntrpVector[1] = unitVector[1];
507 lc3dCurrIntrpVector[2] = unitVector[2];
508 lc3dCurrIntrpRadius = radius < 0. ? GeoTessUtils::getEarthRadius(unitVector) : radius;
509 lc3dCurrIntrpTime = time;
510 return this;
511 }
512
526 void setInterpolator(GeoTessInterpolatorType const* intrpGeographic, GeoTessInterpolatorType const* intrpRadial);
527
532 const GeoTessInterpolatorType& getGeographicInterpolatorType() const
533 {
534 return *geographicInterpolatorType;
535 }
536
541 const GeoTessInterpolatorType& getRadialInterpolatorType() const
542 {
543 return *radialInterpolatorType;
544 }
545
550
584 bool getModelResult(int handle, double& modelValue, double& modelUncertainty);
585
594 const string& getRootPath() const
595 {
596 return lc3dGTRootPath;
597 }
598
607 const string& getOldRootPath() const
608 {
609 return lc3dOldRootPath;
610 }
611
619 const string& getRelGridPath() const
620 {
621 return lc3dGTRelGridPath;
622 }
623
631 const string& getOldRelGridPath() const
632 {
633 return lc3dOldRelTessPath;
634 }
635
660 {
661 return lc3dCurrErrCode;
662 }
663
669 const string& getCurrentErrorMessage() const
670 {
671 return lc3dCurrErrMsg;
672 }
673
674};
675
676// end class LibCorr3D
677
678}// end namespace geotess
679
680#endif // LIBCORR3D_OBJECT_H
Definition: LibCorr3D.h:62
This class is responsible for loading, removing, and interpolating LibCorr3D model objects for travel...
Definition: LibCorr3D.h:117
int getCurrentErrorCode() const
Return current error code.
Definition: LibCorr3D.h:659
const GeoTessInterpolatorType & getGeographicInterpolatorType() const
Returns the current geographic interpolator type.
Definition: LibCorr3D.h:532
bool getModelResult(int handle, double &modelValue, double &modelUncertainty)
The access function used to retrieve the model attribute and associated uncertainty results at the cu...
int loadModel(const string &fname, const GeoTessOptimizationType &optimizationType=GeoTessOptimizationType::SPEED)
Loads a new model from the specified file and returns an associated handle to the caller for later ac...
Definition: LibCorr3D.h:349
const double * getCurrentInterpolationLocation() const
Retrieve the current interpolation location as a unit vector.
Definition: LibCorr3D.h:393
const string & getOldRootPath() const
Returns the old (LibCorr2D) path corrections root path to the caller.
Definition: LibCorr3D.h:607
const string & getOldRelGridPath() const
Returns the path where all old LibCorr2D tessellation files are stored relative to the old root path ...
Definition: LibCorr3D.h:631
LibCorr3DModel * getModel(int handle)
void setInterpolator(GeoTessInterpolatorType const *intrpGeographic, GeoTessInterpolatorType const *intrpRadial)
Sets the geographic and radial interpolators to the specified types.
void removeModel(int handle)
Removes the specified model from the list of supported models and deletes it from memory.
double getCurrentInterpolationLat()
Retrieve the latitude of the current interpolation location in degrees.
Definition: LibCorr3D.h:402
int loadModel(const string &fname, vector< int > &attributeFilter, const GeoTessOptimizationType &optimizationType=GeoTessOptimizationType::SPEED)
Loads a new model from the specified file and returns an associated handle to the caller for later ac...
const string & getRootPath() const
Returns the primary (new GeoTess) root path to the caller.
Definition: LibCorr3D.h:594
virtual ~LibCorr3D()
Destructor.
const GeoTessInterpolatorType & getRadialInterpolatorType() const
Returns the current geographic interpolator type.
Definition: LibCorr3D.h:541
double getCurrentInterpolationRadius()
Retrieve the radius of the current interpolation location in km .
Definition: LibCorr3D.h:420
string getCurrentInterpolationLocation()
Retrieve a string representation of the current interpolation location (lon, lat, depth,...
Definition: LibCorr3D.h:449
LibCorr3D(const string &newRootPath, const string &oldRootPath)
Standard constructor.
const string & getCurrentErrorMessage() const
Return the errorMessage generated by the most recent call to getModelResult().
Definition: LibCorr3D.h:669
const string & getRelGridPath() const
Returns the path where all the grid files are stored (new GeoTess) relative to the input root path (l...
Definition: LibCorr3D.h:619
LONG_INT getMemory()
Return the amount of memory currently occupied by this LibCorr3D object, including all of the LibCorr...
static string getVersion()
Definition: LibCorr3D.h:294
LibCorr3D(const string &rootPath)
Standard constructor.
LibCorr3D * setInterpolationLocation(double lon, double lat, double depth=0.0, double time=NA_VALUE)
Sets the current interpolation location/time.
Definition: LibCorr3D.h:472
double getCurrentInterpolationLon()
Retrieve the longitude of the current interpolation location in degrees.
Definition: LibCorr3D.h:411
LibCorr3D(const string &newRootPath, const string &newRelGridPath, const string &oldRootPath, const string &oldRelGridPath)
Standard constructor.
double getCurrentInterpolationDepth()
Retrieve the depth of the current interpolation location in km .
Definition: LibCorr3D.h:429
LibCorr3D * setInterpolationLocation(double *unitVector, double radius=-1., double time=NA_VALUE)
Sets the current interpolation location/time.
Definition: LibCorr3D.h:502
double getCurrentInterpolationTime()
Retrieve the epoch time of the current interpolation location in seconds since 1970.
Definition: LibCorr3D.h:438
This is a LibCorr3D extension of the GeoTessModel for use by LibCorr3D.
Definition: LibCorr3DModel.h:85