OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimImageHandlerFactory.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 //---
8 // $Id$
9 
14 #include <ossim/base/ossimRegExp.h>
15 #include <ossim/base/ossimTrace.h>
24 // #include <ossim/imaging/ossimPdfReader.h>
44 #include <tiffio.h>
45 
46 #if OSSIM_HAS_HDF5
48 #endif
49 
50 static const ossimTrace traceDebug("ossimImageHandlerFactory:debug");
51 
53 
55 
57 {
59 }
60 
62 {
63  if(!theInstance)
64  {
66 
67  // let's turn off tiff error reporting
68  TIFFSetErrorHandler(0);
69  TIFFSetWarningHandler(0);
70  }
71 
72  return theInstance;
73 }
74 
76  std::shared_ptr<ossim::istream>& str,
77  const std::string& connectionString,
78  bool openOverview ) const
79 {
81 
82  // NITF:
85  if ( ih->open( str, connectionString ) )
86  {
87  result = ih.get();
88  }
89 
90  if( !result )
91  {
92  // Reset the stream for downstream code.
93  str->seekg(0, std::ios_base::beg);
94  str->clear();
95 
96  // TIFF:
99  if ( ihTiff->open( str, connectionString ) )
100  {
101  result = ihTiff.get();
102  }
103 
104  if(!result)
105  {
106  // Reset the stream for downstream code.
107  str->seekg(0, std::ios_base::beg);
108  str->clear();
109 
110  // ossim dot.src file:
111  result = openSrcRecord( str, connectionString, openOverview );
112 
113  if ( !result )
114  {
115  // Reset the stream for downstream code.
116  str->seekg(0, std::ios_base::beg);
117  str->clear();
118  }
119  }
120  }
121 
122  return result;
123 }
124 
126  bool openOverview) const
127 {
128  static const char* M = "ossimImageHandlerFactory::open(filename) -- ";
129  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M <<" Entering..." << std::endl;
130 
131  ossimFilename copyFilename = fileName;
132  if (traceDebug())
133  {
135  << "Attempting to open file: " << fileName.c_str()
136  << "\nopen overview flag: " << (openOverview?"true":"false") << "\n";
137  }
138 
140  while (true)
141  {
142  // Check for empty file.
143  copyFilename.trim();
144  if (copyFilename.empty()) break;
145 
146  // for all of our imagehandlers the filename must exist.
147  // if we have any imagehandlers that require an encoded string and is contrlled in this factory then
148  // we need to move this.
149  if (!copyFilename.exists()) break;
150 
151  ossimString ext = copyFilename.ext().downcase();
152  if(ext == "gz")
153  copyFilename = copyFilename.setExtension("");
154 
155  // Try opening from extension logic first (this is faster than instantiating each type).
156 // if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying via extension...";
157 // result = openFromExtension(copyFilename);
158 // if (result.valid()) break;
159 
160  //---
161  // If here do it the brute force way by going down the list of available
162  // readers...
163  //---
164 
165  //---
166  // NITF at top of list.
167  //
168  // This must be checked first before the NITF raw handler.
169  //---
170  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying Quickbird Nitf...\n";
171  result = new ossimQuickbirdNitfTileSource;
173  if (result->open(copyFilename)) break;
174 
175  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying NITF...\n";
176  result = new ossimNitfTileSource;
178  if (result->open(copyFilename)) break;
179 
180  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying RPF Cache Image...\n";
181  result = new ossimRpfCacheTileSource;
183  if (result->open(copyFilename)) break;
184 
185  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying RPF Image Cache Image...\n";
186  result = new ossimImageCacheTileSource;
188  if (result->open(copyFilename)) break;
189 
190  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying JPEG...\n";
191  result = new ossimJpegTileSource;
193  if (result->open(copyFilename)) break;
194 
195  // this must be checked first before the TIFF handler
196  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying Quickbird TIFF...\n";
197  result = new ossimQuickbirdTiffTileSource;
199  if (result->open(copyFilename)) break;
200 
201  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying TIFF...\n";
202  result = new ossimTiffTileSource;
204  if (result->open(copyFilename)) break;
205 
206  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying CIB/CADRG...\n";
207  result = new ossimCibCadrgTileSource;
209  if (result->open(copyFilename)) break;
210 
211  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying DOQQ...\n";
212  result = new ossimDoqqTileSource;
214  if (result->open(copyFilename)) break;
215 
216  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying DTED...\n";
217  result = new ossimDtedTileSource;
219  if (result->open(copyFilename)) break;
220 
221  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying USGS Dem...\n";
222  result = new ossimUsgsDemTileSource;
224  if (result->open(copyFilename)) break;
225 
226  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying Landsat...\n";
227  result = new ossimLandsatTileSource;
229  if (result->open(copyFilename)) break;
230 
231  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying VPF...\n";
232  result = new ossimVpfTileSource;
234  if (result->open(copyFilename)) break;
235 
236  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ERS...\n";
237  result = new ossimERSTileSource;
239  if (result->open(copyFilename)) break;
240 
241  //---
242  // The srtm and general raser readers were picking up j2k overviews because the
243  // matching base file has an "omd" file that the raster reader can load
244  // so added extension check. (drb - 20100709)
245  //---
246  if (copyFilename.ext() != "ovr")
247  {
248  // Note: ENVI should be in front of general raster..
249  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ENVI...\n";
250  result = new ossimEnviTileSource;
252  if (result->open(copyFilename)) break;
253 
254  // Note: SRTM should be in front of general raster..
255  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying SRTM...\n";
256  result = new ossimSrtmTileSource;
258  if (result->open(copyFilename)) break;
259 
260  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying General Raster...\n";
261  result = new ossimGeneralRasterTileSource;
263  if (result->open(copyFilename)) break;
264  }
265 
266  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ADRG...\n";
267  result = new ossimAdrgTileSource();
269  if (result->open(copyFilename)) break;
270 
271  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ossimQbTileFilesHandler...\n";
272  result = new ossimQbTileFilesHandler();
274  if (result->open(copyFilename)) break;
275 
276  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying Bit Mask...\n";
277  result = new ossimBitMaskTileSource();
279  if (result->open(copyFilename)) break;
280 
281  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying band-separated files...\n";
282  result = new ossimBandSeparateHandler();
284  if (result->open(copyFilename)) break;
285 
286  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying CCF...\n";
287  result = new ossimCcfTileSource();
289  if (result->open(copyFilename)) break;
290 
291  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying OSSIM Range Domes...\n";
292  result = new ossimRangeDomeTileSource();
294  if (result->open(copyFilename)) break;
295 
296  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying Point Cloud...\n";
297  result = new ossimPointCloudImageHandler();
299  if (result->open(copyFilename)) break;
300 
301  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying LAS Reader...\n";
303  result = new ossimLasReader();
304  if (result->open(copyFilename)) break;
305 
306 #if OSSIM_HAS_HDF5
307  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying VIIRS...\n";
308  result = new ossimViirsHandler();
310  if (result->open(copyFilename)) break;
311 #endif
312 
313  result = 0;
314  break;
315  }
316 
317  if (traceDebug())
318  {
319  if (result.valid())
320  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " SUCCESS" << std::endl;
321  else
322  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " Open FAILED" << std::endl;
323  }
324 
325  return result.release();
326 }
327 
329  const char* prefix)const
330 {
331  static const char* M = "ossimImageHandlerFactory::open(kwl,prefix) -- ";
332  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M <<" entered..." << std::endl;
333 
335  while (true)
336  {
337  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying adrg...\n";
338  result = new ossimAdrgTileSource();
339  if (result->loadState(kwl, prefix)) break;
340 
341  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying ccf...\n";
342  result = new ossimCcfTileSource();
343  if (result->loadState(kwl, prefix)) break;
344 
345  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << "trying CIB/CADRG...\n";
346  result = new ossimCibCadrgTileSource();
347  if (result->loadState(kwl, prefix)) break;
348 
349  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "trying RpfCache...\n";
350  result = new ossimRpfCacheTileSource();
351  if (result->loadState(kwl, prefix)) break;
352 
353  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "trying Rpf ImageCache...\n";
354  result = new ossimImageCacheTileSource();
355  if (result->loadState(kwl, prefix)) break;
356 
357  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << "trying DOQQ...\n";
358  result = new ossimDoqqTileSource();
359  if (result->loadState(kwl, prefix)) break;
360 
361  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying DTED...\n";
362  result = new ossimDtedTileSource();
363  if (result->loadState(kwl, prefix)) break;
364 
365  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying jpeg...\n";
366  result = new ossimJpegTileSource();
367  if (result->loadState(kwl, prefix)) break;
368 
369  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying Quickbird NITF...\n";
370  result = new ossimQuickbirdNitfTileSource;
371  if (result->loadState(kwl, prefix)) break;
372 
373  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << "trying Nitf...\n";
374  result = new ossimNitfTileSource();
375  if (result->loadState(kwl, prefix)) break;
376 
377  // Must be before tiff...
378  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying Quickbird TIFF...\n";
379  result = new ossimQuickbirdTiffTileSource;
380  if (result->loadState(kwl, prefix)) break;
381 
382  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying tiff...\n";
383  result = new ossimTiffTileSource();
384  if (result->loadState(kwl, prefix)) break;
385 
386  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying USGS Dem...\n";
387  result = new ossimUsgsDemTileSource();
388  if (result->loadState(kwl, prefix)) break;
389 
390  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying Landsat...\n";
391  result = new ossimLandsatTileSource();
392  if (result->loadState(kwl, prefix)) break;
393 
394  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying VPF...\n";
395  result = new ossimVpfTileSource;
396  if (result->loadState(kwl, prefix)) break;
397 
398  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying ERS...\n";
399  result = new ossimERSTileSource;
400  if (result->loadState(kwl, prefix)) break;
401 
402  // Note: ENVI should be in front of general raster...
403  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying ENVI...\n"<< std::endl;
404  result = new ossimEnviTileSource();
405  if (result->loadState(kwl, prefix)) break;
406 
407  // Note: SRTM should be in front of general raster...
408  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M<< "trying SRTM...\n"<< std::endl;
409  result = new ossimSrtmTileSource();
410  if (result->loadState(kwl, prefix)) break;
411 
412  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << "trying General Raster...\n"<< std::endl;
413  result = new ossimGeneralRasterTileSource();
414  if (result->loadState(kwl, prefix)) break;
415 
416  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"trying ossimQbTileFilesHandler...\n"<<std::endl;
417  result = new ossimQbTileFilesHandler;
418  if (result->loadState(kwl, prefix)) break;
419 
420  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying band-separated files...\n";
421  result = new ossimBandSeparateHandler();
422  if (result->loadState(kwl, prefix)) break;
423 
424  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying Range Domes CSV...\n";
425  result = new ossimRangeDomeTileSource();
426  if (result->loadState(kwl, prefix)) break;
427 
428 #if OSSIM_HAS_HDF5
429  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying VIIRS...\n";
430  result = new ossimViirsHandler();
431  if (result->loadState(kwl, prefix)) break;
432 #endif
433 
434 #ifdef ENABLE_POINT_CLOUD_HANDLER
435  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying ossimPointCloudImageHandler...\n";
436  result = new ossimPointCloudImageHandler();
437  if (result->loadState(kwl, prefix)) break;
438 #endif
439  result = 0;
440  break;
441  }
442 
443  if (traceDebug())
444  {
445  if (result.valid())
446  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " SUCCESS" << std::endl;
447  else
448  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " Open FAILED" << std::endl;
449  }
450 
451  return result.release();
452 }
453 
454 ossimRefPtr<ossimImageHandler> ossimImageHandlerFactory::open(std::shared_ptr<ossim::ImageHandlerState> state)const
455 {
457  if(state)
458  {
459  ossimRefPtr<ossimObject> obj = createObject(state->getImageHandlerType());
460  if(obj)
461  {
462  result = dynamic_cast<ossimImageHandler*>(obj.get());
463  if(result)
464  {
465  if(!result->open(state))
466  {
467  result = 0;
468  }
469  }
470  obj = 0;
471  }
472 
473  }
474 
475  return result;
476 }
477 
479  const ossimFilename& file ) const
480 {
482  if ( file.size() )
483  {
484  result = new ossimTiffTileSource;
485 
486  result->setOpenOverviewFlag( false ); // Always false.
487 
488  if ( result->open( file ) == false )
489  {
490  result = 0;
491  }
492  }
493  return result;
494 }
495 
496 #if 0
497 ossimImageHandler* ossimImageHandlerFactory::openFromExtension(const ossimFilename& fileName) const
498 {
499 
500  static const char* M = "ossimImageHandlerFactory::openFromExtension() -- ";
501  if(traceDebug())
502  ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Attempting to open <"<<fileName<<">"<<std::endl;
503 
504  ossimString ext = fileName.ext().downcase();
506 
507 
508  while (true)
509  {
510  // OVR can be combined with "tif" once we get rid of ossimQuickbirdTiffTileSource
511  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying OVR...\n";
512  if (ext == "ovr")
513  {
514  result = new ossimTiffTileSource;
515  if(result->open(fileName)) break;
516  }
517 
518  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying TIF or TIFF...\n";
519  if ( (ext == "tif") || (ext == "tiff") )
520  {
521  // this must be checked first before the TIFF handler
522  result = new ossimQuickbirdTiffTileSource;
523  if(result->open(fileName)) break;
524  result = new ossimTiffTileSource;
525  if(result->open(fileName)) break;
526  }
527 
528  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying NTF or NITF...\n";
529  if ( (ext == "ntf") || (ext == "nitf") )
530  {
531  // this must be checked first before the NITF raw handler
532  result = new ossimQuickbirdNitfTileSource;
533  if(result->open(fileName)) break;
534  result = new ossimNitfTileSource;
535  if(result->open(fileName)) break;
536  }
537 
538  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying RPF...\n";
539  if ( (fileName == "rpf"))
540  {
541  result = new ossimRpfCacheTileSource;
542  if(result->open(fileName)) break;
543 
544  result = new ossimImagefCacheTileSource;
545  if(result->open(fileName)) break;
546  }
547 
548  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying TOC...\n";
549  if ( (fileName == "a.toc") || (ext == "toc"))
550  {
551  result = new ossimCibCadrgTileSource;
552  if(result->open(fileName)) break;
553  }
554 
555  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying JPG or JPEG...\n";
556  if ( (ext == "jpg") || (ext == "jpeg") )
557  {
558  result = new ossimJpegTileSource;
559  if(result->open(fileName)) break;
560  }
561 
562  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying DOQ or DOQQ...\n";
563  if ( (ext == "doq") || (ext == "doqq") )
564  {
565  result = new ossimDoqqTileSource;
566  if(result->open(fileName)) break;
567  }
568 
569  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying DTn...\n";
570  if ( (ext == "dt2") || (ext == "dt1") || (ext == "dt3") ||
571  (ext == "dt4") || (ext == "dt5") || (ext == "dt0") )
572  {
573  result = new ossimDtedTileSource;
574  if(result->open(fileName)) break;
575  }
576 
577  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying HGT...\n";
578  if (ext == "hgt")
579  {
580  result = new ossimSrtmTileSource;
581  if(result->open(fileName)) break;
582  }
583 
584  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying HRI,HSI\n";
585  if ( (ext == "hri") || (ext == "hsi") )
586  {
587  result = new ossimEnviTileSource;
588  if(result->open(fileName)) break;
589  }
590 
591  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying DEM...\n";
592  if (ext == "dem")
593  {
594  result = new ossimUsgsDemTileSource;
595  if(result->open(fileName)) break;
596  }
597 
598  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying FST...\n";
599  if (ext == "fst")
600  {
601  result = new ossimLandsatTileSource;
602  if(result->open(fileName)) break;
603  }
604 
605  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying RAS or RAW...\n";
606  if ( (ext == "ras") || (ext == "raw") )
607  {
608  result = new ossimGeneralRasterTileSource;
609  if(result->open(fileName)) break;
610  }
611 
612  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying IMG...\n";
613  if (ext == "img")
614  {
615  result = new ossimAdrgTileSource;
616  if(result->open(fileName)) break;
617  }
618 
619  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying CCF...\n";
620  if (ext == "ccf")
621  {
622  result = new ossimCcfTileSource;
623  if(result->open(fileName)) break;
624  }
625 
626  result = 0;
627  break;
628  }
629  if (traceDebug())
630  {
631  if (result.valid())
632  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " SUCCESS" << std::endl;
633  else
634  ossimNotify(ossimNotifyLevel_DEBUG)<<M<< " Open FAILED" << std::endl;
635  }
636  return result.release();
637 }
638 #endif
640 {
641  if(STATIC_TYPE_NAME(ossimAdrgTileSource) == typeName)
642  {
643  return new ossimAdrgTileSource();
644  }
645  if(STATIC_TYPE_NAME(ossimCcfTileSource) == typeName)
646  {
647  return new ossimCcfTileSource();
648  }
650  {
651  return new ossimCibCadrgTileSource();
652  }
654  {
655  return new ossimRpfCacheTileSource();
656  }
658  {
659  return new ossimImageCacheTileSource();
660  }
661  if(STATIC_TYPE_NAME(ossimDoqqTileSource) == typeName)
662  {
663  return new ossimDoqqTileSource();
664  }
665  if(STATIC_TYPE_NAME(ossimDtedTileSource) == typeName)
666  {
667  return new ossimDtedTileSource();
668  }
669  if(STATIC_TYPE_NAME(ossimEnviTileSource) == typeName)
670  {
671  return new ossimEnviTileSource();
672  }
673  if(STATIC_TYPE_NAME(ossimJpegTileSource) == typeName)
674  {
675  return new ossimJpegTileSource();
676  }
677  if(STATIC_TYPE_NAME(ossimNitfTileSource) == typeName)
678  {
679  return new ossimNitfTileSource();
680  }
681  if(STATIC_TYPE_NAME(ossimTiffTileSource) == typeName)
682  {
683  return new ossimTiffTileSource();
684  }
686  {
687  return new ossimUsgsDemTileSource();
688  }
690  {
691  return new ossimLandsatTileSource();
692  }
693  if(STATIC_TYPE_NAME(ossimERSTileSource) == typeName)
694  {
695  return new ossimERSTileSource();
696  }
697  if(STATIC_TYPE_NAME(ossimSrtmTileSource) == typeName)
698  {
699  return new ossimSrtmTileSource();
700  }
702  {
703  return new ossimGeneralRasterTileSource();
704  }
706  {
707  return new ossimQuickbirdNitfTileSource();
708  }
710  {
711  return new ossimQbTileFilesHandler();
712  }
714  {
715  return new ossimBitMaskTileSource();
716  }
718  {
719  return new ossimBandSeparateHandler();
720  }
722  {
723  return new ossimRangeDomeTileSource();
724  }
725 #if OSSIM_HAS_HDF5
726  if(STATIC_TYPE_NAME(ossimViirsHandler) == typeName)
727  {
728  return new ossimViirsHandler();
729  }
730 #endif
731 
732  #ifdef ENABLE_POINT_CLOUD_HANDLER
734  {
735  return new ossimPointCloudImageHandler();
736  }
737 #endif
739  {
740  return new ossimImageHandlerMtAdaptor();
741  }
742 
743  return (ossimObject*)0;
744 }
745 
747 {
748  extensionList.push_back("img");
749  extensionList.push_back("ccf");
750  extensionList.push_back("toc");
751  extensionList.push_back("tif");
752  extensionList.push_back("tiff");
753  extensionList.push_back("doq");
754  extensionList.push_back("doqq");
755  extensionList.push_back("dt0");
756  extensionList.push_back("dt1");
757  extensionList.push_back("dt2");
758  extensionList.push_back("dt3");
759  extensionList.push_back("jpg");
760  extensionList.push_back("jpeg");
761  extensionList.push_back("dem");
762  extensionList.push_back("fst");
763  extensionList.push_back("hdr");
764  extensionList.push_back("ras");
765  extensionList.push_back("hgt");
766  extensionList.push_back("nsf");
767  extensionList.push_back("nitf");
768  extensionList.push_back("ntf");
769  extensionList.push_back("til");
770  extensionList.push_back("mask");
771  extensionList.push_back("txt");
772  extensionList.push_back("csv");
773 #if OSSIM_HAS_HDF5
774  extensionList.push_back("h5");
775 #endif
776 }
777 
779 {
780  static const char* M = "ossimImageHandlerFactory::getImageHandlersBySuffix() -- ";
781  // OVR can be combined with "tif" once we get rid of ossimQuickbirdTiffTileSource
782  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Trying OVR...\n";
783  ossimString testExt = ext.downcase();
784  if (testExt == "ovr")
785  {
786  result.push_back(new ossimTiffTileSource);
787  return;
788  }
789 
790  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing TIF or TIFF...\n";
791  if ( (testExt == "tif") || (testExt == "tiff") )
792  {
793  // this must be checked first before the TIFF handler
794  result.push_back(new ossimQuickbirdTiffTileSource);
795  result.push_back(new ossimTiffTileSource);
796  return;
797  }
798 
799  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing NTF or NITF...\n";
800  if ( (testExt == "ntf") || (testExt == "nitf") )
801  {
802  // this must be checked first before the NITF raw handler
803  result.push_back(new ossimQuickbirdNitfTileSource);
804  result.push_back(new ossimNitfTileSource);
805  return;
806  }
807 
808  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing RPF...\n";
809  if ( (testExt == "rpf"))
810  {
811  result.push_back(new ossimRpfCacheTileSource);
812  result.push_back(new ossimImageCacheTileSource);
813  return;
814  }
815 
816  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing TOC...\n";
817  if ( testExt == "toc")
818  {
819  result.push_back(new ossimCibCadrgTileSource);
820  return;
821  }
822 
823  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing JPG or JPEG...\n";
824  if ( (testExt == "jpg") || (testExt == "jpeg") )
825  {
826  result.push_back(new ossimJpegTileSource);
827  return;
828  }
829 
830  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing DOQ or DOQQ...\n";
831  if ( (testExt == "doq") || (testExt == "doqq") )
832  {
833  result.push_back(new ossimDoqqTileSource);
834  return;
835  }
836 
837  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing DTn...\n";
838  ossimString regExpStr = "dt[0-9]";
839  ossimRegExp regExp(regExpStr);
840  if(regExp.find(testExt))
841  {
842  result.push_back(new ossimDtedTileSource);
843  return;
844  }
845 
846  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing HGT...\n";
847  if (testExt == "hgt")
848  {
849  result.push_back(new ossimSrtmTileSource);
850  return;
851  }
852 
853  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing HRI,HSI...\n";
854  if ( (testExt == "hri") || (testExt == "hsi") )
855  {
856  result.push_back(new ossimEnviTileSource);
857  return;
858  }
859 
860  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing DEM...\n";
861  if (testExt == "dem")
862  {
863  result.push_back(new ossimUsgsDemTileSource);
864  return;
865  }
866 
867  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing FST...\n";
868  if (testExt == "fst")
869  {
870  result.push_back(new ossimLandsatTileSource);
871  return;
872  }
873 
874  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing RAS or RAW or General Raster...\n";
875  if ( (testExt == "ras") || (testExt == "raw") || (testExt == "bil"))
876  {
877  result.push_back(new ossimGeneralRasterTileSource);
878  return;
879  }
880 
881  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing IMG...\n";
882  if (testExt == "img")
883  {
884  result.push_back(new ossimAdrgTileSource);
885  return;
886  }
887 
888  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing CCF...\n";
889  if (testExt == "ccf")
890  {
891  result.push_back(new ossimCcfTileSource);
892  return;
893  }
894 
895  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing TIL...\n";
896  if (testExt == "til")
897  {
898  result.push_back(new ossimQbTileFilesHandler);
899  return;
900  }
901 
902  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing MASK...\n";
903  if (testExt == "mask")
904  {
905  result.push_back(new ossimBitMaskTileSource);
906  return;
907  }
908 
909  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing TXT...\n";
910  if (testExt == "txt")
911  {
912  result.push_back(new ossimBandSeparateHandler);
913  return;
914  }
915 
916  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing CSV...\n";
917  if (testExt == "csv")
918  {
919  result.push_back(new ossimRangeDomeTileSource);
920  return;
921  }
922 
923 #if OSSIM_HAS_HDF5
924  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing VIIRS...\n";
925  if (testExt == "h5")
926  {
927  result.push_back(new ossimViirsHandler);
928  return;
929  }
930 #endif
931 
932 }
933 
935 {
936  ossimString test(mimeType.begin(), mimeType.begin()+6);
937  if(test == "image/")
938  {
939  ossimString mimeTypeTest(mimeType.begin() + 6, mimeType.end());
940  getImageHandlersBySuffix(result, mimeTypeTest);
941  if(mimeTypeTest == "dted")
942  {
943  result.push_back(new ossimDtedTileSource);
944  }
945  }
946 }
947 
949  const char* prefix)const
950 {
951  if(traceDebug())
952  {
954  << "ossimImageHandlerFactory::createObject(kwl, prefix) DEBUG:"
955  << " entering ..." << std::endl;
956  }
957  ossimObject* result = (ossimObject*)0;
958  const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
959 
960  if(type)
961  {
962  if (ossimString(type).trim() == STATIC_TYPE_NAME(ossimImageHandler))
963  {
964  const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
965 
966  if (lookup)
967  {
968  if(traceDebug())
969  {
970  ossimNotify(ossimNotifyLevel_DEBUG) << "BEBUG: filename " << lookup << std::endl;
971  }
972  // Call the open that takes a filename...
973  result = this->open(kwl, prefix);//ossimFilename(lookup));
974  }
975  }
976  else
977  {
978  result = createObject(ossimString(type));
979  if(result)
980  {
981  result->loadState(kwl, prefix);
982  }
983  }
984  }
985 
986  if(traceDebug())
987  {
988  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageHandlerFactory::createObject(kwl, prefix) DEBUG: returning result ..." << std::endl;
989  }
990  return result;
991 }
992 
993 void ossimImageHandlerFactory::getTypeNameList(std::vector<ossimString>& typeList)const
994 {
995  typeList.push_back(STATIC_TYPE_NAME(ossimAdrgTileSource));
996  typeList.push_back(STATIC_TYPE_NAME(ossimCcfTileSource));
997  typeList.push_back(STATIC_TYPE_NAME(ossimCibCadrgTileSource));
998  typeList.push_back(STATIC_TYPE_NAME(ossimEnviTileSource));
999  typeList.push_back(STATIC_TYPE_NAME(ossimRpfCacheTileSource));
1000  typeList.push_back(STATIC_TYPE_NAME(ossimImageCacheTileSource));
1001  typeList.push_back(STATIC_TYPE_NAME(ossimDoqqTileSource));
1002  typeList.push_back(STATIC_TYPE_NAME(ossimDtedTileSource));
1003  typeList.push_back(STATIC_TYPE_NAME(ossimJpegTileSource));
1004  typeList.push_back(STATIC_TYPE_NAME(ossimNitfTileSource));
1005  typeList.push_back(STATIC_TYPE_NAME(ossimTiffTileSource));
1006  typeList.push_back(STATIC_TYPE_NAME(ossimUsgsDemTileSource));
1007  typeList.push_back(STATIC_TYPE_NAME(ossimLandsatTileSource));
1008  typeList.push_back(STATIC_TYPE_NAME(ossimERSTileSource));
1009  typeList.push_back(STATIC_TYPE_NAME(ossimSrtmTileSource));
1010  typeList.push_back(STATIC_TYPE_NAME(ossimGeneralRasterTileSource));
1011  typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdNitfTileSource));
1012  typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdTiffTileSource));
1013  typeList.push_back(STATIC_TYPE_NAME(ossimQbTileFilesHandler));
1014  typeList.push_back(STATIC_TYPE_NAME(ossimBitMaskTileSource));
1015  typeList.push_back(STATIC_TYPE_NAME(ossimRangeDomeTileSource));
1016 
1017 #if OSSIM_HAS_HDF5
1018  typeList.push_back(STATIC_TYPE_NAME(ossimViirsHandler));
1019 #endif
1020 
1021 #ifdef ENABLE_POINT_CLOUD_HANDLER
1022  typeList.push_back(STATIC_TYPE_NAME(ossimPointCloudImageHandler));
1023 #endif
1024 
1025  typeList.push_back(STATIC_TYPE_NAME(ossimImageHandlerMtAdaptor));
1026 }
1027 
1029  std::shared_ptr<ossim::istream>& str,
1030  const std::string& connectionString,
1031  bool openOverview ) const
1032 {
1033  ossimRefPtr<ossimImageHandler> result = 0;
1034  if(!str) return result;
1035  // Check the extension for ".src" before going any further:
1036  std::size_t found = connectionString.find( std::string(".src") );
1037  if ( found != std::string::npos && ( found == (connectionString.size() - 4) ) )
1038  {
1039  ossimKeywordlist kwl;
1040  if ( kwl.parseStream( *str ) )
1041  {
1042  // Right now only concidering one image, i.e. "image0":
1043  std::string prefix = "image0.";
1044  ossimSrcRecord src;
1045  if ( src.loadState(kwl, prefix.c_str() ) )
1046  {
1047  if ( src.getFilename().string().size() )
1048  {
1049  // Avoid recursive loop:
1050  if (src.getFilename().string() != connectionString )
1051  {
1053  openConnection( src.getFilename(), false );
1054 
1055  if ( result.valid() )
1056  {
1057  ossimFilename supportDir = src.getSupportDir();
1058  if ( supportDir.empty() )
1059  {
1060  if ( src.getOverviewPath().size() )
1061  {
1062  if ( src.getOverviewPath().isDir() )
1063  {
1064  supportDir = src.getOverviewPath();
1065  }
1066  else
1067  {
1068  supportDir = src.getOverviewPath().path();
1069  }
1070  }
1071  else if ( src.getHistogramPath().size() )
1072  {
1073  if ( src.getHistogramPath().isDir() )
1074  {
1075  supportDir = src.getHistogramPath();
1076  }
1077  else
1078  {
1079  supportDir = src.getHistogramPath().path();
1080  }
1081  }
1082  }
1083 
1084  if ( supportDir.size() && (src.getFilename().path() != supportDir) )
1085  {
1086  result->setSupplementaryDirectory( supportDir );
1087  }
1088 
1089  if ( src.getEntryIndex() > 0 ) // defaulted to -1.
1090  {
1091  result->setCurrentEntry(
1092  static_cast<ossim_uint32>( src.getEntryIndex() ) );
1093  }
1094 
1095  if ( openOverview && ( result->getOverview() == 0 ) )
1096  {
1097  if ( src.getOverviewPath().size() )
1098  {
1099  result->openOverview( src.getOverviewPath() );
1100  }
1101  else
1102  {
1103  ossimFilename ovrFile = result->
1104  getFilenameWithThisExtension(ossimString(".ovr"));
1105  result->openOverview( ovrFile );
1106  }
1107  }
1108  }
1109  }
1110  }
1111  }
1112 
1113  } // Matches: if ( kwl.parseStream( str ) )
1114 
1115  if ( !result )
1116  {
1117  // Reset the stream for downstream code.
1118  str->seekg(0, std::ios_base::beg);
1119  str->clear();
1120  }
1121  }
1122  return result;
1123 }
virtual bool open()=0
Pure virtual open.
Class used for parsing the command line *.src files.
ossimImageHandlerFactory()
Open method that looks at extension e.g.
ossim_int32 getEntryIndex() const
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Initializes record from an in-memory KWL and prefix.
Intended mainly to provide a mechanism for mutex-locking access to a shared resource during a getTile...
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
RTTI_DEF1(ossimImageHandlerFactory, "ossimImageHandlerFactory", ossimImageHandlerFactoryBase)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Class used for rendering point cloud data into a raster tile.
virtual const ossimImageHandler * getOverview() const
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
bool isDir() const
const ossimFilename & getSupportDir() const
static const char * TYPE_KW
std::string::iterator end()
Definition: ossimString.h:423
virtual bool openOverview()
Searches for an overview.
#define STATIC_TYPE_NAME(T)
Definition: ossimRtti.h:325
const ossimFilename & getOverviewPath() const
See note below on these data members.
const ossimFilename & getFilename() const
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual void getImageHandlersByMimeType(ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &mimeType) const
ossimRefPtr< ossimImageHandler > openSrcRecord(std::shared_ptr< ossim::istream > &str, const std::string &connectionString, bool openOverview) const
Open dot.src (ossimSrcRecord).
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
bool exists() const
virtual ossimImageHandler * open(const ossimFilename &fileName, bool openOverview=true) const
std::string::size_type size() const
Definition: ossimString.h:405
std::string::iterator begin()
Definition: ossimString.h:420
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
This is the image handler for providing mask pixels to an ossimMaskFilter object. ...
T * release()
Definition: ossimRefPtr.h:93
virtual void getImageHandlersBySuffix(ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &ext) const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual ossimObject * createObject(const ossimString &typeName) const
const ossimFilename & getHistogramPath() const
CIB/CADRG formats are encoded the same except that the CIB is a grey scale image and the CADRG is a c...
static ossimImageHandlerFactory * instance()
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual bool open()
Returns true if the image_file can be opened and is a valid nitf file.
virtual bool open(const ossimFilename &image_file)
Returns true if the image_file can be opened and is a valid tiff file.
virtual bool parseStream(ossim::istream &is, bool ignoreBinaryChars)
deprecated method
Image handler used for tiled Quickbird imagery.
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 void setSupplementaryDirectory(const ossimFilename &dir)
Sets the supplementary directory.
static ossimImageHandlerFactory * theInstance
ossimString ext() const
static ossimImageHandlerRegistry * instance()
virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList
Class used for rendering range domes (a.k.a.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
static const char * FILENAME_KW
bool find(const char *)
ossimFilename path() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
Concrete class for reading VIIRS data from HDF5 file.
const std::string & string() const
Definition: ossimString.h:414
OSSIM LAS LIDAR reader.