GeoTessCPP  2.1
Software to facilitate storage and retrieval of 3D information about the Earth.
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
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  &metaData->getOptimizationType());
319  if (!grid)
320  {
321  grid = g;
322 
323  grid->setGridInputFile(metaData->getInputModelFile());
324 
325  if (metaData->isGridReuseOn())
326  reuseGridMap[gridID] = grid;
327  }
328  else
329  delete g;
330  }
331  else if (!grid)
332  {
333  // build the name of the grid file using the input directory and
334  // the relative path to the grid file. Assume that both
335  // inputDirectory and relGridFilePath may be null or empty.
336  string gridFil = gridFileName;
337  if (relGridFilePath != "")
338  gridFil = CPPUtils::insertPathSeparator(relGridFilePath, gridFileName);
339  if (inputDirectory != "")
340  gridFil = CPPUtils::insertPathSeparator(inputDirectory, gridFil);
341 
342  grid = new GeoTessGrid(&metaData->getOptimizationType());
343  grid->loadGrid(gridFil);
344  if (metaData->isGridReuseOn())
345  reuseGridMap[gridID] = grid;
346 
347  // throw an error if the grid ID's are not equal
348 
349  if (grid->getGridID() != gridID)
350  {
351  ostringstream os;
352  os << endl << "ERROR in GeoTessModel::" + funcName << endl
353  << "gridIDs in model file and existingGrid are not equal: "
354  << endl << " Model File gridID = " << gridID << endl
355  << " Grid File gridID = " << grid->getGridID() << endl;
356  throw GeoTessException(os, __FILE__, __LINE__, 1002);
357  }
358  }
359 
360  // add a reference to the grid and build the point map
361 
362  grid->addReference();
363  }
364 
365 private:
366 
367  void constructor(const string& gridFileName, GeoTessGrid* grid, GeoTessMetaData* metaData);
368 
370 
371 public:
372 
381  GeoTessModel(const GeoTessOptimizationType* optimization = &GeoTessOptimizationType::SPEED);
382 
408  GeoTessModel(const string& inputFile, const string& relativeGridPath,
409  const GeoTessOptimizationType* optimization = &GeoTessOptimizationType::SPEED);
410 
427  GeoTessModel(const string& modelInputFile,
428  const GeoTessOptimizationType* optimization = &GeoTessOptimizationType::SPEED);
429 
440  GeoTessModel(vector<int>& attributeFilter, const GeoTessOptimizationType* optimization = &GeoTessOptimizationType::SPEED);
441 
469  GeoTessModel(const string& inputFile, const string& relativeGridPath,
470  vector<int>& attributeFilter,
471  const GeoTessOptimizationType* optimization = &GeoTessOptimizationType::SPEED);
472 
491  GeoTessModel(const string& modelInputFile, vector<int>& attributeFilter,
492  const GeoTessOptimizationType* optimization = &GeoTessOptimizationType::SPEED);
493 
524  GeoTessModel(const string& gridFileName, GeoTessMetaData* metaData);
525 
561  GeoTessModel(GeoTessGrid* grid, GeoTessMetaData* metaData);
562 
566  virtual ~GeoTessModel();
567 
572  static string class_name() { return "GeoTessModel"; }
573 
585  GeoTessModel* loadModel(const string& inputFile, const string& relGridFilePath = "");
586 
593  static bool isGeoTessModel(const string& fileName);
594 
600  static void clearReuseGrid() { reuseGridMap.clear(); }
601 
608  static int getReuseGridMapSize() { return reuseGridMap.size(); }
609 
635  EarthShape& getEarthShape() { return metaData->getEarthShape(); }
636 
662  void setEarthShape(const string& earthShapeName) { metaData->setEarthShape(earthShapeName); }
663 
668  const GeoTessGrid& getGrid() const { return *grid; }
669 
674  GeoTessGrid& getGrid(){ return *grid; }
675 
683  GeoTessMetaData& getMetaData() { return *metaData; }
684 
693  GeoTessPosition* getPosition();
694 
708  GeoTessPosition* getPosition(const GeoTessInterpolatorType& horizontalType);
709 
723  GeoTessPosition* getPosition(const GeoTessInterpolatorType& horizontalType,
724  const GeoTessInterpolatorType& radialType);
725 
730  int getNVertices() const { return grid->getNVertices(); }
731 
736  int getNLayers() const { return metaData->getNLayers(); }
737 
745  int getNRadii(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNRadii(); }
746 
754  int getNData(int vertexId, int layerId) { return profiles[vertexId][layerId]->getNData(); }
755 
760  int getNAttributes() { return metaData->getNAttributes(); }
761 
769  double getRadius(int vertexId, int layerId, int nodeId)
770  { return profiles[vertexId][layerId]->getRadius(nodeId); }
771 
780  double getDepth(int vertexId, int layerId, int nodeId)
781  { return GeoTessUtils::getEarthRadius(grid->getVertex(vertexId))
782  - profiles[vertexId][layerId]->getRadius(nodeId); }
783 
793  double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
794  {
795  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
796  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
797  }
798 
808  float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
809  {
810  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
811  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
812  }
813 
823  LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
824  {
825  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
826  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
827  }
828 
838  int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
839  {
840  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
841  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
842  }
843 
853  short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
854  {
855  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
856  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
857  }
858 
868  byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
869  {
870  GeoTessData* data = profiles[vertexId][layerId]->getData(nodeId);
871  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
872  }
873 
883  template<typename T>
884  void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
885  { profiles[vertexId][layerId]->getData(nodeId)->setValue(attributeIndex, value); }
886 
892  double getRadius(int pointIndex)
893  { return getPointMap()->getPointRadius(pointIndex); }
894 
901  double getDepth(int pointIndex)
902  { return getPointMap()->getPointDepth(pointIndex); }
903 
911  double getValueDouble(int pointIndex, int attributeIndex)
912  {
913  GeoTessData* data = getPointMap()->getPointData(pointIndex);
914  return data == NULL ? NaN_DOUBLE : data->getDouble(attributeIndex);
915  }
916 
924  float getValueFloat(int pointIndex, int attributeIndex)
925  {
926  GeoTessData* data = getPointMap()->getPointData(pointIndex);
927  return data == NULL ? NaN_FLOAT : data->getFloat(attributeIndex);
928  }
929 
937  LONG_INT getValueLong(int pointIndex, int attributeIndex)
938  {
939  GeoTessData* data = getPointMap()->getPointData(pointIndex);
940  return data == NULL ? LONG_MIN : data->getLong(attributeIndex);
941  }
942 
950  int getValueInt(int pointIndex, int attributeIndex)
951  {
952  GeoTessData* data = getPointMap()->getPointData(pointIndex);
953  return data == NULL ? INT_MIN : data->getInt(attributeIndex);
954  }
955 
963  short getValueShort(int pointIndex, int attributeIndex)
964  {
965  GeoTessData* data = getPointMap()->getPointData(pointIndex);
966  return data == NULL ? SHRT_MIN : data->getShort(attributeIndex);
967  }
968 
976  byte getValueByte(int pointIndex, int attributeIndex)
977  {
978  GeoTessData* data = getPointMap()->getPointData(pointIndex);
979  return data == NULL ? CHAR_MIN : data->getByte(attributeIndex);
980  }
981 
989  template<typename T>
990  void setValue(int pointIndex, int attributeIndex, T value)
991  {
992  GeoTessData* data = getPointMap()->getPointData(pointIndex);
993  if (data != NULL) data->setValue(attributeIndex, value);
994  }
995 
1001  int getNPoints() { return getPointMap()->size(); }
1002 
1011  virtual bool operator == (const GeoTessModel& other) const;
1012 
1021  virtual bool operator != (const GeoTessModel& other) const { return !(*this == other); } ;
1022 
1023  bool is2D()
1024  {
1025  return getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE
1026  || getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE_EMPTY;
1027  }
1028 
1029  bool is3D()
1030  {
1031  return !is2D();
1032  }
1033 
1052  {
1053  if (!pointMap->isPopulated())
1054  pointMap->setActiveRegion();
1055  return pointMap;
1056  }
1057 
1066  const set<int>& getConnectedVertices(int layerIndex)
1067  {
1068  return grid->getVertexIndicesTopLevel(metaData->getTessellation(layerIndex));
1069  }
1070 
1077  {
1078  pointMap->setActiveRegion();
1079  }
1080 
1093  void setActiveRegion(const string& polygon)
1094  {
1095  pointMap->setActiveRegion(polygon);
1096  }
1097 
1110  {
1111  if (polygon == NULL)
1112  pointMap->setActiveRegion();
1113  else
1114  pointMap->setActiveRegion(polygon);
1115  }
1116 
1125  GeoTessPolygon* getPolygon() { return pointMap->getPolygon(); }
1126 
1135  void getLayerCount(bool activeOnly, int* layerCount)
1136  {
1137  for (int layer=0; layer<getNLayers(); ++layer)
1138  layerCount[layer] = 0;
1139 
1140  GeoTessProfile** pp;
1141  GeoTessProfile* p;
1142  for (int v=0; v<getNVertices(); ++v)
1143  {
1144  pp = profiles[v];
1145  for (int layer=0; layer<getNLayers(); ++layer)
1146  {
1147  if (activeOnly)
1148  {
1149  p = pp[layer];
1150  for (int n=0; n<p->getNData(); ++n)
1151  if (p->getPointIndex(n) >= 0)
1152  ++layerCount[layer];
1153  }
1154  else
1155  layerCount[layer] += pp[layer]->getNData();
1156  }
1157  }
1158  }
1159 
1167  GeoTessProfile* getProfile(int vertex, int layer)
1168  {
1169  return profiles[vertex][layer];
1170  }
1171 
1179  {
1180  return profiles[vertex];
1181  }
1182 
1187  GeoTessProfile*** getProfiles() const { return profiles; }
1188 
1199  void setProfile(int vertex, int layer, GeoTessProfile* profile);
1200 
1214  template<typename T>
1215  void setProfile(int vertex, int layer, vector<float>& radii, vector<vector<T> >& values)
1216  {
1217  if (getConnectedVertices(layer).count(vertex) == 1)
1218  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, values));
1219  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1]));
1220  }
1221 
1237  template<typename T>
1238  void setProfile(const int& vertex, const int& layer,
1239  float* radii, const int& nRadii,
1240  T** values, const int& nNodes, const int& nAttributes)
1241  {
1242  if (getConnectedVertices(layer).count(vertex) == 1)
1243  setProfile(vertex, layer, GeoTessProfile::newProfile(radii, nRadii, values, nNodes, nAttributes));
1244  else setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1]));
1245  }
1246 
1255  void setProfile(int vertex, int layer, vector<float>& radii)
1256  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[radii.size()-1])); }
1257 
1267  template<typename T>
1268  void setProfile(const int& vertex, const int& layer, float* radii, const int& nRadii)
1269  { setProfile(vertex, layer, new GeoTessProfileEmpty(radii[0], radii[nRadii-1])); }
1270 
1279  template<typename T>
1280  void setProfile(const int& vertex, vector<T>& values)
1281  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values))); }
1282 
1292  template<typename T>
1293  void setProfile(const int& vertex, T* values, const int& nAttributes)
1294  { setProfile(vertex, 0, new GeoTessProfileSurface(GeoTessData::getData(values, nAttributes))); }
1295 
1301  void setProfile(const int& vertex)
1302  { setProfile(vertex, 0, new GeoTessProfileSurfaceEmpty()); }
1303 
1311  void writeModel(const string& outputFile) { writeModel(outputFile, "*"); }
1312 
1327  void writeModel(const string& outputFile, const string& gridFileName);
1328 
1333  string toString();
1334 
1342  void getLayerCount(vector<int>& layerCount, const bool& activeOnly)
1343  {
1344  layerCount.resize(metaData->getNLayers(), 0);
1345 
1346  GeoTessProfile** pp;
1347  GeoTessProfile* p;
1348  for (int vtx=0; vtx<getNVertices(); ++vtx)
1349  {
1350  pp = profiles[vtx];
1351  for (int layer = 0; layer < metaData->getNLayers(); ++layer)
1352  if (activeOnly)
1353  {
1354  p = pp[layer];
1355  for (int n = 0; n < p->getNData(); ++n)
1356  if (p->getPointIndex(n) >= 0)
1357  ++layerCount[layer];
1358  }
1359  else
1360  layerCount[layer] += pp[layer]->getNData();
1361  }
1362  }
1363 
1371  void profileCount(vector< vector<int> >& count)
1372  {
1373  count.clear();
1374 
1375  getPointMap();
1376 
1377  // this is total number of profiles of each type, independent of layer index.
1378  vector<int> totalCount;
1379  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1380  totalCount.push_back(0);
1381 
1382  for (int layer = 0; layer < getNLayers(); ++layer)
1383  {
1384  vector<int> typeCount;
1385 
1386  for (int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1387  typeCount.push_back(0);
1388 
1389  count.push_back(typeCount);
1390  }
1391 
1392  for (int layer = 0; layer < getNLayers(); ++layer)
1393  {
1394  for (int vertex = 0; vertex < metaData->getNVertices(); ++vertex)
1395  {
1396  int pType = profiles[vertex][layer]->getType().ordinal();
1397  count[layer][pType] += 1;
1398  totalCount[pType] += 1;
1399  }
1400  }
1401 
1402  count.push_back(totalCount);
1403  }
1404 
1438  template<typename T>
1439  void initializeData(const vector<string>& attributeNames,
1440  const vector<string>& attributeUnits, T fillValue)
1441  {
1442  if (profiles == NULL)
1443  {
1444  ostringstream os;
1445  os << endl << "ERROR in GeoTessModel::initializeData" << endl
1446  << "Attempting to initialize the model data before Profiles" << endl
1447  << "have been specified (profiles == NULL)" << endl;
1448  throw GeoTessException(os, __FILE__, __LINE__, 1001);
1449  }
1450 
1451  const GeoTessDataType& newDataType = GeoTessDataType::getDataType(fillValue);
1452  int nAttributesNew = attributeNames.size();
1453 
1454  int newDataTypeOrdinal = newDataType.ordinal();
1455  int oldDataTypeOrdinal = metaData->getDataType().ordinal();
1456 
1457  // if neither the dataType or the number of attributes has changed, there is no need to
1458  // copy the data. The only thing that happens is that the attributeNames or attributeUnits might change.
1459  if (newDataTypeOrdinal != oldDataTypeOrdinal || nAttributesNew != metaData->getNAttributes())
1460  {
1461  // initialize an array of the new dataType with number of elements
1462  // equal to the number of new attributes and populate it with fillValue.
1463  T* newValues = new T[nAttributesNew];
1464  for (int i=0; i<nAttributesNew; ++i)
1465  newValues[i] = fillValue;
1466 
1467  GeoTessProfile* profile;
1468  vector<GeoTessData*> data;
1469  for (int v = 0; v < getNVertices(); ++v)
1470  for (int lid = 0; lid < getNLayers(); ++lid)
1471  {
1472  profile = profiles[v][lid];
1473  data.reserve(profile->getNData());
1474  data.clear();
1475  for (int n = 0; n < profile->getNData(); ++n)
1476  {
1477  profile->getData(n)->getValues(newValues, nAttributesNew);
1478  data.push_back(GeoTessData::getData(newValues, nAttributesNew));
1479  }
1480  // set new entries into profile and continue
1481  profile->setData(data);
1482  }
1483  delete[] newValues;
1484  }
1485 
1486  metaData->setDataType(newDataType);
1487 
1488  metaData->setAttributes(attributeNames, attributeUnits);
1489  }
1490 
1503  template<typename T>
1504  void initializeData(const string& attributeNames,
1505  const string& attributeUnits, T fillValue)
1506  {
1507  vector<string> names;
1508  CPPUtils::tokenizeString(attributeNames, ";", names);
1509  vector<string> units;
1510  CPPUtils::tokenizeString(attributeUnits, ";", units);
1511  initializeData(names, units, fillValue);
1512  }
1513 
1538  void getWeights(const double* pointA, const double* pointB, const double& pointSpacing, const double& radius,
1539  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1540 
1564  void getWeights(GeoTessGreatCircle& greatCircle, const double& pointSpacing, const double& radius,
1565  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights);
1566 
1590  void getWeights(const vector<double*>& rayPath,
1591  const vector<double>& radii,
1592  const vector<int>& layerIds,
1593  const GeoTessInterpolatorType& horizontalType,
1594  const GeoTessInterpolatorType& radialType,
1595  map<int, double>& weights);
1596 
1621  void getWeights(double** rayPath, double* radii, int* layerIds, const int& numPoints,
1622  const GeoTessInterpolatorType& horizontalType,
1623  const GeoTessInterpolatorType& radialType,
1624  map<int, double>& weights);
1625 
1638  double getPathIntegral(const int& attribute, const map<int, double>& weights);
1639 
1676  double getPathIntegral(const int& attribute, const bool& reciprocal,
1677  double** rayPath, double* radii, int* layerIds, const int& numPoints,
1678  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1679  map<int, double>* weights = NULL);
1680 
1716  double getPathIntegral(const int& attribute, const bool& reciprocal,
1717  const vector<double*>& rayPath, const vector<double>& radii, const vector<int>& layerIds,
1718  const GeoTessInterpolatorType& horizontalType, const GeoTessInterpolatorType& radialType,
1719  map<int, double>* weights = NULL);
1720 
1758  double getPathIntegral2D(const int& attribute, const bool& reciprocal,
1759  const double* firstPoint, const double* lastPoint, double pointSpacing,
1760  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1761  map<int, double>* weights = NULL);
1762 
1799  double getPathIntegral2D(const int& attribute, const bool& reciprocal,
1800  GeoTessGreatCircle& greatCircle, double pointSpacing,
1801  double earthRadius, const GeoTessInterpolatorType& horizontalType,
1802  map<int, double>* weights = NULL);
1803 
1805 
1806  // The following getWeight() and getPathIntegral() functions are deprecated.
1807  // They were included in GeoTessModel v2.1.1 but were reconfigured in v2.2.0.
1808  // They are included here for backward compatibility, but will not appear in the documentation.
1809  void getWeights(const vector<double*>& rayPath, const vector<double>& radii,
1810  const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1811  { vector<int> layerIds; getWeights(rayPath, radii, layerIds, ht, rt, weights);}
1812 
1813  void getWeights(double** rayPath, double* radii, const int& numPoints,
1814  const GeoTessInterpolatorType& ht,const GeoTessInterpolatorType& rt,map<int, double>& weights)
1815  { getWeights(rayPath, radii, NULL, numPoints, ht, rt, weights);}
1816 
1817  double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1818  const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt)
1819  { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt); }
1820 
1821  double getPathIntegral(const int& attribute, const bool& reciprocal, double** rayPath, double* radii, const int& numPoints,
1822  const GeoTessInterpolatorType& ht, const GeoTessInterpolatorType& rt, map<int, double>& weights)
1823  { return getPathIntegral(attribute, reciprocal, rayPath, radii, NULL, numPoints, ht, rt, &weights); }
1824 
1825  double getPathIntegral2D(const int& attribute, const bool& reciprocal,
1826  const double* firstPoint, const double* lastPoint, const double& pointSpacing,
1827  const double& earthRadius,
1828  const GeoTessInterpolatorType& horizontalType, map<int, double>& weights)
1829  { return getPathIntegral2D(attribute, reciprocal, firstPoint, lastPoint, pointSpacing, earthRadius, horizontalType, &weights); }
1830 
1831 
1835  bool isSupportedFormatVersion(int frmtVrsn) { return (frmtVrsn == 1) ? true : false; }
1836 
1842  bool testLayerRadii();
1843 
1844 
1846 
1847 };
1848 // end class GeoTessModel
1849 
1850 }// end namespace geotess
1851 
1852 #endif // GEOTESSMODEL_OBJECT_H
GeoTessGrid * loadGrid(const string &inputFile)
GeoTessGrid & getGrid()
Definition: GeoTessModel.h:674
void setProfile(int vertex, int layer, vector< float > &radii, vector< vector< T > > &values)
Definition: GeoTessModel.h:1215
void setEarthShape(const string &earthShapeName)
Definition: GeoTessModel.h:662
virtual double getDouble(int attributeIndex) const
virtual float getFloat(int attributeIndex) const
void setAttributes(const string &nms, const string &unts)
Definition: GeoTessMetaData.h:799
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)
Definition: GeoTessModel.h:990
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)
Definition: GeoTessModel.h:1342
const GeoTessGrid & getGrid() const
Definition: GeoTessModel.h:668
void setActiveRegion()
Definition: GeoTessModel.h:1076
LONG_INT getValueLong(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:937
const double * getVertex(int vertex) const
Definition: GeoTessGrid.h:573
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurfaceEmpty.h:77
int getNData(int vertexId, int layerId)
Definition: GeoTessModel.h:754
Information about an interpolated point at an arbitrary position in a model.
Definition: GeoTessPosition.h:101
void setProfile(const int &vertex, vector< T > &values)
Definition: GeoTessModel.h:1280
short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:853
int getNVertices() const
Definition: GeoTessMetaData.h:480
float getValueFloat(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:924
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:79
int getTessellation(int layer) const
Definition: GeoTessMetaData.h:603
virtual LONG_INT getLong(int attributeIndex) const
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:163
int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:838
EarthShape & getEarthShape()
Definition: GeoTessMetaData.h:358
static void clearReuseGrid()
Definition: GeoTessModel.h:600
bool is3D()
Definition: GeoTessModel.h:1029
double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:793
int getNVertices() const
Definition: GeoTessGrid.h:763
static string getGridID(const string &fileName)
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:67
static GeoTessData * getData(const GeoTessDataType &dataType, int nAttributes)
void getLayerCount(bool activeOnly, int *layerCount)
Definition: GeoTessModel.h:1135
virtual GeoTessData ** getData()
void setActiveRegion(const string &polygon)
Definition: GeoTessModel.h:1093
int getNAttributes()
Definition: GeoTessModel.h:760
byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:868
int getNLayers() const
Definition: GeoTessMetaData.h:491
int getNAttributes() const
Definition: GeoTessMetaData.h:829
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)
Definition: GeoTessModel.h:1255
static int getReuseGridMapSize()
Definition: GeoTessModel.h:608
double getDepth(int vertexId, int layerId, int nodeId)
Definition: GeoTessModel.h:780
byte getValueByte(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:976
bool is2D()
Definition: GeoTessModel.h:1023
const set< int > & getConnectedVertices(int layerIndex)
Definition: GeoTessModel.h:1066
int getNRadii(int vertexId, int layerId)
Definition: GeoTessModel.h:745
An exception class for all GeoTess objects.
Definition: GeoTessException.h:65
virtual byte getByte(int attributeIndex) const
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
Definition: GeoTessOptimizationType.h:66
double getDepth(int pointIndex)
Definition: GeoTessModel.h:901
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)
Definition: GeoTessModel.h:823
void setGridInputFile(const string &gridFile)
Definition: GeoTessGrid.h:548
#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)
Definition: GeoTessModel.h:1178
virtual int getInt(int attributeIndex) const
void profileCount(vector< vector< int > > &count)
Definition: GeoTessModel.h:1371
void writeModel(const string &outputFile)
Definition: GeoTessModel.h:1311
virtual void setData(int index, GeoTessData *data)
const GeoTessDataType & getDataType() const
Definition: GeoTessMetaData.h:659
Definition: EarthShape.h:64
GeoTessMetaData & getMetaData()
Definition: GeoTessModel.h:683
virtual GeoTessData & setValue(int attributeIndex, double v)
void setActiveRegion(GeoTessPolygon *polygon)
Definition: GeoTessModel.h:1109
GeoTessProfile *** getProfiles() const
Definition: GeoTessModel.h:1187
void initializeData(const vector< string > &attributeNames, const vector< string > &attributeUnits, T fillValue)
Definition: GeoTessModel.h:1439
float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
Definition: GeoTessModel.h:808
GeoTessProfile * getProfile(int vertex, int layer)
Definition: GeoTessModel.h:1167
GeoTessPointMap * getPointMap()
Definition: GeoTessModel.h:1051
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii)
Definition: GeoTessModel.h:1268
double getValueDouble(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:911
EarthShape & getEarthShape()
Definition: GeoTessModel.h:635
#define LONG_INT
Definition: CPPGlobals.h:111
GeoTessPolygon * getPolygon()
Definition: GeoTessModel.h:1125
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)
Definition: GeoTessModel.h:950
virtual int getPointIndex(int nodeIndex) const
Top level class that manages the GeoTessMetaData, GeoTessGrid and Data that comprise a 3D Earth model...
Definition: GeoTessModel.h:119
short getValueShort(int pointIndex, int attributeIndex)
Definition: GeoTessModel.h:963
virtual void getValues(double values[], const int &n)
void setDataType(const GeoTessDataType &dt)
void initializeData(const string &attributeNames, const string &attributeUnits, T fillValue)
Definition: GeoTessModel.h:1504
double getRadius(int pointIndex)
Definition: GeoTessModel.h:892
void setProfile(const int &vertex)
Definition: GeoTessModel.h:1301
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:96
void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
Definition: GeoTessModel.h:884
const set< int > & getVertexIndicesTopLevel(const int &tessId)
Definition: GeoTessGrid.h:756
static string class_name()
Definition: GeoTessModel.h:572
int getNVertices() const
Definition: GeoTessModel.h:730
double getRadius(int vertexId, int layerId, int nodeId)
Definition: GeoTessModel.h:769
int ordinal() const
Definition: GeoTessEnumType.h:148
void setEarthShape(const string &earthShapeName)
Definition: GeoTessMetaData.h:360
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii, T **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessModel.h:1238
int getNPoints()
Definition: GeoTessModel.h:1001
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
int getNLayers() const
Definition: GeoTessModel.h:736
virtual short getShort(int attributeIndex) const
void setProfile(const int &vertex, T *values, const int &nAttributes)
Definition: GeoTessModel.h:1293
virtual int getNData() const