GeoTessCPP  2.2.3
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessPointMap.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 POINTMAP_OBJECT_H
39 #define POINTMAP_OBJECT_H
40 
41 // **** _SYSTEM INCLUDES_ ******************************************************
42 
43 #include <cstdio>
44 
45 // use standard library objects
46 using namespace std;
47 
48 // **** _LOCAL INCLUDES_ *******************************************************
49 
50 #include "CPPUtils.h"
51 #include "GeoTessGrid.h"
52 #include "GeoTessProfile.h"
53 #include "GeoTessMetaData.h"
54 #include "GeoTessPolygon.h"
55 #include "GeoTessPolygon3D.h"
56 #include "GeoTessPolygonFactory.h"
57 
58 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
59 
60 namespace geotess
61 {
62 
63 // **** _FORWARD REFERENCES_ ***************************************************
64 
65 class GeoTessModel;
66 
67 // **** _CLASS DEFINITION_ *****************************************************
68 
77 {
78 private:
79 
83  GeoTessGrid& grid;
84 
89  GeoTessProfile *** profiles;
90 
107  GeoTessMetaData& metaData;
108 
109  GeoTessPolygon* polygon;
110 
116  vector<vector<int> > pointMap;
117 
118  bool populated;
119 
120 public:
121 
127 
132 
137 
142  bool operator==(const GeoTessPointMap& other);
143 
147  bool operator!=(const GeoTessPointMap& other) { return !(*this == other); }
148 
153 
155  {
156  return (LONG_INT) sizeof(GeoTessPointMap)
157  + (LONG_INT)(pointMap.capacity() * sizeof(vector<int>)
158  + pointMap.size() * 3 * (LONG_INT)sizeof(int));
159  }
160 
168 
179 
189  void setActiveRegion(const string& polygonFileName)
190  {
191  GeoTessPolygon* plgn = GeoTessPolygonFactory::getPolygon(polygonFileName);
192  setActiveRegion(plgn);
193  }
194 
202  GeoTessPolygon* getPolygon() { return polygon; }
203 
211  void clear();
212 
217  bool isPopulated() { return populated; }
218 
224  int size()
225  {
226  return pointMap.size();
227  }
228 
237  int getVertexIndex(int pointIndex)
238  {
239  return pointMap[pointIndex][0];
240  }
241 
250  int getTessId(int pointIndex)
251  {
252  return metaData.getTessellation(pointMap[pointIndex][1]);
253  }
254 
263  int getLayerIndex(int pointIndex)
264  {
265  return pointMap[pointIndex][1];
266  }
267 
276  int getNodeIndex(int pointIndex)
277  {
278  return pointMap[pointIndex][2];
279  }
280 
289  const vector<int>& getPointIndices(int pointIndex)
290  {
291  return pointMap[pointIndex];
292  }
293 
304  int getPointIndex(int vertex, int layer, int node)
305  {
306  return profiles[vertex][layer]->getPointIndex(node);
307  }
308 
319  int getPointIndexLast(int vertex, int layer)
320  {
321  return profiles[vertex][layer]->getPointIndex(profiles[vertex][layer]->getNData()-1);
322  }
323 
334  int getPointIndexFirst(int vertex, int layer)
335  {
336  return profiles[vertex][layer]->getPointIndex(0);
337  }
338 
342  void setPointData(int pointIndex, GeoTessData* data)
343  {
344  vector<int>& map = pointMap[pointIndex];
345  profiles[map[0]][map[1]]->setData(map[2], data);
346  }
347 
353  GeoTessData* getPointData(int pointIndex)
354  {
355  vector<int>& map = pointMap[pointIndex];
356  return profiles[map[0]][map[1]]->getData(map[2]);
357  }
358 
367  template <typename T>
368  void setPointValue(int pointIndex, int attributeIndex, T value)
369  {
370  vector<int>& map = pointMap[pointIndex];
371  profiles[map[0]][map[1]]->getData(map[2])->setValue(attributeIndex,
372  value);
373  }
374 
382  double getPointValue(int pointIndex, int attributeIndex)
383  {
384  vector<int>& map = pointMap[pointIndex];
385  return profiles[map[0]][map[1]]->getValue(attributeIndex, map[2]);
386  }
387 
397  double getPointValueDouble(int pointIndex, int attributeIndex)
398  {
399  vector<int>& map = pointMap[pointIndex];
400  return profiles[map[0]][map[1]]->getData(map[2])->getDouble(attributeIndex);
401  }
402 
412  float getPointValueFloat(int pointIndex, int attributeIndex)
413  {
414  vector<int>& map = pointMap[pointIndex];
415  return profiles[map[0]][map[1]]->getData(map[2])->getFloat(attributeIndex);
416  }
417 
427  LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
428  {
429  vector<int>& map = pointMap[pointIndex];
430  return profiles[map[0]][map[1]]->getData(map[2])->getLong(attributeIndex);
431  }
432 
442  int getPointValueInt(int pointIndex, int attributeIndex)
443  {
444  vector<int>& map = pointMap[pointIndex];
445  return profiles[map[0]][map[1]]->getData(map[2])->getInt(attributeIndex);
446  }
447 
457  short getPointValueShort(int pointIndex, int attributeIndex)
458  {
459  vector<int>& map = pointMap[pointIndex];
460  return profiles[map[0]][map[1]]->getData(map[2])->getShort(attributeIndex);
461  }
462 
472  byte getPointValueByte(int pointIndex, int attributeIndex)
473  {
474  vector<int>& map = pointMap[pointIndex];
475  return profiles[map[0]][map[1]]->getData(map[2])->getByte(attributeIndex);
476  }
477 
487  bool isNaN(int pointIndex, int attributeIndex)
488  {
489  vector<int>& map = pointMap[pointIndex];
490  return profiles[map[0]][map[1]]->isNaN(map[2], attributeIndex);
491  }
492 
501  void getPointVector(int pointIndex, double* v)
502  {
503  vector<int>& map = pointMap[pointIndex];
504  const double* vv = grid.getVertex(map[0]);
505  double r = profiles[map[0]][map[1]]->getRadius(map[2]);
506  v[0] = vv[0] * r;
507  v[1] = vv[1] * r;
508  v[2] = vv[2] * r;
509  }
510 
517  const double* getPointUnitVector(int pointIndex) const
518  {
519  return grid.getVertex(pointMap[pointIndex][0]);
520  }
521 
528  double getPointRadius(int pointIndex)
529  {
530  vector<int>& map = pointMap[pointIndex];
531  return profiles[map[0]][map[1]]->getRadius(map[2]);
532  }
533 
540  double getPointDepth(int pointIndex)
541  {
542  vector<int>& map = pointMap[pointIndex];
543  return GeoTessUtils::getEarthRadius(
544  grid.getVertex(pointMap[pointIndex][0]))
545  - profiles[map[0]][map[1]]->getRadius(map[2]);
546  }
547 
555  double getDistance3D(int pointIndex1, int pointIndex2)
556  {
557  vector<int>& m1 = pointMap[pointIndex1];
558  vector<int>& m2 = pointMap[pointIndex2];
559  return GeoTessUtils::getDistance3D(grid.getVertex(m1[0]),
560  profiles[m1[0]][m1[1]]->getRadius(m1[2]), grid.getVertex(m2[0]),
561  profiles[m2[0]][m2[1]]->getRadius(m2[2]));
562  }
563 
564 // /**
565 // * Append the input new values array to the profile at pointIndex
566 // */
567 // template<typename T>
568 // void appendData(int pointIndex, T* newValues, int n)
569 // {
570 // vector<int>& map = pointMap[pointIndex];
571 // profiles[map[0]][map[1]]->appendData<T>(map[2], newValues, n);
572 // }
573 
574 
598  void getPointNeighbors(set<int>& pointNeighbors, int pointIndex);
599 
605  string getPointLatLonString(int pointIndex)
606  {
607  return GeoTessUtils::getLatLonString(getPointUnitVector(pointIndex));
608  }
609 
615  string toString(int pointIndex)
616  {
617  char s[100];
618  string frmt = "%8.3f";
619  sprintf(s, frmt.c_str(), getPointDepth(pointIndex));
620  return GeoTessUtils::getLatLonString(getPointUnitVector(pointIndex))
621  + " " + s;
622  }
623 
624 };
625 // end class PointMap
626 
627 }// end namespace geotess
628 
629 #endif // POINTMAP_OBJECT_H
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::GeoTessProfile
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:99
geotess::GeoTessPointMap::getPolygon
GeoTessPolygon * getPolygon()
Definition: GeoTessPointMap.h:202
geotess::GeoTessPointMap::getPointValueShort
short getPointValueShort(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:457
geotess::GeoTessPointMap::getPointValueByte
byte getPointValueByte(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:472
GeoTessProfile.h
geotess::GeoTessPointMap::getPointValue
double getPointValue(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:382
geotess::GeoTessPointMap::getPointValueInt
int getPointValueInt(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:442
geotess::GeoTessPointMap::getPointIndexFirst
int getPointIndexFirst(int vertex, int layer)
Definition: GeoTessPointMap.h:334
GeoTessPolygon.h
geotess::GeoTessData::getInt
virtual int getInt(int attributeIndex) const
geotess::GeoTessPointMap::getPointNeighbors
void getPointNeighbors(set< int > &pointNeighbors, int pointIndex)
geotess::GeoTessMetaData::getTessellation
int getTessellation(int layer) const
Definition: GeoTessMetaData.h:685
geotess::GeoTessPointMap::getPointData
GeoTessData * getPointData(int pointIndex)
Definition: GeoTessPointMap.h:353
geotess::GeoTessPointMap::getPointValueLong
LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:427
geotess::GeoTessPointMap::getDistance3D
double getDistance3D(int pointIndex1, int pointIndex2)
Definition: GeoTessPointMap.h:555
geotess::GeoTessProfile::getRadius
virtual float getRadius(int i) const
geotess::GeoTessPointMap::GeoTessPointMap
GeoTessPointMap(GeoTessModel &m)
geotess::GeoTessPointMap::getPointUnitVector
const double * getPointUnitVector(int pointIndex) const
Definition: GeoTessPointMap.h:517
geotess::GeoTessPointMap::getMemory
LONG_INT getMemory()
Definition: GeoTessPointMap.h:154
geotess::GeoTessPointMap::~GeoTessPointMap
~GeoTessPointMap()
GeoTessPolygon3D.h
geotess::GeoTessData::getLong
virtual LONG_INT getLong(int attributeIndex) const
geotess::GeoTessPolygon
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition: GeoTessPolygon.h:114
geotess::GeoTessPointMap::getPointRadius
double getPointRadius(int pointIndex)
Definition: GeoTessPointMap.h:528
geotess::GeoTessPointMap::getPointValueDouble
double getPointValueDouble(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:397
geotess::GeoTessGrid
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:169
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
geotess::GeoTessPointMap::clear
void clear()
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion()
geotess::GeoTessPointMap::getPointIndex
int getPointIndex(int vertex, int layer, int node)
Definition: GeoTessPointMap.h:304
geotess::GeoTessPointMap::operator=
GeoTessPointMap & operator=(const GeoTessPointMap &other)
geotess::GeoTessGrid::getVertex
const double * getVertex(int vertex) const
Definition: GeoTessGrid.h:632
geotess::GeoTessData::getFloat
virtual float getFloat(int attributeIndex) const
geotess::GeoTessPointMap::getLayerIndex
int getLayerIndex(int pointIndex)
Definition: GeoTessPointMap.h:263
geotess::GeoTessPointMap::getTessId
int getTessId(int pointIndex)
Definition: GeoTessPointMap.h:250
geotess::GeoTessPointMap::getVertexIndex
int getVertexIndex(int pointIndex)
Definition: GeoTessPointMap.h:237
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion(GeoTessPolygon *polygon)
geotess::GeoTessData
Abstract base class that manages the data values attached to a single grid point.
Definition: GeoTessData.h:78
geotess::GeoTessProfile::getPointIndex
virtual int getPointIndex(int nodeIndex) const
GeoTessGrid.h
geotess::GeoTessPointMap::getPointLatLonString
string getPointLatLonString(int pointIndex)
Definition: GeoTessPointMap.h:605
geotess::GeoTessPointMap::getPointDepth
double getPointDepth(int pointIndex)
Definition: GeoTessPointMap.h:540
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:73
geotess::GeoTessPointMap::GeoTessPointMap
GeoTessPointMap(GeoTessPointMap &other)
geotess::GeoTessPointMap::isNaN
bool isNaN(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:487
geotess::GeoTessPointMap::setPointValue
void setPointValue(int pointIndex, int attributeIndex, T value)
Definition: GeoTessPointMap.h:368
geotess::GeoTessPointMap::getNodeIndex
int getNodeIndex(int pointIndex)
Definition: GeoTessPointMap.h:276
geotess::GeoTessPointMap::toString
string toString(int pointIndex)
Definition: GeoTessPointMap.h:615
geotess::GeoTessPointMap::getPointIndexLast
int getPointIndexLast(int vertex, int layer)
Definition: GeoTessPointMap.h:319
geotess::GeoTessData::getDouble
virtual double getDouble(int attributeIndex) const
geotess::GeoTessMetaData
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:98
geotess::GeoTessPointMap::getPointValueFloat
float getPointValueFloat(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:412
GeoTessPolygonFactory.h
geotess::GeoTessModel
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
Definition: GeoTessModel.h:123
geotess::GeoTessPointMap::getPointVector
void getPointVector(int pointIndex, double *v)
Definition: GeoTessPointMap.h:501
geotess::GeoTessPointMap::operator!=
bool operator!=(const GeoTessPointMap &other)
Definition: GeoTessPointMap.h:147
GeoTessMetaData.h
geotess::GeoTessPointMap::isPopulated
bool isPopulated()
Definition: GeoTessPointMap.h:217
geotess::GeoTessData::getByte
virtual byte getByte(int attributeIndex) const
geotess::GeoTessPointMap::size
int size()
Definition: GeoTessPointMap.h:224
geotess::GeoTessData::setValue
virtual GeoTessData & setValue(int attributeIndex, double v)
geotess::GeoTessPointMap::setPointData
void setPointData(int pointIndex, GeoTessData *data)
Definition: GeoTessPointMap.h:342
geotess::GeoTessData::getShort
virtual short getShort(int attributeIndex) const
geotess::GeoTessProfile::isNaN
virtual bool isNaN(int nodeIndex, int attributeIndex)
geotess::GeoTessPointMap::getPointIndices
const vector< int > & getPointIndices(int pointIndex)
Definition: GeoTessPointMap.h:289
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion(const string &polygonFileName)
Definition: GeoTessPointMap.h:189
CPPUtils.h
geotess::GeoTessPointMap::operator==
bool operator==(const GeoTessPointMap &other)
geotess::GeoTessProfile::getValue
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double radius, bool allowRadiusOutOfRange) const
geotess::GeoTessProfile::setData
virtual void setData(int index, GeoTessData *data)
geotess::GeoTessProfile::getData
virtual GeoTessData ** getData()