GeoTessCPP
2.2.3
Software to facilitate storage and retrieval of 3D information about the Earth.
|
Go to the documentation of this file.
38 #ifndef GEOTESSMODEL_OBJECT_H
39 #define GEOTESSMODEL_OBJECT_H
72 class GeoTessPosition;
74 class GeoTessMetaData;
75 class GeoTessOptimizationType;
139 static map<string, GeoTessGrid*> reuseGridMap;
180 void deleteProfiles();
192 void loadModelAscii(
const string& inputFile,
const string& relGridFilePath);
210 virtual void loadModelAscii(
IFStreamAscii& input,
const string& inputDirectory,
211 const string& relGridFilePath);
226 void loadModelBinary(
const string& inputFile,
const string& relGridFilePath);
243 virtual void loadModelBinary(
IFStreamBinary& input,
const string& inputDirectory,
244 const string& relGridFilePath);
255 void writeModelAscii(
const string& outputFile,
const string& gridFileName);
266 virtual void writeModelAscii(
IFStreamAscii& output,
const string& gridFileName);
277 void writeModelBinary(
const string& outputFile,
const string& gridFileName);
288 virtual void writeModelBinary(
IFStreamBinary& output,
const string& gridFileName);
303 void loadGrid(T& input,
const string& inputDirectory,
304 const string& relGridFilePath,
const string& gridFileName,
305 const string& gridID,
const string& funcName)
310 map<string, GeoTessGrid*>::iterator it = reuseGridMap.find(gridID);
311 if (it != reuseGridMap.end())
314 if (gridFileName ==
"*")
328 reuseGridMap[gridID] = grid;
338 string gridFil = gridFileName;
339 if (relGridFilePath !=
"")
340 gridFil = CPPUtils::insertPathSeparator(relGridFilePath, gridFileName);
341 if (inputDirectory !=
"")
342 gridFil = CPPUtils::insertPathSeparator(inputDirectory, gridFil);
347 reuseGridMap[gridID] = grid;
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;
364 grid->addReference();
461 vector<int>& attributeFilter);
477 GeoTessModel(
const string& modelInputFile, vector<int>& attributeFilter);
599 for (
int i=0; i<getNVertices(); ++i)
600 for (
int j=0; j<getNLayers(); ++j)
618 LONG_INT memory =
sizeof(map<string, GeoTessGrid*>);
622 for (map<string, GeoTessGrid*>::iterator it = reuseGridMap.begin(); it != reuseGridMap.end(); it++)
623 memory += (
LONG_INT)it->first.length() + it->second->getMemory();
791 int getNData(
int vertexId,
int layerId) {
return profiles[vertexId][layerId]->
getNData(); }
807 {
return profiles[vertexId][layerId]->
getRadius(nodeId); }
817 double getDepth(
int vertexId,
int layerId,
int nodeId)
818 {
return getEarthShape().getEarthRadius(grid->
getVertex(vertexId))
819 - profiles[vertexId][layerId]->
getRadius(nodeId); }
833 return data == NULL ? NaN_DOUBLE : data->
getDouble(attributeIndex);
845 float getValueFloat(
int vertexId,
int layerId,
int nodeId,
int attributeIndex)
848 return data == NULL ? NaN_FLOAT : data->
getFloat(attributeIndex);
863 return data == NULL ? LONG_MIN : data->
getLong(attributeIndex);
875 int getValueInt(
int vertexId,
int layerId,
int nodeId,
int attributeIndex)
878 return data == NULL ? INT_MIN : data->
getInt(attributeIndex);
890 short getValueShort(
int vertexId,
int layerId,
int nodeId,
int attributeIndex)
893 return data == NULL ? SHRT_MIN : data->
getShort(attributeIndex);
905 byte getValueByte(
int vertexId,
int layerId,
int nodeId,
int attributeIndex)
908 return data == NULL ? CHAR_MIN : data->
getByte(attributeIndex);
921 void setValue(
int vertexId,
int layerId,
int nodeId,
int attributeIndex, T value)
922 { profiles[vertexId][layerId]->
getData(nodeId)->
setValue(attributeIndex, value); }
930 {
return getPointMap()->getPointRadius(pointIndex); }
939 {
return getPointMap()->getPointDepth(pointIndex); }
950 GeoTessData* data = getPointMap()->getPointData(pointIndex);
951 return data == NULL ? NaN_DOUBLE : data->
getDouble(attributeIndex);
963 GeoTessData* data = getPointMap()->getPointData(pointIndex);
964 return data == NULL ? NaN_FLOAT : data->
getFloat(attributeIndex);
976 GeoTessData* data = getPointMap()->getPointData(pointIndex);
977 return data == NULL ? LONG_MIN : data->
getLong(attributeIndex);
989 GeoTessData* data = getPointMap()->getPointData(pointIndex);
990 return data == NULL ? INT_MIN : data->
getInt(attributeIndex);
1002 GeoTessData* data = getPointMap()->getPointData(pointIndex);
1003 return data == NULL ? SHRT_MIN : data->
getShort(attributeIndex);
1015 GeoTessData* data = getPointMap()->getPointData(pointIndex);
1016 return data == NULL ? CHAR_MIN : data->
getByte(attributeIndex);
1026 template<
typename T>
1027 void setValue(
int pointIndex,
int attributeIndex, T value)
1029 GeoTessData* data = getPointMap()->getPointData(pointIndex);
1030 if (data != NULL) data->
setValue(attributeIndex, value);
1058 virtual bool operator != (
const GeoTessModel& other)
const {
return !(*
this == other); } ;
1062 return getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE
1063 || getProfile(0, 0)->getType() == GeoTessProfileType::SURFACE_EMPTY;
1148 if (polygon == NULL)
1174 for (
int layer=0; layer<getNLayers(); ++layer)
1175 layerCount[layer] = 0;
1179 for (
int v=0; v<getNVertices(); ++v)
1182 for (
int layer=0; layer<getNLayers(); ++layer)
1187 for (
int n=0; n<p->
getNData(); ++n)
1189 ++layerCount[layer];
1192 layerCount[layer] += pp[layer]->
getNData();
1206 return profiles[vertex][layer];
1217 return profiles[vertex];
1251 template<
typename T>
1252 void setProfile(
int vertex,
int layer, vector<float>& radii, vector<vector<T> >& values)
1254 if (getConnectedVertices(layer).count(vertex) == 1)
1255 setProfile(vertex, layer, GeoTessProfile::newProfile(radii, values));
1274 template<
typename T>
1276 float* radii,
const int& nRadii,
1277 T** values,
const int& nNodes,
const int& nAttributes)
1279 if (getConnectedVertices(layer).count(vertex) == 1)
1280 setProfile(vertex, layer, GeoTessProfile::newProfile(radii, nRadii, values, nNodes, nAttributes));
1304 template<
typename T>
1305 void setProfile(
const int& vertex,
const int& layer,
float* radii,
const int& nRadii)
1316 template<
typename T>
1329 template<
typename T>
1330 void setProfile(
const int& vertex, T* values,
const int& nAttributes)
1364 void writeModel(
const string& outputFile,
const string& gridFileName);
1381 layerCount.resize(metaData->
getNLayers(), 0);
1385 for (
int vtx=0; vtx<getNVertices(); ++vtx)
1388 for (
int layer = 0; layer < metaData->
getNLayers(); ++layer)
1392 for (
int n = 0; n < p->
getNData(); ++n)
1394 ++layerCount[layer];
1397 layerCount[layer] += pp[layer]->
getNData();
1415 vector<int> totalCount;
1416 for (
int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1417 totalCount.push_back(0);
1419 for (
int layer = 0; layer < getNLayers(); ++layer)
1421 vector<int> typeCount;
1423 for (
int profileType=0; profileType<GeoTessProfileType::size(); ++profileType)
1424 typeCount.push_back(0);
1426 count.push_back(typeCount);
1429 for (
int layer = 0; layer < getNLayers(); ++layer)
1431 for (
int vertex = 0; vertex < metaData->
getNVertices(); ++vertex)
1434 count[layer][pType] += 1;
1435 totalCount[pType] += 1;
1439 count.push_back(totalCount);
1475 template<
typename T>
1477 const vector<string>& attributeUnits, T fillValue)
1479 if (profiles == NULL)
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;
1488 const GeoTessDataType& newDataType = GeoTessDataType::getDataType(fillValue);
1489 int nAttributesNew = attributeNames.size();
1491 int newDataTypeOrdinal = newDataType.
ordinal();
1496 if (newDataTypeOrdinal != oldDataTypeOrdinal || nAttributesNew != metaData->
getNAttributes())
1500 T* newValues =
new T[nAttributesNew];
1501 for (
int i=0; i<nAttributesNew; ++i)
1502 newValues[i] = fillValue;
1505 vector<GeoTessData*> data;
1506 for (
int v = 0; v < getNVertices(); ++v)
1507 for (
int lid = 0; lid < getNLayers(); ++lid)
1509 profile = profiles[v][lid];
1512 for (
int n = 0; n < profile->
getNData(); ++n)
1515 data.push_back(GeoTessData::getData(newValues, nAttributesNew));
1540 template<
typename T>
1542 const string& attributeUnits, T fillValue)
1544 vector<string> names;
1545 CPPUtils::tokenizeString(attributeNames,
";", names);
1546 vector<string> units;
1547 CPPUtils::tokenizeString(attributeUnits,
";", units);
1548 initializeData(names, units, fillValue);
1575 void getWeights(
const double* pointA,
const double* pointB,
const double& pointSpacing,
const double& radius,
1628 const vector<double>& radii,
1629 const vector<int>& layerIds,
1632 map<int, double>& weights);
1658 void getWeights(
double** rayPath,
double* radii,
int* layerIds,
const int& numPoints,
1661 map<int, double>& weights);
1711 double** rayPath,
double* radii,
int* layerIds,
const int& numPoints,
1713 map<int, double>* weights = NULL);
1748 const vector<double*>& rayPath,
const vector<double>& radii,
const vector<int>& layerIds,
1750 map<int, double>* weights = NULL);
1788 const double* firstPoint,
const double* lastPoint,
double pointSpacing,
1790 map<int, double>* weights = NULL);
1829 map<int, double>* weights = NULL);
1839 GeoTessModel(
const string& inputFile,
const string& relativeGridPath,
1841 GeoTessModel(
const string& modelInputFile, vector<int>& attributeFilter,
1873 bool isSupportedFormatVersion(
int frmtVrsn) {
return (frmtVrsn == 1) ? true :
false; }
1880 bool testLayerRadii();
1890 #endif // GEOTESSMODEL_OBJECT_H
double getRadius(int vertexId, int layerId, int nodeId)
double getValueDouble(int vertexId, int layerId, int nodeId, int attributeIndex)
void getWeights(const vector< double * > &rayPath, const vector< double > &radii, const vector< int > &layerIds, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > &weights)
float getValueFloat(int vertexId, int layerId, int nodeId, int attributeIndex)
void setProfile(const int &vertex)
Relationships between vertices (2D positions in a tessellation), nodes (1D positions along a radial P...
LONG_INT getValueLong(int pointIndex, int attributeIndex)
short getValueShort(int vertexId, int layerId, int nodeId, int attributeIndex)
Abstract class that manages the radii and data values that span a single layer associated with a sing...
GeoTessPolygon * getPolygon()
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)
GeoTessPosition * getPosition(const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType)
void getLayerCount(vector< int > &layerCount, const bool &activeOnly)
EarthShape & getEarthShape()
GeoTessModel(const string &gridFileName, GeoTessMetaData *metaData)
short getValueShort(int pointIndex, int attributeIndex)
virtual int getInt(int attributeIndex) const
void writeModel(const string &outputFile)
GeoTessModel(GeoTessGrid *grid, GeoTessMetaData *metaData)
static string getGridID(const string &fileName)
void getWeights(GeoTessGreatCircle &greatCircle, const double &pointSpacing, const double &radius, const GeoTessInterpolatorType &horizontalType, map< int, double > &weights)
static LONG_INT getReuseGridMapMemory()
void setProfile(int vertex, int layer, vector< float > &radii, vector< vector< T > > &values)
virtual float getRadius(int i) const
double getPathIntegral(const int &attribute, const map< int, double > &weights)
void initializeData(const vector< string > &attributeNames, const vector< string > &attributeUnits, T fillValue)
int getNData(int vertexId, int layerId)
GeoTessPolygon * getPolygon()
GeoTessProfile ** getProfiles(int vertex)
void setGridInputFile(const string &gridFile)
double getPathIntegral2D(const int &attribute, GeoTessGreatCircle &greatCircle, double pointSpacing, double earthRadius, const GeoTessInterpolatorType &horizontalType, map< int, double > *weights=NULL)
static bool isGeoTessModel(const string &fileName)
virtual LONG_INT getMemory()
void setProfile(int vertex, int layer, vector< float > &radii)
static int getReuseGridMapSize()
GeoTessPointMap * getPointMap()
void setEarthShape(const string &earthShapeName)
void setActiveRegion(const string &polygon)
GeoTessProfile *** getProfiles() const
virtual LONG_INT getLong(int attributeIndex) const
GeoTessMetaData & getMetaData()
GeoTessModel(const string &modelInputFile, vector< int > &attributeFilter)
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Manages information about a great circle path that extends from one point to another point,...
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii, T **values, const int &nNodes, const int &nAttributes)
A Profile object that defines two radii at the bottom and top of the associated layer,...
virtual int getNRadii() const
double getRadius(int pointIndex)
GeoTessModel(const string &modelInputFile)
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Opens ascii file for read and write access.
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
double getPathIntegral(const int &attribute, double **rayPath, double *radii, int *layerIds, const int &numPoints, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > *weights=NULL)
int getNRadii(int vertexId, int layerId)
int getValueInt(int vertexId, int layerId, int nodeId, int attributeIndex)
Defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and be...
GeoTessModel * loadModel(const string &inputFile, const string &relGridFilePath="")
const double * getVertex(int vertex) const
virtual float getFloat(int attributeIndex) const
void setValue(int pointIndex, int attributeIndex, T value)
double getDepth(int vertexId, int layerId, int nodeId)
A Profile object that defines a single Data object and no radius value.
void profileCount(vector< vector< int > > &count)
double getPathIntegral2D(const int &attribute, const double *firstPoint, const double *lastPoint, double pointSpacing, double earthRadius, const GeoTessInterpolatorType &horizontalType, map< int, double > *weights=NULL)
void setProfile(const int &vertex, T *values, const int &nAttributes)
GeoTessModel(const string &inputFile, const string &relativeGridPath, vector< int > &attributeFilter)
GeoTessModel(const string &inputFile, const string &relativeGridPath)
Abstract base class that manages the data values attached to a single grid point.
virtual int getPointIndex(int nodeIndex) const
byte getValueByte(int vertexId, int layerId, int nodeId, int attributeIndex)
double getValueDouble(int pointIndex, int attributeIndex)
byte getValueByte(int pointIndex, int attributeIndex)
void setActiveRegion(GeoTessPolygon *polygon)
float getValueFloat(int pointIndex, int attributeIndex)
void initializeData(const string &attributeNames, const string &attributeUnits, T fillValue)
void setProfile(int vertex, int layer, GeoTessProfile *profile)
LONG_INT getValueLong(int vertexId, int layerId, int nodeId, int attributeIndex)
GeoTessModel(vector< int > &attributeFilter)
void setProfile(const int &vertex, const int &layer, float *radii, const int &nRadii)
virtual int getNData() const
Opens a file for binary read and write access.
void getWeights(const double *pointA, const double *pointB, const double &pointSpacing, const double &radius, const GeoTessInterpolatorType &horizontalType, map< int, double > &weights)
virtual double getDouble(int attributeIndex) const
virtual LONG_INT getMemory()
static string class_name()
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
virtual const GeoTessProfileType & getType() const
static bool isGeoTessModel(const string &fileName, const string &className)
Information about an interpolated point at an arbitrary position in a model.
double getDepth(int pointIndex)
void writeModel(const string &outputFile, const string &gridFileName)
virtual byte getByte(int attributeIndex) const
GeoTessProfile * getProfile(int vertex, int layer)
void setValue(int vertexId, int layerId, int nodeId, int attributeIndex, T value)
GeoTessGrid * loadGrid(const string &inputFile)
virtual GeoTessData & setValue(int attributeIndex, double v)
const set< int > & getConnectedVertices(int layerIndex)
An exception class for all GeoTess objects.
const set< int > & getVertexIndicesTopLevel(const int &tessId)
virtual short getShort(int attributeIndex) const
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
static void clearReuseGrid()
void getWeights(double **rayPath, double *radii, int *layerIds, const int &numPoints, const GeoTessInterpolatorType &horizontalType, const GeoTessInterpolatorType &radialType, map< int, double > &weights)
const GeoTessGrid & getGrid() const
void getLayerCount(bool activeOnly, int *layerCount)
void setProfile(const int &vertex, vector< T > &values)
virtual void setData(int index, GeoTessData *data)
GeoTessPosition * getPosition()
virtual void getValues(double values[], const int &n)
A Profile object that defines a single Data object and no radius value.
GeoTessPosition * getPosition(const GeoTessInterpolatorType &horizontalType)
int getValueInt(int pointIndex, int attributeIndex)
virtual GeoTessData ** getData()
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...