36 #ifndef PROFILE_OBJECT_H
37 #define PROFILE_OBJECT_H
62 class GeoTessInterpolatorType;
63 class GeoTessMetaData;
103 static int aClassCount;
126 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<GeoTessData*>& data);
128 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<vector<double> >& data);
129 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<vector<float> >& data);
130 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<vector<LONG_INT> >& data);
131 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<vector<int> >& data);
132 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<vector<short> >& data);
133 static GeoTessProfile* newProfile(
const vector<float>& radii, vector<vector<byte> >& data);
161 if (nNodes < 1 && nRadii == 2)
162 return GeoTessProfile::newProfile(radii, nRadii, NULL, 0);
167 d[0] = GeoTessData::getData(values[0], nAttributes);
168 return GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
172 for (
int i=0; i<nNodes; ++i) d[i] = GeoTessData::getData(values[i], nAttributes);
173 GeoTessProfile* profile = GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
180 if (nNodes < 1 && nRadii == 2)
181 return GeoTessProfile::newProfile(radii, nRadii, NULL, 0);
186 d[0] = GeoTessData::getData(values[0], nAttributes);
187 return GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
191 for (
int i=0; i<nNodes; ++i) d[i] = GeoTessData::getData(values[i], nAttributes);
192 GeoTessProfile* profile = GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
199 if (nNodes < 1 && nRadii == 2)
200 return GeoTessProfile::newProfile(radii, nRadii, NULL, 0);
205 d[0] = GeoTessData::getData(values[0], nAttributes);
206 return GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
210 for (
int i=0; i<nNodes; ++i) d[i] = GeoTessData::getData(values[i], nAttributes);
211 GeoTessProfile* profile = GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
218 if (nNodes < 1 && nRadii == 2)
219 return GeoTessProfile::newProfile(radii, nRadii, NULL, 0);
224 d[0] = GeoTessData::getData(values[0], nAttributes);
225 return GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
229 for (
int i=0; i<nNodes; ++i) d[i] = GeoTessData::getData(values[i], nAttributes);
230 GeoTessProfile* profile = GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
237 if (nNodes < 1 && nRadii == 2)
238 return GeoTessProfile::newProfile(radii, nRadii, NULL, 0);
243 d[0] = GeoTessData::getData(values[0], nAttributes);
244 return GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
248 for (
int i=0; i<nNodes; ++i) d[i] = GeoTessData::getData(values[i], nAttributes);
249 GeoTessProfile* profile = GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
256 if (nNodes < 1 && nRadii == 2)
257 return GeoTessProfile::newProfile(radii, nRadii, NULL, 0);
262 d[0] = GeoTessData::getData(values[0], nAttributes);
263 return GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
267 for (
int i=0; i<nNodes; ++i) d[i] = GeoTessData::getData(values[i], nAttributes);
268 GeoTessProfile* profile = GeoTessProfile::newProfile(radii, nRadii, d, nNodes);
308 int attributeIndex,
double radius,
bool allowRadiusOutOfRange)
const =
ABSTRACT;
315 const vector<double>& coefficients,
int attributeIndex)
const
318 for (
int i=0; i<(int)nodeIds.size(); ++i)
319 value += getValue(attributeIndex, nodeIds[i])*coefficients[i];
331 virtual double getValue(
int attributeIndex,
int nodeIndex)
const =
ABSTRACT;
343 virtual bool isNaN(
int nodeIndex,
int attributeIndex) =
ABSTRACT;
351 virtual double getValueTop(
int attributeIndex)
const =
ABSTRACT;
361 return getValue(attributeIndex, 0);
368 virtual float getRadius(
int i)
const =
ABSTRACT;
373 virtual int getNRadii()
const =
ABSTRACT;
378 virtual int getNData()
const =
ABSTRACT;
384 virtual float* getRadii() =
ABSTRACT;
418 virtual void setData(
const vector<GeoTessData*>& inData) =
ABSTRACT;
425 virtual void setRadii(
const vector<float>& newRadii) =
ABSTRACT;
430 virtual void setRadius(
int index,
float radius) =
ABSTRACT;
435 virtual float getRadiusTop()
const =
ABSTRACT;
450 virtual float getRadiusBottom()
const =
ABSTRACT;
473 {
return getRadiusIndex(radius, -1); }
505 bool allowOutOfRange)
const
507 if (!allowOutOfRange && (radius < getRadiusBottom() || radius > getRadiusTop()))
521 virtual int getPointIndex(
int nodeIndex)
const =
ABSTRACT;
527 virtual int findClosestRadiusIndex(
double radius)
const =
ABSTRACT;
537 virtual void getWeights(map<int, double>& weights,
538 double dkm,
double radius,
double hcoefficient)
const
542 int index = getPointIndex(0);
548 map<int, double>::iterator it = weights.find(index);
549 if (it == weights.end())
550 weights[index] = dkm * hcoefficient;
552 it->second += dkm * hcoefficient;
561 virtual void getCoefficients(map<int, double>& coefficients,
double radius,
562 double horizontalCoefficient)
const
567 coefficients[getPointIndex(0)] = horizontalCoefficient;
573 GeoTessProfile() { ++aClassCount; };
578 virtual ~GeoTessProfile() { --aClassCount; };
583 static GeoTessProfile* newProfile(IFStreamBinary& ifs, GeoTessMetaData& gtmd);
588 static GeoTessProfile* newProfile(IFStreamAscii& ifs, GeoTessMetaData& gtmd);
593 virtual void write(IFStreamBinary& ofs) =
ABSTRACT;
598 virtual void write(IFStreamAscii& ofs) =
ABSTRACT;
607 virtual void setPointIndex(
int nodeIndex,
int pointIndex) =
ABSTRACT;
616 virtual void resetPointIndices() =
ABSTRACT;
618 virtual void setInterpolationCoefficients(
const GeoTessInterpolatorType& interpType,
619 vector<int>& nodeIndexes, vector<double>& coefficients,
620 double& radius,
bool& allowOutOfRange)
624 nodeIndexes.push_back(0);
625 if (!allowOutOfRange && (radius < getRadiusBottom() || radius > getRadiusTop()))
626 coefficients.push_back(NaN_DOUBLE);
628 coefficients.push_back(1.);
634 virtual GeoTessProfile* copy() =
ABSTRACT;
642 #endif // PROFILE_OBJECT_H
static GeoTessProfile * newProfile(float *radii, const int &nRadii, byte **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessProfile.h:254
double getValue(const vector< int > &nodeIds, const vector< double > &coefficients, int attributeIndex) const
Retrieve the value of the specified attribute interpolated at the specified radius.
Definition: GeoTessProfile.h:314
Definition: ArrayReuse.h:55
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR, NATURAL_NEIGHBOR and CUBIC_SPLINE.
Definition: GeoTessInterpolatorType.h:71
virtual double getValueBottom(int attributeIndex) const
Retrieve the value of the specified attribute at the bottom of the layer.
Definition: GeoTessProfile.h:359
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE...
Definition: GeoTessProfileType.h:69
static int class_count()
Returns the class instance count.
Definition: GeoTessProfile.h:288
virtual const GeoTessProfileType & getType() const
One of EMPTY, THIN, CONSTANT, NPOINT, SURFACE.
double getThickness()
Return the thickness of the layer in km.
Definition: GeoTessProfile.h:465
virtual double getInterpolationCoefficient(int i, double radius, bool allowOutOfRange) const
find interpolation coefficient.
Definition: GeoTessProfile.h:504
static GeoTessProfile * newProfile(float *radii, const int &nRadii, float **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessProfile.h:178
virtual int getRadiusIndex(double radius, int jlo) const
Find index i such that radius is >= radii[i] and < radii[i+1].
Definition: GeoTessProfile.h:486
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
#define ABSTRACT
Global constant used to make pure virtual functions readable.
Definition: CPPGlobals.h:78
#define LONG_INT
Definition: CPPGlobals.h:111
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
virtual int class_size() const
Returns the class size.
Definition: GeoTessProfile.h:281
static GeoTessProfile * newProfile(float *radii, const int &nRadii, short **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessProfile.h:235
static GeoTessProfile * newProfile(float *radii, const int &nRadii, double **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessProfile.h:159
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
static GeoTessProfile * newProfile(float *radii, const int &nRadii, LONG_INT **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessProfile.h:197
int getRadiusIndex(double radius) const
Find index i such that radius is >= radii[i] and < radii[i+1].
Definition: GeoTessProfile.h:472
static GeoTessProfile * newProfile(float *radii, const int &nRadii, int **values, const int &nNodes, const int &nAttributes)
Definition: GeoTessProfile.h:216
static string class_name()
Returns the class name.
Definition: GeoTessProfile.h:276