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);
159 static GeoTessProfile* newProfile(
float* radii,
const int& nRadii,
double** values,
const int& nNodes,
const int& nAttributes)
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);
178 static GeoTessProfile* newProfile(
float* radii,
const int& nRadii,
float** values,
const int& nNodes,
const int& nAttributes)
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);
197 static GeoTessProfile* newProfile(
float* radii,
const int& nRadii,
LONG_INT** values,
const int& nNodes,
const int& nAttributes)
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);
216 static GeoTessProfile* newProfile(
float* radii,
const int& nRadii,
int** values,
const int& nNodes,
const int& nAttributes)
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);
235 static GeoTessProfile* newProfile(
float* radii,
const int& nRadii,
short** values,
const int& nNodes,
const int& nAttributes)
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);
254 static GeoTessProfile* newProfile(
float* radii,
const int& nRadii,
byte** values,
const int& nNodes,
const int& nAttributes)
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;
314 double getValue(
const vector<int>& nodeIds,
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;
359 virtual double getValueBottom(
int attributeIndex)
const
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;
472 int getRadiusIndex(
double radius)
const
486 virtual int getRadiusIndex(
double radius,
int jlo)
const
504 virtual double getInterpolationCoefficient(
int i,
double radius,
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