36 #ifndef GEOTESSMETADATA_OBJECT_H
37 #define GEOTESSMETADATA_OBJECT_H
145 string* attributeNames;
151 string* attributeUnits;
158 bool boolAttributeFilter;
168 vector<int> attributeFilter;
175 vector<int> inputFilter;
181 string attributeFilterString;
186 string inputModelFile;
191 string inputGridFile;
196 double loadTimeModel;
201 string outputModelFile;
206 string outputGridFile;
212 double writeTimeModel;
227 string modelSoftwareVersion;
233 string modelGenerationDate;
255 : earthShape(), description(
""), nLayers(0), nVertices(0), layerNames(NULL), layerTessIds(
256 NULL), dataType(&
GeoTessDataType::NONE), nAttributes(-1), attributeNames(
257 NULL), attributeUnits(NULL), boolAttributeFilter(false),
258 inputModelFile(
"none"), inputGridFile(
"none"), loadTimeModel(-1.0),
259 outputModelFile(
"none"), outputGridFile(
"none"), writeTimeModel(-1.0),
260 refCount(0), reuseGrids(true), modelSoftwareVersion(
""), modelGenerationDate(
"")
298 return !(*
this == other);
319 memory += (
LONG_INT) (description.length() + attributeFilterString.length()
320 + inputModelFile.length() + inputGridFile.length() + outputModelFile.length()
321 + outputGridFile.length() + modelSoftwareVersion.length() + modelGenerationDate.length());
324 memory += nLayers * (
LONG_INT)
sizeof(
string);
325 for (
int i=0; i<nLayers; ++i)
326 memory += (
LONG_INT) layerNames[i].length();
329 memory += nLayers * (
LONG_INT)
sizeof(
int);
338 memory += 2 * nAttributes * (
LONG_INT)
sizeof(
string);
339 for (
int i=0; i<nAttributes; ++i)
341 memory += (
LONG_INT) attributeNames[i].length();
342 memory += (
LONG_INT) attributeUnits[i].length();
347 memory += (
LONG_INT) (attributeFilter.capacity() *
sizeof(int));
350 memory += (
LONG_INT) (inputFilter.capacity() *
sizeof(int));
379 void setReuseGrids(
bool rg)
440 void setEarthShape(
const string& earthShapeName) { earthShape.setEarthShape(earthShapeName); }
447 const string& getInputModelFile()
const
449 return inputModelFile;
458 const string& getInputGridFile()
const
460 return inputGridFile;
468 double getLoadTimeModel()
const
470 return loadTimeModel;
478 const string& getOutputModelFile()
const
480 return outputModelFile;
489 const string& getOutputGridFile()
const
491 return outputGridFile;
500 double getWriteTimeModel()
const
502 return writeTimeModel;
511 const string& getDescription()
const
522 void setDescription(
const string& dscr)
525 description = CPPUtils::stringReplaceAll(
"\r\n",
"\n", description);
526 description = CPPUtils::stringReplaceAll(
"\r",
"\n", description);
531 CPPUtils::removeEOL(description);
532 description += CPPUtils::NEWLINE;
541 void setLayerNames(
const string& lyrNms)
543 vector<string> layrNames;
544 CPPUtils::tokenizeString(lyrNms,
";", layrNames);
545 setLayerNames(layrNames);
553 void setLayerNames(vector<string>& layrNms);
560 int getNVertices()
const
571 int getNLayers()
const
582 int getLayerIndex(
const string& layerName)
const;
589 void getLayerNames(vector<string>& layers)
592 for (
int i=0; i<nLayers; ++i)
593 layers.push_back(layerNames[i]);
601 const string*
const getLayerNames()
611 string getLayerName(
const int& layerIndex)
613 if (layerIndex < 0 || layerIndex >= nLayers)
616 os << endl <<
"ERROR in GeoTessMetaData::getLayerName(int layerIndex)" << endl
617 <<
"attributeIndex (" << layerIndex <<
") is out of range (0-" << nLayers-1 <<
")"
622 return layerNames[layerIndex];
631 string getLayerNamesString();
641 void setLayerTessIds(
int layrTsIds[])
646 os <<
"Cannot call GeoTessMetaData::setLayerTessIds() "
647 <<
"before calling GeoTessMetaData::setLayerNames()" << endl;
651 if (layerTessIds != NULL)
652 delete[] layerTessIds;
653 layerTessIds =
new int[nLayers];
654 for (
int i=0; i<nLayers; ++i)
655 layerTessIds[i] = layrTsIds[i];
663 void setLayerTessIds(vector<int>& layrTsIds);
671 const int* getLayerTessIds()
const
683 int getTessellation(
int layer)
const
685 return layerTessIds[layer];
695 void getLayers(
const int& tessId, vector<int>& layers)
698 for (
int i=0; i<nLayers; ++i)
699 if (layerTessIds[i] == tessId)
710 int getFirstLayer(
const int& tessId)
712 for (
int i=0; i<nLayers; ++i)
713 if (layerTessIds[i] == tessId)
725 int getLastLayer(
const int& tessId)
727 for (
int i=nLayers-1; i >= 0; --i)
728 if (layerTessIds[i] == tessId)
757 void setDataType(
const string& dt);
764 void getAttributeNames(vector<string>& attributes)
767 for (
int i = 0; i < nAttributes; ++i)
768 attributes.push_back(attributeNames[i]);
776 void getAttributeUnits(vector<string>& units)
779 for (
int i = 0; i < nAttributes; ++i)
780 units.push_back(attributeUnits[i]);
788 const string*
const getAttributeNames()
790 return attributeNames;
798 const string*
const getAttributeUnits()
800 return attributeUnits;
810 void setAttributes(
const string& nms,
const string& unts)
812 vector<string> names, units;
813 CPPUtils::tokenizeString(nms,
";", names);
814 CPPUtils::tokenizeString(unts,
";", units);
815 if (names.size() != units.size())
818 os <<
"Error in GeoTessMetaData::setAttributes(const string& nms, const string& unts)" << endl
819 <<
"Attribute names size (" << names.size()
820 <<
") is not equal to units size (" << units.size() <<
")" << endl;
821 names.clear(); units.clear();
824 setAttributes(names, units);
833 void setAttributes(
const vector<string>& names,
const vector<string>& units);
840 int getNAttributes()
const
851 const string& getAttributeName(
int attributeIndex)
const
853 if (attributeIndex < 0 || attributeIndex >= nAttributes)
856 os << endl <<
"ERROR in GeoTessMetaData::getAttributeName(int attributeIndex)" << endl
857 <<
"attributeIndex (" << attributeIndex <<
") is out of range (0-" << nAttributes-1 <<
")"
862 return attributeNames[attributeIndex];
870 int getAttributeIndex(
string name);
878 string getAttributeNamesString()
const;
886 string getAttributeUnitsString()
const;
894 const string& getAttributeUnit(
int attributeIndex)
const
896 if (attributeIndex < 0 || attributeIndex >= nAttributes)
899 os << endl <<
"ERROR in GeoTessMetaData::getAttributeUnit(int attributeIndex)" << endl
900 <<
"attributeIndex (" << attributeIndex <<
") is out of range (0-" << nAttributes-1 <<
")"
904 return attributeUnits[attributeIndex];
913 string getAttributeString(
int attributeIndex)
const
915 if (attributeIndex < 0 || attributeIndex >= nAttributes)
918 os << endl <<
"ERROR in GeoTessMetaData::getAttributeUnit(int attributeIndex)" << endl
919 <<
"attributeIndex (" << attributeIndex <<
") is out of range (0-" << nAttributes-1 <<
")"
923 return attributeNames[attributeIndex] +
" (" + attributeUnits[attributeIndex]+
")";
930 string toString(
const string& className,
LONG_INT memory)
const;
936 string toString()
const;
954 const string& getModelGenerationDate()
955 {
return modelGenerationDate; }
962 void setModelSoftwareVersion(
const string& swVersion)
963 { modelSoftwareVersion = swVersion; }
971 void setModelGenerationDate(
const string& genDate)
972 { modelGenerationDate = genDate; }
985 bool applyAttributeFilter() {
return boolAttributeFilter; }
995 vector<int>& getAttributeFilter() {
return attributeFilter; }
1002 void setAttributeFilter(vector<int>& filter) { inputFilter = filter; }
1009 void checkComplete();
1011 void loadMetaData(IFStreamBinary& input);
1013 void loadMetaData(IFStreamAscii& input);
1015 int getRefCount() {
return refCount; }
1020 void addReference() { ++refCount; }
1025 void removeReference()
1027 if (isNotReferenced())
1030 os << endl <<
"ERROR in GeoTessMetaData::removeReference" << endl
1031 <<
"Reference count (" << refCount <<
") is already zero."
1033 throw GeoTessException(os, __FILE__, __LINE__, 6005);
1042 bool isNotReferenced() {
return (refCount == 0) ?
true :
false; }
1047 void setNVertices(
const int& nvert) { nVertices = nvert; }
1054 void setInputModelFile(
const string& imf) { inputModelFile = imf; }
1061 void setInputGridFile(
const string& igf) { inputGridFile = igf; }
1068 void setLoadTimeModel(
double ltm) { loadTimeModel = ltm; }
1075 void setOutputModelFile(
const string& omf) { outputModelFile = omf; }
1082 void setOutputGridFile(
const string& ogf) { outputGridFile = ogf; }
1089 void setWriteTimeModel(
double wtm) { writeTimeModel = wtm; }
1093 const GeoTessOptimizationType& getOptimizationType()
const {
return GeoTessOptimizationType::SPEED; }
1094 void setOptimizationType(
const GeoTessOptimizationType& ot);
1095 void setOptimizationType(
const string& ot);
1104 #endif // GEOTESSMETADATA_OBJECT_H