Changeset 12873
- Timestamp:
- 11/19/07 19:50:47 (9 months ago)
- Files:
-
- trunk/gdal/ogr/ogrsf_frmts/kml/kml.cpp (modified) (1 diff)
- trunk/gdal/ogr/ogrsf_frmts/kml/kmlnode.cpp (modified) (10 diffs)
- trunk/gdal/ogr/ogrsf_frmts/kml/kmlnode.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/ogr/ogrsf_frmts/kml/kml.cpp
r12871 r12873 397 397 } 398 398 399 bool KML::getExtents(double *pdfXMin, double *pdfXMax, double *pdfYMin, double *pdfYMax) { 400 if(poCurrent_ != NULL) 401 { 402 Extent *poXT = poCurrent_->getExtents(); 399 bool KML::getExtents(double *pdfXMin, double *pdfXMax, double *pdfYMin, double *pdfYMax) 400 { 401 if( poCurrent_ != NULL ) 402 { 403 Extent const* poXT = poCurrent_->getExtents(); 403 404 *pdfXMin = poXT->dfX1; 404 405 *pdfXMax = poXT->dfX2; 405 406 *pdfYMin = poXT->dfY1; 406 407 *pdfYMax = poXT->dfY2; 408 407 409 return TRUE; 408 410 } 409 else 410 return FALSE;411 } 412 411 412 return FALSE; 413 } 414 trunk/gdal/ogr/ogrsf_frmts/kml/kmlnode.cpp
r12872 r12873 242 242 } 243 243 244 Nodetype KMLNode::getType() 244 Nodetype KMLNode::getType() const 245 245 { 246 246 return eType_; … … 252 252 } 253 253 254 std::string KMLNode::getName() 254 std::string KMLNode::getName() const 255 255 { 256 256 return sName_; 257 257 } 258 258 259 void KMLNode::setLevel( unsigned int nLev)259 void KMLNode::setLevel(std::size_t nLev) 260 260 { 261 261 nLevel_ = nLev; 262 262 } 263 263 264 unsigned int KMLNode::getLevel() 264 std::size_t KMLNode::getLevel() const 265 265 { 266 266 return nLevel_; … … 277 277 } 278 278 279 KMLNode* KMLNode::getParent() 279 KMLNode* KMLNode::getParent() const 280 280 { 281 281 return poParent_; … … 287 287 } 288 288 289 unsigned short KMLNode::countChildren()289 std::size_t KMLNode::countChildren() 290 290 { 291 291 return pvpoChildren_->size(); 292 292 } 293 293 294 KMLNode* KMLNode::getChild(unsigned short nNum) 295 { 296 return pvpoChildren_->at(nNum); 297 } 298 299 void KMLNode::addContent(std::string const& sCon) 300 { 301 pvsContent_->push_back(sCon); 302 } 303 304 void KMLNode::appendContent(std::string sCon) 305 { 306 pvsContent_->at(pvsContent_->size()-1) += sCon; 307 } 308 309 std::string KMLNode::getContent(unsigned short nNum) 310 { 311 if(nNum >= pvsContent_->size()) 312 return ""; 313 return pvsContent_->at(nNum); 314 } 315 316 void KMLNode::deleteContent(unsigned short nNum) 317 { 318 if(nNum >= pvsContent_->size()) 319 return; 320 pvsContent_->erase(pvsContent_->begin() + nNum); 321 } 322 323 unsigned short KMLNode::numContent() 294 KMLNode* KMLNode::getChild(std::size_t index) const 295 { 296 return pvpoChildren_->at(index); 297 } 298 299 void KMLNode::addContent(std::string const& text) 300 { 301 pvsContent_->push_back(text); 302 } 303 304 void KMLNode::appendContent(std::string const& text) 305 { 306 std::string& tmp = pvsContent_->at(pvsContent_->size() - 1); 307 tmp += text; 308 } 309 310 std::string KMLNode::getContent(std::size_t index) const 311 { 312 std::string tmp; 313 if( index < pvsContent_->size() ) 314 { 315 tmp = pvsContent_->at(index); 316 } 317 return tmp; 318 } 319 320 void KMLNode::deleteContent(std::size_t index) 321 { 322 if( index < pvsContent_->size() ) 323 { 324 pvsContent_->erase(pvsContent_->begin() + index); 325 } 326 } 327 328 std::size_t KMLNode::numContent() 324 329 { 325 330 return pvsContent_->size(); 326 331 } 327 332 328 void KMLNode::setLayerNumber( short nNum)333 void KMLNode::setLayerNumber(int nNum) 329 334 { 330 335 nLayerNumber_ = nNum; 331 336 } 332 337 333 short KMLNode::getLayerNumber() 338 int KMLNode::getLayerNumber() const 334 339 { 335 340 return nLayerNumber_; 336 341 } 337 342 338 KMLNode* KMLNode::getLayer( unsigned short nNum)339 { 340 KMLNode *poTmp;343 KMLNode* KMLNode::getLayer(int nNum) 344 { 345 KMLNode* poTmp = NULL; 341 346 if(nLayerNumber_ == nNum) 342 347 return this; 343 348 344 for(unsigned short nCount = 0; nCount < pvpoChildren_->size(); nCount++) 345 { 346 if((poTmp = pvpoChildren_->at(nCount)->getLayer(nNum)) != NULL) 349 kml_nodes_t::size_type size = pvpoChildren_->size(); 350 for( kml_nodes_t::size_type i = 0; i < size; ++i ) 351 { 352 if((poTmp = pvpoChildren_->at(i)->getLayer(nNum)) != NULL) 347 353 return poTmp; 348 354 } … … 351 357 } 352 358 353 std::string KMLNode::getNameElement() 354 { 355 std::string sContent; 356 357 for(unsigned short nCount = 0; nCount < pvpoChildren_->size(); nCount++) 358 { 359 if(pvpoChildren_->at(nCount)->sName_.compare("name") == 0) 360 { 361 unsigned int nSize = pvpoChildren_->at(nCount)->pvsContent_->size(); 362 if (nSize > 0) 363 { 364 sContent = pvpoChildren_->at(nCount)->pvsContent_->at(0); 365 for(unsigned int nCount2 = 1; nCount2 < nSize; nCount2++) 359 std::string KMLNode::getNameElement() const 360 { 361 std::string sElem; 362 kml_nodes_t::size_type subsize = 0; 363 kml_nodes_t::size_type size = pvpoChildren_->size(); 364 365 for( kml_nodes_t::size_type i = 0; i < size; ++i ) 366 { 367 if( pvpoChildren_->at(i)->sName_.compare("name") == 0 ) 368 { 369 subsize = pvpoChildren_->at(i)->pvsContent_->size(); 370 if( subsize > 0 ) 371 { 372 sElem = pvpoChildren_->at(i)->pvsContent_->at(0); 373 for( kml_nodes_t::size_type j = 1; j < subsize; ++i ) 366 374 { 367 s Content += " " + pvpoChildren_->at(nCount)->pvsContent_->at(nCount2);375 sElem += " " + pvpoChildren_->at(j)->pvsContent_->at(j); 368 376 } 369 return s Content;377 return sElem; 370 378 } 371 379 break; 372 380 } 373 381 } 374 375 382 return ""; 376 383 } 377 384 378 std::string KMLNode::getDescriptionElement() 379 { 380 std::string sContent; 381 for(unsigned short nCount = 0; nCount < pvpoChildren_->size(); nCount++) 382 { 383 if(pvpoChildren_->at(nCount)->sName_.compare("description") == 0) 384 { 385 unsigned int nSize = pvpoChildren_->at(nCount)->pvsContent_->size(); 386 if (nSize > 0) 387 { 388 sContent = pvpoChildren_->at(nCount)->pvsContent_->at(0); 389 for(unsigned int nCount2 = 1; nCount2 < nSize; nCount2++) 385 std::string KMLNode::getDescriptionElement() const 386 { 387 std::string sElem; 388 kml_nodes_t::size_type subsize = 0; 389 kml_nodes_t::size_type size = pvpoChildren_->size(); 390 for( kml_nodes_t::size_type i = 0; i < size; ++i ) 391 { 392 if( pvpoChildren_->at(i)->sName_.compare("description") == 0 ) 393 { 394 subsize = pvpoChildren_->at(i)->pvsContent_->size(); 395 if ( subsize > 0 ) 396 { 397 sElem = pvpoChildren_->at(i)->pvsContent_->at(0); 398 for( kml_nodes_t::size_type j = 1; j < subsize; ++j ) 390 399 { 391 s Content += " " + pvpoChildren_->at(nCount)->pvsContent_->at(nCount2);400 sElem += " " + pvpoChildren_->at(i)->pvsContent_->at(j); 392 401 } 393 return s Content;402 return sElem; 394 403 } 395 404 break; … … 399 408 } 400 409 401 std::size_t KMLNode::getNumFeatures() 410 std::size_t KMLNode::getNumFeatures() const 402 411 { 403 412 std::size_t nNum = 0; … … 656 665 } 657 666 658 void KMLNode::calcExtent(KML *poKMLClass) 659 { 660 KMLNode *poTmp; 661 Coordinate *psCoors; 667 void KMLNode::calcExtent(KML *poKML) 668 { 669 CPLAssert( NULL != poKML ); 670 671 KMLNode* poTmp = NULL; 672 Coordinate* psCoors = NULL; 662 673 663 if( psExtent_ != NULL)674 if( psExtent_ != NULL ) 664 675 return; 676 665 677 // Handle Features 666 if(poKML Class->isFeature(sName_))667 { 668 psExtent_ = new Extent ;669 psExtent_->dfX1 = psExtent_->dfX2 = psExtent_->dfY1 = psExtent_->dfY2 = 0.0; 678 if(poKML->isFeature(sName_)) 679 { 680 psExtent_ = new Extent(); 681 670 682 // Special for Polygons 671 683 if(sName_.compare("Polygon") == 0) … … 735 747 // Summarize Containers 736 748 } 737 else if( poKML Class->isFeatureContainer(sName_)738 || poKML Class->isContainer(sName_))749 else if( poKML->isFeatureContainer(sName_) 750 || poKML->isContainer(sName_)) 739 751 { 740 752 psExtent_ = new Extent; … … 742 754 for(unsigned short nCount = 0; nCount < pvpoChildren_->size(); nCount++) 743 755 { 744 pvpoChildren_->at(nCount)->calcExtent(poKML Class);756 pvpoChildren_->at(nCount)->calcExtent(poKML); 745 757 if(pvpoChildren_->at(nCount)->psExtent_ != NULL) 746 758 { … … 762 774 } 763 775 764 Extent * KMLNode::getExtents()776 Extent const* KMLNode::getExtents() const 765 777 { 766 778 return psExtent_; trunk/gdal/ogr/ogrsf_frmts/kml/kmlnode.h
r12872 r12873 51 51 void eliminateEmpty(KML* poKML); 52 52 53 void setType(Nodetype );54 Nodetype getType() ;53 void setType(Nodetype type); 54 Nodetype getType() const; 55 55 56 void setName(std::string const& );57 std::string getName() ;56 void setName(std::string const& name); 57 std::string getName() const; 58 58 59 void setLevel( unsigned int);60 unsigned int getLevel();59 void setLevel(std::size_t level); 60 std::size_t getLevel() const; 61 61 62 void addAttribute(Attribute* );62 void addAttribute(Attribute* poAttr); 63 63 64 64 void setParent(KMLNode* poNode); 65 KMLNode* getParent() ;65 KMLNode* getParent() const; 66 66 67 67 void addChildren(KMLNode* poNode); 68 unsigned short countChildren();68 std::size_t countChildren(); 69 69 70 KMLNode* getChild( unsigned short);70 KMLNode* getChild(std::size_t index) const; 71 71 72 void addContent(std::string const& );73 void appendContent(std::string );74 std::string getContent( unsigned short);75 void deleteContent( unsigned short);76 unsigned short numContent();72 void addContent(std::string const& text); 73 void appendContent(std::string const& text); 74 std::string getContent(std::size_t index) const; 75 void deleteContent(std::size_t index); 76 std::size_t numContent(); 77 77 78 void setLayerNumber( short);79 short getLayerNumber();78 void setLayerNumber(int nNum); 79 int getLayerNumber() const; 80 80 81 KMLNode* getLayer( unsigned short);81 KMLNode* getLayer(int); 82 82 83 std::string getNameElement() ;84 std::string getDescriptionElement() ;83 std::string getNameElement() const; 84 std::string getDescriptionElement() const; 85 85 86 std::size_t getNumFeatures() ;86 std::size_t getNumFeatures() const; 87 87 Feature* getFeature(std::size_t nNum); 88 88 89 Extent * getExtents();89 Extent const* getExtents() const; 90 90 91 91 private: … … 101 101 102 102 KMLNode *poParent_; 103 unsigned int nLevel_;103 std::size_t nLevel_; 104 104 std::string sName_; 105 105 106 106 Nodetype eType_; 107 107 108 short nLayerNumber_;108 int nLayerNumber_; 109 109 Extent *psExtent_; 110 110
