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);
306 int attributeIndex,
double radius,
bool allowRadiusOutOfRange)
const =
ABSTRACT;
312 double getValue(
const vector<int>& nodeIds,
313 const vector<double>& coefficients,
int attributeIndex)
const
316 for (
int i=0; i<(int)nodeIds.size(); ++i)
317 value += getValue(attributeIndex, nodeIds[i])*coefficients[i];
329 virtual double getValue(
int attributeIndex,
int nodeIndex)
const =
ABSTRACT;
341 virtual bool isNaN(
int nodeIndex,
int attributeIndex) =
ABSTRACT;
349 virtual double getValueTop(
int attributeIndex)
const =
ABSTRACT;
357 virtual double getValueBottom(
int attributeIndex)
const
359 return getValue(attributeIndex, 0);
366 virtual float getRadius(
int i)
const =
ABSTRACT;
371 virtual int getNRadii()
const =
ABSTRACT;
376 virtual int getNData()
const =
ABSTRACT;
382 virtual float* getRadii() =
ABSTRACT;
416 virtual void setData(
const vector<GeoTessData*>& inData) =
ABSTRACT;
423 virtual void setRadii(
const vector<float>& newRadii) =
ABSTRACT;
428 virtual float getRadiusTop()
const =
ABSTRACT;
443 virtual float getRadiusBottom()
const =
ABSTRACT;
465 int getRadiusIndex(
double radius)
const
479 virtual int getRadiusIndex(
double radius,
int jlo)
const
497 virtual double getInterpolationCoefficient(
int i,
double radius,
498 bool allowOutOfRange)
const
500 if (!allowOutOfRange && (radius < getRadiusBottom() || radius > getRadiusTop()))
514 virtual int getPointIndex(
int nodeIndex)
const =
ABSTRACT;
520 virtual int findClosestRadiusIndex(
double radius)
const =
ABSTRACT;
530 virtual void getWeights(map<int, double>& weights,
531 double dkm,
double radius,
double hcoefficient)
const
535 int index = getPointIndex(0);
541 map<int, double>::iterator it = weights.find(index);
542 if (it == weights.end())
543 weights[index] = dkm * hcoefficient;
545 it->second += dkm * hcoefficient;
554 virtual void getCoefficients(map<int, double>& coefficients,
double radius,
555 double horizontalCoefficient)
const
560 coefficients[getPointIndex(0)] = horizontalCoefficient;
566 GeoTessProfile() { ++aClassCount; };
571 virtual ~GeoTessProfile() { --aClassCount; };
576 static GeoTessProfile* newProfile(IFStreamBinary& ifs, GeoTessMetaData& gtmd);
581 static GeoTessProfile* newProfile(IFStreamAscii& ifs, GeoTessMetaData& gtmd);
586 virtual void write(IFStreamBinary& ofs) =
ABSTRACT;
591 virtual void write(IFStreamAscii& ofs) =
ABSTRACT;
600 virtual void setPointIndex(
int nodeIndex,
int pointIndex) =
ABSTRACT;
609 virtual void resetPointIndices() =
ABSTRACT;
611 virtual void setInterpolationCoefficients(
const GeoTessInterpolatorType& interpType,
612 vector<int>& nodeIndexes, vector<double>& coefficients,
613 double& radius,
bool& allowOutOfRange)
617 nodeIndexes.push_back(0);
618 if (!allowOutOfRange && (radius < getRadiusBottom() || radius > getRadiusTop()))
619 coefficients.push_back(NaN_DOUBLE);
621 coefficients.push_back(1.);
627 virtual GeoTessProfile* copy() =
ABSTRACT;
635 #endif // PROFILE_OBJECT_H