36 #ifndef PROFILE_OBJECT_H
37 #define PROFILE_OBJECT_H
62 class InterpolatorType;
63 class GeoTessMetaData;
103 static int aClassCount;
126 static Profile* newProfile(
const vector<float>& radii, vector<Data*>& data);
128 static Profile* newProfile(
const vector<float>& radii, vector<vector<double> >& data);
129 static Profile* newProfile(
const vector<float>& radii, vector<vector<float> >& data);
130 static Profile* newProfile(
const vector<float>& radii, vector<vector<LONG_INT> >& data);
131 static Profile* newProfile(
const vector<float>& radii, vector<vector<int> >& data);
132 static Profile* newProfile(
const vector<float>& radii, vector<vector<short> >& data);
133 static Profile* newProfile(
const vector<float>& radii, vector<vector<byte> >& data);
157 static Profile* newProfile(
float* radii,
const int& nRadii,
Data** data,
const int& nData);
159 static Profile* newProfile(
float* radii,
const int& nRadii,
double** values,
const int& nNodes,
const int& nAttributes)
161 if (nNodes < 1 && nRadii == 2)
162 return Profile::newProfile(radii, nRadii, NULL, 0);
167 d[0] = Data::getData(values[0], nAttributes);
168 return Profile::newProfile(radii, nRadii, d, nNodes);
172 for (
int i=0; i<nNodes; ++i) d[i] = Data::getData(values[i], nAttributes);
173 Profile* profile = Profile::newProfile(radii, nRadii, d, nNodes);
178 static Profile* newProfile(
float* radii,
const int& nRadii,
float** values,
const int& nNodes,
const int& nAttributes)
180 if (nNodes < 1 && nRadii == 2)
181 return Profile::newProfile(radii, nRadii, NULL, 0);
186 d[0] = Data::getData(values[0], nAttributes);
187 return Profile::newProfile(radii, nRadii, d, nNodes);
191 for (
int i=0; i<nNodes; ++i) d[i] = Data::getData(values[i], nAttributes);
192 Profile* profile = Profile::newProfile(radii, nRadii, d, nNodes);
197 static Profile* newProfile(
float* radii,
const int& nRadii,
LONG_INT** values,
const int& nNodes,
const int& nAttributes)
199 if (nNodes < 1 && nRadii == 2)
200 return Profile::newProfile(radii, nRadii, NULL, 0);
205 d[0] = Data::getData(values[0], nAttributes);
206 return Profile::newProfile(radii, nRadii, d, nNodes);
210 for (
int i=0; i<nNodes; ++i) d[i] = Data::getData(values[i], nAttributes);
211 Profile* profile = Profile::newProfile(radii, nRadii, d, nNodes);
216 static Profile* newProfile(
float* radii,
const int& nRadii,
int** values,
const int& nNodes,
const int& nAttributes)
218 if (nNodes < 1 && nRadii == 2)
219 return Profile::newProfile(radii, nRadii, NULL, 0);
224 d[0] = Data::getData(values[0], nAttributes);
225 return Profile::newProfile(radii, nRadii, d, nNodes);
229 for (
int i=0; i<nNodes; ++i) d[i] = Data::getData(values[i], nAttributes);
230 Profile* profile = Profile::newProfile(radii, nRadii, d, nNodes);
235 static Profile* newProfile(
float* radii,
const int& nRadii,
short** values,
const int& nNodes,
const int& nAttributes)
237 if (nNodes < 1 && nRadii == 2)
238 return Profile::newProfile(radii, nRadii, NULL, 0);
243 d[0] = Data::getData(values[0], nAttributes);
244 return Profile::newProfile(radii, nRadii, d, nNodes);
248 for (
int i=0; i<nNodes; ++i) d[i] = Data::getData(values[i], nAttributes);
249 Profile* profile = Profile::newProfile(radii, nRadii, d, nNodes);
254 static Profile* newProfile(
float* radii,
const int& nRadii,
byte** values,
const int& nNodes,
const int& nAttributes)
256 if (nNodes < 1 && nRadii == 2)
257 return Profile::newProfile(radii, nRadii, NULL, 0);
262 d[0] = Data::getData(values[0], nAttributes);
263 return Profile::newProfile(radii, nRadii, d, nNodes);
267 for (
int i=0; i<nNodes; ++i) d[i] = Data::getData(values[i], nAttributes);
268 Profile* profile = Profile::newProfile(radii, nRadii, d, nNodes);
299 virtual bool operator == (
const Profile& p)
const {
return (getType() == p.
getType()); }
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;
400 virtual void setData(
const vector<Data*>& inData) =
ABSTRACT;
407 virtual void setRadii(
const vector<float>& newRadii) =
ABSTRACT;
412 virtual float getRadiusTop()
const =
ABSTRACT;
427 virtual float getRadiusBottom()
const =
ABSTRACT;
442 virtual int getNRadii()
const =
ABSTRACT;
447 virtual int getNData()
const =
ABSTRACT;
452 virtual float* getRadii() =
ABSTRACT;
464 int getRadiusIndex(
double radius)
const
478 virtual int getRadiusIndex(
double radius,
int jlo)
const
496 virtual double getInterpolationCoefficient(
int i,
double radius,
497 bool allowOutOfRange)
const
499 if (!allowOutOfRange && (radius < getRadiusBottom() || radius > getRadiusTop()))
513 virtual int getPointIndex(
int nodeIndex)
const =
ABSTRACT;
519 virtual int findClosestRadiusIndex(
double radius)
const =
ABSTRACT;
529 virtual void getWeights(map<int, double>& weights,
530 double dkm,
double radius,
double hcoefficient)
const
534 int index = getPointIndex(0);
540 map<int, double>::iterator it = weights.find(index);
541 if (it == weights.end())
542 weights[index] = dkm * hcoefficient;
544 it->second += dkm * hcoefficient;
553 virtual void getCoefficients(map<int, double>& coefficients,
double radius,
554 double horizontalCoefficient)
const
559 coefficients[getPointIndex(0)] = horizontalCoefficient;
565 Profile() { ++aClassCount; };
570 virtual ~Profile() { --aClassCount; };
575 static Profile* newProfile(IFStreamBinary& ifs, GeoTessMetaData& gtmd);
580 static Profile* newProfile(IFStreamAscii& ifs, GeoTessMetaData& gtmd);
585 virtual void write(IFStreamBinary& ofs) =
ABSTRACT;
590 virtual void write(IFStreamAscii& ofs) =
ABSTRACT;
599 virtual void setPointIndex(
int nodeIndex,
int pointIndex) =
ABSTRACT;
608 virtual void resetPointIndices() =
ABSTRACT;
610 virtual void setInterpolationCoefficients(
const InterpolatorType& interpType,
611 vector<int>& nodeIndexes, vector<double>& coefficients,
612 double& radius,
bool& allowOutOfRange)
616 nodeIndexes.push_back(0);
617 if (!allowOutOfRange && (radius < getRadiusBottom() || radius > getRadiusTop()))
618 coefficients.push_back(NaN_DOUBLE);
620 coefficients.push_back(1.);
634 #endif // PROFILE_OBJECT_H