GeoTessCPP  2.2
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 
189  void loadModelAscii(const string& inputFile, const string& relGridFilePath);
190 
207  virtual void loadModelAscii(IFStreamAscii& input, const string& inputDirectory,
208  const string& relGridFilePath);
209 
223  void loadModelBinary(const string& inputFile, const string& relGridFilePath);
224 
240  virtual void loadModelBinary(IFStreamBinary& input, const string& inputDirectory,
241  const string& relGridFilePath);
242 
252  void writeModelAscii(const string& outputFile, const string& gridFileName);
253 
263  virtual void writeModelAscii(IFStreamAscii& output, const string& gridFileName);
264 
274  void writeModelBinary(const string& outputFile, const string& gridFileName);
275 
285  virtual void writeModelBinary(IFStreamBinary& output, const string& gridFileName);
286 
299  template<class T>
300  void loadGrid(T& input, const string& inputDirectory,
301  const string& relGridFilePath, const string& gridFileName,
302  const string& gridID, const string& funcName)
303  {
304  // process grid
305 
306  grid = NULL;
307  map<string, GeoTessGrid*>::iterator it = reuseGridMap.find(gridID);
308  if (it != reuseGridMap.end())
309  grid = it->second;
310 
311  if (gridFileName == "*")
312  {
313  // load the grid from this input file. The grid has to be read from the
314  // file, even a reference was retrieved from the reuseGridMap, so that the
315  // file is positioned where classes that extend GeoTessModel can read
316  // additional data.
317  GeoTessGrid* g = new GeoTessGrid(input);
318  if (!grid)
319  {
320  grid = g;
321 
322  grid->setGridInputFile(metaData->getInputModelFile());
323 
324  if (metaData->isGridReuseOn())
325  reuseGridMap[gridID] = grid;
326  }
327  else
328  delete g;
329  }
330  else if (!grid)
331  {
332  // build the name of the grid file using the input directory and
333  // the relative path to the grid file. Assume that both
334  // inputDirectory and relGridFilePath may be null or empty.
335  string gridFil = gridFileName;
336  if (relGridFilePath != "")
337  gridFil = CPPUtils::insertPathSeparator(relGridFilePath, gridFileName);
338  if (inputDirectory != "")
339  gridFil = CPPUtils::insertPathSeparator(inputDirectory, gridFil);
340 
341  grid = new GeoTessGrid();
342  grid->loadGrid(gridFil);
343  if (metaData->isGridReuseOn())
344  reuseGridMap[gridID] = grid;
345 
346  // throw an error if the grid ID's are not equal
347 
348  if (grid->getGridID() != gridID)
349  {
350  ostringstream os;
351  os << endl << "ERROR in GeoTessModel::" + funcName << endl
352  << "gridIDs in model file and existingGrid are not equal: "
353  << endl << " Model File gridID = " << gridID << endl
354  << " Grid File gridID = " << grid->getGridID() << endl;
355  throw GeoTessException(os, __FILE__, __LINE__, 1002);
356  }
357  }
358 
359  // add a reference to the grid and build the point map
360 
361  grid->addReference();
362  }
363 
364 private:
365 
366  void constructor(const string& gridFileName, GeoTessGrid* grid, GeoTessMetaData* metaData);
367 
369 
370 public:
371 
376  GeoTessModel();
377 
399  GeoTessModel(const string& inputFile, const string& relativeGridPath);
400 
413  GeoTessModel(const string& modelInputFile);
414 
421  GeoTessModel(vector<int>& attributeFilter);
422 
446  GeoTessModel(const string& inputFile, const string& relativeGridPath,
447  vector<int>& attributeFilter);
448 
463  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter);
464 
494  GeoTessModel(const string& gridFileName, GeoTessMetaData* metaData);
495 
530  GeoTessModel(GeoTessGrid* grid, GeoTessMetaData* metaData);
531 
535  virtual ~GeoTessModel();
536 
541  static string class_name() { return "GeoTessModel"; }
542 
554  GeoTessModel* loadModel(const string& inputFile, const string& relGridFilePath = "");
555 
562  static bool isGeoTessModel(const string& fileName);
563 
578  virtual LONG_INT getMemory()
579  {
580  LONG_INT memory = (LONG_INT)sizeof(GeoTessModel);
581 
582  memory += metaData->getMemory();
583 
584  if (profiles)
585  for (int i=0; i<getNVertices(); ++i)
586  for (int j=0; j<getNLayers(); ++j)
587  if (profiles[i][j])
588  memory += profiles[i][j]->getMemory();
589  if (pointMap)
590  memory += pointMap->getMemory();
591  return memory;
592  }
593 
601  {
602  // this ignores some memory allocated to support the map. It is complicated and
603  // platform dependent. Also probably small compared to the size of the Grids.
604  LONG_INT memory = sizeof(map<string, GeoTessGrid*>);
605 
606  memory += (LONG_INT) (reuseGridMap.size() * (sizeof(string) + sizeof(GeoTessGrid*)));
607 
608  for (map<string, GeoTessGrid*>::iterator it = reuseGridMap.begin(); it != reuseGridMap.end(); it++)
609  memory += (LONG_INT)it->first.length() + it->second->getMemory();
610 
611  return memory;
612  }
613 
620  static int getReuseGridMapSize() { return reuseGridMap.size(); }
621 
627  static void clearReuseGrid() { reuseGridMap.clear(); }
628 
657  EarthShape& getEarthShape() { return metaData->getEarthShape(); }
658 
685  void setEarthShape(const string& earthShapeName) { metaData->setEarthShape(earthShapeName); }
686 
691  const GeoTessGrid& getGrid() const { return *grid; }
692 
697  GeoTessGrid& getGrid(){ return *grid; }
698 
706  GeoTessMetaData& getMetaData() { return *metaData; }
707 
716  GeoTessPosition* getPosition();
717 
731  GeoTessPosition* getPosition(const GeoTessInterpolatorType& horizontalType);
732 
746  GeoTessPosition* getPosition(const GeoTessInterpolatorType& horizontalType,
747  const GeoTessInterpolatorType& radialType);
748 
753  int getNVertices() const { return grid->getNVertices(); }
754 
759  int getNLayers() const { return metaData->getNLayers(); }
760 
768  int getNRadii(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNRadii(); }
769 
777  int getNData(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNData(); }
778 
783  int getNAttributes() { return metaData->getNAttributes(); }
784 
792  double getRadius(int vertexId, int layerId, int nodeId)
793  { return profiles[vertexId][layerId]->getRadius(nodeId); }
794 
803  double getDepth(int vertexId, int layerId, int nodeId)
804  { return getEarthShape().getEarthRadius(grid->getVertex(vertexId))
805  - profiles[vertexId][layerId]->getRadius(nodeId); }
806 
816  double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
817  {
818  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
819  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
820  }
821 
831  float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
832  {
833  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
834  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
835  }
836 
846  LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
847  {
848  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
849  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
850  }
851 
861  int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
862  {
863  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
864  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
865  }
866 
876  short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
877  {
878  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
879  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
880  }
881 
891  byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
892  {
893  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
894  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
895  }
896 
906  template<typename T>
907  void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
908  { profiles[vertexId][layerId]->getData(nodeId)->setValue(attributeIndex, value); }
909 
915  double getRadius(int pointIndex)
916  { return getPointMap()->getPointRadius(pointIndex); }
917 
924  double getDepth(int pointIndex)
925  { return getPointMap()->getPointDepth(pointIndex); }
926 
934  double getValueDouble(int pointIndex, int attributeIndex)
935  {
936  GeoTessData* data = getPointMap()->getPointData(pointIndex);
937  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
938  }
939 
947  float getValueFloat(int pointIndex, int attributeIndex)
948  {
949  GeoTessData* data = getPointMap()->getPointData(pointIndex);
950  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
951  }
952 
960  LONG_INT getValueLong(int pointIndex, int attributeIndex)
961  {
962  GeoTessData* data = getPointMap()->getPointData(pointIndex);
963  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
964  }
965 
973  int getValueInt(int pointIndex, int attributeIndex)
974  {
975  GeoTessData* data = getPointMap()->getPointData(pointIndex);
976  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
977  }
978 
986  short getValueShort(int pointIndex, int attributeIndex)
987  {
988  GeoTessData* data = getPointMap()->getPointData(pointIndex);
989  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
990  }
991 
999  byte getValueByte(int pointIndex, int attributeIndex)
1000  {
1001  GeoTessData* data = getPointMap()->getPointData(pointIndex);
1002  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
1003  }
1004 
1012  template<typename T>
1013  void setValue(int pointIndex, int attributeIndex, T value)
1014  {
1015  GeoTessData* data = getPointMap()->getPointData(pointIndex);
1016  if (data != NULL) data->setValue(attributeIndex, value);
1017  }
1018 
1024  int getNPoints() { return getPointMap()->size(); }
1025 
1034  virtual bool operator == (const GeoTessModel& other) const;
1035 
1044  virtual bool operator != (const GeoTessModel& other) const { return !(*this == other); } ;
1045 
1046  bool is2D()
1047  {
1048  return getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE
1049  || getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE_EMPTY;
1050  }
1051 
1052  bool is3D()
1053  {
1054  return !is2D();
1055  }
1056 
1075  {
1076  if (!pointMap->isPopulated())
1077  pointMap->setActiveRegion();
1078  return pointMap;
1079  }
1080 
1089  const set<int>& getConnectedVertices(int layerIndex)
1090  {
1091  return grid->getVertexIndicesTopLevel(metaData->getTessellation(layerIndex));
1092  }
1093 
1100  {
1101  pointMap->setActiveRegion();
1102  }
1103 
1116  void setActiveRegion(const string& polygon)
1117  {
1118  pointMap->setActiveRegion(polygon);
1119  }
1120 
1133  {
1134  if (polygon == NULL)
1135  pointMap->setActiveRegion();
1136  else
1137  pointMap->setActiveRegion(polygon);
1138  }
1139 
1148  GeoTessPolygon* getPolygon() { return pointMap->getPolygon(); }
1149 
1158  void getLayerCount(bool activeOnly, int* layerCount)
1159  {
1160  for (int layer=0; layer<getNLayers(); ++layer)
1161  layerCount[layer] = 0;
1162 
1163  GeoTessProfile** pp;
1164  GeoTessProfile* p;
1165  for (int v=0; v<getNVertices(); ++v)
1166  {
1167  pp = profiles[v];
1168  for (int layer=0; layer<getNLayers(); ++layer)
1169  {
1170  if (activeOnly)
1171  {
1172  p = pp[layer];
1173  for (int n=0; n<p->getNData(); ++n)
1174  if (p->getPointIndex(n) >= 0)
1175  ++layerCount[layer];
1176  }
1177  else
1178  layerCount[layer] += pp[layer]->getNData();
1179  }
1180  }
1181  }
1182 
1190  GeoTessProfile* getProfile(int vertex, int layer)
1191  {
1192  return profiles[vertex][layer];
1193  }
1194 
1202  {
1203  return profiles[vertex];
1204  }
1205 
1210  GeoTessProfile*** getProfiles() const { return profiles; }
1211 
1222  void setProfile(int vertex, int layer, GeoTessProfile* profile);
1223 
1237  template<typename T>
1238  void setProfile(int vertex, int layer, vector<float>& radii, vector<vector<T> >& values)
1239  {
1240  if (getConnectedVertices(layer).count(vertex) == 1)
1241  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, values));
1242  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1]));
1243  }
1244 
1260  template<typename T>
1261  void setProfile(const int& vertex, const int& layer,
1262  float* radii, const int& nRadii,
1263  T** values, const int& nNodes, const int& nAttributes)
1264  {
1265  if (getConnectedVertices(layer).count(vertex) == 1)
1266  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, nRadii, values, nNodes, nAttributes));
1267  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1]));
1268  }
1269 
1278  void setProfile(int vertex, int layer, vector<float>& radii)
1279  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1])); }
1280 
1290  template<typename T>
1291  void setProfile(const int& vertex, const int& layer, float* radii, const int& nRadii)
1292  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1])); }
1293 
1302  template<typename T>
1303  void setProfile(const int& vertex, vector<T>& values)
1304  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values))); }
1305 
1315  template<typename T>
1316  void setProfile(const int& vertex, T* values, const int& nAttributes)
1317  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values, nAttributes))); }
1318 
1324  void setProfile(const int& vertex)
1325  { setProfile(vertex, 0, new GeoTessProfileSurfaceEmpty()); }
1326 
1334  void writeModel(const string& outputFile) { writeModel(outputFile, "*"); }
1335 
1350  void writeModel(const string& outputFile, const string& gridFileName);
1351 
1356  string toString();
1357 
1365  void getLayerCount(vector<int>& layerCount, const bool& activeOnly)
1366  {
1367  layerCount.resize(metaData->getNLayers(), 0);
1368 
1369  GeoTessProfile** pp;
1370  GeoTessProfile* p;
1371  for (int vtx=0; vtx<getNVertices(); ++vtx)
1372  {
1373  pp = profiles[vtx];
1374  for (int layer = 0; layer < metaData->getNLayers(); ++layer)
1375  if (activeOnly)
1376  {
1377  p = pp[layer];
1378  for (int n = 0; n < p->getNData(); ++n)
1379  if (p->getPointIndex(n) >= 0)
1380  ++layerCount[layer];
1381  }
1382  else
1383  layerCount[layer] += pp[layer]->getNData();
1384  }
1385  }
1386 
1394  void profileCount(vector< vector<int> >& count)
1395  {
1396  count.clear();
1397 
1398  getPointMap();
1399 
1400  // this is total number of profiles of each type, independent of layer index.
1401  vector<int> totalCount;
1402  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1403  totalCount.push_back(0);
1404 
1405  for (int layer = 0; layer < getNLayers(); ++layer)
1406  {
1407  vector<int> typeCount;
1408 
1409  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1410  typeCount.push_back(0);
1411 
1412  count.push_back(typeCount);
1413  }
1414 
1415  for (int layer = 0; layer < getNLayers(); ++layer)
1416  {
1417  for (int vertex = 0; vertex < metaData->getNVertices(); ++vertex)
1418  {
1419  int pType = profiles[vertex][layer]->getType().ordinal();
1420  count[layer][pType] += 1;
1421  totalCount[pType] += 1;
1422  }
1423  }
1424 
1425  count.push_back(totalCount);
1426  }
1427 
1461  template<typename T>
1462  void initializeData(const vector<string>& attributeNames,
1463  const vector<string>& attributeUnits, T fillValue)
1464  {
1465  if (profiles == NULL)
1466  {
1467  ostringstream os;
1468  os << endl << "ERROR in GeoTessModel::initializeData" << endl
1469  << "Attempting to initialize the model data before Profiles" << endl
1470  << "have been specified (profiles == NULL)" << endl;
1471  throw GeoTessException(os, __FILE__, __LINE__, 1001);
1472  }
1473 
1474  const GeoTessDataType& newDataType = GeoTessDataType::getDataType(fillValue);
1475  int nAttributesNew = attributeNames.size();
1476 
1477  int newDataTypeOrdinal = newDataType.ordinal();
1478  int oldDataTypeOrdinal = metaData->getDataType().ordinal();
1479 
1480  // if neither the dataType or the number of attributes has changed, there is no need to
1481  // copy the data. The only thing that happens is that the attributeNames or attributeUnits might change.
1482  if (newDataTypeOrdinal != oldDataTypeOrdinal || nAttributesNew != metaData->getNAttributes())
1483  {
1484  // initialize an array of the new dataType with number of elements
1485  // equal to the number of new attributes and populate it with fillValue.
1486  T* newValues = new T[nAttributesNew];
1487  for (int i=0; i<nAttributesNew; ++i)
1488  newValues[i] = fillValue;
1489 
1490  GeoTessProfile* profile;
1491  vector<GeoTessData*> data;
1492  for (int v = 0; v < getNVertices(); ++v)
1493  for (int lid = 0; lid < getNLayers(); ++lid)
1494  {
1495  profile = profiles[v][lid];
1496  data.reserve(profile->getNData());
1497  data.clear();
1498  for (int n = 0; n < profile->getNData(); ++n)
1499  {
1500  profile->getData(n)->getValues(newValues, nAttributesNew);
1501  data.push_back(GeoTessData::getData(newValues, nAttributesNew));
1502  }
1503  // set new entries into profile and continue
1504  profile->setData(data);
1505  }
1506  delete[] newValues;
1507  }
1508 
1509  metaData->setDataType(newDataType);
1510 
1511  metaData->setAttributes(attributeNames, attributeUnits);
1512  }
1513 
1526  template<typename T>
1527  void initializeData(const string& attributeNames,
1528  const string& attributeUnits, T fillValue)
1529  {
1530  vector<string> names;
1531  CPPUtils::tokenizeString(attributeNames, ";", names);
1532  vector<string> units;
1533  CPPUtils::tokenizeString(attributeUnits, ";", units);
1534  initializeData(names, units, fillValue);
1535  }
1536 
1561  void getWeights(const double* pointA, const double* pointB, const double& pointSpacing, const double& radius,
1562  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1563 
1587  void getWeights(GeoTessGreatCircle& greatCircle, const double& pointSpacing, const double& radius,
1588  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1589 
1613  void getWeights(const vector<double*>& rayPath,
1614  const vector<double>& radii,
1615  const vector<int>& layerIds,
1616  const GeoTessInterpolatorType& horizontalType,
1617  const GeoTessInterpolatorType& radialType,
1618  map<int, double>& weights);
1619 
1644  void getWeights(double** rayPath, double* radii, int* layerIds, const int& numPoints,
1645  const GeoTessInterpolatorType& horizontalType,
1646  const GeoTessInterpolatorType& radialType,
1647  map<int, double>& weights);
1648 
1661  double getPathIntegral(const int& attribute, const map<int, double>& weights);
1662 
1696  double getPathIntegral(const int& attribute,
1697  double** rayPath, double* radii, int* layerIds, const int& numPoints,
1698  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1699  map<int, double>* weights = NULL);
1700 
1733  double getPathIntegral(const int& attribute,
1734  const vector<double*>& rayPath, const vector<double>& radii, const vector<int>& layerIds,
1735  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1736  map<int, double>* weights = NULL);
1737 
1773  double getPathIntegral2D(const int& attribute,
1774  const double* firstPoint, const double* lastPoint, double pointSpacing,
1775  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1776  map<int, double>* weights = NULL);
1777 
1812  double getPathIntegral2D(const int& attribute,
1813  GeoTessGreatCircle& greatCircle, double pointSpacing,
1814  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1815  map<int, double>* weights = NULL);
1816 
1818 
1819  // the following constructors are all deprecated because GeoTessOptimization is no longer used.
1820  // GeoTess is always optimized for speed.
1821  GeoTessModel(const GeoTessOptimizationType* optimization);
1822  GeoTessModel(const string& inputFile, const string& relativeGridPath, const GeoTessOptimizationType* optimization);
1823  GeoTessModel(const string& modelInputFile, const GeoTessOptimizationType* optimization);
1824  GeoTessModel(vector<int>& attributeFilter, const GeoTessOptimizationType* optimization);
1825  GeoTessModel(const string& inputFile, const string& relativeGridPath,
1826  vector<int>& attributeFilter, const GeoTessOptimizationType* optimization);
1827  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter,
1828  const GeoTessOptimizationType* optimization);
1829 
1830 // // The following getWeight() and getPathIntegral() functions are deprecated.
1831 // // They were included in GeoTessModel v2.1.1 but were reconfigured in v2.2.0.
1832 // // They are included here for backward compatibility, but will not appear in the documentation.
1833 // void getWeights(const vector<double*>& rayPath, const vector<double>& radii,
1834 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1835 // { vector<int> layerIds; getWeights(rayPath, radii, layerIds, ht, rt, weights);}
1836 //
1837 // void getWeights(double** rayPath, double* radii, const int& numPoints,
1838 // const GeoTessInterpolatorType& ht,const GeoTessInterpolatorType& rt,map<int, double>& weights)
1839 // { getWeights(rayPath, radii, NULL, numPoints, ht, rt, weights);}
1840 //
1841 // double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1842 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt)
1843 // { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt); }
1844 //
1845 // double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1846 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1847 // { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt, &weights); }
1848 //
1849 // double getPathIntegral2D(const int& attribute, const bool& reciprocal,
1850 // const double* firstPoint, const double* lastPoint, const double& pointSpacing,
1851 // const double& earthRadius,
1852 // const GeoTessInterpolatorType& horizontalType, map<int, double>& weights)
1853 // { return getPathIntegral2D(attribute, reciprocal, firstPoint, lastPoint, pointSpacing, earthRadius, horizontalType, &weights); }
1854 
1855 
1859  bool isSupportedFormatVersion(int frmtVrsn) { return (frmtVrsn == 1) ? true : false; }
1860 
1866  bool testLayerRadii();
1867 
1868 
1870 
1871 };
1872 // end class GeoTessModel
1873 
1874 }// end namespace geotess
1875 
1876 #endif // GEOTESSMODEL_OBJECT_H
GeoTessGrid * loadGrid(const string &inputFile)
Load GeoTessGrid object from a File.
void setActiveRegion()
Populates the PointMap such that every node in the entire model is within the active region...
GeoTessGrid & getGrid()
Return a reference to the grid object.
Definition: GeoTessModel.h:697
virtual int getNRadii() const
Get the number of radii that comprise this profile.
void setProfile(int vertex, int layer, vector< float > &radii, vector< vector< T > > &values)
Replace the Profile object at the specified vertex and layer with a new one.
Definition: GeoTessModel.h:1238
void setEarthShape(const string &earthShapeName)
Specify the name of the ellipsoid that is to be used to convert between geocentric and geographic lat...
Definition: GeoTessModel.h:685
virtual double getDouble(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a double value.
virtual float getFloat(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a float value.
void setAttributes(const string &nms, const string &unts)
Specify the names of all the layers that comprise the model.
Definition: GeoTessMetaData.h:810
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition: GeoTessPolygon.h:111
void setValue(int pointIndex, int attributeIndex, T value)
Modify the attribute value stored at the specified vertex, layer, node, attribute.
Definition: GeoTessModel.h:1013
Relationships between vertices (2D positions in a tessellation), nodes (1D positions along a radial P...
Definition: GeoTessPointMap.h:74
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurface.h:76
void getLayerCount(vector< int > &layerCount, const bool &activeOnly)
Retrieve the number of points in each layer of the model.
Definition: GeoTessModel.h:1365
const GeoTessGrid & getGrid() const
Return a reference to the grid object.
Definition: GeoTessModel.h:691
void setActiveRegion()
Set the active region such that it encompasses all the nodes in the model.
Definition: GeoTessModel.h:1099
LONG_INT getValueLong(int pointIndex, int attributeIndex)
Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a LONG_INT if ...
Definition: GeoTessModel.h:960
const double * getVertex(int vertex) const
Retrieve the unit vector that corresponds to the specified vertex.
Definition: GeoTessGrid.h:630
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurfaceEmpty.h:77
int getNData(int vertexId, int layerId)
Return the number of Data objects that are specified in the Profile at vertexId, layerId.
Definition: GeoTessModel.h:777
Information about an interpolated point at an arbitrary position in a model.
Definition: GeoTessPosition.h:101
void setProfile(const int &vertex, vector< T > &values)
Replace the Profile object at the specified vertex with a new one of type ProfileSurface, which supports 2D Earth models.
Definition: GeoTessModel.h:1303
short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
Return the value of the attribute at the specified vertexId, layerId, nodeId, attributeIndex, cast to a short if necessary.
Definition: GeoTessModel.h:876
int getNVertices() const
Retrieve the number of vertices in the 2D grid.
Definition: GeoTessMetaData.h:560
float getValueFloat(int pointIndex, int attributeIndex)
Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a float if nec...
Definition: GeoTessModel.h:947
Definition: ArrayReuse.h:55
bool isPopulated()
Determine whether or not this PointMap is populated.
Definition: GeoTessPointMap.h:215
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:79
int getTessellation(int layer) const
Retrieve the index of the tessellation that supports the specified layer.
Definition: GeoTessMetaData.h:683
LONG_INT getMemory()
Definition: GeoTessMetaData.h:312
virtual LONG_INT getLong(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a LONG_INT value...
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR, NATURAL_NEIGHBOR and CUBIC_SPLINE.
Definition: GeoTessInterpolatorType.h:71
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:166
int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
Return the value of the attribute at the specified vertexId, layerId, nodeId, attributeIndex, cast to a int if necessary.
Definition: GeoTessModel.h:861
EarthShape & getEarthShape()
Retrieve a reference to the ellipsoid that is stored in this GeoTessModel.
Definition: GeoTessMetaData.h:412
static void clearReuseGrid()
GeoTessModel will attempt to reuse grids that it has already loaded into memory when a new model trie...
Definition: GeoTessModel.h:627
bool is3D()
Definition: GeoTessModel.h:1052
double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
Return the value of the attribute at the specified vertexId, layerId, nodeId, attributeIndex, cast to a double if necessary.
Definition: GeoTessModel.h:816
int getNVertices() const
Returns the number of vertices in the vectices array.
Definition: GeoTessGrid.h:820
static string getGridID(const string &fileName)
Open the specified file using the appropriate format, and read only enough of the file to retrieve th...
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:67
void getLayerCount(bool activeOnly, int *layerCount)
Retrieve the number of points in each layer of the model.
Definition: GeoTessModel.h:1158
virtual GeoTessData ** getData()
Retrieve a shallow copy of the array of Data objects associated with this Profile.
void setActiveRegion(const string &polygon)
Set the active region to encompass only the nodes contained within the specified Polygon.
Definition: GeoTessModel.h:1116
int getNAttributes()
Return the number of attributes that are associated with each node in the model.
Definition: GeoTessModel.h:783
byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
Return the value of the attribute at the specified vertexId, layerId, nodeId, attributeIndex, cast to a byte if necessary.
Definition: GeoTessModel.h:891
GeoTessPolygon * getPolygon()
Retrieve the pointer to the Polygon or Polygon3D object that supports this PointMap.
Definition: GeoTessPointMap.h:200
virtual const GeoTessProfileType & getType() const
One of EMPTY, THIN, CONSTANT, NPOINT, SURFACE.
int getNLayers() const
Retrieve the number of layers represented in the model.
Definition: GeoTessMetaData.h:571
int getNAttributes() const
Retrieve the number of attributes supported by the model.
Definition: GeoTessMetaData.h:840
static LONG_INT getReuseGridMapMemory()
GeoTessModel will attempt to reuse grids that it has already loaded into memory when a new model trie...
Definition: GeoTessModel.h:600
Manages information about a great circle path that extends from one point to another point...
Definition: GeoTessGreatCircle.h:168
void setProfile(int vertex, int layer, vector< float > &radii)
Replace the Profile object at the specified vertex and layer with a new ProfileEmpty object...
Definition: GeoTessModel.h:1278
static int getReuseGridMapSize()
GeoTessModel will attempt to reuse grids that it has already loaded into memory when a new model trie...
Definition: GeoTessModel.h:620
double getDepth(int vertexId, int layerId, int nodeId)
Return the depth below surface of current EarthShape in km of the node at vertexId, layerId, nodeId.
Definition: GeoTessModel.h:803
byte getValueByte(int pointIndex, int attributeIndex)
Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a byte if nece...
Definition: GeoTessModel.h:999
bool is2D()
Definition: GeoTessModel.h:1046
const set< int > & getConnectedVertices(int layerIndex)
Return a reference to the set of the indexes of all the vertices that are connected together by ...
Definition: GeoTessModel.h:1089
int getNRadii(int vertexId, int layerId)
Return the number of radii that are specified in the Profile at vertexId, layerId.
Definition: GeoTessModel.h:768
An exception class for all GeoTess objects.
Definition: GeoTessException.h:65
virtual byte getByte(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a bute value.
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
Definition: GeoTessOptimizationType.h:66
double getDepth(int pointIndex)
Return the depth below surface of the current EarthShape in km of the node at pointIndex.
Definition: GeoTessModel.h:924
A Profile object that defines two radii at the bottom and top of the associated layer, and no Data.
Definition: GeoTessProfileEmpty.h:74
LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
Return the value of the attribute at the specified vertexId, layerId, nodeId, attributeIndex, cast to a LONG_INT if necessary.
Definition: GeoTessModel.h:846
void setGridInputFile(const string &gridFile)
Set the grid input file name.
Definition: GeoTessGrid.h:605
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:80
GeoTessProfile ** getProfiles(int vertex)
Get a reference to the array of Profile objects for the specified vertex.
Definition: GeoTessModel.h:1201
virtual int getInt(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a int value.
void profileCount(vector< vector< int > > &count)
Retrieve the number of Profiles of each ProfileType in each layer of the model.
Definition: GeoTessModel.h:1394
void writeModel(const string &outputFile)
Write the model to file.
Definition: GeoTessModel.h:1334
virtual void setData(int index, GeoTessData *data)
Replace the Data currently associated with this Profile with new Data.
const GeoTessDataType & getDataType() const
Return the type of all the data stored in the model; Will be one of DOUBLE, FLOAT, LONG, INT, SHORTINT, BYTE.
Definition: GeoTessMetaData.h:739
Defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and be...
Definition: EarthShape.h:85
GeoTessMetaData & getMetaData()
Return a reference to the GeoTessMetaData object associated with this model.
Definition: GeoTessModel.h:706
virtual GeoTessData & setValue(int attributeIndex, double v)
Set the value of the specified attributeIndex and return a reference to this Data object...
void setActiveRegion(GeoTessPolygon *polygon)
Set the active region to encompass only the nodes contained within the specified Polygon object...
Definition: GeoTessModel.h:1132
GeoTessProfile *** getProfiles() const
Get a reference to all Profile objects.
Definition: GeoTessModel.h:1210
virtual LONG_INT getMemory()
void initializeData(const vector< string > &attributeNames, const vector< string > &attributeUnits, T fillValue)
Reset all the Data objects in the model.
Definition: GeoTessModel.h:1462
float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
Return the value of the attribute at the specified vertexId, layerId, nodeId, attributeIndex, cast to a float if necessary.
Definition: GeoTessModel.h:831
GeoTessProfile * getProfile(int vertex, int layer)
Get a reference to the Profile object for the specified vertex and layer.
Definition: GeoTessModel.h:1190
GeoTessPointMap * getPointMap()
Retrieve a pointer to the pointMap, which is an nPoints by 3 array of indexes.
Definition: GeoTessModel.h:1074
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii)
Replace the Profile object at the specified vertex and layer with a new ProfileEmpty object...
Definition: GeoTessModel.h:1291
double getValueDouble(int pointIndex, int attributeIndex)
Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a double if ne...
Definition: GeoTessModel.h:934
EarthShape & getEarthShape()
Retrieve a reference to the ellipsoid that is stored in this GeoTessModel.
Definition: GeoTessModel.h:657
#define LONG_INT
Definition: CPPGlobals.h:111
bool isGridReuseOn()
Returns true if grid reuse is on.
Definition: GeoTessMetaData.h:369
GeoTessPolygon * getPolygon()
Retrieve the pointer to the Polygon or Polygon3D object that supports this PointMap.
Definition: GeoTessModel.h:1148
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:96
Abstract base class that manages the data values attached to a single grid point. ...
Definition: GeoTessData.h:75
int getValueInt(int pointIndex, int attributeIndex)
Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a int if neces...
Definition: GeoTessModel.h:973
virtual int getPointIndex(int nodeIndex) const
Get the pointIndex that corresponds to the supplied nodeIndex.
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
Definition: GeoTessModel.h:119
short getValueShort(int pointIndex, int attributeIndex)
Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a short if nec...
Definition: GeoTessModel.h:986
virtual void getValues(double values[], const int &n)
Copy the first n data values into the supplied array.
void setDataType(const GeoTessDataType &dt)
Specify the type of the data that is stored in the model.
void initializeData(const string &attributeNames, const string &attributeUnits, T fillValue)
Replace all the Data objects in the entire model.
Definition: GeoTessModel.h:1527
double getRadius(int pointIndex)
Return the radius in km of the node at pointIndex.
Definition: GeoTessModel.h:915
void setProfile(const int &vertex)
Replace the Profile object at the specified vertex with a new one of type ProfileSurfEmpty, which supports 2D Earth models.
Definition: GeoTessModel.h:1324
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:95
void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
Modify the attribute value stored at the specified vertex, layer, node, attribute.
Definition: GeoTessModel.h:907
const set< int > & getVertexIndicesTopLevel(const int &tessId)
Retrieve a set containing the indices of all the vertices that are connected together by triangles on...
Definition: GeoTessGrid.h:813
static string class_name()
Returns the class name.
Definition: GeoTessModel.h:541
int getNVertices() const
Return number of vertices in the 2D geographic grid.
Definition: GeoTessModel.h:753
virtual LONG_INT getMemory()
Return the amount of memory currently occupied by this GeoTessModel object NOT INCLUDING THE GRID...
Definition: GeoTessModel.h:578
double getRadius(int vertexId, int layerId, int nodeId)
Return the radius in km of the node at vertexId, layerId, nodeId.
Definition: GeoTessModel.h:792
int ordinal() const
Returns this Enums ordinal.
Definition: GeoTessEnumType.h:148
void setEarthShape(const string &earthShapeName)
Specify the name of the ellipsoid that is to be used to convert between geocentric and geographic lat...
Definition: GeoTessMetaData.h:440
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii, T **values, const int &nNodes, const int &nAttributes)
Replace the Profile object at the specified vertex and layer with a new one.
Definition: GeoTessModel.h:1261
int getNPoints()
Retrieve the number of points in the model, including all nodes along all profiles at all grid vertic...
Definition: GeoTessModel.h:1024
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
int getNLayers() const
Return the number of layers that comprise the model.
Definition: GeoTessModel.h:759
virtual short getShort(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a short value.
void setProfile(const int &vertex, T *values, const int &nAttributes)
Replace the Profile object at the specified vertex with a new one of type ProfileSurface, which supports 2D Earth models.
Definition: GeoTessModel.h:1316
virtual float getRadius(int i) const
Get the i'th radius value in this profile in km.
const string & getInputModelFile() const
Retrieve the name of the file from which the model was loaded, or "none".
Definition: GeoTessMetaData.h:447
LONG_INT getMemory()
Definition: GeoTessPointMap.h:152
virtual int getNData() const
Get the number of Data objects that comprise this profile.