OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimCcfTileSource.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 ossimCcfTileSource.
12 //*******************************************************************
13 // $Id: ossimCcfTileSource.cpp 17195 2010-04-23 17:32:18Z dburken $
14 
15 #include <algorithm>
17 #include <ossim/base/ossimCommon.h>
18 #include <ossim/base/ossimTrace.h>
19 #include <ossim/base/ossimIpt.h>
20 #include <ossim/base/ossimDpt.h>
21 #include <ossim/base/ossimIrect.h>
31 
32 using namespace std;
33 
34 RTTI_DEF1(ossimCcfTileSource, "ossimCcfTileSource", ossimImageHandler);
35 
36 //***
37 // Define Trace flags for use within this file:
38 //***
39 
40 static ossimTrace traceExec ("ossimCcfTileSource:exec");
41 static ossimTrace traceDebug ("ossimCcfTileSource:debug");
42 
43 // For interleave type enum to string conversions.
44 static const ossimInterleaveTypeLut ILUT;
45 
47  :
49  theCcfHead(),
50  theTile(NULL),
51  theChipBuffer(NULL),
52  theFileStr(NULL),
53  theOutputBandList(1),
54  theByteOrder(ossim::byteOrder())
55 {}
56 
58 {
59  close();
60 }
61 
63  const ossimIrect& rect, ossim_uint32 resLevel)
64 {
65  if (theTile.valid())
66  {
67  // Image rectangle must be set prior to calling getTile.
69 
70  if ( getTile( theTile.get(), resLevel ) == false )
71  {
73  {
74  theTile->makeBlank();
75  }
76  }
77  }
78 
79  return theTile;
80 }
81 
83  ossim_uint32 resLevel)
84 {
85  bool status = false;
86 
87  //---
88  // Not open, this tile source bypassed, or invalid res level,
89  // return a blank tile.
90  //---
91  if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
92  result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
93  {
94  result->ref(); // Increment ref count.
95 
96  //---
97  // Check for overview tile. Some overviews can contain r0 so always
98  // call even if resLevel is 0. Method returns true on success, false
99  // on error.
100  //---
101  status = getOverviewTile(resLevel, result);
102 
103  if (!status) // Did not get an overview tile.
104  {
105  status = true;
106 
107  ossimIrect tile_rect = result->getImageRectangle();
108 
109  ossimIrect image_rect = theCcfHead.imageRect(resLevel);
110 
111  //---
112  // See if any point of the requested tile is in the image.
113  //---
114  if ( tile_rect.intersects(image_rect) )
115  {
116  ossimIrect clip_rect = tile_rect.clipToRect(image_rect);
117 
118  if ( !tile_rect.completely_within(clip_rect) )
119  {
120  // Start with a blank tile.
121  result->makeBlank();
122  }
123 
124  // Load the tile buffer with data from the ccf.
125  status = fillBuffer(tile_rect,
126  clip_rect,
127  image_rect,
128  resLevel,
129  result);
130  if (status)
131  {
132  result->validate();
133  }
134  }
135  }
136 
137  result->unref(); // Decrement ref count.
138  }
139 
140  return status;
141 }
142 
143 //*******************************************************************
144 // Private Method:
145 //*******************************************************************
147  const ossimIrect& clip_rect,
148  const ossimIrect& image_rect,
149  ossim_uint32 reduced_res_level,
150  ossimImageData* tile)
151 {
152  bool status = false;
153 
154  //***
155  // Determine the pixel type and make the appropriate tiles.
156  //***
157  switch (theCcfHead.pixelType())
158  {
159  case OSSIM_UCHAR:
160  status = fillUcharBuffer(tile_rect,
161  clip_rect,
162  image_rect,
163  reduced_res_level,
164  tile);
165  break;
166  case OSSIM_USHORT11:
167  case OSSIM_USHORT12:
168  case OSSIM_USHORT13:
169  case OSSIM_USHORT14:
170  case OSSIM_USHORT15:
171  case OSSIM_USHORT16:
172  status = fillUshortBuffer(tile_rect,
173  clip_rect,
174  image_rect,
175  reduced_res_level,
176  tile);
177  break;
178  default:
181  << "ossimCcfTileSource fillBuffer ERROR:"
182  << "\nUnsupported pixel type!"
183  << "\nBuffer not filled. Returning error." << endl;
184  break;
185  }
186 
187  return status;
188 }
189 
190 //*******************************************************************
191 // Private Method:
192 //*******************************************************************
194  const ossimIrect& clip_rect,
195  const ossimIrect& /* image_rect */,
196  ossim_uint32 reduced_res_level,
197  ossimImageData* tile)
198 {
199  if(!isOpen()) return false;
200 
201  const ossim_uint32 TILE_SIZE_PER_BAND = tile->getSizePerBand();
202  const ossim_uint32 CHIP_SIZE_PER_BAND = theCcfHead.chipSizePerBand();
203  const ossim_uint32 SAMPLES_PER_CHIP = theCcfHead.samplesPerChip();
204  const ossim_uint32 LINES_PER_CHIP = theCcfHead.linesPerChip();
205  const ossim_uint32 BYTES_PER_CHUNK = theCcfHead.bytesPerChunk();
206  const ossim_uint32 BYTES_PER_CHIP = theCcfHead.bytesPerChip();
207  const ossim_uint32 CHIPS_IN_SAMPLE_DIR = theCcfHead.sampleChipsPerChunk();
208  const ossim_uint32 CHIPS_IN_LINE_DIR = theCcfHead.lineChipsPerChunk();
209  const ossim_uint32 NUMBER_OF_INPUT_BANDS = theCcfHead.numberOfBands();
210  const ossim_uint32 CHUNKS_IN_SAMPLE_DIR = theCcfHead.chunksInSampleDir(reduced_res_level);
211  const ossim_uint32 CHUNK_SIDE_SIZE = SAMPLES_PER_CHIP *
212  CHIPS_IN_SAMPLE_DIR;
213  const ossim_uint32 CHIP_OFFSET_TO_END = SAMPLES_PER_CHIP - 1;
214 
215  //***
216  // Shift the upper left corner of the "clip_rect" to the an even chunk
217  // boundry.
218  //***
219  ossimIpt chunkOrigin = clip_rect.ul();
220  adjustToStartOfChunk(chunkOrigin);
221 
222  //***
223  // Calculate the number of chunks needed in the line/sample directions.
224  //***
225  ossim_uint32 size_in_x
226  = static_cast<ossim_uint32>(clip_rect.lr().x - chunkOrigin.x + 1);
227  ossim_uint32 size_in_y
228  = static_cast<ossim_uint32>(clip_rect.lr().y - chunkOrigin.y + 1);
229  ossim_uint32 w = (CHIPS_IN_SAMPLE_DIR*SAMPLES_PER_CHIP);
230  ossim_uint32 h = (CHIPS_IN_LINE_DIR*LINES_PER_CHIP);
231  ossim_uint32 chunks_in_x_dir = size_in_x / w + (size_in_x % w ? 1 : 0);
232  ossim_uint32 chunks_in_y_dir = size_in_y / h + (size_in_y % h ? 1 : 0);
233 
234 
235  //***
236  // Get the start of data for the "reduced_res_level" passed in.
237  //***
238  streampos startOfData = theCcfHead.startOfData(reduced_res_level);
239  ossimIpt ulChunkPt = chunkOrigin;
240 
241  // Chunk loop in line direction.
242  for (ossim_uint32 y=0; y<chunks_in_y_dir; ++y)
243  {
244  ulChunkPt.x = chunkOrigin.x;
245 
246  // Chunk loop in sample direction.
247  for (ossim_uint32 x=0; x<chunks_in_x_dir; ++x)
248  {
249  //***
250  // Sequence through the chips in the chunk.
251  // Grab the ccf data and stuff the tile buffer.
252  //***
253  ossimIpt chip_pt = ulChunkPt;
254 
255  // Chip loop in line direction.
256  for (ossim_uint32 y_chip=0; y_chip<CHIPS_IN_LINE_DIR; ++y_chip)
257  {
258  chip_pt.x = ulChunkPt.x; // Reset x back to front of chunk.
259 
260  // Chip loop in sample direction.
261  for (ossim_uint32 x_chip=0; x_chip<CHIPS_IN_SAMPLE_DIR; ++x_chip)
262  {
263  ossimIrect chip_rect(chip_pt.x,
264  chip_pt.y,
265  chip_pt.x + CHIP_OFFSET_TO_END,
266  chip_pt.y + CHIP_OFFSET_TO_END);
267 
268  if (chip_rect.intersects(clip_rect))
269  {
270  //***
271  // Some point in the chip intersect the tile so grab the
272  // data.
273  //***
274 
275  //***
276  // Get the seek position for the chunk.
277  //***
278  streampos tmp_offset
279  = ( ulChunkPt.y / CHUNK_SIDE_SIZE * BYTES_PER_CHUNK *
280  CHUNKS_IN_SAMPLE_DIR ) +
281  ( ulChunkPt.x / CHUNK_SIDE_SIZE * BYTES_PER_CHUNK );
282 
283  streampos seek_position = startOfData + tmp_offset;
284 
285  // Now move it to the chip.
286  tmp_offset
287  = ( y_chip * BYTES_PER_CHIP * CHIPS_IN_SAMPLE_DIR ) +
288  (x_chip * BYTES_PER_CHIP);
289 
290  seek_position += tmp_offset;
291 
292  // Seek to the chip
293  theFileStr->seekg(seek_position, ios::beg);
294 
295  //***
296  // Read the chip from the ccf file into the chip buffer.
297  // This will get all the bands. Bands are interleaved by
298  // chip.
299  //***
300  if (!theFileStr->read((char*)theChipBuffer, BYTES_PER_CHIP))
301  {
303  cerr << "ossimCcfTileSource fillUchBuffer READ ERROR!"
304  << "\nReturning from method." << endl;
305  return false;
306  }
307 
308  ossimIrect chip_clip_rect = clip_rect.clipToRect(chip_rect);
309 
310  //***
311  // Band loop in sample direction. Bands are interleaved by
312  // chip.
313  //***
314  for (ossim_uint32 band=0; band<NUMBER_OF_INPUT_BANDS; ++band)
315  {
316  //***
317  // Get a pointer positioned at the first valid pixel in
318  // the chip.
319  //***
320  ossim_uint8* s
321  = theChipBuffer +
322  band * CHIP_SIZE_PER_BAND +
323  (chip_clip_rect.ul().y - chip_rect.ul().y) *
324  SAMPLES_PER_CHIP + chip_clip_rect.ul().x -
325  chip_rect.ul().x;
326 
327  //***
328  // Get a pointer positioned at the first valid pixel in
329  // the tile.
330  //***
331  ossim_uint8* d
332  = (ossim_uint8*)tile->getBuf() +
333  band * TILE_SIZE_PER_BAND +
334  (chip_clip_rect.ul().y - tile_rect.ul().y) *
335  tile->getWidth() + chip_clip_rect.ul().x -
336  tile_rect.ul().x;
337 
338  // Line loop through a chip.
339  for (ossim_int32 chip_line = chip_clip_rect.ul().y;
340  chip_line <= chip_clip_rect.lr().y;
341  chip_line++)
342  {
343  // Sample loop through a chip.
344  ossim_uint32 i=0;
345  for (ossim_int32 chip_sample = chip_clip_rect.ul().x;
346  chip_sample <= chip_clip_rect.lr().x;
347  chip_sample++)
348  {
349  d[i] = s[i];
350  i++;
351  }
352 
353  // Increment the pointers by one line.
354  s += SAMPLES_PER_CHIP;
355  d += tile->getWidth();
356  }
357 
358  } // End of band loop.
359 
360  } // End of if (chip_rect.intersects(clip_rect))
361 
362  chip_pt.x += SAMPLES_PER_CHIP;
363 
364  } // End of chip loop in the sample direction.
365 
366  chip_pt.y += LINES_PER_CHIP;
367 
368  } // End of chip loop in the line direction.
369 
370  ulChunkPt.x += CHUNK_SIDE_SIZE;
371 
372  } // End of chunk loop in the sample direction.
373 
374  ulChunkPt.y += CHUNK_SIDE_SIZE;
375 
376  } // End of chunk loop in the line direction.
377 
378  return true;
379 }
380 
381 //*******************************************************************
382 // Private Method:
383 //*******************************************************************
385  const ossimIrect& clip_rect,
386  const ossimIrect& /* image_rect */,
387  ossim_uint32 reduced_res_level,
388  ossimImageData* tile)
389 {
390  const ossim_uint32 TILE_SIZE_PER_BAND = tile->getSizePerBand();
391  const ossim_uint32 CHIP_SIZE_PER_BAND = theCcfHead.chipSizePerBand();
392  const ossim_uint32 SAMPLES_PER_CHIP = theCcfHead.samplesPerChip();
393  const ossim_uint32 LINES_PER_CHIP = theCcfHead.linesPerChip();
394  const ossim_uint32 BYTES_PER_CHUNK = theCcfHead.bytesPerChunk();
395  const ossim_uint32 BYTES_PER_CHIP = theCcfHead.bytesPerChip();
396  const ossim_uint32 CHIPS_IN_SAMPLE_DIR = theCcfHead.sampleChipsPerChunk();
397  const ossim_uint32 CHIPS_IN_LINE_DIR = theCcfHead.lineChipsPerChunk();
398  const ossim_uint32 NUMBER_OF_INPUT_BANDS = theCcfHead.numberOfBands();
399  const ossim_uint32 CHUNKS_IN_SAMPLE_DIR = theCcfHead.
400  chunksInSampleDir(reduced_res_level);
401  const ossim_uint32 CHUNK_SIDE_SIZE = SAMPLES_PER_CHIP *
402  CHIPS_IN_SAMPLE_DIR;
403  const ossim_uint32 CHIP_OFFSET_TO_END = SAMPLES_PER_CHIP - 1;
404 
405  //***
406  // Shift the upper left corner of the "clip_rect" to the an even chunk
407  // boundry.
408  //***
409  ossimIpt chunkOrigin = clip_rect.ul();
410  adjustToStartOfChunk(chunkOrigin);
411 
412  //***
413  // Calculate the number of chunks needed in the line/sample directions.
414  //***
415 
416  ossim_uint32 size_in_x = clip_rect.lr().x - chunkOrigin.x + 1;
417  ossim_uint32 size_in_y = clip_rect.lr().y - chunkOrigin.y + 1;
418  ossim_uint32 w = (CHIPS_IN_SAMPLE_DIR*SAMPLES_PER_CHIP);
419  ossim_uint32 h = (CHIPS_IN_LINE_DIR*LINES_PER_CHIP);
420  ossim_uint32 chunks_in_x_dir = size_in_x / w + (size_in_x % w ? 1 : 0);
421  ossim_uint32 chunks_in_y_dir = size_in_y / h + (size_in_y % h ? 1 : 0);
422  //***
423  // Get the start of data for the "reduced_res_level" passed in.
424  //***
425  streampos startOfData = theCcfHead.startOfData(reduced_res_level);
426  ossimIpt ulChunkPt = chunkOrigin;
427 
428  // Chunk loop in line direction.
429  for (ossim_uint32 y=0; y<chunks_in_y_dir; ++y)
430  {
431  ulChunkPt.x = chunkOrigin.x;
432 
433  // Chunk loop in sample direction.
434  for (ossim_uint32 x=0; x<chunks_in_x_dir; ++x)
435  {
436  //***
437  // Sequence through the chips in the chunk.
438  // Grab the ccf data and stuff the tile buffer.
439  //***
440  ossimIpt chip_pt = ulChunkPt;
441 
442  // Chip loop in line direction.
443  for (ossim_uint32 y_chip=0; y_chip<CHIPS_IN_LINE_DIR; ++y_chip)
444  {
445  chip_pt.x = ulChunkPt.x; // Reset x back to front of chunk.
446 
447  // Chip loop in sample direction.
448  for (ossim_uint32 x_chip=0; x_chip<CHIPS_IN_SAMPLE_DIR; ++x_chip)
449  {
450  ossimIrect chip_rect(chip_pt.x,
451  chip_pt.y,
452  chip_pt.x + CHIP_OFFSET_TO_END,
453  chip_pt.y + CHIP_OFFSET_TO_END);
454 
455  if (chip_rect.intersects(clip_rect))
456  {
457  //***
458  // Some point in the chip intersect the tile so grab the
459  // data.
460  //***
461 
462  //***
463  // Get the seek position for the chunk.
464  //***
465  streampos tmp_offset
466  = ( ulChunkPt.y / CHUNK_SIDE_SIZE * BYTES_PER_CHUNK *
467  CHUNKS_IN_SAMPLE_DIR ) +
468  ( ulChunkPt.x / CHUNK_SIDE_SIZE * BYTES_PER_CHUNK );
469 
470  streampos seek_position = startOfData + tmp_offset;
471 
472  // Now move it to the chip.
473  tmp_offset
474  = ( y_chip * BYTES_PER_CHIP * CHIPS_IN_SAMPLE_DIR ) +
475  (x_chip * BYTES_PER_CHIP);
476 
477  seek_position += tmp_offset;
478 
479  // Seek to the chip
480  theFileStr->seekg(seek_position, ios::beg);
481 
482  //***
483  // Read the chip from the ccf file into the chip buffer.
484  // This will get all the bands. Bands are interleaved by
485  // chip.
486  //***
487  if (!theFileStr->read((char*)theChipBuffer, BYTES_PER_CHIP))
488  {
490  cerr << "ossimCcfTileSource fillUshortBuffer READ ERROR!"
491  << "Returning from method." << endl;
492  return false;
493  }
494 
495  ossimIrect chip_clip_rect = clip_rect.clipToRect(chip_rect);
496 
497  //***
498  // Band loop in sample direction. Bands are interleaved by
499  // chip.
500  //***
501  for (ossim_uint32 band=0; band<NUMBER_OF_INPUT_BANDS; band++)
502  {
503  //***
504  // Get a pointer positioned at the first valid pixel in
505  // the chip.
506  //***
507  ossim_uint16* s
509  band * CHIP_SIZE_PER_BAND +
510  (chip_clip_rect.ul().y - chip_rect.ul().y) *
511  SAMPLES_PER_CHIP + chip_clip_rect.ul().x -
512  chip_rect.ul().x;
513 
514  //***
515  // Get a pointer positioned at the first valid pixel in
516  // the tile.
517  //***
518  ossim_uint16* d
519  = (ossim_uint16*)tile->getBuf() +
520  band * TILE_SIZE_PER_BAND +
521  (chip_clip_rect.ul().y - tile_rect.ul().y) *
522  tile->getWidth() + chip_clip_rect.ul().x -
523  tile_rect.ul().x;
524 
525  // Line loop through a chip.
526  for (ossim_int32 chip_line = chip_clip_rect.ul().y;
527  chip_line <= chip_clip_rect.lr().y;
528  ++chip_line)
529  {
530  // Sample loop through a chip.
531  ossim_uint32 i=0;
532  for (ossim_int32 chip_sample = chip_clip_rect.ul().x;
533  chip_sample <= chip_clip_rect.lr().x;
534  ++chip_sample)
535  {
537  {
538  //***
539  // CCF data alway stored in big endian byte
540  // order so swap the bytes.
541  //***
542  d[i] = (s[i] << 8) | (s[i] >> 8);
543  }
544  else
545  {
546  d[i] = s[i];
547  }
548 
549  ++i;
550  }
551 
552  // Increment the pointers by one line.
553  s += SAMPLES_PER_CHIP;
554  d += tile->getWidth();
555  }
556 
557  } // End of band loop.
558 
559  } // End of if (chip_rect.intersects(clip_rect))
560 
561  chip_pt.x += SAMPLES_PER_CHIP;
562 
563  } // End of chip loop in the sample direction.
564 
565  chip_pt.y += LINES_PER_CHIP;
566 
567  } // End of chip loop in the line direction.
568 
569  ulChunkPt.x += CHUNK_SIDE_SIZE;
570 
571  } // End of chunk loop in the sample direction.
572 
573  ulChunkPt.y += CHUNK_SIDE_SIZE;
574 
575  } // End of chunk loop in the line direction.
576 
577  return true;
578 }
579 
580 
581 //*******************************************************************
582 // Public Method:
583 //*******************************************************************
586 {
587  return theCcfHead.imageRect(reduced_res_level);
588 }
589 
590 //*******************************************************************
591 // Public Method:
592 //*******************************************************************
593 bool ossimCcfTileSource::setOutputBandList(const vector<ossim_uint32>& outputBandList)
594 {
595  static const char MODULE[] = "ossimCcfTileSource::setOutputBandList";
596  if (traceExec()) CLOG << "entering..." << endl;
597 
598  if (outputBandList.size() != theOutputBandList.size())
599  {
600  //***
601  // Verify that each individual band does not bust the range of input
602  // bands.
603  //***
604  for (ossim_uint32 i=0; i<outputBandList.size(); i++)
605  {
606  if (outputBandList[i] > (getNumberOfInputBands() - 1))
607  {
608  setErrorStatus();
609 
610  cerr << MODULE << " ERROR:"
611  << "\nOutput band number in list is greater than the "
612  << "number of bands in the image source!"
613  << "\noutputBandList[" << i << "]: "
614  << "\nHighest availabe band: "
615  << (getNumberOfInputBands() - 1)
616  << "\nError status has been set! Returning..."
617  << endl;
618  return false;
619  }
620  }
621 
622  // Remove the old tiles and reallocate with the new size.
623  theTile = NULL;
624  }
625 
626  theOutputBandList = outputBandList; // Assign the new list.
627 
628  if (traceExec()) CLOG << "returning..." << endl;
629  return true;
630 }
631 
632 //*******************************************************************
633 // Public method:
634 //*******************************************************************
636  const char* prefix) const
637 {
638  // Currently nothing to do here.
639  return ossimImageHandler::saveState(kwl, prefix);
640 }
641 
642 //*******************************************************************
643 // Public method:
644 //*******************************************************************
646  const char* prefix)
647 {
648  if (ossimImageHandler::loadState(kwl, prefix))
649  {
650  if (open())
651  {
652  return true;
653  }
654  }
655 
656  return false;
657 }
658 
659 //*******************************************************************
660 // Public method:
661 //*******************************************************************
663 {
664  static const char MODULE[] = "ossimCcfTileSource::open";
665  if (traceExec()) CLOG << "entering..." << endl;
666 
667  if(isOpen())
668  {
669  close();
670  }
671 
672  if (traceDebug())
673  {
674  CLOG << "DEBUG -- "
675  << "\n\t theImageFile: " << theImageFile << endl;
676  }
677 
679  {
681  if (traceExec()) CLOG << "returning with error..." << endl;
682  return false;
683  }
684 
685  if (traceDebug())
686  {
687  CLOG << "DEBUG -- "
688  << "\n\t theImageFile: " << theImageFile
689  << "\n\t theCcfHead: " << theCcfHead
690  << endl;
691  }
692 
694  // Open up the file for reading.
695  theFileStr->open(theImageFile.c_str(), ios::in | ios::binary);
696 
697  if (!(*theFileStr))
698  {
700 
701  cerr << MODULE << " ERROR!"
702  << "\nCould not open file: " << theImageFile.c_str()
703  << "\nReturning..." << endl;
704  if (traceExec()) CLOG << "returning with error..." << endl;
705 
706  delete theFileStr;
707  theFileStr = NULL;
708  return false;
709  }
710 
712  theTile->initialize();
713 
715 
716  // Initialize the output band list.
718  {
720  }
721 
722  for (ossim_uint32 i=0; i<getNumberOfInputBands(); ++i)
723  {
724  theOutputBandList[i] = i; // One to one for initial setup.
725  }
726 
727  completeOpen();
728 
729  if (traceDebug() && theTile.valid())
730  {
731  CLOG << "DEBUG:"
732  << "\ntheTile:\n" << *theTile << endl;
733  }
734 
735  if (traceExec()) CLOG << "returning..." << endl;
736  return true;
737 }
738 
740 {
741  theTile = NULL;
742  if (theChipBuffer)
743  {
744  delete [] theChipBuffer;
745  theChipBuffer = NULL;
746  }
747  if(theFileStr)
748  {
749  theFileStr->close();
750  theFileStr->clear();
751  delete theFileStr;
752  theFileStr = NULL;
753  }
754 }
755 
756 //*******************************************************************
757 // Public method:
758 //*******************************************************************
760 {
761  return theCcfHead.pixelType();
762 }
763 
764 //*******************************************************************
765 // Public method:
766 //*******************************************************************
768 {
769  return ( theTile.valid() ? theTile->getWidth() : 0 );
770 }
771 
772 //*******************************************************************
773 // Public method:
774 //*******************************************************************
776 {
777  return ( theTile.valid() ? theTile->getHeight() : 0 );
778 }
779 
781 {
782  return 32;
783 }
784 
786 {
787  return 32;
788 }
789 
791 {
792  theValidImageVertices.clear();
793 
794  const vector<ossimIpt>& validImageVertices
796 
797  ossim_uint32 upper = (ossim_uint32)validImageVertices.size();
798  if(!upper) return;
799  for(ossim_uint32 index = 0; index < upper; ++index)
800  {
801  theValidImageVertices.push_back(validImageVertices[index]);
802  }
803 
804  if (traceDebug())
805  {
806  cout << "ossimCcfTileSource::initVerticesFromHeader DEBUG:"
807  << "\nValid image vertices:"
808  << endl;
809  for (ossim_uint32 i=0; i<upper; ++i)
810  {
811  cout << "\npoint[" << i << "]: " << theValidImageVertices[i];
812  }
813  cout << endl;
814  }
815 }
816 
818 {
819  ossimFilename file = filename;
820  file.setExtension("geom");
821 
822  if(file.exists())
823  {
824  char bytes[3];
825  ifstream in(file.c_str());
826 
827  in.read((char*)bytes, 3);
828  ossimString testEcg(bytes,
829  bytes + 3);
830  testEcg = testEcg.downcase();
831  if(in&&(testEcg == "ecg"))
832  {
833  return true;
834  }
835  }
836  return false;
837 }
838 
840 {
841  return ossimString("ccf");
842 }
843 
845 {
846  return ossimString("ccf reader");
847 }
848 
850 {
851  return theCcfHead.numberOfBands();
852 }
853 
855 {
856  return getNumberOfInputBands();
857 }
858 
860 {
861  return theCcfHead.numberOfLines(reduced_res_level);
862 }
863 
865 {
866  return theCcfHead.numberOfSamples(reduced_res_level);
867 }
868 
870 {
872 }
873 
875 {
876  return (theFileStr != NULL);
877 }
878 
880 {
881  if(name == "file_type")
882  {
883 
884  return new ossimStringProperty(name, "CCF");
885  }
886  return ossimImageHandler::getProperty(name);
887 }
888 
889 void ossimCcfTileSource::getPropertyNames(std::vector<ossimString>& propertyNames)const
890 {
892  propertyNames.push_back("file_type");
893 }
894 
896 {
897  pt.x &= 0xffffff00;
898  pt.y &= 0xffffff00;
899 }
900 
902 {
903  pt.x &= 0xffffffe0;
904  pt.y &= 0xffffffe0;
905 }
ossim_uint32 samplesPerChip() const
Definition: ossimCcfHead.h:124
16 bit unsigned integer (15 bits used)
const std::vector< ossimIpt > & getValidImageVertices() const
Definition: ossimCcfHead.h:138
virtual ossim_uint32 getWidth() const
ossim_uint32 x
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
vector< ossim_uint32 > theOutputBandList
virtual ossim_uint32 getTileHeight() const
Returns the height of the output tile.
virtual ossim_uint32 getNumberOfBands() const
#define CLOG
Definition: ossimTrace.h:23
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
virtual ossim_uint32 getTileWidth() const
Returns the width of the output tile.
Represents serializable keyword/value map.
ossim_uint32 y
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
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 pixelType() const
Definition: ossimCcfHead.h:99
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
ossim_uint32 numberOfReducedResSets() const
Definition: ossimCcfHead.h:55
virtual ossimIrect getImageRectangle(ossim_uint32 reduced_res_level=0) const
Returns the zero based image rectangle for the reduced resolution data set (rrds) passed in...
const ossimIpt & ul() const
Definition: ossimIrect.h:274
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
virtual void close()
Deletes the overview and clears the valid image vertices.
16 bit unsigned integer (13 bits used)
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
unsigned short ossim_uint16
ossim_uint32 bytesPerChunk() const
Definition: ossimCcfHead.h:104
virtual bool isOpen() const
Derived classes must implement this method to be concrete.
virtual void initialize()
Initialize the data buffer.
void ref() const
increment the reference count by one, indicating that this object has another pointer which is refere...
bool fillUcharBuffer(const ossimIrect &tile_rect, const ossimIrect &clip_rect, const ossimIrect &image_rect, ossim_uint32 reduced_res_level, ossimImageData *tile)
Returns true on success, false on error.
bool setOutputBandList(const vector< ossim_uint32 > &outputBandList)
Set the output band list.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level=0) const
Returns the number of samples in the image.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
RTTI_DEF1(ossimCcfTileSource, "ossimCcfTileSource", ossimImageHandler)
bool completely_within(const ossimIrect &rect) const
Definition: ossimIrect.cpp:425
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
static ossimImageDataFactory * instance()
bool fillBuffer(const ossimIrect &tile_rect, const ossimIrect &clip_rect, const ossimIrect &image_rect, ossim_uint32 reduced_res_level, ossimImageData *tile)
Returns true on success, false on error.
ossim_uint32 chunksInSampleDir(ossim_uint32 reduced_res_level) const
virtual ossimDataObjectStatus validate() const
bool exists() const
bool parseCcfHeader(const char *ccf_file)
ossimRefPtr< ossimImageData > theTile
virtual ossim_uint32 getSizePerBand() const
Returns the number of pixels in a single band in a tile.
unsigned int ossim_uint32
virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level=0) const
Returns the number of lines in the image.
virtual ossimIrect getImageRectangle() const
virtual ossimString getShortName() const
vector< ossimIpt > theValidImageVertices
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of reduced resolution data sets (rrds).
const ossimIpt & lr() const
Definition: ossimIrect.h:276
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossim_uint32 chipSizePerBand() const
Definition: ossimCcfHead.h:135
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossim_uint32 numberOfSamples(ossim_uint32 reduced_res_level) const
std::streampos startOfData(ossim_uint32 reduced_res_level) const
ossimScalarType
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
void unref() const
decrement the reference count by one, indicating that a pointer to this object is referencing it...
return status
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void makeBlank()
Initializes data to null pixel values.
virtual ossimString getLongName() const
virtual void completeOpen()
Will complete the opening process.
16 bit unsigned integer (11 bits used)
bool fillUshortBuffer(const ossimIrect &tile_rect, const ossimIrect &clip_rect, const ossimIrect &image_rect, ossim_uint32 reduced_res_level, ossimImageData *tile)
Returns true on success, false on error.
ossim_uint8 * theChipBuffer
ossim_uint32 bytesPerChip() const
Definition: ossimCcfHead.h:109
ossim_uint32 numberOfLines(ossim_uint32 reduced_res_level) const
void adjustToStartOfChunk(ossimIpt &pt) const
Adjust point to even 256 boundary.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
ossim_uint32 linesPerChip() const
Definition: ossimCcfHead.h:129
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
ossim_uint32 lineChipsPerChunk() const
Definition: ossimCcfHead.h:119
ossimIrect imageRect(ossim_uint32 reduced_res_level) const
ossim_uint32 numberOfBands() const
Definition: ossimCcfHead.h:94
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
ossim_int32 x
Definition: ossimIpt.h:141
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
ossim_uint32 sampleChipsPerChunk() const
Definition: ossimCcfHead.h:114
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Gets a list of property names available.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void adjustToStartOfChip(ossimIpt &pt) const
Adjust point to even 32 boundary.
16 bit unsigned iteger
unsigned char ossim_uint8
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for matching name.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
8 bit unsigned iteger
int ossim_int32
bool isEcgGeom(const ossimFilename &filename) const
16 bit unsigned integer (12 bits used)
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.