Ticket #1831: kml_variable_fixes.diff
| File kml_variable_fixes.diff, 6.1 kB (added by mloskot, 1 year ago) |
|---|
-
ogr/ogrsf_frmts/kml/kmlnode.cpp
old new 112 112 } 113 113 114 114 KMLnode::~KMLnode() { 115 for(unsigned short z = 0; z < this->pvpoChildren->size();z++) 115 unsigned short nCount; 116 for(nCount = 0; nCount < this->pvpoChildren->size(); nCount++) 116 117 { 117 delete(this->pvpoChildren->at( z));118 delete(this->pvpoChildren->at(nCount)); 118 119 } 119 120 delete(this->pvpoChildren); 120 121 delete(this->pvsContent); 121 for( unsigned short z = 0; z < this->pvoAttributes->size();z++)122 for(nCount = 0; nCount < this->pvoAttributes->size(); nCount++) 122 123 { 123 delete this->pvoAttributes->at( z);124 delete this->pvoAttributes->at(nCount); 124 125 } 125 126 delete(this->pvoAttributes); 126 127 if(this->psExtent != NULL) … … 129 130 130 131 void KMLnode::print(unsigned int what) { 131 132 std::string indent(""); 132 for(unsigned int z = 0; z < this->nLevel; z++) 133 unsigned int nCount; 134 for(nCount = 0; nCount < this->nLevel; nCount++) 133 135 indent += " "; 134 136 if(this->nLevel > 0) { 135 137 if(this->nLayerNumber > -1) … … 157 159 indent.c_str(), this->sName.c_str(), Nodetype2String(this->eType).c_str(), this->nLevel, this->pvpoChildren->size(), 158 160 this->pvsContent->size(), this->pvoAttributes->size()); 159 161 if(what == 1 || what == 3) 160 for( unsigned int z = 0; z < this->pvsContent->size(); z++)161 CPLDebug("KML", "%s|->pvsContent: '%s'", indent.c_str(), this->pvsContent->at( z).c_str());162 for(nCount = 0; nCount < this->pvsContent->size(); nCount++) 163 CPLDebug("KML", "%s|->pvsContent: '%s'", indent.c_str(), this->pvsContent->at(nCount).c_str()); 162 164 if(what == 2 || what == 3) 163 for( unsigned int z = 0; z < this->pvoAttributes->size(); z++)164 CPLDebug("KML", "%s|->pvoAttributes: %s = '%s'", indent.c_str(), this->pvoAttributes->at( z)->sName.c_str(), this->pvoAttributes->at(z)->sValue.c_str());165 for( unsigned int z = 0; z < this->pvpoChildren->size(); z++)166 this->pvpoChildren->at( z)->print(what);165 for(nCount = 0; nCount < this->pvoAttributes->size(); nCount++) 166 CPLDebug("KML", "%s|->pvoAttributes: %s = '%s'", indent.c_str(), this->pvoAttributes->at(nCount)->sName.c_str(), this->pvoAttributes->at(nCount)->sValue.c_str()); 167 for(nCount = 0; nCount < this->pvpoChildren->size(); nCount++) 168 this->pvpoChildren->at(nCount)->print(what); 167 169 } 168 170 169 171 void KMLnode::classify(KML *kmlclass) { … … 171 173 172 174 CPLDebug("KML", "Start -- sName: %s\tnLevel: %d\t", this->sName.c_str(), this->nLevel); 173 175 174 for(unsigned int z = 0; z < this->pvpoChildren->size(); z++) {176 for(unsigned int nCount = 0; nCount < this->pvpoChildren->size(); nCount++) { 175 177 // Leafs are ignored 176 if(kmlclass->isLeaf(this->pvpoChildren->at( z)->sName))178 if(kmlclass->isLeaf(this->pvpoChildren->at(nCount)->sName)) 177 179 continue; 178 180 // Classify pvpoChildren 179 this->pvpoChildren->at( z)->classify(kmlclass);181 this->pvpoChildren->at(nCount)->classify(kmlclass); 180 182 181 183 if(kmlclass->isContainer(this->sName)) 182 curr = this->pvpoChildren->at( z)->eType;184 curr = this->pvpoChildren->at(nCount)->eType; 183 185 else if(kmlclass->isFeatureContainer(this->sName)) { 184 if(kmlclass->isFeature(this->pvpoChildren->at( z)->sName)) {185 if(this->pvpoChildren->at( z)->sName.compare("Point") == 0)186 if(kmlclass->isFeature(this->pvpoChildren->at(nCount)->sName)) { 187 if(this->pvpoChildren->at(nCount)->sName.compare("Point") == 0) 186 188 curr = Point; 187 else if(this->pvpoChildren->at( z)->sName.compare("LineString") == 0)189 else if(this->pvpoChildren->at(nCount)->sName.compare("LineString") == 0) 188 190 curr = LineString; 189 else if(this->pvpoChildren->at( z)->sName.compare("Polygon") == 0)191 else if(this->pvpoChildren->at(nCount)->sName.compare("Polygon") == 0) 190 192 curr = Polygon; 191 193 } else if(kmlclass->isContainer(this->sName)) 192 curr = this->pvpoChildren->at( z)->eType;194 curr = this->pvpoChildren->at(nCount)->eType; 193 195 } else if(kmlclass->isFeature(this->sName) || kmlclass->isRest(this->sName)) 194 196 curr = Empty; 195 197 … … 211 213 } 212 214 213 215 void KMLnode::eliminateEmpty(KML *kmlclass) { 214 for(unsigned int z = 0; z < this->pvpoChildren->size(); z++) {215 if(this->pvpoChildren->at( z)->eType == Empty &&216 (kmlclass->isContainer(this->pvpoChildren->at( z)->sName) ||217 kmlclass->isFeatureContainer(this->pvpoChildren->at( z)->sName))) {218 CPLDebug("KML", "Deleting sName: %s\tClassify sName: %s\tnLevel: %d\tpoParent: %s", this->pvpoChildren->at( z)->sName.c_str(), Nodetype2String(this->pvpoChildren->at(z)->eType).c_str(), this->pvpoChildren->at(z)->nLevel, this->sName.c_str());219 delete this->pvpoChildren->at( z);220 this->pvpoChildren->erase(this->pvpoChildren->begin() + z);221 z--;216 for(unsigned int nCount = 0; nCount < this->pvpoChildren->size(); nCount++) { 217 if(this->pvpoChildren->at(nCount)->eType == Empty && 218 (kmlclass->isContainer(this->pvpoChildren->at(nCount)->sName) || 219 kmlclass->isFeatureContainer(this->pvpoChildren->at(nCount)->sName))) { 220 CPLDebug("KML", "Deleting sName: %s\tClassify sName: %s\tnLevel: %d\tpoParent: %s", this->pvpoChildren->at(nCount)->sName.c_str(), Nodetype2String(this->pvpoChildren->at(nCount)->eType).c_str(), this->pvpoChildren->at(nCount)->nLevel, this->sName.c_str()); 221 delete this->pvpoChildren->at(nCount); 222 this->pvpoChildren->erase(this->pvpoChildren->begin() + nCount); 223 nCount--; 222 224 } else 223 this->pvpoChildren->at( z)->eliminateEmpty(kmlclass);225 this->pvpoChildren->at(nCount)->eliminateEmpty(kmlclass); 224 226 } 225 227 this->calcExtent(kmlclass); 226 228 }
