Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: FITS Driver 4 : * Purpose: Implement FITS raster read/write support 5 : * Author: Simon Perkins, s.perkins@lanl.gov 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2001, Simon Perkins 9 : * Copyright (c) 2008-2020, Even Rouault <even dot rouault at spatialys.com> 10 : * Copyright (c) 2018, Chiara Marmo <chiara dot marmo at u-psud dot fr> 11 : * 12 : * SPDX-License-Identifier: MIT 13 : ****************************************************************************/ 14 : 15 : #include "fitsdrivercore.h" 16 : 17 : /************************************************************************/ 18 : /* FITSDriverIdentify() */ 19 : /************************************************************************/ 20 : 21 65702 : int FITSDriverIdentify(GDALOpenInfo *poOpenInfo) 22 : 23 : { 24 65702 : if (STARTS_WITH(poOpenInfo->pszFilename, "FITS:")) 25 18 : return true; 26 : 27 65684 : const char *fitsID = "SIMPLE = T"; // Spaces important! 28 65684 : const size_t fitsIDLen = strlen(fitsID); // Should be 30 chars long 29 : 30 65684 : if (static_cast<size_t>(poOpenInfo->nHeaderBytes) < fitsIDLen) 31 51827 : return false; 32 13857 : if (memcmp(poOpenInfo->pabyHeader, fitsID, fitsIDLen) != 0) 33 13745 : return false; 34 112 : return true; 35 : } 36 : 37 : /************************************************************************/ 38 : /* FITSDriverSetCommonMetadata() */ 39 : /************************************************************************/ 40 : 41 1304 : void FITSDriverSetCommonMetadata(GDALDriver *poDriver) 42 : { 43 1304 : poDriver->SetDescription(DRIVER_NAME); 44 1304 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 45 1304 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 46 1304 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES"); 47 1304 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES"); 48 1304 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, 49 1304 : "Flexible Image Transport System"); 50 1304 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/fits.html"); 51 1304 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES, 52 1304 : "Byte UInt16 Int16 UInt32 Int32 Float32 Float64"); 53 1304 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "fits"); 54 : 55 1304 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATATYPES, 56 : "Integer Integer64 Real String IntegerList " 57 1304 : "Integer64List RealList"); 58 1304 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATASUBTYPES, 59 1304 : "Boolean Int16 Float32"); 60 : 61 1304 : poDriver->SetMetadataItem( 62 : GDAL_DS_LAYER_CREATIONOPTIONLIST, 63 : "<LayerCreationOptionList>" 64 : " <Option name='REPEAT_*' type='int' description='Repeat value for " 65 : "fields of type List'/>" 66 : " <Option name='COMPUTE_REPEAT' type='string-select' " 67 : "description='Determine when the repeat value for fields is computed'>" 68 : " <Value>AT_FIELD_CREATION</Value>" 69 : " <Value>AT_FIRST_FEATURE_CREATION</Value>" 70 : " </Option>" 71 1304 : "</LayerCreationOptionList>"); 72 : 73 1304 : poDriver->pfnIdentify = FITSDriverIdentify; 74 1304 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 75 1304 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES"); 76 1304 : } 77 : 78 : /************************************************************************/ 79 : /* DeclareDeferredFITSPlugin() */ 80 : /************************************************************************/ 81 : 82 : #ifdef PLUGIN_FILENAME 83 1595 : void DeclareDeferredFITSPlugin() 84 : { 85 1595 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 86 : { 87 302 : return; 88 : } 89 1293 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 90 : #ifdef PLUGIN_INSTALLATION_MESSAGE 91 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 92 : PLUGIN_INSTALLATION_MESSAGE); 93 : #endif 94 1293 : FITSDriverSetCommonMetadata(poDriver); 95 1293 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 96 : } 97 : #endif