OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimOpjJp2Reader.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: See top level LICENSE.txt file
4 //
5 // Author: David Burken
6 //
7 // Description: OSSIM Open JPEG JP2 reader (tile source).
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 #include <ossimOpjJp2Reader.h>
13 #include <ossimOpjCommon.h>
14 
15 #include <ossim/base/ossimCommon.h>
17 #include <ossim/base/ossimDpt.h>
18 #include <ossim/base/ossimEndian.h>
21 #include <ossim/base/ossimIpt.h>
22 #include <ossim/base/ossimIrect.h>
26 #include <ossim/base/ossimTrace.h>
28 
33 
37 
44 
45 #include <openjpeg.h>
46 #include <fstream>
47 
48 RTTI_DEF1(ossimOpjJp2Reader, "ossimOpjJp2Reader", ossimImageHandler)
49 
50 #ifdef OSSIM_ID_ENABLED
51  static const char OSSIM_ID[] = "$Id: ossimOpjJp2Reader.cpp 11439 2007-07-29 17:43:24Z dburken $";
52 #endif
53 
54 static ossimTrace traceDebug(ossimString("ossimOpjJp2Reader:degug"));
55 
56 static const ossim_uint16 SOC_MARKER = 0xff4f; // start of codestream marker
57 static const ossim_uint16 SIZ_MARKER = 0xff51; // size maker
58 
59 
61  :
63  m_sizRecord(),
64  m_tile(0),
65  m_str(0),
66  m_minDwtLevels(0)
67 {
68  // Uncomment to enable trace for debug:
69  // traceDebug.setTraceFlag(true);
70 
71  if (traceDebug())
72  {
74  << "ossimOpjJp2Reader::ossimOpjJp2Reader entered..." << std::endl;
75 #ifdef OSSIM_ID_ENABLED
77  << "OSSIM_ID: " << OSSIM_ID << endl;
78 #endif
79  }
80 }
81 
83 {
84  destroy();
85 }
86 
88 {
89  m_tile = 0; // ossimRefPtr
90  m_cacheTile = 0; // ossimRefPtr
91 
92  if ( m_str )
93  {
94  m_str->close();
95  delete m_str;
96  m_str = 0;
97  }
98 }
99 
101 {
102  static const char MODULE[] = "ossimOpjJp2Reader::open";
103 
104  if (traceDebug())
105  {
107  << MODULE << " entered..."
108  << "\nFile: " << theImageFile.c_str()
109  << std::endl;
110  }
111 
112  bool status = false;
113 
114  close();
115 
116  if ( theImageFile.size() )
117  {
118  m_str = new std::ifstream();
119  m_str->open( theImageFile.string().c_str(), std::ios_base::in | std::ios_base::binary);
120 
121  if ( m_str->good() )
122  {
124 
125  if ( m_format != OPJ_CODEC_UNKNOWN )
126  {
127  m_str->seekg(0, ios_base::beg);
128  if ( initSizRecord( m_str, m_sizRecord ) )
129  {
130  ossimJ2kCodRecord codRecord;
131  status = initCodRecord( m_str, codRecord );
132 
133  if ( status )
134  {
135  // Number of built in reduced res sets.
137 
138  // Put the stream back:
139  m_str->seekg(0, ios_base::beg);
140 
141  if ( traceDebug() )
142  {
144  << " DEBUG: J2K COD RECORD:\n"
145  << codRecord
146  << "\n";
147  }
148  }
149  }
150  }
151 
152  if ( status && traceDebug() )
153  {
155  << " DEBUG: J2K SIZ RECORD:\n"
156  << m_sizRecord
157  << "\n";
158  }
159  }
160  else if ( traceDebug() )
161  {
163  << "Cannot open: " << theImageFile.c_str() << "\n";
164  }
165 
166  }
167 
168  if ( !status )
169  {
170  m_str->close();
171  delete m_str;
172  m_str = 0;
173  }
174 
175  if (traceDebug())
176  {
178  << MODULE << " exit status " << (status?"true\n":"false\n");
179  }
180  return status;
181 }
182 
184 {
185  destroy();
187 }
188 
190  const ossimIrect& rect, ossim_uint32 resLevel)
191 {
192  ossimRefPtr<ossimImageData> result = 0;
193 
194  if( isSourceEnabled() && isOpen() && isValidRLevel(resLevel) )
195  {
196  if ( m_tile.valid() == false )
197  {
198  allocate(); // First time though.
199  }
200 
201  // Rectangle must be set prior to getOverviewTile call.
202  m_tile->setImageRectangle(rect);
203 
204  // tmp drb...
205  m_tile->makeBlank();
206 
207  if ( getOverviewTile( resLevel, m_tile.get() ) )
208  {
209  result = m_tile.get();
210  }
211  }
212 
213  return result;
214 }
215 
217  ossimImageData* result)
218 {
219  bool status = false;
220 
221  if ( result )
222  {
223  if (resLevel <= m_minDwtLevels)
224  {
225  // Using internal overviews.
226 
227  //---
228  // NOTE:
229  //
230  // The geojp2 doqq's that I have all have an offset in them. In
231  // other words the "pos" from "get_dims" is not always 0,0. I
232  // think this was intended for mosaicing without any projection. I
233  // do NOT think it was intended to be used as a sub image offset
234  // into the projection picked up by the geotiff_box. If this were
235  // so the current code here would not mosaic correctly.
236  //
237  // This may not be the case though with all data sets... In which
238  // case some kind of logic would have to be added to this code.
239 
240  ossimIrect tileRect = result->getImageRectangle();
241  ossimIrect imageRect = getImageRectangle( resLevel );
242  ossimIrect clipRect = tileRect.clipToRect(imageRect);
243 
246 
247  // tmp drb...
248  // ossimIrect rect(0,0,255,255);
249 
250  ossimIrect shiftedRect = clipRect + offset;
251  if ( traceDebug() )
252  {
254  << "ossimOpjJp2Reader::getOverviewTile DEBUG:"
255  << "\ntile rect: " << tileRect
256  << "\nimageRect: " << imageRect
257  << "\nclipRect: " << clipRect
258  << "\nshiftedRect: " << shiftedRect
259  << "\noffset: " << offset
260  << "\nresLevel: " << resLevel
261  << std::endl;
262  }
263 
264  m_cacheTile->setImageRectangle( clipRect );
265 
266  try
267  {
269  shiftedRect,
270  resLevel,
271  m_format,
272  0,
273  m_cacheTile.get() );
274 
275  if ( status )
276  {
277 
278  result->loadTile(m_cacheTile->getBuf(), clipRect, OSSIM_BSQ);
279  result->validate();
280  }
281  }
282  catch( const ossimException& e )
283  {
285  << __FILE__ << " " << __LINE__ << " caught exception\n"
286  << e.what() << "\n File:" << this->theImageFile << "\n";
287  status = false;
288  }
289  catch( ... )
290  {
292  << __FILE__ << " " << __LINE__ << " caught unknown exception\n";
293  }
294 
295  // result->setImageRectangle(originalTileRect);
296 
297  try
298  {
299 #if 0
300  if ( theChannels )
301  {
302  status = ossim::copyRegionToTile(theChannels,
303  theCodestream,
304  static_cast<int>(resLevel),
305  theThreadEnv,
306  theOpenTileThreadQueue,
307  result);
308  }
309  else
310  {
311  status = ossim::copyRegionToTile(theCodestream,
312  static_cast<int>(resLevel),
313  theThreadEnv,
314  theOpenTileThreadQueue,
315  result);
316  }
317 #endif
318  }
319  catch(const ossimException& e)
320  {
322  << __FILE__ << " " << __LINE__ << " caught exception\n"
323  << e.what();
324  status = false;
325  }
326 
327  // Set the rect back.
328  // result->setImageRectangle(originalTileRect);
329 
330  } // matches: if (resLevel <= theMinDwtLevels)
331  else
332  {
333  // Using external overview.
334  status = theOverview->getTile(result, resLevel);
335  }
336  }
337 
338  return status;
339 }
340 
343 {
344  return ossimIrect(0,
345  0,
346  getNumberOfSamples(reduced_res_level) - 1,
347  getNumberOfLines(reduced_res_level) - 1);
348 }
349 
351  const char* prefix) const
352 {
353  return ossimImageHandler::saveState(kwl, prefix);
354 }
355 
357  const char* prefix)
358 {
359  if (ossimImageHandler::loadState(kwl, prefix))
360  {
361  return open();
362  }
363 
364  return false;
365 }
366 
368 {
369  ossim_uint32 result = 1; // Add r0
370 
371  if (m_minDwtLevels)
372  {
373  //---
374  // Add internal overviews.
375  //---
376  result += m_minDwtLevels;
377  }
378 
379  if (theOverview.valid())
380  {
381  //---
382  // Add external overviews.
383  //---
385  }
386 
387  return result;
388 }
389 
391 {
392  ossim_uint32 result = 0;
393  if ( isValidRLevel(resLevel) )
394  {
395  if (resLevel <= m_minDwtLevels)
396  {
398  if ( resLevel )
399  {
400  ossim_float32 x = 2.0;
401  ossim_float32 y = resLevel;
402  result = (ossim_uint32) result / std::pow(x, y);
403  }
404  }
405  else if (theOverview.valid())
406  {
407  result = theOverview->getNumberOfLines(resLevel);
408  }
409  }
410  return result;
411 }
412 
414 {
415  ossim_uint32 result = 0;
416  if ( isValidRLevel(resLevel) )
417  {
418  if (resLevel <= m_minDwtLevels)
419  {
421  if ( resLevel )
422  {
423  ossim_float32 x = 2.0;
424  ossim_float32 y = resLevel;
425  result = (ossim_uint32) result / std::pow(x, y);
426  }
427  }
428  else if (theOverview.valid())
429  {
430  result = theOverview->getNumberOfLines(resLevel);
431  }
432  }
433  return result;
434 }
435 
436 //---
437 // Use the internal j2k tile size if it's not the same as the image(one BIG tile).
438 //---
440 {
441  ossim_uint32 result = 0;
443  {
445  }
446  return result;
447 }
448 
450 {
451  ossim_uint32 result = 0;
453  {
455  }
456  return result;
457 }
458 
460 {
461  return ossimString("ossim_openjpeg_reader");
462 }
463 
465 {
466  return ossimString("ossim open jpeg reader");
467 }
468 
470 {
471  return ossimString("ossimOpjJp2Reader");
472 }
473 
475 {
476  return m_sizRecord.m_Csiz;
477 }
478 
480 {
481  return m_sizRecord.m_Csiz;
482 }
483 
485 {
486  return m_sizRecord.getScalarType();
487 }
488 
490 {
491  return m_str ? m_str->is_open() : false;
492 }
493 
495 {
496 
497  if (m_tile.valid())
498  {
499  return m_tile->getMaxPix(band);
500  }
501  return 255.0;
502 }
503 
505  ossimJ2kSizRecord& sizRecord ) const
506 {
507  bool result = false;
508 
509  if ( str )
510  {
511  if ( str->good() )
512  {
513  // Looking for SOC, SIZ markers: 0xff, 0x4f, 0xff, 0x51
514  const ossim_uint8 AFF = 0xff;
515  const ossim_uint8 A4F = 0x4f;
516  const ossim_uint8 A51 = 0x51;
517 
518  union
519  {
520  char c;
521  ossim_uint8 uc;
522  } ct;
523 
524  // Read in the box.
525  while ( str->get( ct.c ) )
526  {
527  if ( ct.uc == AFF ) // Found FF byte.
528  {
529  if ( str->get( ct.c ) )
530  {
531  if ( ct.uc == A4F ) // Found 4F byte.
532  {
533  if ( str->get( ct.c ) )
534  {
535  if ( ct.uc == AFF ) // Found FF byte.
536  {
537  if ( str->get( ct.c ) )
538  {
539  if ( ct.uc == A51 ) // Found 51 byte.
540  {
541  sizRecord.parseStream( *str );
542  result = true;
543  break;
544  }
545  }
546  }
547  }
548  }
549  }
550  }
551  }
552  }
553  }
554 
555  return result;
556 }
557 
559  ossimJ2kCodRecord& codRecord ) const
560 {
561  bool result = false;
562 
563  if ( str )
564  {
565  if ( str->good() )
566  {
567  // Looking for COD marker: 0xff, 0x51
568  const ossim_uint8 AFF = 0xff;
569  const ossim_uint8 A52 = 0x52;
570 
571  union
572  {
573  char c;
574  ossim_uint8 uc;
575  } ct;
576 
577  // Read in the box.
578  while ( str->get( ct.c ) )
579  {
580  if ( ct.uc == AFF ) // Found FF byte.
581  {
582  if ( str->get( ct.c ) )
583  {
584  if ( ct.uc == A52 ) // Found 52 byte.
585  {
586  codRecord.parseStream( *str );
587  result = true;
588  break;
589  }
590  }
591  }
592  }
593  }
594  }
595 
596  return result;
597 }
598 
600 {
601  if ( !theGeometry )
602  {
603  //---
604  // Check for external geom - this is a file.geom not to be confused with
605  // geometries picked up from dot.xml, dot.prj, dot.j2w and so on. We
606  // will check for that later if the getInternalImageGeometry fails.
607  //---
609 
610  if ( !theGeometry )
611  {
612  //---
613  // Check for external files other than .geom, i.e. file.xml & j2w:
614  //---
616 
617  if ( !theGeometry )
618  {
619  // Check the internal geometry first to avoid a factory call.
621 
622  //---
623  // WARNING:
624  // Must create/set the geometry at this point or the next call to
625  // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop
626  // as it does a recursive call back to ossimImageHandler::getImageGeometry().
627  //---
628  if ( !theGeometry )
629  {
631  }
632 
633  // Check for set projection.
634  if ( !theGeometry->getProjection() )
635  {
636  // Last try factories for projection.
638  }
639  }
640  }
641 
642  // Set image things the geometry object should know about.
644  }
645  return theGeometry;
646 }
647 
649 {
650  static const char MODULE[] = "ossimOpjJp2Reader::getInternalImageGeometry";
651 
652  if (traceDebug())
653  {
654  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
655  }
656 
658 
659  if ( isOpen() )
660  {
661  std::streamoff pos = m_str->tellg();
662 
663  m_str->seekg(0, std::ios_base::beg );
664 
665  // Straight up J2k has no boxes.
666  if ( ossim::getCodecFormat( m_str ) == OPJ_CODEC_JP2 )
667  {
668  m_str->seekg(4, std::ios_base::beg );
669 
670  // Try to get geom from GML box:
672 
673  if ( geom.valid() == false )
674  {
675  // Try to get geom from geotiff box:
677  }
678  }
679 
680  // Seek back to original position.
681  m_str->seekg(pos, std::ios_base::beg );
682  }
683 
684  return geom;
685 
686 } // End: ossimOpjJp2Reader::getInternalImageGeometry()
687 
689 {
690  static const char MODULE[] = "ossimOpjJp2Reader::getImageGeometryFromGeotiffBox";
691 
692  if (traceDebug())
693  {
694  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
695  }
697 
698  if ( isOpen() )
699  {
700  std::streamoff pos = m_str->tellg();
701 
702  m_str->seekg(0, std::ios_base::beg );
703 
704  std::vector<ossim_uint8> box;
705  ossimJp2Info jp2Info;
706 
707  std::streamoff boxPos = jp2Info.getGeotiffBox( *m_str, box );
708 
709  // Seek back to original position.
710  m_str->seekg(pos, std::ios_base::beg );
711 
712  if ( boxPos && box.size() )
713  {
714  if (traceDebug())
715  {
717  << "Found geotiff uuid at: " << boxPos+8 << "\n";
718  }
719 
720  //---
721  // Create a string stream and set the vector buffer as its source.
722  // Note: The box has the 16 GEOTIFF_UUID bytes in there so offset
723  // address and size.
724  //---
725 #if 0
726  // This doesn't work with VS2010...
727  // Create a string stream and set the vector buffer as its source.
728  std::istringstream boxStream;
729  boxStream.rdbuf()->pubsetbuf( (char*)&box.front()+GEOTIFF_UUID_SIZE,
730  box.size()-GEOTIFF_UUID_SIZE );
731 #else
732  // convert the vector into a string
733  std::string boxString( box.begin()+GEOTIFF_UUID_SIZE, box.end() );
734  std::istringstream boxStream;
735  boxStream.str( boxString );
736 #endif
737 
738 
739  // Give the stream to tiff info to create a geometry.
740  ossimTiffInfo info;
741  ossim_uint32 entry = 0;
742  ossimKeywordlist kwl; // Used to capture geometry data.
743 
744  if ( info.getImageGeometry(boxStream, kwl, entry) )
745  {
746  //---
747  // The tiff embedded in the geojp2 only has one line
748  // and one sample by design so overwrite the lines and
749  // samples with the real value.
750  //---
751  ossimString pfx = "image";
752  pfx += ossimString::toString(entry);
753  pfx += ".";
754 
755  // Add the lines.
757  getNumberOfLines(0), true);
758 
759  // Add the samples.
761  getNumberOfSamples(0), true);
762 
763  // Create the projection.
766  if ( proj.valid() )
767  {
768  // Create and assign projection to our ossimImageGeometry object.
769  geom = new ossimImageGeometry();
770  geom->setProjection( proj.get() );
771  if (traceDebug())
772  {
773  ossimNotify(ossimNotifyLevel_DEBUG) << "Found GeoTIFF box." << std::endl;
774  }
775 
776  // Get the internal raster pixel alignment type and set the base class.
777  const char* lookup = kwl.find(pfx.chars(), ossimKeywordNames::PIXEL_TYPE_KW);
778  if ( lookup )
779  {
780  ossimString type = lookup;
781  type.downcase();
782  if ( type == "pixel_is_area" )
783  {
785  }
786  else if ( type == "pixel_is_point" )
787  {
789  }
790  }
791  }
792  }
793  }
794  else // Did not find box in file.
795  {
796  m_str->clear();
797  }
798  }
799  return geom;
800 
801 } // End: ossimOpjJp2Reader::getImageGeometryFromGeotiffBox
802 
803 
805 {
806  static const char MODULE[] = "ossimOpjJp2Reader::getImageGeometryFromGmlBox";
807 
808  if (traceDebug())
809  {
810  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
811  }
813 
814  if ( isOpen() )
815  {
816  std::streamoff pos = m_str->tellg();
817 
818  m_str->seekg(0, std::ios_base::beg );
819 
820  std::vector<ossim_uint8> box;
821  ossimJp2Info jp2Info;
822 
823  std::streamoff boxPos = jp2Info.getGmlBox( *m_str, box );
824 
825  // Seek back to original position.
826  m_str->seekg(pos, std::ios_base::beg );
827 
828  if ( boxPos && box.size() )
829  {
830  if (traceDebug())
831  {
833  << "Found gml box at: " << boxPos+8
834  << "\nbox size: " << box.size() << "\n";
835  }
836 
837 #if 0
838  // This doesn't work with VS2010...
839  // Create a string stream and set the vector buffer as its source.
840  std::istringstream boxStream;
841  boxStream.rdbuf()->pubsetbuf( (char*)&box.front(), box.size() );
842 #else
843  // convert the vector into a string
844  std::string boxString( box.begin(), box.end() );
845  std::istringstream boxStream;
846  boxStream.str( boxString );
847 #endif
848 
850 
851  if ( gml->initialize( boxStream ) )
852  {
853  // Tmp drb
854  //cout << *(gml->getXmlDoc().get()) << endl;
855 
856  ossimKeywordlist geomKwl;
857  if ( gml->getImageGeometry( geomKwl ) )
858  {
859  // Make projection:
860  // Create the projection.
863  if ( proj.valid() )
864  {
865  // Create and assign projection to our ossimImageGeometry object.
866  geom = new ossimImageGeometry();
867  geom->setProjection( proj.get() );
868  if (traceDebug())
869  {
870  ossimNotify(ossimNotifyLevel_DEBUG) << "Found GMLJP2 box." << std::endl;
871  }
872  }
873  }
874  }
875 
876  // Cleanup:
877  delete gml;
878  gml = 0;
879  }
880  else // Did not find box in file.
881  {
882  m_str->clear();
883  }
884  }
885  return geom;
886 
887 } // End: ossimOpjJp2Reader::getImageGeometryFromGmlBox
888 
890 {
891  static const char M[] = "ossimOpjJp2Reader::getMetadataImageGeometry";
892  if ( traceDebug() )
893  {
894  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
895  }
896 
899 
900  // See if we can pick up the projection from the FGDC file:
901  ossimFilename fdgcFile = theImageFile;
902 
903  fdgcFile += ".xml"; // file.jp2.xml
904  if ( fdgcFile.exists() == false )
905  {
906  fdgcFile = theImageFile;
907  fdgcFile.setExtension(ossimString("xml")); // file.xml
908  }
909 
910  if ( fdgcFile.exists() )
911  {
912  ossimFgdcXmlDoc fgdcDoc;
913  if ( fgdcDoc.open(fdgcFile) )
914  {
915  try
916  {
917  proj = fgdcDoc.getGridCoordSysProjection();
918  }
919  catch (const ossimException& e)
920  {
921  ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
922  }
923 
924  if ( proj.valid() )
925  {
926  geom = new ossimImageGeometry();
927 
928  ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(proj.get());
929  if ( mapProj )
930  {
931  // See if we have a world file. Seems they have a more accurate tie point.
932  ossimFilename worldFile = theImageFile;
933  worldFile.setExtension(ossimString("j2w")); // file.j2w
934  if ( worldFile.exists() )
935  {
936  //---
937  // Note need a way to determine pixel type from fgdc doc.
938  // This can result in a half pixel shift.
939  //---
941  ossimUnitType unitType = fgdcDoc.getUnitType();
942 
943  ossimTiffWorld tfw;
944  if ( tfw.open(worldFile, pixelType, unitType) )
945  {
946  ossimDpt gsd = tfw.getScale();
947  gsd.y = std::fabs(gsd.y); // y positive up so negate.
948  ossimDpt tie = tfw.getTranslation();
949 
950  if ( unitType != OSSIM_METERS )
951  {
953 
954  // GSD (scale):
955  uct.setValue(gsd.x, unitType);
956  gsd.x = uct.getValue(OSSIM_METERS);
957  uct.setValue(gsd.y, unitType);
958  gsd.y = uct.getValue(OSSIM_METERS);
959 
960  // Tie point:
961  uct.setValue(tie.x, unitType);
962  tie.x = uct.getValue(OSSIM_METERS);
963  uct.setValue(tie.y, unitType);
964  tie.y = uct.getValue(OSSIM_METERS);
965  }
966 
967  mapProj->setMetersPerPixel(gsd);
968  mapProj->setUlTiePoints(tie);
969  }
970 
971  if ( tfw.getRotation() != 0.0 )
972  {
974  << M << " Unhandled rotation in tfw file." << std::endl;
975  }
976  }
977 
978  } // if ( worldFile.exists() )
979 
980  geom->setProjection( proj.get() );
981 
982  } // if ( proj.valid() )
983 
984  } // if ( fgdcDoc.open(fdgcFile) )
985 
986  } // if ( fdgcFile.exists() )
987 
988  if (traceDebug())
989  {
991  << M << " exit status = " << (geom.valid()?"true":"false\n")
992  << std::endl;
993  }
994 
995  return geom;
996 }
997 
999 {
1001  m_tile->initialize();
1004 
1005  if (traceDebug())
1006  {
1008  << "ossimOpjJp2Reader::allocate DEBUG:"
1009  << "\nm_tile:\n" << *(m_tile.get())
1010  << endl;
1011  }
1012 }
ossim_uint32 x
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
bool open(const ossimFilename &file, ossimPixelType ptype, ossimUnitType unit)
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
virtual const ossim_float64 * getMaxPix() const
ossim_uint32 m_XTOsiz
Horizontal offset from the orgin of reference grid to the left edge of first tile.
double getValue(ossimUnitType unitType=OSSIM_METERS) const
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
void allocate()
Initializes tiles.
ossim_uint32 m_YTOsiz
Vertical offset from the orgin of reference grid to the top edge of first tile.
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
virtual ossimRefPtr< ossimImageGeometry > getImageGeometryFromGeotiffBox()
ossim_uint32 m_Xsiz
width of reference grid
ossimUnitType
Represents serializable keyword/value map.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
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
const char * find(const char *key) const
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
float ossim_float32
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 ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)
virtual ossimString getLongName() const
double y
Definition: ossimDpt.h:165
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &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 double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
void parseStream(std::istream &in)
Parse method.
bool getImageGeometry(ossimKeywordlist &geomKwl, ossim_uint32 entryIndex) const
Extracts geometry info to keyword list.
ossimRefPtr< ossimProjection > getGridCoordSysProjection()
Gets projection from Grid Coordinate system node.
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_LINES_KW
virtual void close()
close method
virtual ossimString getShortName() const
TIFF info class.
Definition: ossimTiffInfo.h:36
unsigned short ossim_uint16
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void initialize()
Initialize the data buffer.
ossimRefPtr< ossimImageData > m_tile
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...
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossimPixelType thePixelType
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.
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of decimation levels.
ossim_uint32 m_YTsiz
height of one reference tile
GML support data class.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
bool getImageGeometry(ossimKeywordlist &geomKwl) const
Extracts geometry info to keyword list.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
ossim_uint16 m_Csiz
number of component in the image
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
static ossimImageDataFactory * instance()
virtual ossimString getClassName() const
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
bool initSizRecord(std::istream *str, ossimJ2kSizRecord &sizRecord) const
virtual ~ossimOpjJp2Reader()
virtual destructor
ossim_uint32 m_XOsiz
Horizontal offset from the orgin of reference grid to the left side of image.
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry()
virtual ossimDataObjectStatus validate() const
bool exists() const
virtual const char * what() const
Returns the error message.
bool initCodRecord(std::istream *str, ossimJ2kCodRecord &sizRecord) const
std::string::size_type size() const
Definition: ossimString.h:405
ossim_uint32 m_minDwtLevels
JP2 info class.
Definition: ossimJp2Info.h:21
ossim_uint32 m_XTsiz
width of one reference tile
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
Class for FGDC XML doc parsing.
ossim_uint8 m_numberOfDecompositionLevels
SPcod - Number of decomposition levels.
virtual ossimIrect getImageRectangle() const
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.
virtual void close()
Deletes the overview and clears the valid image vertices.
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
bool initialize(const ossimImageGeometry *geom, const ossimIrect &rect)
Initializes gml block from geometry file.
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
bool opj_decode(std::ifstream *in, const ossimIrect &rect, ossim_uint32 resLevel, ossim_int32 format, std::streamoff fileOffset, ossimImageData *tile)
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimScalarType
static ossimProjectionFactoryRegistry * instance()
ossimRefPtr< ossimImageData > m_cacheTile
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
return status
virtual void makeBlank()
Initializes data to null pixel values.
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossimPixelType
ossimRefPtr< ossimImageHandler > theOverview
bool copyRegionToTile(kdu_supp::kdu_channel_mapping *channelMapping, kdu_core::kdu_codestream &codestream, int discard_levels, kdu_core::kdu_thread_env *threadEnv, kdu_core::kdu_thread_queue *threadQueue, ossimImageData *destTile)
Copies region from codestream to tile at a given rlevel.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
const ossimDpt & getScale() const
Converts world file parameters into x, y scale (for use in affine transform)
virtual bool open()
open method.
virtual const void * getBuf() const
static const char * PIXEL_TYPE_KW
ossimJ2kSizRecord m_sizRecord
double x
Definition: ossimDpt.h:164
const ossimDpt & getTranslation() const
Provides access to the translation (for use in affine transform)
ossimOpjJp2Reader()
default constructor
virtual bool isOpen() const
Derived classes must implement this method to be concrete.
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
virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level=0) const
Returns the number of lines in the image.
virtual void setUlTiePoints(const ossimGpt &gpt)
bool open(const ossimFilename &xmlFileName)
Open method.
double getRotation() const
Converts world file parameters into RH rotation in radians (for use in affine transform) ...
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
ossimRefPtr< ossimImageGeometry > getMetadataImageGeometry() const
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Gets an overview tile.
ossim_int32 getCodecFormat(std::istream *str)
Gets codec format from magic number.
std::streamoff getGmlBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GML Box.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
ossimUnitType getUnitType() const
std::streamoff getGeotiffBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GeoTIFF box.
std::ifstream * m_str
static const char * NUMBER_SAMPLES_KW
unsigned char ossim_uint8
ossimScalarType getScalarType() const
Gets the scalar type.
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 getNumberOfSamples(ossim_uint32 reduced_res_level=0) const
Returns the number of samples in the image.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometryFromGmlBox()
ossim_uint32 m_YOsiz
Vertical offset from the orgin of reference grid to the top of image.
ossim_uint32 m_Ysiz
height of reference grid
int ossim_int32
const std::string & string() const
Definition: ossimString.h:414
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
void parseStream(ossim::istream &in)
Parse method.