GeoTessCPP  2.6.1
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessModel.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 GEOTESSMODEL_OBJECT_H
37 #define GEOTESSMODEL_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
48 using namespace std;
49 
50 // **** _LOCAL INCLUDES_ *******************************************************
51 
52 #include "CPPUtils.h"
53 #include "GeoTessUtils.h"
55 #include "GeoTessException.h"
56 #include "GeoTessPointMap.h"
57 #include "GeoTessProfileSurface.h"
58 #include "GeoTessProfileEmpty.h"
60 #include "GeoTessProfileType.h"
61 #include "EarthShape.h"
62 
63 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
64 
65 namespace geotess
66 {
67 
68 // **** _FORWARD REFERENCES_ ***************************************************
69 
70 class GeoTessPosition;
71 class GeoTessGrid;
72 class GeoTessMetaData;
73 class GeoTessOptimizationType;
74 class GeoTessProfile;
75 class IFStreamAscii;
76 class IFStreamBinary;
77 
78 // **** _CLASS DEFINITION_ *****************************************************
79 
120 {
122 
123 protected:
124 
136  static map<string, GeoTessGrid*> reuseGridMap;
137 
141  GeoTessGrid* grid;
142 
147  GeoTessProfile*** profiles;
148 
165  GeoTessMetaData* metaData;
166 
172  GeoTessPointMap* pointMap;
173 
177  void deleteProfiles();
178 
182  void loadModelAscii(const string& inputFile, const string& relGridFilePath);
183 
193  virtual void loadModelAscii(IFStreamAscii& input, const string& inputDirectory,
194  const string& relGridFilePath);
195 
203  void loadModelBinary(const string& inputFile, const string& relGridFilePath);
204 
213  virtual void loadModelBinary(IFStreamBinary& input, const string& inputDirectory,
214  const string& relGridFilePath);
215 
225  void writeModelAscii(const string& outputFile, const string& gridFileName);
226 
236  virtual void writeModelAscii(IFStreamAscii& output, const string& gridFileName);
237 
247  void writeModelBinary(const string& outputFile, const string& gridFileName);
248 
258  virtual void writeModelBinary(IFStreamBinary& output, const string& gridFileName);
259 
272  template<class T>
273  void loadGrid(T& input, const string& inputDirectory,
274  const string& relGridFilePath, const string& gridFileName,
275  const string& gridID, const string& funcName)
276  {
277  // process grid
278 
279  grid = NULL;
280  map<string, GeoTessGrid*>::iterator it = reuseGridMap.find(gridID);
281  if (it != reuseGridMap.end())
282  grid = it->second;
283 
284  if (gridFileName == "*")
285  {
286  // load the grid from this input file. The grid has to be read from the
287  // file, even a reference was retrieved from the reuseGridMap, so that the
288  // file is positioned where classes that extend GeoTessModel can read
289  // additional data.
290  GeoTessGrid* g = new GeoTessGrid(input);
291  if (!grid)
292  {
293  grid = g;
294 
295  grid->setGridInputFile(metaData->getInputModelFile());
296 
297  if (metaData->isGridReuseOn())
298  reuseGridMap[gridID] = grid;
299  }
300  else
301  delete g;
302  }
303  else if (!grid)
304  {
305  // build the name of the grid file using the input directory and
306  // the relative path to the grid file. Assume that both
307  // inputDirectory and relGridFilePath may be null or empty.
308  string gridFil = gridFileName;
309  if (relGridFilePath != "")
310  gridFil = CPPUtils::insertPathSeparator(relGridFilePath, gridFileName);
311  if (inputDirectory != "")
312  gridFil = CPPUtils::insertPathSeparator(inputDirectory, gridFil);
313 
314  grid = new GeoTessGrid();
315  grid->loadGrid(gridFil);
316  if (metaData->isGridReuseOn())
317  reuseGridMap[gridID] = grid;
318 
319  // throw an error if the grid ID's are not equal
320 
321  if (grid->getGridID() != gridID)
322  {
323  ostringstream os;
324  os << endl << "ERROR in GeoTessModel::" + funcName << endl
325  << "gridIDs in model file and existingGrid are not equal: "
326  << endl << " Model File gridID = " << gridID << endl
327  << " Grid File gridID = " << grid->getGridID() << endl;
328  throw GeoTessException(os, __FILE__, __LINE__, 1002);
329  }
330  }
331 
332  // add a reference to the grid and build the point map
333 
334  grid->addReference();
335  }
336 
337 private:
338 
339  void constructor(const string& gridFileName, GeoTessGrid* grid, GeoTessMetaData* metaData);
340 
342 
343 public:
344 
350 
372  GeoTessModel(const string& inputFile, const string& relativeGridPath);
373 
386  GeoTessModel(const string& modelInputFile);
387 
394  GeoTessModel(vector<int>& attributeFilter);
395 
419  GeoTessModel(const string& inputFile, const string& relativeGridPath,
420  vector<int>& attributeFilter);
421 
436  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter);
437 
467  GeoTessModel(const string& gridFileName, GeoTessMetaData* metaData);
468 
504 
508  virtual ~GeoTessModel();
509 
514  virtual string class_name() { return "GeoTessModel"; }
515 
527  GeoTessModel* loadModel(const string& inputFile, const string& relGridFilePath = "");
528 
535  static bool isGeoTessModel(const string& fileName);
536 
544  static string getClassName(const string& fileName, const string& relGridFilePath = ".");
545 
560  virtual LONG_INT getMemory()
561  {
562  LONG_INT memory = (LONG_INT)sizeof(GeoTessModel);
563 
564  memory += metaData->getMemory();
565 
566  if (profiles)
567  for (int i=0; i<getNVertices(); ++i)
568  for (int j=0; j<getNLayers(); ++j)
569  if (profiles[i][j])
570  memory += profiles[i][j]->getMemory();
571  if (pointMap)
572  memory += pointMap->getMemory();
573  return memory;
574  }
575 
583  {
584  // this ignores some memory allocated to support the map. It is complicated and
585  // platform dependent. Also probably small compared to the size of the Grids.
586  LONG_INT memory = sizeof(map<string, GeoTessGrid*>);
587 
588  memory += (LONG_INT) (reuseGridMap.size() * (sizeof(string) + sizeof(GeoTessGrid*)));
589 
590  for (map<string, GeoTessGrid*>::iterator it = reuseGridMap.begin(); it != reuseGridMap.end(); it++)
591  memory += (LONG_INT)it->first.length() + it->second->getMemory();
592 
593  return memory;
594  }
595 
602  static int getReuseGridMapSize() { return reuseGridMap.size(); }
603 
609  static void clearReuseGrid() { reuseGridMap.clear(); }
610 
639  EarthShape& getEarthShape() { return metaData->getEarthShape(); }
640 
667  void setEarthShape(const string& earthShapeName) { metaData->setEarthShape(earthShapeName); }
668 
673  const GeoTessGrid& getGrid() const { return *grid; }
674 
679  GeoTessGrid& getGrid(){ return *grid; }
680 
688  GeoTessMetaData& getMetaData() { return *metaData; }
689 
699 
714 
729  const GeoTessInterpolatorType& radialType);
730 
735  int getNVertices() const { return grid->getNVertices(); }
736 
741  int getNLayers() const { return metaData->getNLayers(); }
742 
750  int getNRadii(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNRadii(); }
751 
759  int getNData(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNData(); }
760 
765  int getNAttributes() { return metaData->getNAttributes(); }
766 
774  double getRadius(int vertexId, int layerId, int nodeId)
775  { return profiles[vertexId][layerId]->getRadius(nodeId); }
776 
785  double getDepth(int vertexId, int layerId, int nodeId)
786  { return getEarthShape().getEarthRadius(grid->getVertex(vertexId))
787  - profiles[vertexId][layerId]->getRadius(nodeId); }
788 
798  double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
799  {
800  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
801  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
802  }
803 
813  float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
814  {
815  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
816  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
817  }
818 
828  LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
829  {
830  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
831  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
832  }
833 
843  int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
844  {
845  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
846  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
847  }
848 
858  short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
859  {
860  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
861  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
862  }
863 
873  byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
874  {
875  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
876  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
877  }
878 
888  template<typename T>
889  void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
890  { profiles[vertexId][layerId]->getData(nodeId)->setValue(attributeIndex, value); }
891 
897  double getRadius(int pointIndex)
898  { return getPointMap()->getPointRadius(pointIndex); }
899 
906  double getDepth(int pointIndex)
907  { return getPointMap()->getPointDepth(pointIndex); }
908 
916  double getValueDouble(int pointIndex, int attributeIndex)
917  {
918  GeoTessData* data = getPointMap()->getPointData(pointIndex);
919  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
920  }
921 
929  float getValueFloat(int pointIndex, int attributeIndex)
930  {
931  GeoTessData* data = getPointMap()->getPointData(pointIndex);
932  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
933  }
934 
942  LONG_INT getValueLong(int pointIndex, int attributeIndex)
943  {
944  GeoTessData* data = getPointMap()->getPointData(pointIndex);
945  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
946  }
947 
955  int getValueInt(int pointIndex, int attributeIndex)
956  {
957  GeoTessData* data = getPointMap()->getPointData(pointIndex);
958  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
959  }
960 
968  short getValueShort(int pointIndex, int attributeIndex)
969  {
970  GeoTessData* data = getPointMap()->getPointData(pointIndex);
971  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
972  }
973 
981  byte getValueByte(int pointIndex, int attributeIndex)
982  {
983  GeoTessData* data = getPointMap()->getPointData(pointIndex);
984  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
985  }
986 
994  template<typename T>
995  void setValue(int pointIndex, int attributeIndex, T value)
996  {
997  GeoTessData* data = getPointMap()->getPointData(pointIndex);
998  if (data != NULL) data->setValue(attributeIndex, value);
999  }
1000 
1006  int getNPoints() { return getPointMap()->size(); }
1007 
1016  virtual bool operator == (const GeoTessModel& other) const;
1017 
1026  virtual bool operator != (const GeoTessModel& other) const { return !(*this == other); } ;
1027 
1028  bool is2D()
1029  {
1030  return getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE
1031  || getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE_EMPTY;
1032  }
1033 
1034  bool is3D()
1035  {
1036  return !is2D();
1037  }
1038 
1057  {
1058  if (!pointMap->isPopulated())
1059  pointMap->setActiveRegion();
1060  return pointMap;
1061  }
1062 
1071  const set<int>& getConnectedVertices(int layerIndex)
1072  {
1073  return grid->getVertexIndicesTopLevel(metaData->getTessellation(layerIndex));
1074  }
1075 
1082  {
1083  pointMap->setActiveRegion();
1084  }
1085 
1098  void setActiveRegion(const string& polygon)
1099  {
1100  pointMap->setActiveRegion(polygon);
1101  }
1102 
1115  {
1116  if (polygon == NULL)
1117  pointMap->setActiveRegion();
1118  else
1119  pointMap->setActiveRegion(polygon);
1120  }
1121 
1130  GeoTessPolygon* getPolygon() { return pointMap->getPolygon(); }
1131 
1140  void getLayerCount(bool activeOnly, int* layerCount)
1141  {
1142  for (int layer=0; layer<getNLayers(); ++layer)
1143  layerCount[layer] = 0;
1144 
1145  GeoTessProfile** pp;
1146  GeoTessProfile* p;
1147  for (int v=0; v<getNVertices(); ++v)
1148  {
1149  pp = profiles[v];
1150  for (int layer=0; layer<getNLayers(); ++layer)
1151  {
1152  if (activeOnly)
1153  {
1154  p = pp[layer];
1155  for (int n=0; n<p->getNData(); ++n)
1156  if (p->getPointIndex(n) >= 0)
1157  ++layerCount[layer];
1158  }
1159  else
1160  layerCount[layer] += pp[layer]->getNData();
1161  }
1162  }
1163  }
1164 
1172  GeoTessProfile* getProfile(int vertex, int layer)
1173  {
1174  return profiles[vertex][layer];
1175  }
1176 
1184  {
1185  return profiles[vertex];
1186  }
1187 
1192  GeoTessProfile*** getProfiles() const { return profiles; }
1193 
1204  void setProfile(int vertex, int layer, GeoTessProfile* profile);
1205 
1219  template<typename T>
1220  void setProfile(int vertex, int layer, vector<float>& radii, vector<vector<T> >& values)
1221  {
1222  if (getConnectedVertices(layer).count(vertex) == 1)
1223  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, values));
1224  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1]));
1225  }
1226 
1242  template<typename T>
1243  void setProfile(const int& vertex, const int& layer,
1244  float* radii, const int& nRadii,
1245  T** values, const int& nNodes, const int& nAttributes)
1246  {
1247  if (getConnectedVertices(layer).count(vertex) == 1)
1248  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, nRadii, values, nNodes, nAttributes));
1249  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1]));
1250  }
1251 
1260  void setProfile(int vertex, int layer, vector<float>& radii)
1261  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1])); }
1262 
1272  template<typename T>
1273  void setProfile(const int& vertex, const int& layer, float* radii, const int& nRadii)
1274  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1])); }
1275 
1284  template<typename T>
1285  void setProfile(const int& vertex, vector<T>& values)
1286  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values))); }
1287 
1297  template<typename T>
1298  void setProfile(const int& vertex, T* values, const int& nAttributes)
1299  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values, nAttributes))); }
1300 
1306  void setProfile(const int& vertex)
1307  { setProfile(vertex, 0, new GeoTessProfileSurfaceEmpty()); }
1308 
1323  void writeModel(const string& outputFile, const string& gridFileName = "*");
1324 
1329  string toString();
1330 
1338  void getLayerCount(vector<int>& layerCount, const bool& activeOnly)
1339  {
1340  layerCount.resize(metaData->getNLayers(), 0);
1341 
1342  GeoTessProfile** pp;
1343  GeoTessProfile* p;
1344  for (int vtx=0; vtx<getNVertices(); ++vtx)
1345  {
1346  pp = profiles[vtx];
1347  for (int layer = 0; layer < metaData->getNLayers(); ++layer)
1348  if (activeOnly)
1349  {
1350  p = pp[layer];
1351  for (int n = 0; n < p->getNData(); ++n)
1352  if (p->getPointIndex(n) >= 0)
1353  ++layerCount[layer];
1354  }
1355  else
1356  layerCount[layer] += pp[layer]->getNData();
1357  }
1358  }
1359 
1367  void profileCount(vector< vector<int> >& count)
1368  {
1369  count.clear();
1370 
1371  getPointMap();
1372 
1373  // this is total number of profiles of each type, independent of layer index.
1374  vector<int> totalCount;
1375  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1376  totalCount.push_back(0);
1377 
1378  for (int layer = 0; layer < getNLayers(); ++layer)
1379  {
1380  vector<int> typeCount;
1381 
1382  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1383  typeCount.push_back(0);
1384 
1385  count.push_back(typeCount);
1386  }
1387 
1388  for (int layer = 0; layer < getNLayers(); ++layer)
1389  {
1390  for (int vertex = 0; vertex < metaData->getNVertices(); ++vertex)
1391  {
1392  int pType = profiles[vertex][layer]->getType().ordinal();
1393  count[layer][pType] += 1;
1394  totalCount[pType] += 1;
1395  }
1396  }
1397 
1398  count.push_back(totalCount);
1399  }
1400 
1434  template<typename T>
1435  void initializeData(const vector<string>& attributeNames,
1436  const vector<string>& attributeUnits, T fillValue)
1437  {
1438  if (profiles == NULL)
1439  {
1440  ostringstream os;
1441  os << endl << "ERROR in GeoTessModel::initializeData" << endl
1442  << "Attempting to initialize the model data before Profiles" << endl
1443  << "have been specified (profiles == NULL)" << endl;
1444  throw GeoTessException(os, __FILE__, __LINE__, 1001);
1445  }
1446 
1447  const GeoTessDataType& newDataType = GeoTessDataType::getDataType(fillValue);
1448  int nAttributesNew = attributeNames.size();
1449 
1450  int newDataTypeOrdinal = newDataType.ordinal();
1451  int oldDataTypeOrdinal = metaData->getDataType().ordinal();
1452 
1453  // if neither the dataType or the number of attributes has changed, there is no need to
1454  // copy the data. The only thing that happens is that the attributeNames or attributeUnits might change.
1455  if (newDataTypeOrdinal != oldDataTypeOrdinal || nAttributesNew != metaData->getNAttributes())
1456  {
1457  // initialize an array of the new dataType with number of elements
1458  // equal to the number of new attributes and populate it with fillValue.
1459  T* newValues = new T[nAttributesNew];
1460  for (int i=0; i<nAttributesNew; ++i)
1461  newValues[i] = fillValue;
1462 
1463  GeoTessProfile* profile;
1464  vector<GeoTessData*> data;
1465  for (int v = 0; v < getNVertices(); ++v)
1466  for (int lid = 0; lid < getNLayers(); ++lid)
1467  {
1468  profile = profiles[v][lid];
1469  data.reserve(profile->getNData());
1470  data.clear();
1471  for (int n = 0; n < profile->getNData(); ++n)
1472  {
1473  profile->getData(n)->getValues(newValues, nAttributesNew);
1474  data.push_back(GeoTessData::getData(newValues, nAttributesNew));
1475  }
1476  // set new entries into profile and continue
1477  profile->setData(data);
1478  }
1479  delete[] newValues;
1480  }
1481 
1482  metaData->setDataType(newDataType);
1483 
1484  metaData->setAttributes(attributeNames, attributeUnits);
1485  }
1486 
1499  template<typename T>
1500  void initializeData(const string& attributeNames,
1501  const string& attributeUnits, T fillValue)
1502  {
1503  vector<string> names;
1504  CPPUtils::tokenizeString(attributeNames, ";", names);
1505  vector<string> units;
1506  CPPUtils::tokenizeString(attributeUnits, ";", units);
1507  initializeData(names, units, fillValue);
1508  }
1509 
1534  void getWeights(const double* pointA, const double* pointB, const double& pointSpacing, const double& radius,
1535  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1536 
1560  void getWeights(GeoTessGreatCircle& greatCircle, const double& pointSpacing, const double& radius,
1561  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1562 
1586  void getWeights(const vector<double*>& rayPath,
1587  const vector<double>& radii,
1588  const vector<int>& layerIds,
1589  const GeoTessInterpolatorType& horizontalType,
1590  const GeoTessInterpolatorType& radialType,
1591  map<int, double>& weights);
1592 
1617  void getWeights(double** rayPath, double* radii, int* layerIds, const int& numPoints,
1618  const GeoTessInterpolatorType& horizontalType,
1619  const GeoTessInterpolatorType& radialType,
1620  map<int, double>& weights);
1621 
1634  double getPathIntegral(const int& attribute, const map<int, double>& weights);
1635 
1669  double getPathIntegral(const int& attribute,
1670  double** rayPath, double* radii, int* layerIds, const int& numPoints,
1671  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1672  map<int, double>* weights = NULL);
1673 
1706  double getPathIntegral(const int& attribute,
1707  const vector<double*>& rayPath, const vector<double>& radii, const vector<int>& layerIds,
1708  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1709  map<int, double>* weights = NULL);
1710 
1746  double getPathIntegral2D(const int& attribute,
1747  const double* firstPoint, const double* lastPoint, double pointSpacing,
1748  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1749  map<int, double>* weights = NULL);
1750 
1785  double getPathIntegral2D(const int& attribute,
1786  GeoTessGreatCircle& greatCircle, double pointSpacing,
1787  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1788  map<int, double>* weights = NULL);
1789 
1791 
1792  // the following constructors are all deprecated because GeoTessOptimization is no longer used.
1793  // GeoTess is always optimized for speed.
1794  GeoTessModel(const GeoTessOptimizationType* optimization);
1795  GeoTessModel(const string& inputFile, const string& relativeGridPath, const GeoTessOptimizationType* optimization);
1796  GeoTessModel(const string& modelInputFile, const GeoTessOptimizationType* optimization);
1797  GeoTessModel(vector<int>& attributeFilter, const GeoTessOptimizationType* optimization);
1798  GeoTessModel(const string& inputFile, const string& relativeGridPath,
1799  vector<int>& attributeFilter, const GeoTessOptimizationType* optimization);
1800  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter,
1801  const GeoTessOptimizationType* optimization);
1802 
1803 // // The following getWeight() and getPathIntegral() functions are deprecated.
1804 // // They were included in GeoTessModel v2.1.1 but were reconfigured in v2.2.0.
1805 // // They are included here for backward compatibility, but will not appear in the documentation.
1806 // void getWeights(const vector<double*>& rayPath, const vector<double>& radii,
1807 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1808 // { vector<int> layerIds; getWeights(rayPath, radii, layerIds, ht, rt, weights);}
1809 //
1810 // void getWeights(double** rayPath, double* radii, const int& numPoints,
1811 // const GeoTessInterpolatorType& ht,const GeoTessInterpolatorType& rt,map<int, double>& weights)
1812 // { getWeights(rayPath, radii, NULL, numPoints, ht, rt, weights);}
1813 //
1814 // double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1815 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt)
1816 // { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt); }
1817 //
1818 // double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1819 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1820 // { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt, &weights); }
1821 //
1822 // double getPathIntegral2D(const int& attribute, const bool& reciprocal,
1823 // const double* firstPoint, const double* lastPoint, const double& pointSpacing,
1824 // const double& earthRadius,
1825 // const GeoTessInterpolatorType& horizontalType, map<int, double>& weights)
1826 // { return getPathIntegral2D(attribute, reciprocal, firstPoint, lastPoint, pointSpacing, earthRadius, horizontalType, &weights); }
1827 
1828 
1834  bool testLayerRadii();
1835 
1836 
1838 
1839 };
1840 // end class GeoTessModel
1841 
1842 }// end namespace geotess
1843 
1844 #endif // GEOTESSMODEL_OBJECT_H
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
#define LONG_INT
Definition: CPPGlobals.h:111
Defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and be...
Definition: EarthShape.h:86
Abstract base class that manages the data values attached to a single grid point.
Definition: GeoTessData.h:76
virtual GeoTessData & setValue(int attributeIndex, double v)
virtual byte getByte(int attributeIndex) const
virtual float getFloat(int attributeIndex) const
virtual double getDouble(int attributeIndex) const
virtual LONG_INT getLong(int attributeIndex) const
virtual int getInt(int attributeIndex) const
virtual void getValues(double values[], const int &n)
virtual short getShort(int attributeIndex) const
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
An exception class for all GeoTess objects.
Manages information about a great circle path that extends from one point to another point,...
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:167
const double * getVertex(int vertex) const
Definition: GeoTessGrid.h:630
GeoTessGrid * loadGrid(const string &inputFile)
const set< int > & getVertexIndicesTopLevel(const int &tessId)
Definition: GeoTessGrid.h:813
void setGridInputFile(const string &gridFile)
Definition: GeoTessGrid.h:605
int getNVertices() const
Definition: GeoTessGrid.h:820
static string getGridID(const string &fileName)
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...
Basic metadata information about a GeoTessModel.
const GeoTessDataType & getDataType() const
const string & getInputModelFile() const
void setDataType(const GeoTessDataType &dt)
void setEarthShape(const string &earthShapeName)
EarthShape & getEarthShape()
void setAttributes(const string &nms, const string &unts)
int getTessellation(int layer) const
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
Definition: GeoTessModel.h:120
void setProfile(int vertex, int layer, GeoTessProfile *profile)
GeoTessModel(const string &inputFile, const string &relativeGridPath)
GeoTessProfile *** getProfiles() const
GeoTessGrid & getGrid()
Definition: GeoTessModel.h:679
int getNData(int vertexId, int layerId)
Definition: GeoTessModel.h:759
int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:843
void profileCount(vector< vector< int > > &count)
void setActiveRegion(const string &polygon)
void setEarthShape(const string &earthShapeName)
Definition: GeoTessModel.h:667
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii, T **values, const int &nNodes, const int &nAttributes)
void getWeights(const double *pointA, const double *pointB, const double &pointSpacing, const double &radius, const GeoTessInterpolatorType &horizontalType, map< int, double > &weights)
int getNVertices() const
Definition: GeoTessModel.h:735
static string getClassName(const string &fileName, const string &relGridFilePath=".")
short getValueShort(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:968
short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:858
void getLayerCount(bool activeOnly, int *layerCount)
GeoTessModel(GeoTessGrid *grid, GeoTessMetaData *metaData)
void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
Definition: GeoTessModel.h:889
GeoTessPosition * getPosition(const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType)
void getWeights(const vector< double * > &rayPath, const vector< double > &radii, const vector< int > &layerIds, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > &weights)
const set< int > & getConnectedVertices(int layerIndex)
void initializeData(const vector< string > &attributeNames, const vector< string > &attributeUnits, T fillValue)
GeoTessModel(const string &inputFile, const string &relativeGridPath, vector< int > &attributeFilter)
virtual LONG_INT getMemory()
Definition: GeoTessModel.h:560
void setActiveRegion(GeoTessPolygon *polygon)
void writeModel(const string &outputFile, const string &gridFileName="*")
void setProfile(const int &vertex)
float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:813
double getPathIntegral(const int &attribute, const map< int, double > &weights)
GeoTessPosition * getPosition()
GeoTessModel(const string &modelInputFile)
double getRadius(int vertexId, int layerId, int nodeId)
Definition: GeoTessModel.h:774
void setProfile(const int &vertex, vector< T > &values)
int getNRadii(int vertexId, int layerId)
Definition: GeoTessModel.h:750
byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:873
GeoTessMetaData & getMetaData()
Definition: GeoTessModel.h:688
GeoTessPosition * getPosition(const GeoTessInterpolatorType &horizontalType)
GeoTessModel(const string &gridFileName, GeoTessMetaData *metaData)
double getDepth(int pointIndex)
Definition: GeoTessModel.h:906
GeoTessModel * loadModel(const string &inputFile, const string &relGridFilePath="")
double getPathIntegral2D(const int &attribute, GeoTessGreatCircle &greatCircle, double pointSpacing, double earthRadius, const GeoTessInterpolatorType &horizontalType, map< int, double > *weights=NULL)
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii)
EarthShape & getEarthShape()
Definition: GeoTessModel.h:639
static LONG_INT getReuseGridMapMemory()
Definition: GeoTessModel.h:582
GeoTessPolygon * getPolygon()
void setProfile(int vertex, int layer, vector< float > &radii, vector< vector< T > > &values)
virtual string class_name()
Definition: GeoTessModel.h:514
static void clearReuseGrid()
Definition: GeoTessModel.h:609
double getPathIntegral2D(const int &attribute, const double *firstPoint, const double *lastPoint, double pointSpacing, double earthRadius, const GeoTessInterpolatorType &horizontalType, map< int, double > *weights=NULL)
float getValueFloat(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:929
GeoTessProfile * getProfile(int vertex, int layer)
double getRadius(int pointIndex)
Definition: GeoTessModel.h:897
void getWeights(double **rayPath, double *radii, int *layerIds, const int &numPoints, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > &weights)
static int getReuseGridMapSize()
Definition: GeoTessModel.h:602
LONG_INT getValueLong(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:942
void setValue(int pointIndex, int attributeIndex, T value)
Definition: GeoTessModel.h:995
double getDepth(int vertexId, int layerId, int nodeId)
Definition: GeoTessModel.h:785
static bool isGeoTessModel(const string &fileName)
byte getValueByte(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:981
void getLayerCount(vector< int > &layerCount, const bool &activeOnly)
double getPathIntegral(const int &attribute, double **rayPath, double *radii, int *layerIds, const int &numPoints, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > *weights=NULL)
int getValueInt(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:955
GeoTessPointMap * getPointMap()
int getNLayers() const
Definition: GeoTessModel.h:741
GeoTessModel(vector< int > &attributeFilter)
GeoTessProfile ** getProfiles(int vertex)
LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:828
double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:798
const GeoTessGrid & getGrid() const
Definition: GeoTessModel.h:673
void getWeights(GeoTessGreatCircle &greatCircle, const double &pointSpacing, const double &radius, const GeoTessInterpolatorType &horizontalType, map< int, double > &weights)
void initializeData(const string &attributeNames, const string &attributeUnits, T fillValue)
double getPathIntegral(const int &attribute, const vector< double * > &rayPath, const vector< double > &radii, const vector< int > &layerIds, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > *weights=NULL)
void setProfile(int vertex, int layer, vector< float > &radii)
GeoTessModel(const string &modelInputFile, vector< int > &attributeFilter)
void setProfile(const int &vertex, T *values, const int &nAttributes)
double getValueDouble(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:916
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
Relationships between vertices (2D positions in a tessellation), nodes (1D positions along a radial P...
GeoTessPolygon * getPolygon()
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Information about an interpolated point at an arbitrary position in a model.
A Profile object that defines two radii at the bottom and top of the associated layer,...
Abstract class that manages the radii and data values that span a single layer associated with a sing...
virtual int getNRadii() const
virtual const GeoTessProfileType & getType() const
virtual LONG_INT getMemory()
virtual float getRadius(int i) const
virtual int getNData() const
virtual void setData(int index, GeoTessData *data)
virtual GeoTessData ** getData()
virtual int getPointIndex(int nodeIndex) const
A Profile object that defines a single Data object and no radius value.
A Profile object that defines a single Data object and no radius value.
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:81
Opens a file for binary read and write access.