GeoTessCPP  2.2.3
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 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government 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 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37 
38 #ifndef GEOTESSMODEL_OBJECT_H
39 #define GEOTESSMODEL_OBJECT_H
40 
41 // **** _SYSTEM INCLUDES_ ******************************************************
42 
43 #include <iostream>
44 #include <string>
45 #include <fstream>
46 #include <vector>
47 #include <map>
48 
49 // use standard library objects
50 using namespace std;
51 
52 // **** _LOCAL INCLUDES_ *******************************************************
53 
54 #include "CPPUtils.h"
55 #include "GeoTessUtils.h"
57 #include "GeoTessException.h"
58 #include "GeoTessPointMap.h"
59 #include "GeoTessProfileSurface.h"
60 #include "GeoTessProfileEmpty.h"
62 #include "GeoTessProfileType.h"
63 #include "EarthShape.h"
64 
65 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
66 
67 namespace geotess
68 {
69 
70 // **** _FORWARD REFERENCES_ ***************************************************
71 
72 class GeoTessPosition;
73 class GeoTessGrid;
74 class GeoTessMetaData;
75 class GeoTessOptimizationType;
76 class GeoTessProfile;
77 class IFStreamAscii;
78 class IFStreamBinary;
79 
80 // **** _CLASS DEFINITION_ *****************************************************
81 
123 {
125 
126 protected:
127 
139  static map<string, GeoTessGrid*> reuseGridMap;
140 
144  GeoTessGrid* grid;
145 
150  GeoTessProfile*** profiles;
151 
168  GeoTessMetaData* metaData;
169 
175  GeoTessPointMap* pointMap;
176 
180  void deleteProfiles();
181 
192  void loadModelAscii(const string& inputFile, const string& relGridFilePath);
193 
210  virtual void loadModelAscii(IFStreamAscii& input, const string& inputDirectory,
211  const string& relGridFilePath);
212 
226  void loadModelBinary(const string& inputFile, const string& relGridFilePath);
227 
243  virtual void loadModelBinary(IFStreamBinary& input, const string& inputDirectory,
244  const string& relGridFilePath);
245 
255  void writeModelAscii(const string& outputFile, const string& gridFileName);
256 
266  virtual void writeModelAscii(IFStreamAscii& output, const string& gridFileName);
267 
277  void writeModelBinary(const string& outputFile, const string& gridFileName);
278 
288  virtual void writeModelBinary(IFStreamBinary& output, const string& gridFileName);
289 
302  template<class T>
303  void loadGrid(T& input, const string& inputDirectory,
304  const string& relGridFilePath, const string& gridFileName,
305  const string& gridID, const string& funcName)
306  {
307  // process grid
308 
309  grid = NULL;
310  map<string, GeoTessGrid*>::iterator it = reuseGridMap.find(gridID);
311  if (it != reuseGridMap.end())
312  grid = it->second;
313 
314  if (gridFileName == "*")
315  {
316  // load the grid from this input file. The grid has to be read from the
317  // file, even a reference was retrieved from the reuseGridMap, so that the
318  // file is positioned where classes that extend GeoTessModel can read
319  // additional data.
320  GeoTessGrid* g = new GeoTessGrid(input);
321  if (!grid)
322  {
323  grid = g;
324 
325  grid->setGridInputFile(metaData->getInputModelFile());
326 
327  if (metaData->isGridReuseOn())
328  reuseGridMap[gridID] = grid;
329  }
330  else
331  delete g;
332  }
333  else if (!grid)
334  {
335  // build the name of the grid file using the input directory and
336  // the relative path to the grid file. Assume that both
337  // inputDirectory and relGridFilePath may be null or empty.
338  string gridFil = gridFileName;
339  if (relGridFilePath != "")
340  gridFil = CPPUtils::insertPathSeparator(relGridFilePath, gridFileName);
341  if (inputDirectory != "")
342  gridFil = CPPUtils::insertPathSeparator(inputDirectory, gridFil);
343 
344  grid = new GeoTessGrid();
345  grid->loadGrid(gridFil);
346  if (metaData->isGridReuseOn())
347  reuseGridMap[gridID] = grid;
348 
349  // throw an error if the grid ID's are not equal
350 
351  if (grid->getGridID() != gridID)
352  {
353  ostringstream os;
354  os << endl << "ERROR in GeoTessModel::" + funcName << endl
355  << "gridIDs in model file and existingGrid are not equal: "
356  << endl << " Model File gridID = " << gridID << endl
357  << " Grid File gridID = " << grid->getGridID() << endl;
358  throw GeoTessException(os, __FILE__, __LINE__, 1002);
359  }
360  }
361 
362  // add a reference to the grid and build the point map
363 
364  grid->addReference();
365  }
366 
367 private:
368 
369  void constructor(const string& gridFileName, GeoTessGrid* grid, GeoTessMetaData* metaData);
370 
372 
373 protected:
374 
382  static bool isGeoTessModel(const string& fileName, const string& className);
383 
384 public:
385 
391 
413  GeoTessModel(const string& inputFile, const string& relativeGridPath);
414 
427  GeoTessModel(const string& modelInputFile);
428 
435  GeoTessModel(vector<int>& attributeFilter);
436 
460  GeoTessModel(const string& inputFile, const string& relativeGridPath,
461  vector<int>& attributeFilter);
462 
477  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter);
478 
508  GeoTessModel(const string& gridFileName, GeoTessMetaData* metaData);
509 
545 
549  virtual ~GeoTessModel();
550 
555  static string class_name() { return "GeoTessModel"; }
556 
568  GeoTessModel* loadModel(const string& inputFile, const string& relGridFilePath = "");
569 
576  static bool isGeoTessModel(const string& fileName);
577 
592  virtual LONG_INT getMemory()
593  {
594  LONG_INT memory = (LONG_INT)sizeof(GeoTessModel);
595 
596  memory += metaData->getMemory();
597 
598  if (profiles)
599  for (int i=0; i<getNVertices(); ++i)
600  for (int j=0; j<getNLayers(); ++j)
601  if (profiles[i][j])
602  memory += profiles[i][j]->getMemory();
603  if (pointMap)
604  memory += pointMap->getMemory();
605  return memory;
606  }
607 
615  {
616  // this ignores some memory allocated to support the map. It is complicated and
617  // platform dependent. Also probably small compared to the size of the Grids.
618  LONG_INT memory = sizeof(map<string, GeoTessGrid*>);
619 
620  memory += (LONG_INT) (reuseGridMap.size() * (sizeof(string) + sizeof(GeoTessGrid*)));
621 
622  for (map<string, GeoTessGrid*>::iterator it = reuseGridMap.begin(); it != reuseGridMap.end(); it++)
623  memory += (LONG_INT)it->first.length() + it->second->getMemory();
624 
625  return memory;
626  }
627 
634  static int getReuseGridMapSize() { return reuseGridMap.size(); }
635 
641  static void clearReuseGrid() { reuseGridMap.clear(); }
642 
671  EarthShape& getEarthShape() { return metaData->getEarthShape(); }
672 
699  void setEarthShape(const string& earthShapeName) { metaData->setEarthShape(earthShapeName); }
700 
705  const GeoTessGrid& getGrid() const { return *grid; }
706 
711  GeoTessGrid& getGrid(){ return *grid; }
712 
720  GeoTessMetaData& getMetaData() { return *metaData; }
721 
731 
746 
761  const GeoTessInterpolatorType& radialType);
762 
767  int getNVertices() const { return grid->getNVertices(); }
768 
773  int getNLayers() const { return metaData->getNLayers(); }
774 
782  int getNRadii(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNRadii(); }
783 
791  int getNData(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNData(); }
792 
797  int getNAttributes() { return metaData->getNAttributes(); }
798 
806  double getRadius(int vertexId, int layerId, int nodeId)
807  { return profiles[vertexId][layerId]->getRadius(nodeId); }
808 
817  double getDepth(int vertexId, int layerId, int nodeId)
818  { return getEarthShape().getEarthRadius(grid->getVertex(vertexId))
819  - profiles[vertexId][layerId]->getRadius(nodeId); }
820 
830  double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
831  {
832  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
833  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
834  }
835 
845  float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
846  {
847  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
848  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
849  }
850 
860  LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
861  {
862  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
863  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
864  }
865 
875  int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
876  {
877  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
878  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
879  }
880 
890  short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
891  {
892  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
893  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
894  }
895 
905  byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
906  {
907  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
908  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
909  }
910 
920  template<typename T>
921  void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
922  { profiles[vertexId][layerId]->getData(nodeId)->setValue(attributeIndex, value); }
923 
929  double getRadius(int pointIndex)
930  { return getPointMap()->getPointRadius(pointIndex); }
931 
938  double getDepth(int pointIndex)
939  { return getPointMap()->getPointDepth(pointIndex); }
940 
948  double getValueDouble(int pointIndex, int attributeIndex)
949  {
950  GeoTessData* data = getPointMap()->getPointData(pointIndex);
951  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
952  }
953 
961  float getValueFloat(int pointIndex, int attributeIndex)
962  {
963  GeoTessData* data = getPointMap()->getPointData(pointIndex);
964  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
965  }
966 
974  LONG_INT getValueLong(int pointIndex, int attributeIndex)
975  {
976  GeoTessData* data = getPointMap()->getPointData(pointIndex);
977  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
978  }
979 
987  int getValueInt(int pointIndex, int attributeIndex)
988  {
989  GeoTessData* data = getPointMap()->getPointData(pointIndex);
990  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
991  }
992 
1000  short getValueShort(int pointIndex, int attributeIndex)
1001  {
1002  GeoTessData* data = getPointMap()->getPointData(pointIndex);
1003  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
1004  }
1005 
1013  byte getValueByte(int pointIndex, int attributeIndex)
1014  {
1015  GeoTessData* data = getPointMap()->getPointData(pointIndex);
1016  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
1017  }
1018 
1026  template<typename T>
1027  void setValue(int pointIndex, int attributeIndex, T value)
1028  {
1029  GeoTessData* data = getPointMap()->getPointData(pointIndex);
1030  if (data != NULL) data->setValue(attributeIndex, value);
1031  }
1032 
1038  int getNPoints() { return getPointMap()->size(); }
1039 
1048  virtual bool operator == (const GeoTessModel& other) const;
1049 
1058  virtual bool operator != (const GeoTessModel& other) const { return !(*this == other); } ;
1059 
1060  bool is2D()
1061  {
1062  return getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE
1063  || getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE_EMPTY;
1064  }
1065 
1066  bool is3D()
1067  {
1068  return !is2D();
1069  }
1070 
1089  {
1090  if (!pointMap->isPopulated())
1091  pointMap->setActiveRegion();
1092  return pointMap;
1093  }
1094 
1103  const set<int>& getConnectedVertices(int layerIndex)
1104  {
1105  return grid->getVertexIndicesTopLevel(metaData->getTessellation(layerIndex));
1106  }
1107 
1114  {
1115  pointMap->setActiveRegion();
1116  }
1117 
1130  void setActiveRegion(const string& polygon)
1131  {
1132  pointMap->setActiveRegion(polygon);
1133  }
1134 
1147  {
1148  if (polygon == NULL)
1149  pointMap->setActiveRegion();
1150  else
1151  pointMap->setActiveRegion(polygon);
1152  }
1153 
1162  GeoTessPolygon* getPolygon() { return pointMap->getPolygon(); }
1163 
1172  void getLayerCount(bool activeOnly, int* layerCount)
1173  {
1174  for (int layer=0; layer<getNLayers(); ++layer)
1175  layerCount[layer] = 0;
1176 
1177  GeoTessProfile** pp;
1178  GeoTessProfile* p;
1179  for (int v=0; v<getNVertices(); ++v)
1180  {
1181  pp = profiles[v];
1182  for (int layer=0; layer<getNLayers(); ++layer)
1183  {
1184  if (activeOnly)
1185  {
1186  p = pp[layer];
1187  for (int n=0; n<p->getNData(); ++n)
1188  if (p->getPointIndex(n) >= 0)
1189  ++layerCount[layer];
1190  }
1191  else
1192  layerCount[layer] += pp[layer]->getNData();
1193  }
1194  }
1195  }
1196 
1204  GeoTessProfile* getProfile(int vertex, int layer)
1205  {
1206  return profiles[vertex][layer];
1207  }
1208 
1216  {
1217  return profiles[vertex];
1218  }
1219 
1224  GeoTessProfile*** getProfiles() const { return profiles; }
1225 
1236  void setProfile(int vertex, int layer, GeoTessProfile* profile);
1237 
1251  template<typename T>
1252  void setProfile(int vertex, int layer, vector<float>& radii, vector<vector<T> >& values)
1253  {
1254  if (getConnectedVertices(layer).count(vertex) == 1)
1255  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, values));
1256  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1]));
1257  }
1258 
1274  template<typename T>
1275  void setProfile(const int& vertex, const int& layer,
1276  float* radii, const int& nRadii,
1277  T** values, const int& nNodes, const int& nAttributes)
1278  {
1279  if (getConnectedVertices(layer).count(vertex) == 1)
1280  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, nRadii, values, nNodes, nAttributes));
1281  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1]));
1282  }
1283 
1292  void setProfile(int vertex, int layer, vector<float>& radii)
1293  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1])); }
1294 
1304  template<typename T>
1305  void setProfile(const int& vertex, const int& layer, float* radii, const int& nRadii)
1306  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1])); }
1307 
1316  template<typename T>
1317  void setProfile(const int& vertex, vector<T>& values)
1318  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values))); }
1319 
1329  template<typename T>
1330  void setProfile(const int& vertex, T* values, const int& nAttributes)
1331  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values, nAttributes))); }
1332 
1338  void setProfile(const int& vertex)
1339  { setProfile(vertex, 0, new GeoTessProfileSurfaceEmpty()); }
1340 
1348  void writeModel(const string& outputFile) { writeModel(outputFile, "*"); }
1349 
1364  void writeModel(const string& outputFile, const string& gridFileName);
1365 
1370  string toString();
1371 
1379  void getLayerCount(vector<int>& layerCount, const bool& activeOnly)
1380  {
1381  layerCount.resize(metaData->getNLayers(), 0);
1382 
1383  GeoTessProfile** pp;
1384  GeoTessProfile* p;
1385  for (int vtx=0; vtx<getNVertices(); ++vtx)
1386  {
1387  pp = profiles[vtx];
1388  for (int layer = 0; layer < metaData->getNLayers(); ++layer)
1389  if (activeOnly)
1390  {
1391  p = pp[layer];
1392  for (int n = 0; n < p->getNData(); ++n)
1393  if (p->getPointIndex(n) >= 0)
1394  ++layerCount[layer];
1395  }
1396  else
1397  layerCount[layer] += pp[layer]->getNData();
1398  }
1399  }
1400 
1408  void profileCount(vector< vector<int> >& count)
1409  {
1410  count.clear();
1411 
1412  getPointMap();
1413 
1414  // this is total number of profiles of each type, independent of layer index.
1415  vector<int> totalCount;
1416  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1417  totalCount.push_back(0);
1418 
1419  for (int layer = 0; layer < getNLayers(); ++layer)
1420  {
1421  vector<int> typeCount;
1422 
1423  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1424  typeCount.push_back(0);
1425 
1426  count.push_back(typeCount);
1427  }
1428 
1429  for (int layer = 0; layer < getNLayers(); ++layer)
1430  {
1431  for (int vertex = 0; vertex < metaData->getNVertices(); ++vertex)
1432  {
1433  int pType = profiles[vertex][layer]->getType().ordinal();
1434  count[layer][pType] += 1;
1435  totalCount[pType] += 1;
1436  }
1437  }
1438 
1439  count.push_back(totalCount);
1440  }
1441 
1475  template<typename T>
1476  void initializeData(const vector<string>& attributeNames,
1477  const vector<string>& attributeUnits, T fillValue)
1478  {
1479  if (profiles == NULL)
1480  {
1481  ostringstream os;
1482  os << endl << "ERROR in GeoTessModel::initializeData" << endl
1483  << "Attempting to initialize the model data before Profiles" << endl
1484  << "have been specified (profiles == NULL)" << endl;
1485  throw GeoTessException(os, __FILE__, __LINE__, 1001);
1486  }
1487 
1488  const GeoTessDataType& newDataType = GeoTessDataType::getDataType(fillValue);
1489  int nAttributesNew = attributeNames.size();
1490 
1491  int newDataTypeOrdinal = newDataType.ordinal();
1492  int oldDataTypeOrdinal = metaData->getDataType().ordinal();
1493 
1494  // if neither the dataType or the number of attributes has changed, there is no need to
1495  // copy the data. The only thing that happens is that the attributeNames or attributeUnits might change.
1496  if (newDataTypeOrdinal != oldDataTypeOrdinal || nAttributesNew != metaData->getNAttributes())
1497  {
1498  // initialize an array of the new dataType with number of elements
1499  // equal to the number of new attributes and populate it with fillValue.
1500  T* newValues = new T[nAttributesNew];
1501  for (int i=0; i<nAttributesNew; ++i)
1502  newValues[i] = fillValue;
1503 
1504  GeoTessProfile* profile;
1505  vector<GeoTessData*> data;
1506  for (int v = 0; v < getNVertices(); ++v)
1507  for (int lid = 0; lid < getNLayers(); ++lid)
1508  {
1509  profile = profiles[v][lid];
1510  data.reserve(profile->getNData());
1511  data.clear();
1512  for (int n = 0; n < profile->getNData(); ++n)
1513  {
1514  profile->getData(n)->getValues(newValues, nAttributesNew);
1515  data.push_back(GeoTessData::getData(newValues, nAttributesNew));
1516  }
1517  // set new entries into profile and continue
1518  profile->setData(data);
1519  }
1520  delete[] newValues;
1521  }
1522 
1523  metaData->setDataType(newDataType);
1524 
1525  metaData->setAttributes(attributeNames, attributeUnits);
1526  }
1527 
1540  template<typename T>
1541  void initializeData(const string& attributeNames,
1542  const string& attributeUnits, T fillValue)
1543  {
1544  vector<string> names;
1545  CPPUtils::tokenizeString(attributeNames, ";", names);
1546  vector<string> units;
1547  CPPUtils::tokenizeString(attributeUnits, ";", units);
1548  initializeData(names, units, fillValue);
1549  }
1550 
1575  void getWeights(const double* pointA, const double* pointB, const double& pointSpacing, const double& radius,
1576  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1577 
1601  void getWeights(GeoTessGreatCircle& greatCircle, const double& pointSpacing, const double& radius,
1602  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1603 
1627  void getWeights(const vector<double*>& rayPath,
1628  const vector<double>& radii,
1629  const vector<int>& layerIds,
1630  const GeoTessInterpolatorType& horizontalType,
1631  const GeoTessInterpolatorType& radialType,
1632  map<int, double>& weights);
1633 
1658  void getWeights(double** rayPath, double* radii, int* layerIds, const int& numPoints,
1659  const GeoTessInterpolatorType& horizontalType,
1660  const GeoTessInterpolatorType& radialType,
1661  map<int, double>& weights);
1662 
1675  double getPathIntegral(const int& attribute, const map<int, double>& weights);
1676 
1710  double getPathIntegral(const int& attribute,
1711  double** rayPath, double* radii, int* layerIds, const int& numPoints,
1712  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1713  map<int, double>* weights = NULL);
1714 
1747  double getPathIntegral(const int& attribute,
1748  const vector<double*>& rayPath, const vector<double>& radii, const vector<int>& layerIds,
1749  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1750  map<int, double>* weights = NULL);
1751 
1787  double getPathIntegral2D(const int& attribute,
1788  const double* firstPoint, const double* lastPoint, double pointSpacing,
1789  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1790  map<int, double>* weights = NULL);
1791 
1826  double getPathIntegral2D(const int& attribute,
1827  GeoTessGreatCircle& greatCircle, double pointSpacing,
1828  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1829  map<int, double>* weights = NULL);
1830 
1832 
1833  // the following constructors are all deprecated because GeoTessOptimization is no longer used.
1834  // GeoTess is always optimized for speed.
1835  GeoTessModel(const GeoTessOptimizationType* optimization);
1836  GeoTessModel(const string& inputFile, const string& relativeGridPath, const GeoTessOptimizationType* optimization);
1837  GeoTessModel(const string& modelInputFile, const GeoTessOptimizationType* optimization);
1838  GeoTessModel(vector<int>& attributeFilter, const GeoTessOptimizationType* optimization);
1839  GeoTessModel(const string& inputFile, const string& relativeGridPath,
1840  vector<int>& attributeFilter, const GeoTessOptimizationType* optimization);
1841  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter,
1842  const GeoTessOptimizationType* optimization);
1843 
1844 // // The following getWeight() and getPathIntegral() functions are deprecated.
1845 // // They were included in GeoTessModel v2.1.1 but were reconfigured in v2.2.0.
1846 // // They are included here for backward compatibility, but will not appear in the documentation.
1847 // void getWeights(const vector<double*>& rayPath, const vector<double>& radii,
1848 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1849 // { vector<int> layerIds; getWeights(rayPath, radii, layerIds, ht, rt, weights);}
1850 //
1851 // void getWeights(double** rayPath, double* radii, const int& numPoints,
1852 // const GeoTessInterpolatorType& ht,const GeoTessInterpolatorType& rt,map<int, double>& weights)
1853 // { getWeights(rayPath, radii, NULL, numPoints, ht, rt, weights);}
1854 //
1855 // double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1856 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt)
1857 // { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt); }
1858 //
1859 // double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1860 // const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1861 // { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt, &weights); }
1862 //
1863 // double getPathIntegral2D(const int& attribute, const bool& reciprocal,
1864 // const double* firstPoint, const double* lastPoint, const double& pointSpacing,
1865 // const double& earthRadius,
1866 // const GeoTessInterpolatorType& horizontalType, map<int, double>& weights)
1867 // { return getPathIntegral2D(attribute, reciprocal, firstPoint, lastPoint, pointSpacing, earthRadius, horizontalType, &weights); }
1868 
1869 
1873  bool isSupportedFormatVersion(int frmtVrsn) { return (frmtVrsn == 1) ? true : false; }
1874 
1880  bool testLayerRadii();
1881 
1882 
1884 
1885 };
1886 // end class GeoTessModel
1887 
1888 }// end namespace geotess
1889 
1890 #endif // GEOTESSMODEL_OBJECT_H
geotess::GeoTessModel::getRadius
double getRadius(int vertexId, int layerId, int nodeId)
Definition: GeoTessModel.h:806
geotess::GeoTessModel::getValueDouble
double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:830
geotess::GeoTessModel::getWeights
void getWeights(const vector< double * > &rayPath, const vector< double > &radii, const vector< int > &layerIds, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > &weights)
geotess::GeoTessModel::getValueFloat
float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:845
geotess::GeoTessModel::setProfile
void setProfile(const int &vertex)
Definition: GeoTessModel.h:1338
geotess::GeoTessPointMap
Relationships between vertices (2D positions in a tessellation), nodes (1D positions along a radial P...
Definition: GeoTessPointMap.h:77
geotess
Definition: ArrayReuse.h:57
geotess::GeoTessModel::getValueLong
LONG_INT getValueLong(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:974
GeoTessException.h
geotess::GeoTessModel::getValueShort
short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:890
geotess::GeoTessProfile
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:99
GeoTessProfileType.h
geotess::GeoTessMetaData::getNAttributes
int getNAttributes() const
Definition: GeoTessMetaData.h:842
geotess::GeoTessPointMap::getPolygon
GeoTessPolygon * getPolygon()
Definition: GeoTessPointMap.h:202
geotess::GeoTessModel::getPathIntegral
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)
geotess::GeoTessModel::getPosition
GeoTessPosition * getPosition(const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType)
geotess::GeoTessModel::getLayerCount
void getLayerCount(vector< int > &layerCount, const bool &activeOnly)
Definition: GeoTessModel.h:1379
geotess::GeoTessModel::getNPoints
int getNPoints()
Definition: GeoTessModel.h:1038
geotess::GeoTessModel::getEarthShape
EarthShape & getEarthShape()
Definition: GeoTessModel.h:671
geotess::GeoTessMetaData::setEarthShape
void setEarthShape(const string &earthShapeName)
Definition: GeoTessMetaData.h:442
GeoTessProfileSurface.h
geotess::GeoTessModel::GeoTessModel
GeoTessModel(const string &gridFileName, GeoTessMetaData *metaData)
geotess::GeoTessModel::getValueShort
short getValueShort(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:1000
geotess::GeoTessData::getInt
virtual int getInt(int attributeIndex) const
geotess::GeoTessMetaData::getTessellation
int getTessellation(int layer) const
Definition: GeoTessMetaData.h:685
geotess::GeoTessModel::writeModel
void writeModel(const string &outputFile)
Definition: GeoTessModel.h:1348
GeoTessPointMap.h
geotess::GeoTessModel::GeoTessModel
GeoTessModel(GeoTessGrid *grid, GeoTessMetaData *metaData)
geotess::GeoTessGrid::getGridID
static string getGridID(const string &fileName)
geotess::GeoTessModel::getWeights
void getWeights(GeoTessGreatCircle &greatCircle, const double &pointSpacing, const double &radius, const GeoTessInterpolatorType &horizontalType, map< int, double > &weights)
geotess::GeoTessModel::getReuseGridMapMemory
static LONG_INT getReuseGridMapMemory()
Definition: GeoTessModel.h:614
geotess::GeoTessModel::setActiveRegion
void setActiveRegion()
Definition: GeoTessModel.h:1113
geotess::GeoTessModel::setProfile
void setProfile(int vertex, int layer, vector< float > &radii, vector< vector< T > > &values)
Definition: GeoTessModel.h:1252
geotess::GeoTessProfile::getRadius
virtual float getRadius(int i) const
geotess::GeoTessModel::getPathIntegral
double getPathIntegral(const int &attribute, const map< int, double > &weights)
geotess::GeoTessModel::initializeData
void initializeData(const vector< string > &attributeNames, const vector< string > &attributeUnits, T fillValue)
Definition: GeoTessModel.h:1476
geotess::GeoTessModel::getNData
int getNData(int vertexId, int layerId)
Definition: GeoTessModel.h:791
geotess::GeoTessMetaData::getNVertices
int getNVertices() const
Definition: GeoTessMetaData.h:562
geotess::GeoTessMetaData::getMemory
LONG_INT getMemory()
Definition: GeoTessMetaData.h:314
geotess::GeoTessModel::getPolygon
GeoTessPolygon * getPolygon()
Definition: GeoTessModel.h:1162
geotess::GeoTessModel::getProfiles
GeoTessProfile ** getProfiles(int vertex)
Definition: GeoTessModel.h:1215
geotess::GeoTessGrid::setGridInputFile
void setGridInputFile(const string &gridFile)
Definition: GeoTessGrid.h:607
geotess::GeoTessModel::getPathIntegral2D
double getPathIntegral2D(const int &attribute, GeoTessGreatCircle &greatCircle, double pointSpacing, double earthRadius, const GeoTessInterpolatorType &horizontalType, map< int, double > *weights=NULL)
geotess::GeoTessModel::isGeoTessModel
static bool isGeoTessModel(const string &fileName)
geotess::GeoTessPointMap::getMemory
LONG_INT getMemory()
Definition: GeoTessPointMap.h:154
geotess::GeoTessProfile::getMemory
virtual LONG_INT getMemory()
geotess::GeoTessModel::toString
string toString()
geotess::GeoTessModel::setProfile
void setProfile(int vertex, int layer, vector< float > &radii)
Definition: GeoTessModel.h:1292
geotess::GeoTessModel::getReuseGridMapSize
static int getReuseGridMapSize()
Definition: GeoTessModel.h:634
geotess::GeoTessModel::getPointMap
GeoTessPointMap * getPointMap()
Definition: GeoTessModel.h:1088
geotess::GeoTessModel::setEarthShape
void setEarthShape(const string &earthShapeName)
Definition: GeoTessModel.h:699
geotess::GeoTessModel::setActiveRegion
void setActiveRegion(const string &polygon)
Definition: GeoTessModel.h:1130
geotess::GeoTessModel::getProfiles
GeoTessProfile *** getProfiles() const
Definition: GeoTessModel.h:1224
geotess::GeoTessModel::getNAttributes
int getNAttributes()
Definition: GeoTessModel.h:797
geotess::GeoTessData::getLong
virtual LONG_INT getLong(int attributeIndex) const
geotess::GeoTessEnumType::ordinal
int ordinal() const
Definition: GeoTessEnumType.h:150
GeoTessUtils.h
geotess::GeoTessMetaData::getNLayers
int getNLayers() const
Definition: GeoTessMetaData.h:573
geotess::GeoTessModel::getMetaData
GeoTessMetaData & getMetaData()
Definition: GeoTessModel.h:720
EarthShape.h
geotess::GeoTessModel::GeoTessModel
GeoTessModel(const string &modelInputFile, vector< int > &attributeFilter)
geotess::GeoTessPolygon
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition: GeoTessPolygon.h:114
geotess::GeoTessGreatCircle
Manages information about a great circle path that extends from one point to another point,...
Definition: GeoTessGreatCircle.h:171
geotess::GeoTessModel::setProfile
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii, T **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessModel.h:1275
geotess::GeoTessProfileEmpty
A Profile object that defines two radii at the bottom and top of the associated layer,...
Definition: GeoTessProfileEmpty.h:77
geotess::GeoTessProfile::getNRadii
virtual int getNRadii() const
GeoTessProfileSurfaceEmpty.h
geotess::GeoTessModel::getRadius
double getRadius(int pointIndex)
Definition: GeoTessModel.h:929
geotess::GeoTessModel::GeoTessModel
GeoTessModel(const string &modelInputFile)
geotess::GeoTessGrid
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:169
geotess::IFStreamAscii
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:83
geotess::GeoTessDataType
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:70
geotess::GeoTessModel::getPathIntegral
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)
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
geotess::GeoTessModel::getNRadii
int getNRadii(int vertexId, int layerId)
Definition: GeoTessModel.h:782
geotess::GeoTessMetaData::getEarthShape
EarthShape & getEarthShape()
Definition: GeoTessMetaData.h:414
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion()
geotess::GeoTessModel::getValueInt
int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:875
geotess::GeoTessModel::getGrid
GeoTessGrid & getGrid()
Definition: GeoTessModel.h:711
geotess::EarthShape
Defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and be...
Definition: EarthShape.h:88
geotess::GeoTessModel::loadModel
GeoTessModel * loadModel(const string &inputFile, const string &relGridFilePath="")
geotess::GeoTessGrid::getVertex
const double * getVertex(int vertex) const
Definition: GeoTessGrid.h:632
geotess::GeoTessData::getFloat
virtual float getFloat(int attributeIndex) const
geotess::GeoTessModel::getNVertices
int getNVertices() const
Definition: GeoTessModel.h:767
geotess::GeoTessModel::setValue
void setValue(int pointIndex, int attributeIndex, T value)
Definition: GeoTessModel.h:1027
geotess::GeoTessModel::getDepth
double getDepth(int vertexId, int layerId, int nodeId)
Definition: GeoTessModel.h:817
geotess::GeoTessProfileSurface
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurface.h:79
geotess::GeoTessModel::profileCount
void profileCount(vector< vector< int > > &count)
Definition: GeoTessModel.h:1408
geotess::GeoTessModel::getPathIntegral2D
double getPathIntegral2D(const int &attribute, const double *firstPoint, const double *lastPoint, double pointSpacing, double earthRadius, const GeoTessInterpolatorType &horizontalType, map< int, double > *weights=NULL)
geotess::GeoTessModel::setProfile
void setProfile(const int &vertex, T *values, const int &nAttributes)
Definition: GeoTessModel.h:1330
geotess::GeoTessModel::GeoTessModel
GeoTessModel(const string &inputFile, const string &relativeGridPath, vector< int > &attributeFilter)
geotess::GeoTessModel::~GeoTessModel
virtual ~GeoTessModel()
geotess::GeoTessModel::GeoTessModel
GeoTessModel(const string &inputFile, const string &relativeGridPath)
geotess::GeoTessData
Abstract base class that manages the data values attached to a single grid point.
Definition: GeoTessData.h:78
GeoTessInterpolatorType.h
geotess::GeoTessProfile::getPointIndex
virtual int getPointIndex(int nodeIndex) const
geotess::GeoTessModel::getValueByte
byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:905
geotess::GeoTessModel::getValueDouble
double getValueDouble(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:948
geotess::GeoTessMetaData::setAttributes
void setAttributes(const string &nms, const string &unts)
Definition: GeoTessMetaData.h:812
geotess::GeoTessModel::getValueByte
byte getValueByte(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:1013
geotess::GeoTessModel::setActiveRegion
void setActiveRegion(GeoTessPolygon *polygon)
Definition: GeoTessModel.h:1146
geotess::GeoTessModel::is3D
bool is3D()
Definition: GeoTessModel.h:1066
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:73
geotess::GeoTessMetaData::setDataType
void setDataType(const GeoTessDataType &dt)
geotess::GeoTessModel::getValueFloat
float getValueFloat(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:961
geotess::GeoTessModel::initializeData
void initializeData(const string &attributeNames, const string &attributeUnits, T fillValue)
Definition: GeoTessModel.h:1541
geotess::GeoTessModel::setProfile
void setProfile(int vertex, int layer, GeoTessProfile *profile)
geotess::GeoTessModel::getValueLong
LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:860
geotess::GeoTessModel::GeoTessModel
GeoTessModel(vector< int > &attributeFilter)
geotess::GeoTessModel::setProfile
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii)
Definition: GeoTessModel.h:1305
geotess::GeoTessProfile::getNData
virtual int getNData() const
geotess::IFStreamBinary
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:82
geotess::GeoTessModel::getWeights
void getWeights(const double *pointA, const double *pointB, const double &pointSpacing, const double &radius, const GeoTessInterpolatorType &horizontalType, map< int, double > &weights)
geotess::GeoTessModel::GeoTessModel
GeoTessModel()
geotess::GeoTessData::getDouble
virtual double getDouble(int attributeIndex) const
geotess::GeoTessMetaData
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:98
geotess::GeoTessModel::is2D
bool is2D()
Definition: GeoTessModel.h:1060
geotess::GeoTessModel::getMemory
virtual LONG_INT getMemory()
Definition: GeoTessModel.h:592
geotess::GeoTessModel::class_name
static string class_name()
Definition: GeoTessModel.h:555
geotess::GeoTessModel
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
Definition: GeoTessModel.h:123
geotess::GeoTessProfile::getType
virtual const GeoTessProfileType & getType() const
geotess::GeoTessMetaData::isGridReuseOn
bool isGridReuseOn()
Definition: GeoTessMetaData.h:371
geotess::GeoTessModel::isGeoTessModel
static bool isGeoTessModel(const string &fileName, const string &className)
geotess::GeoTessPosition
Information about an interpolated point at an arbitrary position in a model.
Definition: GeoTessPosition.h:104
geotess::GeoTessModel::getDepth
double getDepth(int pointIndex)
Definition: GeoTessModel.h:938
geotess::GeoTessModel::writeModel
void writeModel(const string &outputFile, const string &gridFileName)
geotess::GeoTessPointMap::isPopulated
bool isPopulated()
Definition: GeoTessPointMap.h:217
geotess::GeoTessData::getByte
virtual byte getByte(int attributeIndex) const
geotess::GeoTessModel::getProfile
GeoTessProfile * getProfile(int vertex, int layer)
Definition: GeoTessModel.h:1204
geotess::GeoTessModel::setValue
void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
Definition: GeoTessModel.h:921
geotess::GeoTessGrid::loadGrid
GeoTessGrid * loadGrid(const string &inputFile)
geotess::GeoTessData::setValue
virtual GeoTessData & setValue(int attributeIndex, double v)
geotess::GeoTessModel::getConnectedVertices
const set< int > & getConnectedVertices(int layerIndex)
Definition: GeoTessModel.h:1103
geotess::GeoTessException
An exception class for all GeoTess objects.
Definition: GeoTessException.h:68
geotess::GeoTessGrid::getVertexIndicesTopLevel
const set< int > & getVertexIndicesTopLevel(const int &tessId)
Definition: GeoTessGrid.h:815
geotess::GeoTessMetaData::getDataType
const GeoTessDataType & getDataType() const
Definition: GeoTessMetaData.h:741
geotess::GeoTessData::getShort
virtual short getShort(int attributeIndex) const
geotess::GeoTessGrid::getNVertices
int getNVertices() const
Definition: GeoTessGrid.h:822
geotess::GeoTessOptimizationType
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
Definition: GeoTessOptimizationType.h:69
geotess::GeoTessModel::clearReuseGrid
static void clearReuseGrid()
Definition: GeoTessModel.h:641
geotess::GeoTessModel::getWeights
void getWeights(double **rayPath, double *radii, int *layerIds, const int &numPoints, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > &weights)
CPPUtils.h
geotess::GeoTessModel::getGrid
const GeoTessGrid & getGrid() const
Definition: GeoTessModel.h:705
geotess::GeoTessMetaData::getInputModelFile
const string & getInputModelFile() const
Definition: GeoTessMetaData.h:449
GeoTessProfileEmpty.h
geotess::GeoTessModel::getLayerCount
void getLayerCount(bool activeOnly, int *layerCount)
Definition: GeoTessModel.h:1172
geotess::GeoTessModel::setProfile
void setProfile(const int &vertex, vector< T > &values)
Definition: GeoTessModel.h:1317
geotess::GeoTessProfile::setData
virtual void setData(int index, GeoTessData *data)
geotess::GeoTessModel::getPosition
GeoTessPosition * getPosition()
geotess::GeoTessData::getValues
virtual void getValues(double values[], const int &n)
geotess::GeoTessProfileSurfaceEmpty
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurfaceEmpty.h:79
geotess::GeoTessModel::getPosition
GeoTessPosition * getPosition(const GeoTessInterpolatorType &horizontalType)
geotess::GeoTessModel::getValueInt
int getValueInt(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:987
geotess::GeoTessProfile::getData
virtual GeoTessData ** getData()
geotess::GeoTessModel::getNLayers
int getNLayers() const
Definition: GeoTessModel.h:773
geotess::GeoTessInterpolatorType
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...
Definition: GeoTessInterpolatorType.h:74