1 //******************************************************************* 2 // 3 // License: MIT 4 // 5 // See LICENSE.txt file in the top level directory for more details. 6 // 7 // Author: Garrett Potts 8 // 9 // Description: 10 // 11 // This class defines an abstract image handler which all loaders should 12 // derive from. 13 // 14 //******************************************************************** 15 // $Id: ossimImageHandler.h 22960 2014-11-06 15:42:13Z okramer $ 16 #ifndef ossimImageHandler_HEADER 17 #define ossimImageHandler_HEADER 1 18 19 #include <ossim/imaging/ossimImageSource.h> 20 #include <ossim/base/ossimConstants.h> 21 #include <ossim/base/ossimFilename.h> 22 #include <ossim/base/ossimIrect.h> 23 #include <ossim/base/ossimNBandLutDataObject.h> 24 #include <ossim/base/ossimRefPtr.h> 25 #include <ossim/imaging/ossimFilterResampler.h> 26 #include <ossim/support_data/ossimImageMetaData.h> 27 #include <ossim/support_data/ImageHandlerState.h> 28 29 class ossimMultiResLevelHistogram; 30 31 /** 32 * This class defines an abstract Handler which all image handlers(loaders) 33 * should derive from. 34 */ 35 class OSSIMDLLEXPORT ossimImageHandler : public ossimImageSource 36 { 37 public: 38 39 enum ossimImageHandlerOverviewCompressionType 40 { 41 OSSIM_OVERVIEW_COMPRESSION_NONE= 0, 42 OSSIM_OVERVIEW_COMPRESSION_JPEG, 43 OSSIM_OVERVIEW_COMPRESSION_LZW, 44 OSSIM_OVERVIEW_COMPRESSION_DEFLATE, 45 OSSIM_OVERVIEW_COMPRESSION_PACKBITS 46 }; 47 48 /** Constructor (default): */ 49 ossimImageHandler(); 50 51 /** 52 * Destructor: 53 * Derived classes should implement. 54 */ 55 virtual ~ossimImageHandler(); 56 57 /** 58 * initialize 59 * Does nothing in this class. Implemented to satisfy pure virtual. 60 */ 61 virtual void initialize(); 62 63 /** 64 * Searches for an overview. Uses theImageFile as a key. 65 * If theImageFile = "foo.tif" it will look for "foo.ovr" first, 66 * then "foo_ovr.tif" next. 67 * Calls openOverview(const ossimFilename& overview_file) 68 * @return true on success, false on error. 69 * @see openOverview(const ossimFilename& overview_file) 70 */ 71 virtual bool openOverview(); 72 73 /** 74 * Calls closeOverview(), then attempts to open the overview_file. 75 * On success, theOverviewFile will be set and theOverview will be 76 * initialized. On failure, theOverviewFile will be cleared and 77 * theOverview deleted and set to NULL. 78 * @param overview_file ossimFilename representing overview file. 79 * @return true on success, false on error. 80 * @see closeOverview() 81 */ 82 virtual bool openOverview(const ossimFilename& overview_file); 83 84 /** 85 * If theOverview is initialized it will be deleted and set to NULL. Also 86 * clears theOverviewFile. 87 * @return void 88 */ 89 virtual void closeOverview(); 90 91 /** 92 * @return the image handler of the overview, if it has been 93 * successfully opened. 94 */ 95 virtual const ossimImageHandler* getOverview() const; 96 97 /** 98 * @return true if getNumberOfReducedResSets > 1, false if not. 99 * @see getNumberOfReducedResSets() 100 */ 101 virtual bool hasOverviews() const; 102 103 /** 104 * @return ossimFilename represents an external OSSIM overview filename. 105 */ 106 virtual ossimFilename createDefaultOverviewFilename() const; 107 108 /** 109 * @return ossimFilename represents an external OSSIM geometry filename. 110 */ 111 virtual ossimFilename createDefaultGeometryFilename() const; 112 113 /** 114 * @return ossimFilename represents an external OSSIM metadata filename. 115 */ 116 virtual ossimFilename createDefaultMetadataFilename() const; 117 118 /** 119 * @return ossimFilename represents an external OSSIM histogram filename. 120 */ 121 virtual ossimFilename createDefaultHistogramFilename() const; 122 123 /** 124 * @return ossimFilename represents an external OSSIM valid vertices filename. 125 */ 126 virtual ossimFilename createDefaultValidVerticesFilename() const; 127 128 /** 129 * Outputs vertices to file and updates the internal vertex 130 * array variable "theValidImageVertices". 131 * @param vertices Array of ossimIpts to write. 132 * @param file Name of output file to write to. If file is empty, the 133 * output file will be the image file with no extension + _vertices.kwl. 134 * So if the image is "foo.tif" you'll get "foo_vertices.kwl". 135 * @return true on success, false on error. 136 */ 137 virtual bool writeValidImageVertices(const std::vector<ossimIpt>& vertices, 138 const ossimFilename& file=ossimFilename("")); 139 140 /** 141 * Opens the valid image vertices file and sets theValidImageVerticesFile 142 * variable. 143 * @param vertices_file File name containing valid vertices for image. 144 * @return true on success, false on error. 145 */ 146 virtual bool openValidVertices(const ossimFilename& vertices_file); 147 148 /** 149 * Creates vertices file name based on image, then tries to open. 150 * If theImageFile = "foo.tif" it will look for "foo_vertices.kwl". 151 * @return true on success, false on error. 152 */ 153 virtual bool openValidVertices(); 154 155 /** 156 * Pure virtual open. Derived classes must implement. 157 * 158 * @return Returns true on success, false on error. 159 * 160 * @note This method relies on the data member ossimImageData::theImageFile 161 * being set. Callers should do a "setFilename" prior to calling this 162 * method or use the ossimImageHandler::open that takes a file name and an 163 * entry index. 164 */ 165 virtual bool open() = 0; 166 167 /** 168 * Opens the image file. 169 * 170 * @param imageFile File to open. 171 * 172 * @param entryIndex 173 * @return true on success, false on error. 174 */ 175 virtual bool open(const ossimFilename& imageFile, 176 ossim_uint32 entryIndex); 177 178 virtual bool open(const ossimFilename& imageFile); 179 180 virtual bool open(std::shared_ptr<ossim::ImageHandlerState> state); 181 /** 182 * Deletes the overview and clears the valid image vertices. Derived 183 * classes should implement. 184 */ 185 virtual void close(); 186 187 /** 188 * Derived classes must implement this method to be concrete. 189 * 190 * @return true if open, false if not. 191 */ 192 virtual bool isOpen()const=0; 193 194 /** 195 * Build a histogram for image file. 196 * 197 * @param numberOfRLevels sets the maximum number of reduced resolution 198 * level to compute histogram for. 199 * 200 * @param mode OSSIM_HISTO_MODE_NORMAL or OSSIM_HISTO_MODE_FAST. 201 * 202 * @return true on success, false if not open. 203 */ 204 virtual bool buildHistogram( 205 int numberOfRLevels=0, ossimHistogramMode mode=OSSIM_HISTO_MODE_NORMAL ); 206 207 /** 208 * Build a histograms for all image entries. 209 * 210 * @param numberOfRLevels sets the maximum number of reduced resolution 211 * level to compute histogram for. 212 * 213 * @param mode OSSIM_HISTO_MODE_NORMAL or OSSIM_HISTO_MODE_FAST. 214 * 215 * @return true on success, false if not open. 216 */ 217 virtual bool buildAllHistograms( 218 int numberOfRLevels=0, ossimHistogramMode mode=OSSIM_HISTO_MODE_NORMAL ); 219 220 /** 221 * Will build over file for theImageFile. 222 * 223 * @param includeFullResFlag if true the full resolution layer will also 224 * be put in the overview format. This is handly for inefficeint formats. 225 */ 226 virtual bool buildOverview(ossimImageHandlerOverviewCompressionType compressionType = OSSIM_OVERVIEW_COMPRESSION_NONE, 227 ossim_uint32 quality = 75, 228 ossimFilterResampler::ossimFilterResamplerType resampleType = ossimFilterResampler::ossimFilterResampler_BOX, 229 bool includeFullResFlag=false); 230 231 /** 232 * Will build over file for all image entries. 233 * 234 * @param includeFullResFlag if true the full resolution layer will also 235 * be put in the overview format. This is handly for inefficeint formats. 236 */ 237 virtual bool buildAllOverviews(ossimImageHandlerOverviewCompressionType compressionType = OSSIM_OVERVIEW_COMPRESSION_NONE, 238 ossim_uint32 quality = 75, 239 ossimFilterResampler::ossimFilterResamplerType resampleType = ossimFilterResampler::ossimFilterResampler_BOX, 240 bool includeFullResFlag=false); 241 242 /** 243 * Will build an over file for filename. 244 * @param filename Name of image file. 245 * 246 * @param includeFullResFlag if true the full resolution layer will also 247 * be put in the overview format. This is handly for inefficeint formats. 248 */ 249 virtual bool buildOverview(const ossimFilename& filename, 250 ossimImageHandlerOverviewCompressionType compressionType = OSSIM_OVERVIEW_COMPRESSION_NONE, 251 ossim_uint32 quality = 75, 252 ossimFilterResampler::ossimFilterResamplerType resampleType = ossimFilterResampler::ossimFilterResampler_BOX, 253 bool includeFullResFlag=false); 254 255 /** 256 * @brief Fetches the current entry image's histogram. 257 * 258 * @return Ref pointer to histogram or null if histogram does not exist. 259 * 260 * @note Old behaviour: "If none exists, it will be created." taken out. 261 * 262 * Do: 263 * ossimRefPtr<ossimMultiResLevelHistogram> his = ih->getImageHistogram(); 264 * if ( ih.valid() ) 265 * { 266 * } 267 * else 268 * { 269 * ih->buildHistogram(); 270 * } 271 * 272 */ 273 ossimRefPtr<ossimMultiResLevelHistogram> getImageHistogram() const; 274 275 /** 276 * Returns the image geometry object associated with this tile source or 277 * NULL if non defined. The geometry contains full-to-local image 278 * transform as well as projection (image-to-world). 279 */ 280 virtual ossimRefPtr<ossimImageGeometry> getImageGeometry(); 281 282 /** 283 * Sets the image geometry object. 284 * 285 * @note Callers should note that this will override any existing 286 * geometry. 287 * 288 * @note This does not write the geometry to disk, to do so call 289 * one of the saveImageGeometry methods. 290 */ 291 virtual void setImageGeometry(ossimImageGeometry* geom); 292 293 /** 294 * Saves the image geometry to a file that will be made based on the image 295 * file name. 296 */ 297 virtual void saveImageGeometry() const; 298 299 /** 300 * Saves the image geometry to a file that will be made based on the image 301 * file name. 302 */ 303 virtual void saveImageGeometry(const ossimFilename& geometry_file) const; 304 305 /** 306 * Pure virtual, derived classes must implement. 307 * 308 * @param resLevel Reduced resolution level to return lines of. 309 * Default = 0 310 * 311 * @return The number of lines for specified reduced resolution level. 312 */ 313 virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel = 0) const = 0; 314 315 /** 316 * Pure virtual, derived classes must implement. 317 * 318 * @param resLevel Reduced resolution level to return samples of. 319 * Default = 0 320 * 321 * @return The number of samples for specified reduced resolution level. 322 */ 323 virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel = 0) const = 0; 324 325 /** 326 * @brief Returns zero-based bounding rectangle of the image. 327 * Note sub-image offset now in ossimImageGeometry class. 328 * 329 * @param resLevel Reduced resolution level for rectangle. 330 * 331 * @return Rectangle of reduced resolution level. 332 */ 333 virtual ossimIrect getImageRectangle(ossim_uint32 resLevel = 0) const; 334 335 /** 336 * @brief Returns zero-based bounding rectangle of the image. 337 * Same as getImageRectangle() call. Note sub-image offset now 338 * in ossimImageGeometry class. 339 * 340 * @param resLevel Reduced resolution level for rectangle. 341 * 342 * @return Rectangle of reduced resolution level. 343 */ 344 virtual ossimIrect getBoundingRect(ossim_uint32 resLevel = 0) const; 345 346 /** 347 * @param resLevel Reduced resolution set for requested decimation. 348 * 349 * @param result ossimDpt to initialize with requested decimation. 350 * 351 * @note Initialized "result" with the decimation factor for the passed in 352 * resLevel. 353 * Most of the time the returned factor is a square decimation along x 354 * and y indicated by result.x and .y = 1.0/(resLevel^2) where ^ 355 * means rasing to the power of. If the resLevel is 1 then the return 356 * decimation .5, .5. this is not the decimation to each resolution 357 * level but the total decimation from res level 0. 358 * So if resLevel is 2 then the return is .25, .25. 359 * 360 * @note Derived classes should override if the decimation is anything other 361 * than a power of two change in each direction per res level. 362 */ 363 virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt& result) const; 364 365 /** 366 * This returns all decimation for all levels. 367 */ 368 virtual void getDecimationFactors(std::vector<ossimDpt>& decimations) const; 369 370 /** 371 * This returns the total number of decimation levels. It is important to 372 * note that res level 0 or full resolution is included in the list and has 373 * decimation values 1.0, 1.0 374 */ 375 virtual ossim_uint32 getNumberOfDecimationLevels() const; 376 377 /** 378 * This method is obsolete. Please use getNumberOfDecimationLevels. 379 * 380 * For backwards compatibility this calls getNumberOfDecimationLevels. 381 */ 382 virtual ossim_uint32 getNumberOfReducedResSets()const; 383 384 /** 385 * Sets the filename 386 */ 387 virtual void setFilename(const ossimFilename& filename); 388 389 /** 390 * Returns the filename 391 */ 392 virtual const ossimFilename& getFilename()const; 393 394 /** 395 * Method to save the state of an object to a keyword list. 396 * Return true if ok or false on error. 397 */ 398 virtual bool saveState(ossimKeywordlist& kwl, 399 const char* prefix=0)const; 400 401 /** 402 * Method to the load (recreate) the state of an object from a keyword 403 * list. Return true if ok or false on error. 404 */ 405 virtual bool loadState(const ossimKeywordlist& kwl, 406 const char* prefix=0); 407 408 /** 409 * @brief Determines if the passed in reslution level is valid. 410 * 411 * If this reader is used as an overview the caller should pass in a 412 * resLevel relative to the full image. 413 * 414 * @param resLevel zero base resolution level. 415 * @return true on success, false on error. 416 */ 417 virtual bool isValidRLevel(ossim_uint32 resLevel) const; 418 419 /** 420 * Connection rule. Since image handler currently don't have any 421 * inputs this will just return false saying we can't connect anything 422 * to an image handler. 423 */ 424 bool canConnectMyInputTo(ossim_int32 inputIndex, 425 const ossimConnectableObject* object) const; 426 427 /** 428 * ordering specifies how the vertices should be arranged. 429 * valid image vertices is basically the tightly fit convex hull 430 * of the image. Usually an image has NULL values and are 431 * internally not upright rectangular. This can cause 432 * problems some spatial filters. 433 * 434 * The default implementation is to return the bounding rect. 435 */ 436 virtual void getValidImageVertices(std::vector<ossimIpt>& validVertices, 437 ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, 438 ossim_uint32 resLevel=0)const; 439 440 /** 441 * @brief Indicates whether or not the image handler can control output 442 * band selection via the setOutputBandList method. 443 * @return true if band selector; false, if not. 444 */ 445 virtual bool isBandSelector() const; 446 447 /** 448 * @brief If the image handler "isBandSeletor()" then the band selection 449 * of the output chip can be controlled. 450 * 451 * This method returns false. Derived classes that are band selectors should 452 * override. 453 * 454 * @param band_list Requested bands. 455 * 456 * @return true on success, false on error. 457 */ 458 virtual bool setOutputBandList(const std::vector<ossim_uint32>& band_list); 459 460 /** 461 * @brief If the image handler "isBandSeletor()" then the band selection 462 * of the output are set to input or identity. Does nothing and returns 463 * false if not a band selector. 464 * 465 * @return If band selector, returns the output of setOutputBandList; if 466 * not, returns false. 467 */ 468 virtual bool setOutputToInputBandList(); 469 470 /** 471 * @brief Convenience method to see if band list is identity. 472 * @param bandList List to check. 473 * @return true if band selector; false, if not. 474 */ 475 virtual bool isIdentityBandList( const std::vector<ossim_uint32>& bandList ) const; 476 477 /** 478 * Indicates whether or not the image is tiled internally. 479 * This implementation returns true if (getImageTileWidth() && 480 * getImageTileHeight()) are both non zero. 481 * Override in the image handler if something else is desired. 482 * Returns true if tiled, false if not. 483 */ 484 virtual bool isImageTiled() const; 485 486 /** 487 * Returns the tile width of the image or 0 if the image is not tiled. 488 * Note: this is not the same as the ossimImageSource::getTileWidth which 489 * returns the output tile width which can be different than the internal 490 * image tile width on disk. 491 */ 492 virtual ossim_uint32 getImageTileWidth() const = 0; 493 494 /** 495 * Returns the tile width of the image or 0 if the image is not tiled. 496 * Note: this is not the same as the ossimImageSource::getTileWidth which 497 * returns the output tile width which can be different than the internal 498 * image tile width on disk. 499 */ 500 virtual ossim_uint32 getImageTileHeight() const = 0; 501 502 virtual bool hasMetaData() const; 503 504 virtual ossimRefPtr<ossimNBandLutDataObject> getLut()const; 505 506 virtual bool hasLut() const; 507 508 /** 509 * There is an external file with an omd extension. this file contains 510 * additional information about the image such as the null pixel, min and 511 * max values. 512 * For general raster it will contain much more than that. 513 */ 514 virtual void loadMetaData(); 515 516 /** 517 * Retuns the min pixel value. If there was an external eta data file 518 * then use the meta data from that file. If not given then we will 519 * return the default min 520 */ 521 virtual double getMinPixelValue(ossim_uint32 band=0)const; 522 virtual double getMaxPixelValue(ossim_uint32 band=0)const; 523 virtual double getNullPixelValue(ossim_uint32 band=0)const; 524 525 /** 526 * @brief convenience method to set min pixel value. 527 * 528 * Added for overview readers so that the image handler that owns the 529 * overview reader can pass on it's min value. 530 * 531 * @param band Zero based band to set. 532 * 533 * @param pix Min pixel value. 534 */ 535 virtual void setMinPixelValue(ossim_uint32 band, const ossim_float64& pix); 536 537 /** 538 * @brief convenience method to set max pixel value. 539 * 540 * Added for overview readers so that the image handler that owns the 541 * overview reader can pass on it's max value. 542 * 543 * @param band Zero based band to set. 544 * 545 * @param pix Max pixel value. 546 */ 547 virtual void setMaxPixelValue(ossim_uint32 band, const ossim_float64& pix); 548 549 /** 550 * @brief convenience method to set null pixel value. 551 * 552 * Added for overview readers so that the image handler that owns the 553 * overview reader can pass on it's max value. 554 * 555 * @param band Zero based band to set. 556 * 557 * @param pix Null pixel value. 558 */ 559 virtual void setNullPixelValue(ossim_uint32 band, const ossim_float64& pix); 560 561 /** 562 * @return The current entry number. 563 * 564 * @note This implementation returns 0. Derived classes should override 565 * if of multiple entry image type. 566 */ 567 virtual ossim_uint32 getCurrentEntry()const; 568 569 /** 570 * @return The number of entries (images) in the image file. 571 */ 572 virtual ossim_uint32 getNumberOfEntries()const; 573 574 /** 575 * @brief Get the name of entry as a string. 576 * 577 * This implementation clears name. Derived classes that support multiple 578 * entries and have "named" entries should re-implement to provide entry 579 * names. Example given from HDF5 file: 580 * 581 * entry_name: /All_Data/VIIRS-IMG-GTM-EDR-GEO_All/QF1_VIIRSGTMGEO 582 * 583 * @param entryIdx Zero based entry index. If out of range name will 584 * be cleared. 585 * 586 * @param name Initialized by this. 587 */ 588 virtual void getEntryName( ossim_uint32 entryIdx, 589 std::string& name ) const; 590 591 /** 592 * @param entryList This is the list to initialize with entry indexes. 593 * 594 * @note This implementation returns puts one entry "0" in the list. 595 */ 596 virtual void getEntryList(std::vector<ossim_uint32>& entryList) const; 597 598 /** 599 * @param getEntryNames List to initialize with strings associated with 600 * entries. 601 * 602 * @note This implementation calls getEntryList and converts entries in 603 * the list to strings. Derived classes that support multiple entries 604 * with associated strings should re-implement. 605 */ 606 virtual void getEntryNames(std::vector<ossimString>& entryNames) const; 607 608 /** 609 * @brief Convenience method to determine if entry index should be used for 610 * support files, e.g. file.his or file_e1.his. 611 * 612 * @returns true if file is open, && 613 * ( (entryList.size() > 1) || (entryList[0] != 0) ) 614 * false otherwise. 615 * 616 * @note This is just a hint. Put here as code was duplicated everywhere. 617 * Callers can do what they wish. 618 */ 619 bool useEntryIndex() const; 620 621 ossimFilename getOverviewFile()const; 622 623 /** 624 * @param entryIdx Entry number to select. 625 * 626 * @note The implementation does nothing. Derived classes that handle 627 * multiple images should override. 628 * 629 * @return true if it was able to set the current entry and false otherwise. 630 */ 631 virtual bool setCurrentEntry(ossim_uint32 entryIdx); 632 633 virtual void setProperty(ossimRefPtr<ossimProperty> property); 634 virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const; 635 virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const; 636 637 /** 638 * @brief Returns the image file with extension set using supplentary 639 * directory for dirname if set. 640 * 641 * Default behaviour is to add the "_en.ext" only if the file is 642 * multi-entry. Use set_e0_prefix to override this. 643 * 644 * Examples: 645 * 646 * - theImageFile = "foo.hdf" 647 * - The number of entries = 1 648 * - ext parameter = "geom" 649 * - return of method will = "foo.geom" 650 * 651 * - theImageFile = "foo.hdf" 652 * - The number of entries = 12 653 * - The current entry = 3 654 * - ext parameter = "geom" 655 * - return of method will = "foo_e3.geom" 656 * 657 * @param ext Extension to tack onto file. Can have or have not ".", it 658 * will be added if "." is not the first character. 659 * 660 * @param set_e0_prefix If true and the number of entries = 1 then 661 * "foo.geom" would come out "foo_e0.geom" instead. Default = false. 662 * 663 * @return theImageFile with the extension replaced with ext. 664 */ 665 ossimFilename getFilenameWithThisExtension(const ossimString& ext, 666 bool set_e0_prefix=false) const; 667 668 /** 669 * Returns the image file with extension set using supplentary directory 670 * for dirname if set. This is like the getFilenameWithThisExtension(...) 671 * method except it does NOT add the "_en" if image is multi entry. 672 * 673 * Examples: 674 * 675 * - theImageFile = "foo.tif" 676 * - ext parameter = "geom" 677 * - return of method will = "foo.geom" 678 * 679 * @param ext Extension to tack onto file. Can have or have not ".", it 680 * will be added if "." is not the first character. 681 * 682 * @param f Initialized by this. 683 */ 684 void getFilenameWithThisExt( const ossimString& ext, 685 ossimFilename& f ) const; 686 687 ossim_uint32 getStartingResLevel() const; 688 689 void setStartingResLevel(ossim_uint32 level); 690 691 /** @return theOpenOverviewFlag */ 692 bool getOpenOverviewFlag() const; 693 694 /** 695 * @brief Sets theOpenOverviewFlag. 696 * 697 * If true opening of overviews will be attempted on normal open. If 698 * false only the base image will be opened (shallow open). 699 * Defaulted to true in constructor. 700 */ 701 void setOpenOverviewFlag(bool flag); 702 703 /** 704 * Sets the supplementary directory 705 */ 706 virtual void setSupplementaryDirectory(const ossimFilename& dir); 707 708 /** 709 * Returns the supplementary directory 710 */ 711 virtual const ossimFilename& getSupplementaryDirectory()const; 712 713 //! Fetches the image ID. This is initialized to -1 in the constructor but is searched for in 714 //! loadState(): getImageID()715 const ossimString& getImageID() const { return theImageID; } 716 717 //! Sets the image ID in case it is externally generated setImageID(const ossimString & id)718 void setImageID(const ossimString& id) { theImageID = id; } 719 720 //! Returns the raster pixel alignment type. OSSIM treats all alignments internally as 721 //! pixel-is-point. This is only a flag to identify the source's alignment type. getPixelType()722 ossimPixelType getPixelType() const { return thePixelType; } 723 724 /** 725 * @brief Convenience method to get the zero based rgb output band list. 726 * 727 * This method returns false and is here only so derived classes can 728 * override. 729 * 730 * @param bandList 731 * @return false 732 */ 733 virtual bool getRgbBandList(std::vector<ossim_uint32>& bandList) const; 734 735 736 template <class T> getStateAs()737 std::shared_ptr<T> getStateAs(){return std::dynamic_pointer_cast<T> (m_state);} 738 template <class T> getStateAs()739 std::shared_ptr<const T> getStateAs()const{return std::dynamic_pointer_cast<const T> (m_state);} getState()740 std::shared_ptr<ossim::ImageHandlerState> getState(){return m_state;} getState()741 std::shared_ptr<const ossim::ImageHandlerState> getState()const{return m_state;} setState(std::shared_ptr<ossim::ImageHandlerState> state)742 void setState(std::shared_ptr<ossim::ImageHandlerState> state){m_state = state;} 743 protected: 744 745 /** 746 * Returns the image geometry object associated with this tile source or 747 * NULL if non defined. The geometry contains full-to-local image 748 * transform as well as projection (image-to-world). 749 * 750 * This method just looks for external .geom style override only. 751 * If you want to go through a registry then call getImageGeometry(). 752 */ 753 virtual ossimRefPtr<ossimImageGeometry> getExternalImageGeometry() const; 754 755 virtual ossimRefPtr<ossimImageGeometry> getInternalImageGeometry() const; 756 757 /** 758 * @brief Method to get an overview tile. Derived classes should override if 759 * they have built in overviews or something different than the standard 760 * external overview file. Image handlers can call this method from getTile 761 * in place of inlining code or if derived class needs to override this 762 * method. 763 * 764 * @param resLevel The resolution level to pull from with resLevel 0 being 765 * full res. 766 * 767 * @param result The tile to stuff. 768 * passing. 769 * 770 * @return true on success false on error. Typically this will return false 771 * if resLevel==0 unless the overview has r0. If return is false, result 772 * is undefined so caller should handle appropriately with makeBlank or 773 * whatever. 774 */ 775 virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData* result); 776 777 /** 778 * Opens file and attempts to initialize the valid image vertices. 779 * Returns true on success, false on error. 780 */ 781 bool initVertices(const char* file); 782 783 /** 784 * Will complete the opening process. 785 * If there are overviews it will open them. 786 * If there is meta data it will open that and if there 787 * is valid vertices it will open that. 788 */ 789 virtual void completeOpen(); 790 791 /** 792 * @brief Convenience method to set things needed in the image geometry from 793 * the image handler. At time of writing sets the decimation and image size. 794 * @param geom ossimImageGeometry to initiale. 795 */ 796 void initImageParameters(ossimImageGeometry* geom) const; 797 798 /** 799 * @brief Virtual method determines the decimation factors at each resolution level. This 800 * base class implementation computes the decimation by considering the ratios in image size 801 * between resolution levels, with fuzzy logic for rounding ratios to the nearest power of 2 802 * if possible. Derived classes need to override this method if the decimations are provided 803 * as part of the image metadata. 804 */ 805 virtual void establishDecimationFactors(); 806 807 /** 808 * @brief Convenience method to set output band list. 809 * 810 * This performs range checking and calls theOverview->setOutputBandList 811 * on success. 812 * 813 * @param inBandList The new band list. 814 * @param outBandList Band list to initialize. 815 * @return true on success, false on error. 816 */ 817 virtual bool setOutputBandList(const std::vector<ossim_uint32>& inBandList, 818 std::vector<ossim_uint32>& outBandList); 819 820 821 /** 822 * @brief Get filename with no extension, using supplentary directory for 823 * dirname if set. 824 * 825 * Examples: 826 * 827 * f = "foo.tif" 828 * f = "foo" 829 */ 830 void getFilenameWithNoExtension( ossimFilename& f ) const; 831 832 ossimFilename theImageFile; 833 ossimFilename theOverviewFile; 834 ossimFilename theSupplementaryDirectory; 835 ossimRefPtr<ossimImageHandler> theOverview; 836 std::vector<ossimIpt> theValidImageVertices; 837 ossimImageMetaData theMetaData; 838 mutable ossimRefPtr<ossimImageGeometry> theGeometry; 839 ossimRefPtr<ossimNBandLutDataObject> theLut; 840 std::vector<ossimDpt> theDecimationFactors; 841 ossimString theImageID; 842 843 /** 844 * theStartingResLevel If set to something other than zero(default) this is 845 * indicative that the reader is an overview. 846 */ 847 ossim_uint32 theStartingResLevel; // 0 being full or highest res. 848 849 /** 850 * If true opening of overviews will be attempted. If false only the base 851 * image will be opened (shallow open). Defaulted to true in constructor. 852 */ 853 bool theOpenOverviewFlag; 854 mutable ossimPixelType thePixelType; // pixel-is-point or pixel-is-area 855 856 std::shared_ptr<ossim::ImageHandlerState> m_state; 857 TYPE_DATA 858 }; 859 860 #endif /* #ifndef ossimImageHandler_HEADER */ 861