OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimMrSidReader.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 // Description: Class definition for MRSID reader.
8 //
9 //----------------------------------------------------------------------------
10 // $Id: ossimMrSidReader.cpp 2645 2011-05-26 15:21:34Z oscar.kramer $
11 
12 
13 #include "ossimMrSidReader.h"
14 
15 //ossim includes
16 #include <ossim/base/ossimCommon.h>
17 #include <ossim/base/ossimDpt.h>
18 #include <ossim/base/ossimEndian.h>
22 #include <ossim/base/ossimNotify.h>
24 #include <ossim/base/ossimTrace.h>
26 
29 
34 
38 
39 //LizardTech Includes
40 #include <lt_base.h>
41 #include <lt_fileSpec.h>
42 #include <lt_ioFileStream.h>
43 #include <lti_imageReader.h>
44 #include <lti_pixel.h>
45 #include <lti_scene.h>
46 #include <lti_sceneBuffer.h>
47 #include <lt_fileSpec.h>
48 #include <lti_geoCoord.h>
49 #include <lt_ioFileStream.h>
50 #include <lti_pixelLookupTable.h>
51 #include <lti_utils.h>
52 #include <lti_metadataDatabase.h>
53 #include <lti_metadataRecord.h>
54 
55 // System:
56 #include <fstream>
57 #include <iostream>
58 #include <string>
59 
60 #ifdef OSSIM_ID_ENABLED
61 static const char OSSIM_ID[] = "$Id";
62 #endif
63 
64 static ossimTrace traceDebug("ossimMrSidReader:debug");
65 static ossimTrace traceDump("ossimMrSidReader:dump");
66 //static ossimOgcWktTranslator wktTranslator;
67 
69  "ossimMrSidReader",
71 
74  theReader(0),
75  theImageNavigator(0),
76  theMinDwtLevels(0),
77  theImageRect(),
78  theMrSidDims(),
79  theNumberOfBands(0),
80  theScalarType(OSSIM_SCALAR_UNKNOWN),
81  theTile(0)
82 {
83 }
84 
86 {
87  closeEntry();
88 
89  // Note: Not a ref ptr. This is a MrSIDImageReader*.
90  if ( theReader )
91  {
92  theReader->release();
93  theReader = 0;
94  }
95  if (theImageNavigator != 0)
96  {
97  delete theImageNavigator;
99  }
100 }
101 
103 {
104  return ossimString("ossim_mrsid_reader");
105 }
106 
108 {
109  return ossimString("ossim mrsid reader");
110 }
111 
113 {
114  return ossimString("ossimMrSidReader");
115 }
116 
118  ossimDpt& result) const
119 {
120  if (theGeometry.valid())
121  {
122  theGeometry->decimationFactor(resLevel, result);
123  }
124  else
125  {
126  result.makeNan();
127  }
128 }
129 
131  vector<ossimDpt>& decimations) const
132 {
133  if (theGeometry.valid())
134  {
136  {
137  theGeometry->decimationFactors(decimations);
138  }
139  else
140  {
141  // First time called...
142  if ( computeDecimationFactors(decimations) )
143  {
144  theGeometry->setDiscreteDecimation(decimations);
145  }
146  else
147  {
148  decimations.clear();
149  }
150  }
151  }
152  else
153  {
154  if ( !computeDecimationFactors(decimations) )
155  {
156  decimations.clear();
157  }
158  }
159 }
160 
162 {
163  ossim_uint32 result = 1; // Add r0
164 
165  if (theMinDwtLevels)
166  {
167  //---
168  // Add internal overviews.
169  //---
170  result += theMinDwtLevels;
171  }
172 
173  if (theOverview.valid())
174  {
175  //---
176  // Add external overviews.
177  //---
179  }
180 
181  return result;
182 }
183 
185  ossim_uint32 resLevel) const
186 {
187  ossim_uint32 result = 0;
188  if ( isValidRLevel(resLevel) )
189  {
190  if (resLevel <= theMinDwtLevels)
191  {
192  if (theMrSidDims.size() > 0)
193  {
194  result = theMrSidDims[resLevel].height();
195  }
196  }
197  else if (theOverview.valid())
198  {
199  result = theOverview->getNumberOfSamples(resLevel);
200  }
201  }
202  return result;
203 }
204 
206  ossim_uint32 resLevel) const
207 {
208  ossim_uint32 result = 0;
209  if ( isValidRLevel(resLevel) )
210  {
211  if (resLevel <= theMinDwtLevels)
212  {
213  if (theMrSidDims.size() > 0)
214  {
215  result = theMrSidDims[resLevel].width();
216  }
217  }
218  else if (theOverview.valid())
219  {
220  result = theOverview->getNumberOfSamples(resLevel);
221  }
222  }
223  return result;
224 }
225 
227 {
228  static const char MODULE[] = "ossimMrSidReader::open";
229 
230  if (traceDebug())
231  {
233  << MODULE << " entered...\n"
234  << "image: " << theImageFile << "\n";
235  }
236 
237  bool result = false;
238 
239  if(isOpen())
240  {
241  closeEntry();
242  }
243 
244  ossimString ext = theImageFile.ext();
245  ext.downcase();
246  if ( ext != "sid" )
247  {
248  return false;
249  }
250 
251  LT_STATUS sts = LT_STS_Uninit;
252 
253  const LTFileSpec fileSpec(theImageFile.c_str());
254 
255  theReader = MrSIDImageReader::create();
256  sts = theReader->initialize(fileSpec, true);
257  if (LT_SUCCESS(sts) == false)
258  {
259  return false;
260  }
261 
262  theImageNavigator = new LTINavigator(*theReader);
263 
264  theImageRect = ossimIrect(0, 0, theReader->getWidth()-1, theReader->getHeight()-1);
265  theNumberOfBands = theReader->getNumBands();
266  theMinDwtLevels = theReader->getNumLevels();
267 
268  getDataType();
269 
271  {
273  {
274  ossim_uint32 width = theReader->getWidth();
275  ossim_uint32 height = theReader->getHeight();
276 
277  // Check for zero width, height.
278  if ( !width || !height )
279  {
280  ossimIpt tileSize;
281  ossim::defaultTileSize(tileSize);
282 
283  width = tileSize.x;
284  height = tileSize.y;
285  }
286 
288 
289  theTile->initialize();
290 
291  // Call the base complete open to pick up overviews.
292  computeMinMax();
293  completeOpen();
294 
295  result = true;
296  }
297  }
298 
299  if (result == false)
300  {
301  closeEntry();
302  }
303 
304  if (traceDebug())
305  {
307  << MODULE << " exit status = " << (result?"true":"false\n")
308  << std::endl;
309  }
310 
311  return result;
312 }
313 
315 {
316  return theTile.get();
317 }
318 
320 {
321  theTile = 0;
322 
324 }
325 
327  const ossimIrect& rect, ossim_uint32 resLevel)
328 {
329  LT_STATUS sts = LT_STS_Uninit;
330 
331  // This tile source bypassed, or invalid res level, return null tile.
332  if(!isSourceEnabled() || !isOpen() || !isValidRLevel(resLevel))
333  {
335  }
336 
337  ossimIrect imageBound = getBoundingRect(resLevel);
338  if(!rect.intersects(imageBound))
339  {
341  }
342 
343  // Check for overview.
344  if( resLevel > theMinDwtLevels )
345  {
346  if(theOverview.valid())
347  {
348  ossimRefPtr<ossimImageData> tileData = theOverview->getTile(rect, resLevel);
349  tileData->setScalarType(getOutputScalarType());
350  return tileData;
351  }
352  }
353 
354  theTile->setImageRectangle(rect);
355 
356  // Compute clip rectangle with respect to the image bounds.
357  ossimIrect clipRect = rect.clipToRect(imageBound);
358 
359  if (rect.completely_within(clipRect) == false)
360  {
361  // Not filling whole tile so blank it out first.
362  theTile->makeBlank();
363  }
364 
365  lt_uint16 anOssimBandIndex = 0;
366 
367  LTIPixel pixel(theReader->getColorSpace(), theNumberOfBands, theReader->getDataType());
368  LTISceneBuffer sceneBuffer(pixel, clipRect.width(), clipRect.height(), NULL);
369 
370  if (!theGeometry.valid())
371  {
373  }
374  double mag = theGeometry->decimationFactor(resLevel).lat;
375  sts = theImageNavigator->setSceneAsULWH(clipRect.ul().x,
376  clipRect.ul().y,
377  clipRect.lr().x - clipRect.ul().x + 1,
378  clipRect.lr().y - clipRect.ul().y + 1, mag);
379 
380  LTIScene scene = theImageNavigator->getScene();
381  sts = theReader->read(scene, sceneBuffer);
382 
383  if (LT_SUCCESS(sts) == true)
384  {
385  if(clipRect == rect)
386  {
387  void *buf = theTile->getBuf();
388  sceneBuffer.exportDataBSQ(buf);
389  }
390  else
391  {
392  for(anOssimBandIndex = 0; anOssimBandIndex < theNumberOfBands; anOssimBandIndex++)
393  {
394  theTile->loadBand(sceneBuffer.getBandData(anOssimBandIndex),//sceneBuffer.getTotalBandData(anOssimBandIndex),
395  clipRect, anOssimBandIndex);
396  }
397  }
398  }
399 
400  theTile->validate();
401  return theTile;
402 }
403 
405 {
406  return theNumberOfBands;
407 }
408 
410 {
411  return theNumberOfBands;
412 }
413 
415 {
416  ossim_uint32 result = 0;
417  if ( theMrSidDims.size() )
418  {
419  if ( theMrSidDims[0].width() != theImageRect.width() )
420  {
421  // Not a single tile.
422  result = theMrSidDims[0].width();
423  }
424  }
425  return result;
426 }
427 
429 {
430  ossim_uint32 result = 0;
431  if ( theMrSidDims.size() )
432  {
433  if ( theMrSidDims[0].height() != theImageRect.height() )
434  {
435  // Not a single tile.
436  result = theMrSidDims[0].height();
437  }
438  }
439  return result;
440 }
441 
443 {
444  return theScalarType;
445 }
446 
448 {
449  if ( !theGeometry )
450  {
451  //---
452  // Check for external geom:
453  //---
455 
456  if ( !theGeometry )
457  {
458  //---
459  // Check the internal geometry first to avoid a factory call.
460  //---
462 
463  // At this point it is assured theGeometry is set.
464 
465  // Check for set projection.
466  if ( !theGeometry->getProjection() )
467  {
468  // Try factories for projection.
470  }
471  }
472 
473  // Set image things the geometry object should know about.
475  }
476 
477  return theGeometry;
478 }
479 
481 {
482  // Check for external .geom file:
484  if ( geom.valid() == false )
485  {
486  // Check for .aux.xml file:
487  ossimFilename auxXmlFile = theImageFile;
488  auxXmlFile += ".aux.xml";
489  if ( auxXmlFile.exists() )
490  {
492  ossimRefPtr<ossimProjection> proj = sd.getProjection( auxXmlFile );
493  if ( proj.valid() )
494  {
495  geom = new ossimImageGeometry();
496  geom->setProjection( proj.get() );
497  }
498  }
499  }
500  return geom;
501 }
502 
504 {
505  static const char MODULE[] = "ossimMrSidReader::getInternalImageGeometry";
506  if (traceDebug())
507  {
508  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
509  }
510 
512 
513  // Must cast away constness.
514  ossimMrSidReader* th = const_cast<ossimMrSidReader*>(this);
516 
517  geom->setProjection(proj.get());
518 
519  return geom;
520 }
521 
523  std::vector<ossimDpt>& decimations) const
524 {
525  bool result = true;
526 
527  decimations.clear();
528 
529  const ossim_uint32 LEVELS = getNumberOfDecimationLevels();
530 
531  for (ossim_uint32 level = 0; level < LEVELS; ++level)
532  {
533  ossimDpt pt;
534 
535  if (level == 0)
536  {
537  // Assuming r0 is full res for now.
538  pt.x = 1.0;
539  pt.y = 1.0;
540  }
541  else
542  {
543  // Get the sample decimation.
545  ossim_float64 rL = getNumberOfSamples(level);
546  if ( (r0 > 0.0) && (rL > 0.0) )
547  {
548  pt.x = rL / r0;
549  }
550  else
551  {
552  result = false;
553  break;
554  }
555 
556  // Get the line decimation.
557  r0 = getNumberOfLines(0);
558  rL = getNumberOfLines(level);
559  if ( (r0 > 0.0) && (rL > 0.0) )
560  {
561  pt.y = rL / r0;
562  }
563  else
564  {
565  result = false;
566  break;
567  }
568  }
569 
570  decimations.push_back(pt);
571  }
572 
573  if (traceDebug())
574  {
576  << "ossimMrSidReader::computeDecimationFactors DEBUG\n";
577  for (ossim_uint32 i = 0; i < decimations.size(); ++i)
578  {
580  << "decimation[" << i << "]: " << decimations[i]
581  << std::endl;
582  }
583  }
584 
585  return result;
586 }
587 
588 bool ossimMrSidReader::getImageDimensions(std::vector<ossimIrect>& tileDims) const
589 {
590  bool result = true;
591 
592  tileDims.clear();
593 
594  if (theReader != 0)
595  {
596  ossim_uint32 levels = theReader->getNumLevels();
597 
598  for (ossim_uint32 level=0; level <= levels; ++level)
599  {
600  lt_uint32 width = 0;
601  lt_uint32 height = 0;
602 
603  double mag = LTIUtils::levelToMag(level);
604  LTIUtils::getDimsAtMag(theImageRect.width(), theImageRect.height(), mag, width, height);
605 
606  // Make the imageRect upper left relative to any sub image offset.
607  ossimIrect imageRect(0, 0, width-1, height-1);
608 
609  tileDims.push_back(imageRect);
610  }
611  }
612  else
613  {
614  result = false;
615  }
616 
617  return result;
618 }
619 
621  const char* prefix)
622 {
623  bool result = false;
624 
625  if ( ossimImageHandler::loadState(kwl, prefix) )
626  {
627  result = open();
628  }
629 
630  return result;
631 }
632 
634 {
635  if (theReader != 0)
636  {
637  LTIDataType pixelType = theReader->getPixelProps().getDataType();
638 
639  LTIPixel pixel = theReader->getPixelProps();
640 
641  switch (pixelType)
642  {
643  case LTI_DATATYPE_UINT8:
644  {
646  break;
647  }
648  case LTI_DATATYPE_SINT8:
649  {
651  break;
652  }
653  case LTI_DATATYPE_UINT16:
654  {
656  break;
657  }
658  case LTI_DATATYPE_SINT16:
659  {
661  break;
662  }
663  case LTI_DATATYPE_UINT32:
664  {
666  break;
667  }
668  case LTI_DATATYPE_SINT32:
669  {
671  break;
672  }
673  case LTI_DATATYPE_FLOAT32:
674  {
676  break;
677  }
678  case LTI_DATATYPE_FLOAT64:
679  {
681  break;
682  }
683  default:
684  {
686  break;
687  }
688  }
689  }
690 }
691 
693 {
694  if (theReader == 0)
695  return 0;
696 
697  // A local KWL will be filled as items are read from the support data. At the end,
698  // the projection factory will be provided with the populated KWL to instantiate proper
699  // map projection. No prefix needed.
700  ossimKeywordlist kwl;
701 
702  // Add the lines and samples.
705 
706  ossimString proj_type;
707  ossimString datum_type;
708  ossimString scale_units = "unknown";
709  ossimString tie_pt_units = "unknown";
710 
711  ossim_uint32 code = 0;
712  ossim_uint32 gcsCode = 0;
713  ossim_uint32 pcsCode = 0;
714 
715  const LTIGeoCoord& geo = theReader->getGeoCoord();
716  LTIMetadataDatabase metaDb = theReader->getMetadata();
717 
718 #if 0 /* Please keep for debug. (drb) */
719  for (ossim_uint32 i = 0; i < metaDb.getIndexCount(); ++i )
720  {
721  const LTIMetadataRecord* rec = 0;
722  metaDb.getDataByIndex(i, rec);
723  cout << "rec.getTagName(): " << rec->getTagName() << endl;
724  }
725  const char* projStr = geo.getWKT();
726  if ( projStr )
727  {
728  std::string wktStr = projStr;
729 
730  cout << "wktStr: " << wktStr << endl;
731  ossimWkt wkt;
732  if ( wkt.open( wktStr ) )
733  {
734  cout << "kwl:\n" << wkt.getKwl() << endl;
735  }
736  }
737 #endif
738 
739  // Can only handle non-rotated images since only projection object returned (no 2d transform):
740  if( (geo.getXRot() != 0.0) || (geo.getYRot() != 0.0))
741  return 0;
742 
743  bool gcsFound = getMetadataElement(
744  metaDb, "GEOTIFF_NUM::2048::GeographicTypeGeoKey", &gcsCode);
745  bool pcsFound = getMetadataElement(
746  metaDb, "GEOTIFF_NUM::3072::ProjectedCSTypeGeoKey", &pcsCode);
747 
748  if (gcsFound && !pcsFound)
749  {
750  code = gcsCode;
751  kwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection");
752  proj_type = "ossimEquDistCylProjection";
754  tie_pt_units = "degrees";
755 
756  // Assign units if set in Metadata
757  char unitStr[200];
758  if (getMetadataElement(metaDb, "GEOTIFF_CHAR::GeogAngularUnitsGeoKey",
759  &unitStr, sizeof(unitStr)) == true)
760  {
761  ossimString unitTag(unitStr);
762  if ( unitTag.contains("Angular_Degree") ) // decimal degrees
763  scale_units = "degrees";
764  else if ( unitTag.contains("Angular_Minute") ) // decimal minutes
765  scale_units = "minutes";
766  else if ( unitTag.contains("Angular_Second") ) // decimal seconds
767  scale_units = "seconds";
768  }
769  }
770  else
771  {
772  if (!pcsFound)
773  {
774  pcsFound = getMetadataElement(metaDb, "GEOTIFF_NUM::3074::ProjectionGeoKey", &code);
775  }
776  else
777  {
778  code = pcsCode;
779  }
780 
781  if (pcsFound)
782  {
784 
785  ossimString unitTag;
786 
787  char unitStr[200];
788  if (getMetadataElement(metaDb, "GEOTIFF_CHAR::ProjLinearUnitsGeoKey", &unitStr,
789  sizeof(unitStr)) == true )
790  {
791  unitTag = unitStr;
792  }
793  else
794  {
795  // Have data with no ProjLinearUnitsGeoKey so try WKT string.
796  const char* wktProjStr = geo.getWKT();
797  if ( wktProjStr )
798  {
799  std::string wktStr = wktProjStr;
800  ossimWkt wkt;
801  if ( wkt.parse( wktStr ) )
802  {
803  unitTag = wkt.getKwl().findKey( std::string("PROJCS.UNIT.name") );
804  }
805  }
806  }
807 
808  if ( unitTag.size() )
809  {
810  unitTag.downcase();
811 
812  if ( unitTag.contains("meter") || unitTag.contains("metre") )
813  {
814  scale_units = "meters";
815  }
816  else if ( unitTag.contains("linear_foot_us_survey") )
817  {
818  scale_units = "us_survey_feet";
819  }
820  else if ( unitTag.contains("linear_foot") )
821  {
822  scale_units = "feet";
823  }
824  tie_pt_units = scale_units;
825  }
826 
827  }
828  else
829  {
830  // Try with WKT:
831  const char* projStr = geo.getWKT();
832  kwl.add(ossimKeywordNames::TYPE_KW, projStr);
833  }
834  }
835 
836  char rasterTypeStr[200];
837  strcpy( rasterTypeStr, "unnamed" );
838  double topLeftX = geo.getX(); // AMBIGUOUS! OLK 5/10
839  double topLeftY = geo.getY(); // AMBIGUOUS! OLK 5/10
840  if (getMetadataElement(metaDb, "GEOTIFF_CHAR::GTRasterTypeGeoKey", &rasterTypeStr, sizeof(rasterTypeStr)) == true)
841  {
842  ossimString rasterTypeTag(rasterTypeStr);
843 
844  // If the raster type is pixel_is_area, shift the tie point by
845  // half a pixel to locate it at the pixel center.
846  if ( rasterTypeTag.contains("RasterPixelIsPoint") )
847  {
848  topLeftX -= geo.getXRes() / 2.0; // AMBIGUOUS -- DOESN'T MATCH COMMENT! OLK 5/10
849  topLeftY += geo.getYRes() / 2.0; // AMBIGUOUS! OLK 5/10
850  }
851  }
852  ossimDpt gsd(fabs(geo.getXRes()), fabs(geo.getYRes()));
853  ossimDpt tie(topLeftX, topLeftY);
854 
855  // CANNOT HANDLE 2D TRANSFORMS -- ONLY REAL PROJECTIONS. (OLK 5/10)
856  //std::stringstream mString;
858  //mString << ossimString::toString(geo.getXRes(), 20)
859  // << " " << ossimString::toString(geo.getXRot(), 20)
860  // << " " << 0 << " "
861  // << ossimString::toString(geo.getX(), 20)
862  // << " " << ossimString::toString(geo.getYRot(), 20)
863  // << " " << ossimString::toString(geo.getYRes(), 20)
864  // << " " << 0 << " "
865  // << ossimString::toString(geo.getY(), 20)
866  // << " " << 0 << " " << 0 << " " << 1 << " " << 0
867  // << " " << 0 << " " << 0 << " " << 0 << " " << 1;
868  //kwl.add(ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW, mString.str().c_str());
869 
870  // if meta data does not have the code info, try to read from .aux file
871  if (code == 0)
872  {
873  ossimFilename auxFile = theImageFile;
874  auxFile.setExtension("aux");
875  ossimAuxFileHandler auxHandler;
876  if (auxFile.exists() && auxHandler.open(auxFile))
877  {
878  ossimString proj_name = auxHandler.getProjectionName();
879  ossimString datum_name = auxHandler.getDatumName();
880  ossimString unitType = auxHandler.getUnitType();
881 
882  // HACK: Geographic projection is specified in non-WKT format. Intercepting here. OLK 5/10
883  // TODO: Need projection factory that can handle miscellaneous non-WKT specs as they are
884  // encountered.
885  if (proj_name.contains("Geographic"))
886  {
887  kwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection", false);
888  scale_units = "degrees";
889  tie_pt_units = "degrees";
890  }
891  else
892  {
893  // pass along MrSid's projection name and pray it can be resolved:
894  kwl.add(ossimKeywordNames::PROJECTION_KW, proj_name, false);
895  if (unitType.empty())
896  {
897  if (proj_name.downcase().contains("feet"))
898  {
899  scale_units = "feet";
900  tie_pt_units = "feet";
901  }
902  }
903  else
904  {
905  scale_units = unitType;
906  tie_pt_units = unitType;
907  }
908  }
909 
910  // HACK: WGS-84 is specified in non-WKT format. Intercepting here. OLK 5/10
911  // TODO: Need datum factory that can handle miscellaneous non-WKT specs as they are
912  // encountered.
913  if (datum_name.contains("WGS") && datum_name.contains("84"))
914  kwl.add(ossimKeywordNames::DATUM_KW, "EPSG:6326");
915  else
916  kwl.add(ossimKeywordNames::DATUM_KW, datum_name, false);
917  }
918  }
919 
920  if ( scale_units.empty() || (scale_units == "unknown" ) ||
921  tie_pt_units.empty() || (tie_pt_units == "unknown" ) )
922  {
924  << "ossimMrSidReader::getProjection WARNING: Undefined units!"
925  << "\nscale units: " << scale_units
926  << "\ntie_pt_units: " << tie_pt_units
927  << std::endl;
928  }
929 
933  kwl.add(ossimKeywordNames::TIE_POINT_UNITS_KW, tie_pt_units);
934 
935  ossimProjection* proj =
937  return proj;
938 }
939 
940 bool ossimMrSidReader::getMetadataElement(LTIMetadataDatabase metaDb,
941  const char *tagName,
942  void *pValue,
943  int iLength)
944 {
945  if (!metaDb.has(tagName))
946  {
947  return false;
948  }
949 
950  const LTIMetadataRecord* metaRec = 0;
951  metaDb.get(tagName, metaRec );
952 
953  if (!metaRec->isScalar())
954  {
955  return false;
956  }
957 
958  // XXX: return FALSE if we have more than one element in metadata record
959  int iSize;
960  switch(metaRec->getDataType())
961  {
962  case LTI_METADATA_DATATYPE_UINT8:
963  case LTI_METADATA_DATATYPE_SINT8:
964  iSize = 1;
965  break;
966  case LTI_METADATA_DATATYPE_UINT16:
967  case LTI_METADATA_DATATYPE_SINT16:
968  iSize = 2;
969  break;
970  case LTI_METADATA_DATATYPE_UINT32:
971  case LTI_METADATA_DATATYPE_SINT32:
972  case LTI_METADATA_DATATYPE_FLOAT32:
973  iSize = 4;
974  break;
975  case LTI_METADATA_DATATYPE_FLOAT64:
976  iSize = 8;
977  break;
978  case LTI_METADATA_DATATYPE_ASCII:
979  iSize = iLength;
980  break;
981  default:
982  iSize = 0;
983  break;
984  }
985 
986  if ( metaRec->getDataType() == LTI_METADATA_DATATYPE_ASCII )
987  {
988  strncpy( (char *)pValue, ((const char**)metaRec->getScalarData())[0], iSize );
989  ((char *)pValue)[iSize - 1] = '\0';
990  }
991  else
992  {
993  memcpy( pValue, metaRec->getScalarData(), iSize);
994  }
995 
996  return true;
997 }
998 
1000 {
1001 }
virtual void loadBand(const void *src, const ossimIrect &src_rect, ossim_uint32 band)
8 bit signed integer
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
const ossimString & getProjectionName() const
Reads a single record from a aux file.
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
static ossimImageGeometryRegistry * instance()
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Gets number of lines for res level.
bool getImageDimensions(std::vector< ossimIrect > &tileDims) const
ossimRefPtr< ossimImageGeometry > theGeometry
ossimMrSidReader()
default construtor
virtual bool open()
Open method.
static const char * PROJECTION_KW
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossimIrect theImageRect
const ossimString & getDatumName() const
static const char * DATUM_KW
64 bit floating point
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
16 bit unsigned integer
Represents serializable keyword/value map.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
virtual void closeEntry()
Method to close current entry.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Method to grab a tile(rectangle) from image.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
bool contains(char aChar) const
Definition: ossimString.h:58
static const char * NUMBER_LINES_KW
virtual void getDecimationFactors(vector< ossimDpt > &decimations) const
Get array of decimations for all levels.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
16 bit signed integer
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
Gets the decimation factor for a resLevel.
32 bit floating point
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
virtual ossimString getClassName() const
Returns class name.
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry() const
Method to get geometry from internal mrsid tags.
32 bit unsigned integer
static const char * TYPE_KW
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void initialize()
Initialize the data buffer.
RTTI_DEF1_INST(ossimMrSidReader, "ossimMrSidReader", ossimImageHandler) ossimMrSidReader
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 open(const ossimFilename &file)
the file for reading
const ossimString & getUnitType() const
virtual ~ossimMrSidReader()
virtural destructor
bool completely_within(const ossimIrect &rect) const
Definition: ossimIrect.cpp:425
static const char * PIXEL_SCALE_XY_KW
double ossim_float64
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool computeDecimationFactors(std::vector< ossimDpt > &decimations) const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
static ossimImageDataFactory * instance()
double lat
Definition: ossimDpt.h:165
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
virtual ossimDataObjectStatus validate() const
static const char * TIE_POINT_XY_KW
bool exists() const
std::string::size_type size() const
Definition: ossimString.h:405
32 bit signed integer
unsigned int ossim_uint32
ossimRefPtr< ossimImageData > theTile
const ossimIpt & lr() const
Definition: ossimIrect.h:276
virtual void close()
Deletes the overview and clears the valid image vertices.
Utility/support data class to parse WKT text string to an ossimKeywordlist.
Definition: ossimWkt.h:68
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimScalarType theScalarType
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual ossimString getShortName() const
Returns short name.
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
std::vector< ossimIrect > theMrSidDims
Has sub image offset.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimScalarType
static ossimProjectionFactoryRegistry * instance()
ossim_uint32 theNumberOfBands
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
Utility/support data class to extract the projection from a dot aux dot xml file commonly found with ...
void decimationFactors(std::vector< ossimDpt > &decimations) const
Gets array of all decimation levels.
void setDiscreteDecimation(const std::vector< ossimDpt > &decimation_list)
Sets the decimation scheme to a discrete list of decimation factors.
virtual void makeBlank()
Initializes data to null pixel values.
static const char * PCS_CODE_KW
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void completeOpen()
Will complete the opening process.
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
ossimProjection * getGeoProjection()
bool getMetadataElement(LTIMetadataDatabase metaDb, const char *tagName, void *pValue, int iLength=0)
ossimString toString(ossim_uint32 precision=15) const
Definition: ossimDpt.cpp:160
ossimRefPtr< ossimImageHandler > theOverview
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Gets the image geometry from external ".geom" or ".aux.xml" file.
virtual bool isOpen() const
Method to test for open file stream.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
ossim_int32 y
Definition: ossimIpt.h:142
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of decimation levels.
virtual const void * getBuf() const
double x
Definition: ossimDpt.h:164
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
bool empty() const
Definition: ossimString.h:411
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimString getLongName() const
Returns long name.
ossimString ext() const
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
ossim_int32 x
Definition: ossimIpt.h:141
LTINavigator * theImageNavigator
ossim_uint32 theMinDwtLevels
8 bit unsigned integer
virtual void setScalarType(ossimScalarType type)
See ossimScalarType in ossimConstants for a full list.
bool parse(const std::string &wkt)
Parses string to keyword list.
Definition: ossimWkt.cpp:52
const ossimKeywordlist & getKwl() const
Definition: ossimWkt.cpp:63
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
MrSIDImageReader * theReader
ossim_uint32 getNumberOfDecimations() const
static const char * NUMBER_SAMPLES_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
ossimRefPtr< ossimProjection > getProjection(const ossimFilename &file) const
Method to get a projection if possible.
static const char * PIXEL_SCALE_UNITS_KW
static const char * TIE_POINT_UNITS_KW
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Gets the number of samples for res level.
ossimDpt decimationFactor(ossim_uint32 r_index) const
Returns the decimation factor from R0 for the resolution level specified.
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 ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)