OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeneralRasterTileSource.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description:
10 //
11 // Contains class definition for ossimGeneralRasterTileSource.
12 //*******************************************************************
13 // $Id: ossimGeneralRasterTileSource.cpp 22763 2014-05-06 14:07:51Z dburken $
14 
17 #include <ossim/base/ossimDpt.h>
18 #include <ossim/base/ossimEndian.h>
22 #include <ossim/base/ossimIpt.h>
23 #include <ossim/base/ossimIrect.h>
28 #include <ossim/base/ossimTrace.h>
34 
36  "ossimGeneralRasterTileSource",
38 
39 static ossimTrace traceDebug("ossimGeneralRasterTileSource:debug");
40 
41 // For interleave type enum to string conversions.
42 static const ossimInterleaveTypeLut ILUT;
43 
44 //*******************************************************************
45 // Public Constructor:
46 //*******************************************************************
48  :
50  m_tile(0),
51  m_buffer(0),
52  m_lineBuffer(0),
54  m_fileStrList(0),
55  m_rasterInfo(),
56  m_bufferRect(0, 0, 0, 0),
57  m_swapBytesFlag(false),
58  m_bufferSizeInPixels(0),
59  m_outputBandList(0)
60 {}
61 
63 {
64  close();
65 }
66 
68  const ossimIrect& tile_rect, ossim_uint32 resLevel)
69 {
70  if ( m_tile.valid() == false )
71  {
72  allocateTile(); // First time through...
73  }
74 
75  if (m_tile.valid())
76  {
77  // Image rectangle must be set prior to calling getTile.
78  m_tile->setImageRectangle(tile_rect);
79 
80  if ( getTile( m_tile.get(), resLevel ) == false )
81  {
83  {
84  m_tile->makeBlank();
85  }
86  }
87  }
88 
89  return m_tile;
90 }
91 
93  ossim_uint32 resLevel)
94 {
95  bool status = false;
96 
97  //---
98  // Not open, this tile source bypassed, or invalid res level,
99  // return a blank tile.
100  //---
101  if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
102  result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
103  {
104  //---
105  // Check for overview tile. Some overviews can contain r0 so always
106  // call even if resLevel is 0. Method returns true on success, false
107  // on error.
108  //---
109  status = getOverviewTile(resLevel, result);
110  if (status)
111  {
113  {
114  //---
115  // Temp fix:
116  // The overview handler could return a tile of OSSIM_UINT16 if
117  // the max sample value was not set to 2047.
118  //---
119  result->setScalarType(OSSIM_USHORT11);
120  }
121  else if(getOutputScalarType() == OSSIM_USHORT12)
122  {
123  result->setScalarType(OSSIM_USHORT12);
124  }
125  else if(getOutputScalarType() == OSSIM_USHORT13)
126  {
127  result->setScalarType(OSSIM_USHORT13);
128  }
129  else if(getOutputScalarType() == OSSIM_USHORT14)
130  {
131  result->setScalarType(OSSIM_USHORT14);
132  }
133  else if(getOutputScalarType() == OSSIM_USHORT15)
134  {
135  result->setScalarType(OSSIM_USHORT15);
136  }
137  }
138 
139  if (!status) // Did not get an overview tile.
140  {
141  status = true;
142 
143  //---
144  // Subtract any sub image offset to get the zero based image space
145  // rectangle.
146  //---
147  ossimIrect tile_rect = result->getImageRectangle();
148 
149  // This should be the zero base image rectangle for this res level.
150  ossimIrect image_rect = getImageRectangle(resLevel);
151 
152  //---
153  // See if any point of the requested tile is in the image.
154  //---
155  if ( tile_rect.intersects(image_rect) )
156  {
157  // Make the tile rectangle zero base.
158  result->setImageRectangle(tile_rect);
159 
160  // Initialize the tile if needed as we're going to stuff it.
161  if (result->getDataObjectStatus() == OSSIM_NULL)
162  {
163  result->initialize();
164  }
165 
166  ossimIrect clip_rect = tile_rect.clipToRect(image_rect);
167 
168  if ( ! tile_rect.completely_within(m_bufferRect) )
169  {
170  // A new buffer must be loaded.
171  if ( !tile_rect.completely_within(clip_rect) )
172  {
173  //---
174  // Start with a blank tile since the whole tile buffer will
175  // not be
176  // filled.
177  //---
178  result->makeBlank();
179  }
180 
181  // Reallocate the buffer if needed.
182  if ( m_bufferSizeInPixels != result->getSize() )
183  {
184  allocateBuffer( result );
185  }
186 
187  ossimIpt size(static_cast<ossim_int32>(result->getWidth()),
188  static_cast<ossim_int32>(result->getHeight()));
189 
190  if( !fillBuffer(clip_rect.ul(), size) )
191  {
193  << "Error from fill buffer..."
194  << std::endl;
195  //---
196  // Error in filling buffer.
197  //---
198  setErrorStatus();
199  status = false;
200  }
201  }
202 
203  result->loadTile(m_buffer,
204  m_bufferRect,
205  clip_rect,
207  result->validate();
208 
209  // Set the rectangle back.
210  result->setImageRectangle(tile_rect);
211 
212  }
213  else // No intersection.
214  {
215  result->makeBlank();
216  }
217  }
218  }
219  return status;
220 }
221 
223 {
224 
225  static const char MODULE[] = "ossimGeneralRasterTileSource::fillBuffer";
226 
227  // Note: InterleaveType enumerations in "constants.h" file.
228  bool status = false;
229  switch ( m_rasterInfo.interleaveType() )
230  {
231  case OSSIM_BIP:
232  {
233  status = fillBIP(origin, size);
234  break;
235  }
236  case OSSIM_BIL:
237  {
238  status = fillBIL(origin, size);
239  break;
240  }
241  case OSSIM_BSQ:
242  {
243  status = fillBSQ(origin, size);
244  break;
245  }
247  {
248  status = fillBsqMultiFile(origin, size);
249  break;
250  }
251  default:
252  {
254  << MODULE << " ERROR:\n"
255  << " Unsupported interleave type: "
257  << std::endl;
258  }
259  }
260 
261  if (status && m_swapBytesFlag)
262  {
263  ossimEndian oe;
265  m_buffer,
267  }
268 
269  return status;
270 }
271 
272 bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin, const ossimIpt& size )
273 {
274  static const char MODULE[] = "ossimGeneralRasterTileSource::fillBIP ";
275 
276  m_bufferRect.set_ul(origin);
277  m_bufferRect.set_lry(min( (origin.y + size.y -1),
278  m_rasterInfo.imageRect().lr().y));
279  m_bufferRect.set_lrx(min( (origin.x + size.x -1),
280  m_rasterInfo.imageRect().lr().x));
281 
282  const ossim_int32 WIDTH = static_cast<ossim_int32>( m_bufferRect.width() );
283  const ossim_int32 HEIGHT = static_cast<ossim_int32>( m_bufferRect.height() );
284  const ossim_int32 INPUT_BANDS = m_rasterInfo.numberOfBands();
285  const ossim_int32 OUTPUT_BANDS = static_cast<ossim_int32>( m_outputBandList.size() );
286  const ossim_int32 BYTES_PER_PIXEL = m_rasterInfo.bytesPerPixel();
287  const ossim_int32 INPUT_BYTES_PER_SAMPLE = BYTES_PER_PIXEL * INPUT_BANDS;
288  const ossim_int32 OUTPUT_BYTES_PER_SAMPLE = BYTES_PER_PIXEL * OUTPUT_BANDS;
289 
290  // Seek position.
291  std::streamoff rasterOffset = m_rasterInfo.offsetToFirstValidSample() +
292  origin.y * m_rasterInfo.bytesPerRawLine() +
293  origin.x * INPUT_BYTES_PER_SAMPLE;
294 
295  // Input line buffer, all bands.
296  std::streamsize inputLineBufferWidth = WIDTH * INPUT_BYTES_PER_SAMPLE;
297 
298  // Output buffer width:
299  std::streamsize outputLineBufferWidth = WIDTH * OUTPUT_BYTES_PER_SAMPLE;
300 
301 #if 0 /* Please keep for debug. (drb) */
303  << "\nDEBUG:"
304  << "\norigin: " << origin
305  << "\nSeek position: " << rasterOffset
306  << "\ninputLineBufferWidth: " << inputLineBufferWidth
307  << "\noutputLineBufferWidth: " << outputLineBufferWidth
308  << "\nINPUT_BANDS: " << INPUT_BANDS
309  << "\nOUTPUT_BANDS: " << OUTPUT_BANDS
310  << std::endl;
311 #endif
312 
313  ossim_int32 bufferOffset = 0;
314 
315  // Line loop:
316  ossim_int32 currentLine = 0;
317  while ( currentLine < HEIGHT )
318  {
319  // Seek to line.
320  m_fileStrList[0]->seekg(rasterOffset, ios::beg);
321  if (!(*m_fileStrList[0]))
322  {
325  << MODULE << " ERROR:\n"
326  << " Seek error! Returning with error..." << std::endl;
327  return false;
328  }
329 
330  // Read image data from line for all bands into line buffer.
331  m_fileStrList[0]->read( (char*)m_lineBuffer, inputLineBufferWidth );
332  if ( m_fileStrList[0]->gcount() != inputLineBufferWidth )
333  {
336  << MODULE << "\nERROR: Reading image line." << std::endl;
337  return false;
338  }
339 
340  // Sample loop:
341  for ( ossim_int32 sample = 0; sample < WIDTH; ++sample )
342  {
343  // Band loop:
344  for ( ossim_int32 band = 0; band < OUTPUT_BANDS; ++band )
345  {
346  ossim_int32 selectedBand = static_cast<ossim_int32>(m_outputBandList[band]);
347  memcpy( (void*)(m_buffer + bufferOffset +
348  sample * OUTPUT_BYTES_PER_SAMPLE +
349  band * BYTES_PER_PIXEL),
350  (void*)(m_lineBuffer +
351  sample * INPUT_BYTES_PER_SAMPLE +
352  selectedBand * BYTES_PER_PIXEL),
353  BYTES_PER_PIXEL );
354  }
355  }
356 
357  ++currentLine;
358  bufferOffset += outputLineBufferWidth;
359  rasterOffset += m_rasterInfo.bytesPerRawLine();
360  }
361 
362  return true;
363 
364 } // End: bool ossimGeneralRasterTileSource::fillBipBandSelect(...
365 
367  const ossimIpt& size)
368 {
369  static const char MODULE[] = "ossimGeneralRasterTileSource::fillBIL";
370 
371  //***
372  // This will fill a buffer the full width of valid samples * tileHeight().
373  //***
374  m_bufferRect.set_ul(origin);
375  m_bufferRect.set_lry(min((origin.y + size.y - 1),
376  m_rasterInfo.imageRect().lr().y));
377  m_bufferRect.set_lrx(min((origin.x + size.x - 1),
378  m_rasterInfo.imageRect().lr().x));
379 
380  ossim_sint64 currentLine = origin.y;
381 
382  // Bytes in one line all bands.
383  const std::streamoff LINE_OFFSET =
385 
386  // Start seek position.
387  std::streamoff offset = ( m_rasterInfo.offsetToFirstValidSample() +
388  currentLine * LINE_OFFSET +
389  origin.x * m_rasterInfo.bytesPerPixel() );
390 
391  //---
392  // Loop through and process lines.
393  //---
394  ossim_int32 linesProcessed = 0;
395  std::streamsize buffer_width = m_bufferRect.width() * m_rasterInfo.bytesPerPixel();
396  ossim_uint8* buf = m_buffer;
397 
398 #if 0 /* Please leave for debug. (drb) */
400  << "\nDEBUG:"
401  << "\norigin: " << origin
402  << "\nSeek position: " << offset
403  << "\nStarting line number: " << currentLine
404  << "\nbuffer_width: " << buffer_width << std::endl;
405 #endif
406 
407  // Line loop:
408  while ((currentLine <= static_cast<ossim_sint64>(m_rasterInfo.imageRect().lr().y)) &&
409  linesProcessed < size.y)
410  {
411  // Band loop:
412  std::vector<ossim_uint32>::const_iterator i = m_outputBandList.begin();
413  while ( i != m_outputBandList.end() )
414  {
415  ossim_int64 band = static_cast<ossim_sint64>( (*i) );
416  const std::streamoff bandOffset = band * m_rasterInfo.bytesPerRawLine();
417 
418  // Seek to line.
419  m_fileStrList[0]->seekg(offset + bandOffset, ios::beg);
420  if (!m_fileStrList[0])
421  {
424  << MODULE << " ERROR:\n"
425  << " Seek error! Returning with error..." << std::endl;
426  return false;
427  }
428 
429  // Read the line of image data.
430  m_fileStrList[0]->read( (char*)buf, buffer_width );
431 
432  if ( m_fileStrList[0]->gcount() != buffer_width )
433  {
436  << MODULE << "\nERROR: Reading image line."
437  << "\ncurrentLine: " << currentLine << std::endl;
438  return false;
439  }
440 
441  buf += buffer_width;
442  ++i;
443 
444  } // End of band loop.
445 
446  ++linesProcessed;
447  ++currentLine;
448  offset += LINE_OFFSET;
449 
450  } // End: line loop
451 
452  return true;
453 }
454 
455 //*******************************************************************
456 // Private Method:
457 //*******************************************************************
459  const ossimIpt& size)
460 {
461  static const char MODULE[] = "ossimGeneralRasterTileSource::fillBSQ";
462 
463  // This will fill a buffer the full width of valid samples * tileHeight().
464 
465  m_bufferRect.set_ul(origin);
466 
467  m_bufferRect.set_lry(min((origin.y + size.y -1),
468  m_rasterInfo.imageRect().lr().y));
469  m_bufferRect.set_lrx(min((origin.x + size.x - 1),
470  m_rasterInfo.imageRect().lr().x));
471 
472  // Start seek position.
473  std::streamoff startSeekPosition
475  origin.y * m_rasterInfo.bytesPerRawLine() +
476  origin.x * m_rasterInfo.bytesPerPixel();
477 
478  std::streamsize buffer_width = m_bufferRect.width() * m_rasterInfo.bytesPerPixel();
479 
481 
482  std::streamoff bandOffset
484 
485 #if 0 /* Please leave for debug. (drb) */
487  << "\nDEBUG:"
488  << "\norigin: " << origin
489  << "\nSeek position: " << startSeekPosition
490  << "\nStarting line number: " << origin.y
491  << "\nbuffer_width: " << buffer_width
492  << "\nbytesPerRawLine(): "
494  << "\nm_rasterInfo.offsetToFirstValidSample(): "
496  << "\nbandOffset: " << bandOffset << std::endl;
497 #endif
498 
499  ossim_int32 num_bands = m_rasterInfo.numberOfBands();
500  ossim_int32 height = size.y;
501 
502  // Band loop:
503  for (ossim_int32 band = 0; band < num_bands; ++band)
504  {
505  ossim_sint64 currentLine = origin.y;
506  ossim_sint64 linesProcessed = 0;
507 
508  std::streamoff offset = startSeekPosition + (band * bandOffset);
509 
510  // Line loop:
511  while (currentLine <= m_rasterInfo.imageRect().lr().y &&
512  linesProcessed < height)
513  {
514  // Seek to line.
515  m_fileStrList[0]->seekg(offset, ios::beg);
516  if (!m_fileStrList[0])
517  {
520  << MODULE << " ERROR:\n"
521  << " Seek error! Returning with error..." << std::endl;
522  return false;
523  }
524 
525  // Read the line of image data.
526  m_fileStrList[0]->read( (char*)buf, buffer_width );
527  if ( m_fileStrList[0]->gcount() != buffer_width )
528  {
531  << MODULE << "\nERROR: Reading image line."
532  << "\ncurrentLine: " << currentLine << std::endl;
533  return false;
534  }
535 
536  // Increment everybody accordingly.
537  buf += buffer_width;
538  offset += m_rasterInfo.bytesPerRawLine();
539  ++linesProcessed;
540  ++currentLine;
541 
542  } // End of line loop.
543 
544  } // End of band loop.
545 
546  return true;
547 }
548 
549 //*******************************************************************
550 // Private Method:
551 //*******************************************************************
553 {
554  static const char MODULE[] = "ossimGeneralRasterTileSource::fillBsqMultiFile";
555 
556  if (traceDebug()) CLOG << " Entered..." << std::endl;
557 
558 
559  // This will fill a buffer the full width of valid samples * tileHeight().
560  m_bufferRect.set_ul(origin);
561 
562  m_bufferRect.set_lry(min((origin.y + size.y -1),
563  m_rasterInfo.imageRect().lr().y));
564  m_bufferRect.set_lrx(min((origin.x + size.x - 1),
565  m_rasterInfo.imageRect().lr().x));
566 
567  //---
568  // Start seek position.
569  //---
570  std::streamoff startSeekPosition = m_rasterInfo.offsetToFirstValidSample() +
571  origin.y * m_rasterInfo.bytesPerRawLine() +
572  origin.x * m_rasterInfo.bytesPerPixel();
573 
574  //---
575  // Loop through and process lines.
576  //---
577  std::streamsize buffer_width = m_bufferRect.width() * m_rasterInfo.bytesPerPixel();
578 
580 
581 #if 0
582  if (traceDebug())
583  {
585  << "\nDEBUG:"
586  << "\norigin: " << origin
587  << "\nSeek position: " << startSeekPosition
588  << "\nStarting line number: " << origin.y
589  << "\nbuffer_width: " << buffer_width
590  << "\nbuffer_rect: " << m_bufferRect
591  << "\nbytesPerRawLine(): "
593  << "\nm_rasterInfo.offsetToFirstValidSample(): "
594  << m_rasterInfo.offsetToFirstValidSample() << std::endl;
595  }
596 #endif
597 
598  // ossim_int32 num_bands = m_rasterInfo.numberOfBands();
599  std::vector<ossim_uint32>::const_iterator bandIter = m_outputBandList.begin();
600  while ( bandIter != m_outputBandList.end() )
601  {
602  ossim_int32 currentLine = origin.y;
603  ossim_int32 linesProcessed = 0;
604  ossim_int64 offset = startSeekPosition;
605 
606  while (currentLine <= m_rasterInfo.imageRect().lr().y && linesProcessed < size.y)
607  {
608  //---
609  // Seek to line.
610  //---
611  m_fileStrList[ *bandIter ]->seekg(offset, ios::beg);
612 
613  if ( !m_fileStrList[ *bandIter ] )
614  {
617  << MODULE << " ERROR:\n"
618  << " Seek error! Returning with error..." << std::endl;
619  return false;
620  }
621 
622  //---
623  // Read the line of image data.
624  //---
625  m_fileStrList[ *bandIter ]->read((char*)buf, buffer_width);
626 
627  if ( m_fileStrList[ *bandIter ]->gcount() != buffer_width)
628  {
631  << MODULE << "\nERROR: Reading image line."
632  << "\ncurrentLine: " << currentLine << std::endl;
633  return false;
634  }
635 
636  // Increment everybody accordingly.
637  buf += buffer_width;
638  offset += m_rasterInfo.bytesPerRawLine();
639  ++linesProcessed;
640  ++currentLine;
641 
642  } // End of line loop.
643 
644  ++bandIter; // Next band...
645 
646  } // End: while ( bandIter ! = m_outputBandList.end() )
647 
648  return true;
649 }
650 
651 //*******************************************************************
652 // Public method:
653 //*******************************************************************
655  const char* prefix) const
656 {
657  // Our stuff:
658  m_rasterInfo.saveState(kwl, prefix);
659 
660  // Base class:
661  bool result = ossimImageHandler::saveState(kwl, prefix);
662 
663  if ( result && isBandSelector() && m_outputBandList.size() )
664  {
665  if ( isIdentityBandList( m_outputBandList ) == false )
666  {
667  // If we're not identity output the bands.
668  ossimString bandsString;
670  kwl.add(prefix,
672  bandsString,
673  true);
674  }
675  }
676 
677  return result;
678 }
679 
680 //*******************************************************************
681 // Public method:
682 //*******************************************************************
684  const char* prefix)
685 {
686  bool result = false;
687  m_outputBandList.clear();
688 
689  if ( ossimImageHandler::loadState(kwl, prefix) )
690  {
691  // Set the band list if key is present.
692  std::string pfx = ( prefix ? prefix : "" );
693  std::string key = ossimKeywordNames::BANDS_KW;
694  ossimString value;
695  value.string() = kwl.findKey( pfx, key );
696  if ( value.size() )
697  {
699  }
700  result = open();
701  }
702  return result;
703 }
704 
705 //*******************************************************************
706 // Public method:
707 //*******************************************************************
709 {
711 }
712 
713 //*******************************************************************
714 // Public method:
715 //*******************************************************************
717 {
718  ossim_uint32 result = 0;
719  if ( m_tile.valid() )
720  {
721  m_tile->getWidth();
722  }
723  else
724  {
725  ossimIpt tileSize;
726  ossim::defaultTileSize(tileSize);
727  result = tileSize.x;
728  }
729  return result;
730 }
731 
732 //*******************************************************************
733 // Public method:
734 //*******************************************************************
736 {
737  ossim_uint32 result = 0;
738  if ( m_tile.valid() )
739  {
740  m_tile->getHeight();
741  }
742  else
743  {
744  ossimIpt tileSize;
745  ossim::defaultTileSize(tileSize);
746  result = tileSize.y;
747  }
748  return result;
749 }
750 
751 //*******************************************************************
752 // Public method:
753 //*******************************************************************
754 bool
756 {
757  static const char MODULE[] = "ossimGeneralRasterTileSource::isValidRLevel";
758 
759  if (reduced_res_level == 0)
760  {
761  return true;
762  }
763  else if (theOverview.valid())
764  {
765  return theOverview->isValidRLevel(reduced_res_level);
766  }
767  else
768  {
770  << MODULE
771  << " Invalid reduced_res_level: " << reduced_res_level
772  << "\nHighest available: " << (getNumberOfDecimationLevels() - 1)
773  << std::endl;
774  return false;
775  }
776 }
777 
778 
779 
780 //*******************************************************************
781 // Public method:
782 //*******************************************************************
785 {
786  if (reduced_res_level == 0)
787  {
788  return m_rasterInfo.validLines();
789  }
790  else if (theOverview.valid())
791  {
792  return theOverview->getNumberOfLines(reduced_res_level);
793  }
794 
795  return 0;
796 }
797 
798 //*******************************************************************
799 // Public method:
800 //*******************************************************************
802  ossim_uint32 reduced_res_level) const
803 {
804  if (reduced_res_level == 0)
805  {
806  return m_rasterInfo.validSamples();
807  }
808  else if (theOverview.valid())
809  {
810  return theOverview->getNumberOfSamples(reduced_res_level);
811  }
812 
813  return 0;
814 }
815 
817 {
819 }
820 
822 {
823  return m_rasterInfo.getImageMetaData().getMinPix(band);
824 }
825 
827 {
828  return m_rasterInfo.getImageMetaData().getMaxPix(band);
829 }
830 
832 {
833  static const char MODULE[] = "ossimGeneralRasterTileSource::open";
834 
835  if (traceDebug()) CLOG << " Entered..." << std::endl;
836 
837  bool result = false;
838 
839  if(isOpen())
840  {
841  close();
842  }
843 
844  //---
845  // Find the header file:
846  //
847  // We need lines, samples, bands, scalar and interleave at a minimum:
848  //
849  // A general raster image requires a keyword list to get essential image
850  // information or meta data as its sometimes called. The meta data file
851  // can have four types of extensions: ".omd", ".hdr", ".kwl" and xml.
852  // Look for them in that order.
853  // Note that the ".omd" extension is for "Ossim Meta Data" and was made
854  // up to avoid conflicting with other software packages ".hdr" files.
855  //---
856  if ( m_rasterInfo.open( theImageFile ) )
857  {
859 
860  result = initializeHandler();
861  if ( result )
862  {
863  completeOpen();
864 
865  if ( isBandSelector() && m_outputBandList.size() &&
866  ( isIdentityBandList( m_outputBandList ) == false ) )
867  {
868  // This does range checking and will pass to overview if open.
870  }
871  }
872  }
873 
874  if ( traceDebug() )
875  {
877  << MODULE << " Exit status: " << (result?"true":"false") << std::endl;
878  }
879  return result;
880 }
881 
883 {
884  if( isOpen() )
885  {
886  close();
887  }
888 
889  m_rasterInfo = info;
890 
891  bool result = initializeHandler();
892 
893  if ( result )
894  {
895  completeOpen();
896 
897  if ( isBandSelector() && m_outputBandList.size() &&
898  ( isIdentityBandList( m_outputBandList ) == false ) )
899  {
900  // This does range checking and will pass to overview if open.
902  }
903  }
904 
905  return result;
906 }
907 
909 {
910  //---
911  // This private method assumes that "m_rasterInfo" object has been
912  // initialized. Note that "close() should have already been called if
913  // there was an open file prior to this.
914  //---
915  std::vector<ossimFilename> aList = m_rasterInfo.getImageFileList();
916 
917  for (ossim_uint32 i=0; i<aList.size(); ++i)
918  {
919  ossimFilename f = aList[i];
920 
921  // open it...
922  std::shared_ptr<ossim::istream> is = ossim::StreamFactoryRegistry::instance()->
923  createIstream(f);
924 
925  // check the stream...
926  if( is )
927  {
928  // Check the file stream.
929  if ( is->fail() )
930  {
933  << "ossimGeneralRasterTileSource::open" << " ERROR:\n"
934  << "Cannot open: " << f.c_str() << std::endl;
935  is = 0;
936  return false;
937  }
938  }
939 
940  // Check the file size (removed).
941 
942  m_fileStrList.push_back(is); // Add it to the list...
943  }
944 
945  if ((aList.size()==1) && theImageFile.empty())
946  {
947  theImageFile = aList[0];
948  }
949 
950  // Set the buffer interleave type.
953  {
955  }
956 
957  if ( m_outputBandList.empty() )
958  {
959  // Set starting output band list to identity.
961  }
962 
963  //---
964  // Get the byte order of the image data and host machine. If different,
965  // set the swap bytes flag...
966  //---
968  {
969  m_swapBytesFlag = true;
970  }
971 
972  if (traceDebug())
973  {
975  << "ossimGeneralRasterTileSource::initializeHandler()" << " DEBUG:"
976  << "\nScalar type: "
978  getEntryString(m_rasterInfo.getImageMetaData().getScalarType())
979  << "\nByte swapping is "
980  << (m_swapBytesFlag?"enabled.":"not enabled.")
981  // << "\nm_bufferSizeInPixels: " << m_bufferSizeInPixels
982  // << "\nbuffer size: " << buffer_size
983  << "\nRasterInfo:\n";
985  }
986 
987  return true;
988 }
989 
991 {
992  bool result = false;
993  if (m_fileStrList.size() > 0)
994  {
995  if( m_fileStrList[0] )
996  {
997  result = !(m_fileStrList[0]->fail());
998  }
999  }
1000  return result;
1001 }
1002 
1004 {
1005  ossimImageHandler::close(); // base class
1006 
1007  m_tile = 0; // Not a leak, ref ptr.
1008 
1009  if ( m_buffer )
1010  {
1011  delete [] m_buffer;
1012  m_buffer = 0;
1013  m_bufferSizeInPixels = 0; // Must zero out for check in getTile method.
1014  }
1015 
1016  if ( m_lineBuffer )
1017  {
1018  delete [] m_lineBuffer;
1019  m_lineBuffer = 0;
1020  }
1021 
1022  std::vector< shared_ptr<ossim::istream> >::iterator is = m_fileStrList.begin();
1023  while (is != m_fileStrList.end())
1024  {
1025  (*is) = 0;
1026 
1027  ++is;
1028  }
1029  m_fileStrList.clear();
1030 }
1031 
1033 {
1034  return 0;
1035 }
1036 
1038 {
1039  return 0;
1040 }
1041 
1043 {
1044  return ossimString("ossim_raster");
1045 }
1046 
1048 {
1049  return ossimString("general raster reader");
1050 }
1051 
1053 {
1055 }
1056 
1058 {
1059  ossim_uint32 result = 0;
1060  if ( isBandSelector() && m_outputBandList.size() )
1061  {
1062  result = (ossim_uint32)m_outputBandList.size();
1063  }
1064  else
1065  {
1067  }
1068  return result;
1069 }
1070 
1072 {
1073  ossimKeywordlist kwl;
1074  char delimeter = ' ';
1075  kwl.change_delimiter(delimeter);
1076  kwl.addFile(hdrFile);
1077  kwl.downcaseKeywords();
1078 
1079  ossimKeywordlist geoKwl;
1080  ossim_uint32 lines = 0;
1081  ossim_uint32 samples = 0;
1082  ossim_float32 noData = -9999;
1083  ossimString scalarType = "ossim_uint8";
1084  ossim_int32 numBands = 1;
1085  // ossim_int32 skipBytes = 0;
1086  ossim_int32 numBits = -1;
1087  ossimString chPixelType = "N"; // not defined
1088  ossimString interleaveType = "BIL";
1090  bool noDataFound = false;
1091 
1092  const char* lookup = kwl.find("ncols");
1093  if (lookup)
1094  {
1095  samples = ossimString(lookup).toUInt32();
1096  geoKwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, samples);
1097  }
1098 
1099  lookup = kwl.find("nrows");
1100  if (lookup)
1101  {
1102  lines = ossimString(lookup).toUInt32();
1103  geoKwl.add(ossimKeywordNames::NUMBER_LINES_KW, lines);
1104  }
1105 
1106  // lookup = kwl.find("skipbytes");
1107  // if (lookup)
1108  // {
1109  // skipBytes = ossimString(lookup).toInt();
1110  // }
1111 
1112  lookup = kwl.find("nbands");
1113  if (lookup)
1114  {
1115  numBands = ossimString(lookup).toInt();
1116  }
1117 
1118  lookup = kwl.find("nodata");
1119  if (lookup)
1120  {
1121  noData = ossimString(lookup).toFloat32();
1122  noDataFound = true;
1123  }
1124  lookup = kwl.find("nodata_value");
1125  if (lookup)
1126  {
1127  noData = ossimString(lookup).toFloat32();
1128  noDataFound = true;
1129  }
1130 
1131  lookup = kwl.find("nbits");
1132  if (lookup)
1133  {
1134  numBits = ossimString(lookup).toInt();
1135  }
1136 
1137  lookup = kwl.find("pixeltype");
1138  if (lookup)
1139  {
1140  chPixelType = ossimString(lookup);
1141  }
1142 
1143  lookup = kwl.find("layout");
1144  if (lookup)
1145  {
1146  interleaveType = ossimString(lookup);
1147  }
1148 
1149  lookup = kwl.find("byteorder");
1150  if (lookup)
1151  {
1152  byteOrder = ossimString(lookup);
1153  }
1154 
1155  if (numBits == -1)
1156  {
1157  FILE* fp;
1158  ossim_int64 size = 0;
1159  fp = fopen(theImageFile.c_str(), "r");
1160  if (fp != 0)
1161  {
1162  fseek(fp, 0, SEEK_END);
1163  size = ftell(fp);
1164  }
1165  fclose(fp);
1166 
1167  if (lines > 0 && samples > 0)
1168  {
1169  ossim_int32 numBytes = size/samples/lines/numBands;
1170  if( numBytes > 0 && numBytes != 3 )
1171  {
1172  numBits = numBytes*8;
1173 
1174  if( numBytes == 4 )
1175  {
1176  chPixelType = "F";
1177  }
1178  }
1179  }
1180  }
1181 
1182  if( numBits == 16 )
1183  {
1184  if (chPixelType == "S")
1185  {
1186  scalarType = "ossim_sint16";
1187  }
1188  else
1189  {
1190  scalarType = "ossim_uint16"; // default
1191  }
1192  }
1193  else if( numBits == 32 )
1194  {
1195  if( chPixelType == "S")
1196  {
1197  scalarType = "ossim_sint32";
1198  }
1199  else if( chPixelType == "F")
1200  {
1201  scalarType = "ossim_float32";
1202  }
1203  else
1204  {
1205  scalarType = "ossim_uint32"; // default
1206  }
1207  }
1208  else if( numBits == 8 )
1209  {
1210  scalarType = "ossim_uint8";
1211  numBits = 8;
1212  }
1213  else if( numBits < 8 && numBits >= 1 )
1214  {
1215  scalarType = "ossim_uint8";
1216  }
1217  else if(numBits == -1)
1218  {
1219  if( chPixelType == "F")
1220  {
1221  scalarType = "ossim_float32";
1222  numBits = 32;
1223  }
1224  else
1225  {
1226  scalarType = "ossim_uint8";
1227  numBits = 8;
1228  }
1229  }
1230 
1231  if (noDataFound)
1232  {
1233  for (ossim_int32 i = 0; i < numBands; i++)
1234  {
1235  ossimString prefix = "band" + ossimString::toString(i+1) + ": ";
1236  geoKwl.add(prefix, ossimKeywordNames::NULL_VALUE_KW, noData);
1237  }
1238  }
1239 
1240  geoKwl.add(ossimKeywordNames::NUMBER_BANDS_KW, numBands);
1241  geoKwl.add(ossimKeywordNames::SCALAR_TYPE_KW, scalarType);
1242  geoKwl.add(ossimKeywordNames::INTERLEAVE_TYPE_KW, interleaveType);
1243 
1244  return geoKwl;
1245 }
1246 
1248 {
1249  ossimKeywordlist kwl;
1250  ossimFgdcXmlDoc file;
1251  if (file.open(xmlFile))
1252  {
1253 
1254  ossimString scalarType = "ossim_uint8";
1255  ossim_int32 numBits = -1;
1256  ossimString interleaveType = "BIL";
1257 
1258  ossimIpt size;
1259  ossim_int32 samples = 0;
1260  ossim_int32 lines = 0;
1261  if (file.getImageSize(size))
1262  {
1263  samples = size.x;
1264  lines = size.y;
1265  }
1266  if (samples > 0)
1267  {
1269  }
1270  if (lines > 0)
1271  {
1273  }
1274 
1275  ossim_int32 bands = file.getNumberOfBands();
1276  if (bands > 0)
1277  {
1279  }
1280  else
1281  {
1282  if (samples > 0 && lines > 0)//if there is no bands info but samples and lines info, default number of bands to 1
1283  {
1284  bands = 1;
1286  }
1287  }
1288 
1289  ossimString eainfo;
1290  file.getPath("/metadata/eainfo/detailed/enttyp/enttypd", eainfo);
1291 
1292  if (numBits == -1)
1293  {
1294  if ( (lines > 0) && (samples > 0) && (bands > 0) )
1295  {
1297  ossim_int32 numBytes = size/samples/lines/bands;
1298  if( numBytes > 0 && numBytes != 3 )
1299  {
1300  numBits = numBytes*8;
1301  }
1302  }
1303  }
1304 
1305  if( numBits == 16 )
1306  {
1307  scalarType = "ossim_uint16"; // default
1308  }
1309  else if( numBits == 32 )
1310  {
1311  if(eainfo.contains("float"))
1312  {
1313  scalarType = "ossim_float32";
1314  }
1315  else
1316  {
1317  scalarType = "ossim_uint32"; // default
1318  }
1319  }
1320  else if( numBits == 8 )
1321  {
1322  scalarType = "ossim_uint8";
1323  numBits = 8;
1324  }
1325  else if( numBits < 8 && numBits >= 1 )
1326  {
1327  scalarType = "ossim_uint8";
1328  }
1329 
1330  kwl.add(ossimKeywordNames::SCALAR_TYPE_KW, scalarType);
1331  kwl.add(ossimKeywordNames::INTERLEAVE_TYPE_KW, interleaveType);
1332  }
1333  return kwl;
1334 }
1335 
1337 {
1338  if ( !theGeometry.valid() )
1339  {
1340  // Check for external geom:
1342 
1343  if ( !theGeometry.valid() )
1344  {
1346 
1347  ossimString ext = theImageFile.ext();
1348  ossimFilename hdrFile = theImageFile;
1349  ossimFilename xmlFile = theImageFile;
1350  hdrFile = hdrFile.setExtension("hdr");
1351  xmlFile = xmlFile.setExtension("xml");
1352  if (hdrFile.exists())
1353  {
1354  ossimKeywordlist geoKwl;
1355  ossimKeywordlist kwl(hdrFile, ' ');
1356  kwl.downcaseKeywords();
1357 
1358  ossim_uint32 lines = 0;
1359  ossim_uint32 samples = 0;
1360  ossim_float32 ll_lon = 0.0;
1361  ossim_float32 ll_lat = 0.0;
1362  ossim_float32 xCellSize = 1.0;
1363  ossim_float32 yCellSize = 1.0;
1364 
1365  const char* lookup = kwl.find("ncols");
1366  if (lookup)
1367  {
1368  samples = ossimString(lookup).toUInt32();
1369  geoKwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, samples);
1370  }
1371 
1372  lookup = kwl.find("nrows");
1373  if (lookup)
1374  {
1375  lines = ossimString(lookup).toUInt32();
1376  geoKwl.add(ossimKeywordNames::NUMBER_LINES_KW, lines);
1377  }
1378 
1379  lookup = kwl.find("cellsize");
1380  if (lookup)
1381  {
1382  xCellSize = ossimString(lookup).toFloat32();
1383  yCellSize = xCellSize;
1386  }
1387 
1388  lookup = kwl.find("xdim");
1389  if (lookup)
1390  {
1391  xCellSize = ossimString(lookup).toFloat32();
1393  }
1394 
1395  lookup = kwl.find("ydim");
1396  if (lookup)
1397  {
1398  yCellSize = ossimString(lookup).toFloat32();
1400  }
1401 
1402  lookup = kwl.find("xllcenter");
1403  if (lookup)
1404  {
1405  ossim_float32 centerX = ossimString(lookup).toFloat32();
1406  ll_lon = centerX + xCellSize * 0.5;
1407  geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon);
1408  }
1409 
1410  lookup = kwl.find("yllcenter");
1411  if (lookup)
1412  {
1413  ossim_float32 centerY = ossimString(lookup).toFloat32();
1414  ll_lat = (centerY + (lines - 1) * yCellSize) + yCellSize * 0.5;
1415  geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat);
1416  }
1417 
1418  lookup = kwl.find("xllcorner");
1419  if (lookup)
1420  {
1421  ll_lon = ossimString(lookup).toFloat32();
1422  geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon);
1423  }
1424 
1425  lookup = kwl.find("yllcorner");
1426  if (lookup)
1427  {
1428  ossim_uint32 centerY = ossimString(lookup).toFloat32();
1429  ll_lat = centerY + lines * yCellSize;
1430  geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat);
1431  }
1432 
1433  lookup = kwl.find("ulxmap");
1434  if (lookup)
1435  {
1436  ll_lon = ossimString(lookup).toFloat32();
1437  geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon);
1438  }
1439 
1440  lookup = kwl.find("ulymap");
1441  if (lookup)
1442  {
1443  ossim_uint32 centerY = ossimString(lookup).toFloat32();
1444  ll_lat = centerY + lines * yCellSize;
1445  geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat);
1446  }
1447 
1449 
1450  geoKwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection");
1451 
1453  code());
1454 
1456  createProjection(geoKwl);
1457 
1458  if ( proj.valid() )
1459  {
1460  theGeometry->setProjection(proj.get());
1461  }
1462  }
1463  else if (xmlFile.exists())
1464  {
1465  ossimFgdcXmlDoc file;
1466  if ( file.open(xmlFile) )
1467  {
1469  if ( !proj.valid() )
1470  {
1471  proj = file.getGridCoordSysProjection();
1472  }
1473  if ( proj.valid() )
1474  {
1475  theGeometry->setProjection(proj.get());
1476  }
1477  }
1478 
1479  } // xml file exist...
1480 
1481  } // Matches second if ( !theGeometry.valid() )
1482 
1483  //---
1484  // WARNING:
1485  // Must have theGeometry at this point or the next call to
1486  // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop
1487  // as it does a recursive call back to ossimImageHandler::getImageGeometry().
1488  //---
1489 
1490  // Check for set projection.
1491  if ( !theGeometry->getProjection() )
1492  {
1493  // Try factories for projection.
1495  }
1496 
1497  // Set image things the geometry object should know about.
1499 
1500  } // Matches first if ( !theGeometry.valid() )
1501 
1502  return theGeometry;
1503 }
1504 
1506 {
1507  bool result = false;
1511  {
1512  result = true;
1513  }
1514 
1515  if ( result && theOverview.valid() )
1516  {
1517  result = theOverview->isBandSelector();
1518  }
1519  return result;
1520 }
1521 
1522 bool ossimGeneralRasterTileSource::setOutputBandList(const std::vector<ossim_uint32>& band_list)
1523 {
1524  bool result = false;
1525  if ( isBandSelector() )
1526  {
1527  // Making a copy as passed in list could be our m_outputBandList.
1528  std::vector<ossim_uint32> inputList = band_list;
1530  if ( result && m_tile.valid() )
1531  {
1532  if ( m_tile->getNumberOfBands() != m_outputBandList.size() )
1533  {
1534  m_tile = 0; // Force a reinitialize on next getTile.
1535  }
1536  }
1537  }
1538  return result;
1539 }
1540 
1541 void ossimGeneralRasterTileSource::getOutputBandList(std::vector<ossim_uint32>& bandList) const
1542 {
1543  bandList = m_outputBandList;
1544 }
1545 
1547 {
1548  m_tile = 0;
1549  ossim_uint32 bands = 0;
1550  if ( m_outputBandList.empty() )
1551  {
1552  bands = m_rasterInfo.numberOfBands();
1553  }
1554  else
1555  {
1556  bands = (ossim_uint32)m_outputBandList.size();
1557  }
1558 
1559  if ( bands )
1560  {
1562  this, m_rasterInfo.getImageMetaData().getScalarType(), bands );
1563 
1564  if ( m_tile.valid() )
1565  {
1566  // These values can be overridden by loadState...
1567  for(ossim_uint32 band = 0; band < bands; ++ band)
1568  {
1572  }
1573  m_tile->initialize(); // This does a makeBlank().
1574  }
1575  }
1576 }
1577 
1579 {
1580  if( m_buffer )
1581  {
1582  delete [] m_buffer;
1583  m_buffer = 0;
1584  m_bufferSizeInPixels = 0; // Must zero out for check in getTile method.
1585  }
1586  if ( m_lineBuffer )
1587  {
1588  delete [] m_lineBuffer;
1589  m_lineBuffer = 0;
1590  }
1591 
1592  if ( tile )
1593  {
1594  // Store the size of the buffer in pixels for swapping bytes.
1595  m_bufferSizeInPixels = tile->getSize();
1596  if ( m_bufferSizeInPixels )
1597  {
1598  // Initialize buffer. This is bytes, not pixels.
1599  m_buffer = new ossim_uint8[ tile->getSizeInBytes() ];
1600 
1601  // Zero out the buffer rect.
1602  m_bufferRect = ossimIrect(0, 0, 0, 0);
1603  }
1604 
1606  {
1607  // Big enough to hold a whole line all bands.
1608  ossim_uint32 widthInBytes =
1611 
1612  m_lineBuffer = new ossim_uint8[ widthInBytes ];
1613  }
1614  }
1615 }
16 bit unsigned integer (15 bits used)
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
static const char * DECIMAL_DEGREES_PER_PIXEL_LAT
ossim_int32 validSamples() const
Returns the number of samples within "theValidImageRect".
virtual bool open()
Pure virtual open.
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossim_int32 bytesPerPixel() const
Bytes per pixel.
virtual ossim_uint32 getNumberOfBands() const
static const char * DATUM_KW
#define CLOG
Definition: ossimTrace.h:23
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
ossim_uint32 getBytesPerPixel() const
double getMinPix(ossim_uint32 band) const
Represents serializable keyword/value map.
bool addFile(const char *file)
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimInterleaveType interleaveType() const
Enumerated in InterleaveTypeLUT.
virtual bool fillBIL(const ossimIpt &origin, const ossimIpt &size)
const char * find(const char *key) const
ossim_int64 fileSize() const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
float ossim_float32
virtual ossimString getEntryString(ossim_int32 entry_number) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimScalarType getScalarType() const
std::vector< ossim_uint32 > m_outputBandList
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level=0) const
Returns the number of samples in the image.
ossim_uint32 getNumberOfBands()
Get Bands.
std::streamoff offsetToFirstValidSample() const
Returns the offset in bytes to the first valid sample in the image.
ossimKeywordlist & downcaseKeywords()
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Override base getXXXXPixValue methods since the null/min/max can be set to something different...
static ossimMapProjectionFactory * instance()
ossim_uint32 height() const
Definition: ossimIrect.h:487
bool contains(char aChar) const
Definition: ossimString.h:58
static const char * NULL_VALUE_KW
virtual bool fillBIP(const ossimIpt &origin, const ossimIpt &size)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossimRefPtr< ossimProjection > getGridCoordSysProjection()
Gets projection from Grid Coordinate system node.
static ossimString toString(bool aValue)
Numeric to string methods.
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.
static const char * NUMBER_LINES_KW
static const char * TIE_POINT_LON_KW
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
double getMaxPix(ossim_uint32 band) const
virtual bool isOpen() const
Derived classes must implement this method to be concrete.
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
void toSimpleStringList(ossimString &result, const std::vector< T > &valuesList)
This will output a vector of values inst a string.
Definition: ossimCommon.h:484
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossim_int32 bytesPerRawLine() const
Returns the number of bytes in a raw line.
void change_delimiter(char del)
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
ossim_uint32 toUInt32() const
16 bit unsigned integer (13 bits used)
static StreamFactoryRegistry * instance()
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossim_int32 validLines() const
Returns the number of lines within "theValidImageRect".
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
Returns a pointer to a tile given an origin representing the upper left corner of the tile to grab fr...
virtual bool fillBsqMultiFile(const ossimIpt &origin, const ossimIpt &size)
virtual ossim_uint32 getTileHeight() const
Returns the height of the output tile.
double getNullPix(ossim_uint32 band) const
static const char * TYPE_KW
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void initialize()
Initialize the data buffer.
ossim_uint32 getNumberOfBands() const
ossimByteOrder getImageDataByteOrder() const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual std::ostream & print(std::ostream &out) const
Generic print method.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
bool toSimpleVector(std::vector< T > &result, const ossimString &stringOfPoints)
Definition: ossimCommon.h:537
void set_ul(const ossimIpt &pt)
Definition: ossimIrect.h:589
bool completely_within(const ossimIrect &rect) const
Definition: ossimIrect.cpp:425
virtual bool fillBSQ(const ossimIpt &origin, const ossimIpt &size)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
#define RTTI_DEF1_INST(cls, name, b1)
Definition: ossimRtti.h:481
const std::vector< ossimFilename > & getImageFileList() const
std::vector< std::shared_ptr< ossim::istream > > m_fileStrList
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual void setNullPix(ossim_float64 null_pix)
virtual bool setOutputBandList(const std::vector< ossim_uint32 > &band_list)
If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled...
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
static ossimImageDataFactory * instance()
virtual bool fillBuffer(const ossimIpt &origin, const ossimIpt &size)
Methods return true on succes false on error.
bool open(const ossimFilename &imageFile)
Takes image file and attempts to derive/find header file to parse for general raster data...
virtual ossim_uint32 getSizeInBytes() const
Returns the total number of bytes for all bands.
virtual ossim_uint32 getTileWidth() const
Returns the width of the output tile.
yy_size_t size
virtual ossimDataObjectStatus validate() const
bool exists() const
std::string::size_type size() const
Definition: ossimString.h:405
virtual bool isIdentityBandList(const std::vector< ossim_uint32 > &bandList) const
Convenience method to see if band list is identity.
bool isValidRLevel(ossim_uint32 reduced_res_level) const
Determines if the passed in reslution level is valid.
unsigned int ossim_uint32
virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level=0) const
Returns the number of lines in the image.
ossim_int32 rawLines() const
Returns the number of lines within "theRawImageRect".
Class for FGDC XML doc parsing.
static ossimDatumFactory * instance()
virtual ossimIrect getImageRectangle() const
static const char * DECIMAL_DEGREES_PER_PIXEL_LON
bool getImageSize(ossimIpt &size) const
virtual ossimKeywordlist getHdrInfo(ossimFilename hdrFile)
ossim_float32 toFloat32() const
const ossimIpt & lr() const
Definition: ossimIrect.h:276
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
static const char * NUMBER_BANDS_KW
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 width() const
Definition: ossimIrect.h:500
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
static const char * BANDS_KW
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
virtual ossimKeywordlist getXmlInfo(ossimFilename xmlFile)
virtual void close()
Deletes the overview and clears the valid image vertices.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimScalarType
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimRefPtr< ossimImageData > m_tile
static const char * ORIGIN_LATITUDE_KW
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
void set_lrx(ossim_int32 x)
Definition: ossimIrect.h:693
return status
ossimRefPtr< ossimProjection > getProjection()
Gets projection from document.
virtual void makeBlank()
Initializes data to null pixel values.
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void completeOpen()
Will complete the opening process.
16 bit unsigned integer (11 bits used)
static const char * INTERLEAVE_TYPE_KW
ossimImageMetaData theMetaData
ossimRefPtr< ossimImageHandler > theOverview
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList to the zero based order of output bands.
virtual void setMaxPix(ossim_float64 max_pix)
This class defines an abstract Handler which all image handlers(loaders) should derive from...
void set_lry(ossim_int32 y)
Definition: ossimIrect.h:702
virtual ossim_uint32 getSize() const
Returns the total number of pixels in a tile for all bands.
ossim_int32 y
Definition: ossimIpt.h:142
long long ossim_int64
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
static const char * SCALAR_TYPE_KW
bool empty() const
Definition: ossimString.h:411
const ossimImageMetaData & getImageMetaData() const
const ossimIrect & imageRect() const
Zero based rectangle of the valid image.
ossimString ext() const
bool open(const ossimFilename &xmlFileName)
Open method.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
ossim_int32 x
Definition: ossimIpt.h:141
static const char * TIE_POINT_LAT_KW
virtual void setScalarType(ossimScalarType type)
See ossimScalarType in ossimConstants for a full list.
void allocateBuffer(const ossimImageData *tile)
Allocates m_buffer.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual bool setOutputBandList(const std::vector< ossim_uint32 > &band_list)
If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled...
virtual void setMinPix(ossim_float64 min_pix)
ossim_int32 numberOfBands() const
Number of bands.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
static const char * NUMBER_SAMPLES_KW
unsigned char ossim_uint8
int toInt() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
signed long long ossim_sint64
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
#define min(a, b)
Definition: auxiliary.h:75
int ossim_int32
const std::string & string() const
Definition: ossimString.h:414
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
16 bit unsigned integer (12 bits used)