48 #include <rok4/utils/Keyword.h>
49 #include <rok4/utils/TileMatrixLimits.h>
60 static TiXmlElement*
buildTextNode ( std::string elementName, std::string value ) {
61 TiXmlElement * elem =
new TiXmlElement ( elementName );
62 TiXmlText * text =
new TiXmlText ( value );
63 elem->LinkEndChild ( text );
72 const TiXmlNode* child = pElem->FirstChild();
74 const TiXmlText* childText = child->ToText();
76 return childText->ValueStr();
88 static TiXmlElement*
getXml(std::string elName, Keyword k) {
89 TiXmlElement* el =
new TiXmlElement ( elName );
90 el->LinkEndChild (
new TiXmlText ( k.getContent() ) );
92 for ( std::map<std::string,std::string>::const_iterator it = k.getAttributes()->begin(); it != k.getAttributes()->end(); it++ ) {
93 el->SetAttribute ( ( *it ).first, ( *it ).second );
112 dbVal = fmod(dbVal, 1);
113 static const int MAX_DP = 10;
114 double THRES = pow ( 0.1, MAX_DP );
118 while ( dbVal - floor ( dbVal ) > THRES && nDecimal < MAX_DP && ceil(dbVal)-dbVal > THRES) {
132 static TiXmlElement*
getXml(TileMatrixLimits tml) {
133 TiXmlElement* tmLimitsEl =
new TiXmlElement (
"TileMatrixLimits" );
134 tmLimitsEl->LinkEndChild (
buildTextNode (
"TileMatrix", tml.tileMatrixId ) );
135 tmLimitsEl->LinkEndChild (
buildTextNode (
"MinTileRow", std::to_string(tml.minTileRow) ) );
136 tmLimitsEl->LinkEndChild (
buildTextNode (
"MaxTileRow", std::to_string(tml.maxTileRow) ) );
137 tmLimitsEl->LinkEndChild (
buildTextNode (
"MinTileCol", std::to_string(tml.minTileCol) ) );
138 tmLimitsEl->LinkEndChild (
buildTextNode (
"MaxTileCol", std::to_string(tml.maxTileCol) ) );
154 static TiXmlElement*
getXml(BoundingBox<double> bbox, std::string crs =
"") {
156 std::ostringstream os;
159 TiXmlElement * el =
new TiXmlElement (
"EX_GeographicBoundingBox" );
178 TiXmlElement * el =
new TiXmlElement (
"BoundingBox" );
180 el->SetAttribute (
"CRS", crs );
182 floatprecision = std::max ( floatprecision,
GetDecimalPlaces ( bbox.xmax ) );
183 floatprecision = std::max ( floatprecision,
GetDecimalPlaces ( bbox.ymin ) );
184 floatprecision = std::max ( floatprecision,
GetDecimalPlaces ( bbox.ymax ) );
185 floatprecision = std::min ( floatprecision,9 );
188 os<< std::fixed << std::setprecision ( floatprecision );
190 el->SetAttribute (
"minx",os.str() );
193 el->SetAttribute (
"miny",os.str() );
196 el->SetAttribute (
"maxx",os.str() );
199 el->SetAttribute (
"maxy",os.str() );