| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: PALSAR JAXA imagery reader |
| 4 | * Purpose: Support for PALSAR L1.1/1.5 imagery and appropriate metadata from |
| 5 | * JAXA and JAXA-supported ground stations (ASF, ESA, etc.). This |
| 6 | * driver does not support ERSDAC products. |
| 7 | * Author: Philippe Vachon <[email protected]> |
| 8 | * |
| 9 | ****************************************************************************** |
| 10 | * Copyright (c) 2007, Philippe P. Vachon <[email protected]> |
| 11 | * Copyright (c) 2008-2011, Even Rouault <even dot rouault at spatialys.com> |
| 12 | * |
| 13 | * SPDX-License-Identifier: MIT |
| 14 | ****************************************************************************/ |
| 15 | |
| 16 | #include "gdal_frmts.h"cxx . . $ `<file>/gcore/gdal_frmts.h`/ |
| 17 | #include "gdal_pam.h"cxx . . $ `<file>/gcore/gdal_pam.h`/ |
| 18 | #include "gdal_driver.h"cxx . . $ `<file>/gcore/gdal_driver.h`/ |
| 19 | #include "gdal_drivermanager.h"cxx . . $ `<file>/gcore/gdal_drivermanager.h`/ |
| 20 | #include "gdal_openinfo.h"cxx . . $ `<file>/gcore/gdal_openinfo.h`/ |
| 21 | #include "gdal_cpp_functions.h"cxx . . $ `<file>/gcore/gdal_cpp_functions.h`/ |
| 22 | |
| 23 | #if defined(_WIN32) |
| 24 | #define SEP_STRING "\\" |
| 25 | #else |
| 26 | #define SEP_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:26:9`! "/" |
| 27 | #endif |
| 28 | |
| 29 | /* read binary fields */ |
| 30 | #ifdef CPL_LSBcxx . . $ `port/cpl_port.h:608:9`! |
| 31 | #define READ_WORDcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:31:9`!(f, x) \ |
| 32 | do \ |
| 33 | { \ |
| 34 | VSIFReadL(&(x), 4, 1, (f)); \ |
| 35 | (x) = CPL_SWAP32cxx . . $ `port/cpl_port.h:658:9`!((x)); \ |
| 36 | } while (false); |
| 37 | #define READ_SHORTcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:37:9`!(f, x) \ |
| 38 | do \ |
| 39 | { \ |
| 40 | VSIFReadL(&(x), 2, 1, (f)); \ |
| 41 | (x) = CPL_SWAP16((x)); \ |
| 42 | } while (false); |
| 43 | #else |
| 44 | #define READ_WORD(f, x) \ |
| 45 | do \ |
| 46 | { \ |
| 47 | VSIFReadL(&(x), 4, 1, (f)); \ |
| 48 | } while (false); |
| 49 | #define READ_SHORT(f, x) \ |
| 50 | do \ |
| 51 | { \ |
| 52 | VSIFReadL(&(x), 2, 1, (f)); \ |
| 53 | } while (false); |
| 54 | #endif /* def CPL_LSB */ |
| 55 | #define READ_BYTEcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:55:9`!(f, x) \ |
| 56 | do \ |
| 57 | { \ |
| 58 | VSIFReadL(&(x), 1, 1, (f)); \ |
| 59 | } while (false); |
| 60 | |
| 61 | /* read floating point value stored as ASCII */ |
| 62 | #define READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(n, l, f) \ |
| 63 | do \ |
| 64 | { \ |
| 65 | char psBuf[(l + 1)]; \ |
| 66 | psBuf[(l)] = '\0'; \ |
| 67 | VSIFReadL(&psBuf, (l), 1, (f)); \ |
| 68 | (n) = CPLAtof(psBuf); \ |
| 69 | } while (false); |
| 70 | |
| 71 | /* read numbers stored as ASCII */ |
| 72 | #define READ_CHAR_VALcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:72:9`!(x, n, f) \ |
| 73 | do \ |
| 74 | { \ |
| 75 | char psBuf[(n + 1)]; \ |
| 76 | psBuf[(n)] = '\0'; \ |
| 77 | VSIFReadL(&psBuf, (n), 1, (f)); \ |
| 78 | (x) = atoi(psBuf); \ |
| 79 | } while (false); |
| 80 | |
| 81 | /* read string fields |
| 82 | * note: string must be size of field to be extracted + 1 |
| 83 | */ |
| 84 | #define READ_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:84:9`!(s, n, f) \ |
| 85 | do \ |
| 86 | { \ |
| 87 | VSIFReadL(&(s), 1, (n), (f)); \ |
| 88 | (s)[(n)] = '\0'; \ |
| 89 | } while (false); |
| 90 | |
| 91 | /*************************************************************************/ |
| 92 | /* a few key offsets in the volume directory file */ |
| 93 | #define VOL_DESC_RECORD_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:93:9`! 360 |
| 94 | #define FILE_PTR_RECORD_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:94:9`! 360 |
| 95 | #define NUM_RECORDS_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:95:9`! 160 |
| 96 | |
| 97 | /* a few key offsets and values within the File Pointer record */ |
| 98 | #define REF_FILE_CLASS_CODE_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:98:9`! 66 |
| 99 | #define REF_FILE_CLASS_CODE_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:99:9`! 4 |
| 100 | #define FILE_NAME_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:100:9`! 310 |
| 101 | |
| 102 | /* some image option descriptor records */ |
| 103 | #define BITS_PER_SAMPLE_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:103:9`! 216 |
| 104 | #define BITS_PER_SAMPLE_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:104:9`! 4 |
| 105 | #define SAMPLES_PER_GROUP_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:105:9`! 220 |
| 106 | #define SAMPLES_PER_GROUP_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:106:9`! 4 |
| 107 | #define NUMBER_LINES_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:107:9`! 236 |
| 108 | #define NUMBER_LINES_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:108:9`! 8 |
| 109 | #define SAR_DATA_RECORD_LENGTH_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:109:9`! 186 |
| 110 | #define SAR_DATA_RECORD_LENGTH_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:110:9`! 6 |
| 111 | |
| 112 | #define IMAGE_OPT_DESC_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:112:9`! 720 |
| 113 | |
| 114 | #define SIG_DAT_REC_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:114:9`! 412 |
| 115 | #define PROC_DAT_REC_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:115:9`! 192 |
| 116 | |
| 117 | /* metadata to be extracted from the leader file */ |
| 118 | #define LEADER_FILE_DESCRIPTOR_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:118:9`! 720 |
| 119 | #define DATA_SET_SUMMARY_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:119:9`! 4096 |
| 120 | |
| 121 | /* relative to end of leader file descriptor */ |
| 122 | #define EFFECTIVE_LOOKS_AZIMUTH_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:122:9`! 1174 /* floating point text */ |
| 123 | #define EFFECTIVE_LOOKS_AZIMUTH_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:123:9`! 16 |
| 124 | |
| 125 | /* relative to leader file descriptor + dataset summary length */ |
| 126 | #define PIXEL_SPACING_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:126:9`! 92 |
| 127 | #define LINE_SPACING_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:127:9`! 108 |
| 128 | #define ALPHANUMERIC_PROJECTION_NAME_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:128:9`! 412 |
| 129 | #define TOP_LEFT_LAT_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:129:9`! 1072 |
| 130 | #define TOP_LEFT_LON_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:130:9`! 1088 |
| 131 | #define TOP_RIGHT_LAT_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:131:9`! 1104 |
| 132 | #define TOP_RIGHT_LON_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:132:9`! 1120 |
| 133 | #define BOTTOM_RIGHT_LAT_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:133:9`! 1136 |
| 134 | #define BOTTOM_RIGHT_LON_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:134:9`! 1152 |
| 135 | #define BOTTOM_LEFT_LAT_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:135:9`! 1168 |
| 136 | #define BOTTOM_LEFT_LON_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:136:9`! 1184 |
| 137 | |
| 138 | namespace gdalcxx . . $ gdal/::PSALSARJaxacxx . . $ gdal/PSALSARJaxa/ |
| 139 | { |
| 140 | /* a few useful enums */ |
| 141 | enum eFileTypecxx . . $ gdal/PSALSARJaxa/eFileType# |
| 142 | { |
| 143 | level_11cxx . . $ gdal/PSALSARJaxa/level_11. = 0, |
| 144 | level_15cxx . . $ gdal/PSALSARJaxa/level_15., |
| 145 | level_10cxx . . $ gdal/PSALSARJaxa/level_10., |
| 146 | level_unknowncxx . . $ gdal/PSALSARJaxa/level_unknown. = 999, |
| 147 | }; |
| 148 | |
| 149 | enum ePolarizationcxx . . $ gdal/PSALSARJaxa/ePolarization# |
| 150 | { |
| 151 | hhcxx . . $ gdal/PSALSARJaxa/hh. = 0, |
| 152 | hvcxx . . $ gdal/PSALSARJaxa/hv., |
| 153 | vhcxx . . $ gdal/PSALSARJaxa/vh., |
| 154 | vvcxx . . $ gdal/PSALSARJaxa/vv. |
| 155 | }; |
| 156 | } // namespace gdal::PSALSARJaxa |
| 157 | |
| 158 | using namespace gdalcxx . . $ gdal/::PSALSARJaxa; |
| 159 | |
| 160 | /************************************************************************/ |
| 161 | /* ==================================================================== */ |
| 162 | /* PALSARJaxaDataset */ |
| 163 | /* ==================================================================== */ |
| 164 | /************************************************************************/ |
| 165 | |
| 166 | class PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#; |
| 167 | |
| 168 | class PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset# final : public GDALPamDatasetcxx . . $ GDALPamDataset# |
| 169 | { |
| 170 | friend class PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#; |
| 171 | |
| 172 | private: |
| 173 | GDAL_GCP *pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.; |
| 174 | int nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount.; |
| 175 | eFileTypecxx . . $ gdal/PSALSARJaxa/eFileType# nFileTypecxx . . $ PALSARJaxaDataset#nFileType.; |
| 176 | |
| 177 | public: |
| 178 | PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#PALSARJaxaDataset(49f6e7a06ebc5aa8).(); |
| 179 | ~cxx . . $ PALSARJaxaDataset#`~PALSARJaxaDataset`(ced63f7c635d850d).PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#() override; |
| 180 | |
| 181 | int GetGCPCountcxx . . $ PALSARJaxaDataset#GetGCPCount(b126dc7c1de90089).() override; |
| 182 | const GDAL_GCP *GetGCPscxx . . $ PALSARJaxaDataset#GetGCPs(1fe99069f2353d76).() override; |
| 183 | |
| 184 | static GDALDatasetcxx . . $ GDALDataset# *Opencxx . . $ PALSARJaxaDataset#Open(905b7966ba8c1649).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo); |
| 185 | static int Identifycxx . . $ PALSARJaxaDataset#Identify(48f695ac6b30cd84).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo); |
| 186 | static void ReadMetadatacxx . . $ PALSARJaxaDataset#ReadMetadata(400e65ef57299c0f).(PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset# *poDS, VSILFILE *fp); |
| 187 | }; |
| 188 | |
| 189 | PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#PALSARJaxaDataset(49f6e7a06ebc5aa8).() |
| 190 | : pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.(nullptr), nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount.(0), nFileTypecxx . . $ PALSARJaxaDataset#nFileType.(level_unknowncxx . . $ gdal/PSALSARJaxa/level_unknown.) |
| 191 | { |
| 192 | } |
| 193 | |
| 194 | PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::~cxx . . $ PALSARJaxaDataset#`~PALSARJaxaDataset`(ced63f7c635d850d).PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#() |
| 195 | { |
| 196 | if (nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount. > 0) |
| 197 | { |
| 198 | GDALDeinitGCPs(nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount., pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.); |
| 199 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /************************************************************************/ |
| 204 | /* ==================================================================== */ |
| 205 | /* PALSARJaxaRasterBand */ |
| 206 | /* ==================================================================== */ |
| 207 | /************************************************************************/ |
| 208 | |
| 209 | class PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand# final : public GDALRasterBandcxx . . $ GDALRasterBand# |
| 210 | { |
| 211 | VSILFILE *fpcxx . . $ PALSARJaxaRasterBand#fp.; |
| 212 | ePolarizationcxx . . $ gdal/PSALSARJaxa/ePolarization# nPolarizationcxx . . $ PALSARJaxaRasterBand#nPolarization.; |
| 213 | eFileTypecxx . . $ gdal/PSALSARJaxa/eFileType# nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType.; |
| 214 | int nBitsPerSamplecxx . . $ PALSARJaxaRasterBand#nBitsPerSample.; |
| 215 | int nSamplesPerGroupcxx . . $ PALSARJaxaRasterBand#nSamplesPerGroup.; |
| 216 | int nRecordSizecxx . . $ PALSARJaxaRasterBand#nRecordSize.; |
| 217 | |
| 218 | public: |
| 219 | PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#PALSARJaxaRasterBand(cf9a3409ea7c0cd2).(PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset# *poDS, int nBand, VSILFILE *fp); |
| 220 | ~cxx . . $ PALSARJaxaRasterBand#`~PALSARJaxaRasterBand`(ced63f7c635d850d).PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#() override; |
| 221 | |
| 222 | CPLErr IReadBlockcxx . . $ PALSARJaxaRasterBand#IReadBlock(282c12597d894d0d).(int nBlockXOff, int nBlockYOff, void *pImage) override; |
| 223 | }; |
| 224 | |
| 225 | /************************************************************************/ |
| 226 | /* PALSARJaxaRasterBand() */ |
| 227 | /************************************************************************/ |
| 228 | |
| 229 | PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#::PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#PALSARJaxaRasterBand(cf9a3409ea7c0cd2).(PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset# *poDSIn, |
| 230 | int nBandIn, VSILFILE *fpIn) |
| 231 | : fpcxx . . $ PALSARJaxaRasterBand#fp.(fpIn), nPolarizationcxx . . $ PALSARJaxaRasterBand#nPolarization.(hhcxx . . $ gdal/PSALSARJaxa/hh.), nBitsPerSamplecxx . . $ PALSARJaxaRasterBand#nBitsPerSample.(0), nSamplesPerGroupcxx . . $ PALSARJaxaRasterBand#nSamplesPerGroup.(0), |
| 232 | nRecordSizecxx . . $ PALSARJaxaRasterBand#nRecordSize.(0) |
| 233 | { |
| 234 | poDScxx . . $ GDALRasterBand#poDS. = poDSIn; |
| 235 | nBandcxx . . $ GDALRasterBand#nBand. = nBandIn; |
| 236 | |
| 237 | /* Read image options record to determine the type of data */ |
| 238 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpcxx . . $ PALSARJaxaRasterBand#fp., BITS_PER_SAMPLE_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:103:9`!, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 239 | READ_CHAR_VALcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:72:9`!(nBitsPerSample, BITS_PER_SAMPLE_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:104:9`!, fp); |
| 240 | READ_CHAR_VALcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:72:9`!(nSamplesPerGroup, SAMPLES_PER_GROUP_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:106:9`!, fp); |
| 241 | |
| 242 | if (nBitsPerSamplecxx . . $ PALSARJaxaRasterBand#nBitsPerSample. == 32 && nSamplesPerGroupcxx . . $ PALSARJaxaRasterBand#nSamplesPerGroup. == 2) |
| 243 | { |
| 244 | eDataTypecxx . . $ GDALRasterBand#eDataType. = GDT_CFloat32; |
| 245 | nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. = level_11cxx . . $ gdal/PSALSARJaxa/level_11.; |
| 246 | } |
| 247 | else if (nBitsPerSamplecxx . . $ PALSARJaxaRasterBand#nBitsPerSample. == 8 && nSamplesPerGroupcxx . . $ PALSARJaxaRasterBand#nSamplesPerGroup. == 2) |
| 248 | { |
| 249 | eDataTypecxx . . $ GDALRasterBand#eDataType. = GDT_CInt16; /* should be 2 x signed byte */ |
| 250 | nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. = level_10cxx . . $ gdal/PSALSARJaxa/level_10.; |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | eDataTypecxx . . $ GDALRasterBand#eDataType. = GDT_UInt16; |
| 255 | nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. = level_15cxx . . $ gdal/PSALSARJaxa/level_15.; |
| 256 | } |
| 257 | |
| 258 | poDSIn->nFileTypecxx . . $ PALSARJaxaDataset#nFileType. = nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType.; |
| 259 | |
| 260 | /* Read number of range/azimuth lines */ |
| 261 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpcxx . . $ PALSARJaxaRasterBand#fp., NUMBER_LINES_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:107:9`!, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 262 | READ_CHAR_VALcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:72:9`!(nRasterYSize, NUMBER_LINES_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:108:9`!, fp); |
| 263 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpcxx . . $ PALSARJaxaRasterBand#fp., SAR_DATA_RECORD_LENGTH_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:109:9`!, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 264 | READ_CHAR_VALcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:72:9`!(nRecordSize, SAR_DATA_RECORD_LENGTH_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:110:9`!, fp); |
| 265 | const int nDenom = ((nBitsPerSamplecxx . . $ PALSARJaxaRasterBand#nBitsPerSample. / 8) * nSamplesPerGroupcxx . . $ PALSARJaxaRasterBand#nSamplesPerGroup.); |
| 266 | if (nDenom != 0) |
| 267 | nRasterXSizecxx . . $ GDALRasterBand#nRasterXSize. = |
| 268 | (nRecordSizecxx . . $ PALSARJaxaRasterBand#nRecordSize. - (nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. != level_15cxx . . $ gdal/PSALSARJaxa/level_15. ? SIG_DAT_REC_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:114:9`! |
| 269 | : PROC_DAT_REC_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:115:9`!)) / |
| 270 | nDenom; |
| 271 | |
| 272 | poDSIn->nRasterXSizecxx . . $ GDALDataset#nRasterXSize. = nRasterXSizecxx . . $ GDALRasterBand#nRasterXSize.; |
| 273 | poDSIn->nRasterYSizecxx . . $ GDALDataset#nRasterYSize. = nRasterYSizecxx . . $ GDALRasterBand#nRasterYSize.; |
| 274 | |
| 275 | /* Polarization */ |
| 276 | switch (nBandcxx . . $ GDALRasterBand#nBand.) |
| 277 | { |
| 278 | case 0: |
| 279 | nPolarizationcxx . . $ PALSARJaxaRasterBand#nPolarization. = hhcxx . . $ gdal/PSALSARJaxa/hh.; |
| 280 | SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).("POLARIMETRIC_INTERP", "HH"); |
| 281 | break; |
| 282 | case 1: |
| 283 | nPolarizationcxx . . $ PALSARJaxaRasterBand#nPolarization. = hvcxx . . $ gdal/PSALSARJaxa/hv.; |
| 284 | SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).("POLARIMETRIC_INTERP", "HV"); |
| 285 | break; |
| 286 | case 2: |
| 287 | nPolarizationcxx . . $ PALSARJaxaRasterBand#nPolarization. = vhcxx . . $ gdal/PSALSARJaxa/vh.; |
| 288 | SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).("POLARIMETRIC_INTERP", "VH"); |
| 289 | break; |
| 290 | case 3: |
| 291 | nPolarizationcxx . . $ PALSARJaxaRasterBand#nPolarization. = vvcxx . . $ gdal/PSALSARJaxa/vv.; |
| 292 | SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).("POLARIMETRIC_INTERP", "VV"); |
| 293 | break; |
| 294 | // TODO: What about the default? |
| 295 | } |
| 296 | |
| 297 | /* size of block we can read */ |
| 298 | nBlockXSizecxx . . $ GDALRasterBand#nBlockXSize. = nRasterXSizecxx . . $ GDALRasterBand#nRasterXSize.; |
| 299 | nBlockYSizecxx . . $ GDALRasterBand#nBlockYSize. = 1; |
| 300 | |
| 301 | /* set the file pointer to the first SAR data record */ |
| 302 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fpcxx . . $ PALSARJaxaRasterBand#fp., IMAGE_OPT_DESC_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:112:9`!, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 303 | } |
| 304 | |
| 305 | /************************************************************************/ |
| 306 | /* ~PALSARJaxaRasterBand() */ |
| 307 | /************************************************************************/ |
| 308 | |
| 309 | PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#::~cxx . . $ PALSARJaxaRasterBand#`~PALSARJaxaRasterBand`(ced63f7c635d850d).PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#() |
| 310 | { |
| 311 | if (fpcxx . . $ PALSARJaxaRasterBand#fp.) |
| 312 | VSIFCloseL(fpcxx . . $ PALSARJaxaRasterBand#fp.); |
| 313 | } |
| 314 | |
| 315 | /************************************************************************/ |
| 316 | /* IReadBlock() */ |
| 317 | /************************************************************************/ |
| 318 | |
| 319 | CPLErr PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#::IReadBlockcxx . . $ PALSARJaxaRasterBand#IReadBlock(282c12597d894d0d).(CPL_UNUSEDcxx . . $ `port/cpl_port.h:1040:9`! int nBlockXOff, |
| 320 | int nBlockYOff, void *pImage) |
| 321 | { |
| 322 | int nNumBytes = 0; |
| 323 | if (nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. == level_11cxx . . $ gdal/PSALSARJaxa/level_11.) |
| 324 | { |
| 325 | nNumBytes = 8; |
| 326 | } |
| 327 | else |
| 328 | { |
| 329 | nNumBytes = 2; |
| 330 | } |
| 331 | |
| 332 | const vsi_l_offset nOffset = |
| 333 | IMAGE_OPT_DESC_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:112:9`! + |
| 334 | (static_cast<vsi_l_offset>(nBlockYOff - 1) * nRecordSizecxx . . $ PALSARJaxaRasterBand#nRecordSize.) + |
| 335 | (nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. == level_11cxx . . $ gdal/PSALSARJaxa/level_11. ? SIG_DAT_REC_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:114:9`! : PROC_DAT_REC_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:115:9`!); |
| 336 | |
| 337 | VSIFSeekL(fpcxx . . $ PALSARJaxaRasterBand#fp., nOffset, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 338 | VSIFReadL(pImage, nNumBytes, nRasterXSizecxx . . $ GDALRasterBand#nRasterXSize., fpcxx . . $ PALSARJaxaRasterBand#fp.); |
| 339 | |
| 340 | #ifdef CPL_LSBcxx . . $ `port/cpl_port.h:608:9`! |
| 341 | if (nFileTypecxx . . $ PALSARJaxaRasterBand#nFileType. == level_11cxx . . $ gdal/PSALSARJaxa/level_11.) |
| 342 | GDALSwapWords(pImage, 4, nBlockXSizecxx . . $ GDALRasterBand#nBlockXSize. * 2, 4); |
| 343 | else |
| 344 | GDALSwapWords(pImage, 2, nBlockXSizecxx . . $ GDALRasterBand#nBlockXSize., 2); |
| 345 | #endif |
| 346 | |
| 347 | return CE_None; |
| 348 | } |
| 349 | |
| 350 | /************************************************************************/ |
| 351 | /* ==================================================================== */ |
| 352 | /* PALSARJaxaDataset */ |
| 353 | /* ==================================================================== */ |
| 354 | /************************************************************************/ |
| 355 | |
| 356 | /************************************************************************/ |
| 357 | /* ReadMetadata() */ |
| 358 | /************************************************************************/ |
| 359 | |
| 360 | int PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::GetGCPCountcxx . . $ PALSARJaxaDataset#GetGCPCount(b126dc7c1de90089).() |
| 361 | { |
| 362 | return nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount.; |
| 363 | } |
| 364 | |
| 365 | /************************************************************************/ |
| 366 | /* GetGCPs() */ |
| 367 | /************************************************************************/ |
| 368 | |
| 369 | const GDAL_GCP *PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::GetGCPscxx . . $ PALSARJaxaDataset#GetGCPs(1fe99069f2353d76).() |
| 370 | { |
| 371 | return pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.; |
| 372 | } |
| 373 | |
| 374 | /************************************************************************/ |
| 375 | /* ReadMetadata() */ |
| 376 | /************************************************************************/ |
| 377 | |
| 378 | void PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::ReadMetadatacxx . . $ PALSARJaxaDataset#ReadMetadata(400e65ef57299c0f).(PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset# *poDS, VSILFILE *fp) |
| 379 | { |
| 380 | /* seek to the end of the leader file descriptor */ |
| 381 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, LEADER_FILE_DESCRIPTOR_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:118:9`!, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 382 | if (poDS->nFileTypecxx . . $ PALSARJaxaDataset#nFileType. == level_10cxx . . $ gdal/PSALSARJaxa/level_10.) |
| 383 | { |
| 384 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("PRODUCT_LEVEL", "1.0"); |
| 385 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("AZIMUTH_LOOKS", "1.0"); |
| 386 | } |
| 387 | else if (poDS->nFileTypecxx . . $ PALSARJaxaDataset#nFileType. == level_11cxx . . $ gdal/PSALSARJaxa/level_11.) |
| 388 | { |
| 389 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("PRODUCT_LEVEL", "1.1"); |
| 390 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("AZIMUTH_LOOKS", "1.0"); |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("PRODUCT_LEVEL", "1.5"); |
| 395 | /* extract equivalent number of looks */ |
| 396 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).( |
| 397 | fp, LEADER_FILE_DESCRIPTOR_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:118:9`! + EFFECTIVE_LOOKS_AZIMUTH_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:122:9`!, |
| 398 | SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 399 | char szENL[17]; |
| 400 | double dfENL; |
| 401 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfENL, 16, fp); |
| 402 | snprintf(szENL, sizeof(szENL), "%-16.1f", dfENL); |
| 403 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("AZIMUTH_LOOKS", szENL); |
| 404 | |
| 405 | /* extract pixel spacings */ |
| 406 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, |
| 407 | LEADER_FILE_DESCRIPTOR_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:118:9`! + DATA_SET_SUMMARY_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:119:9`! + |
| 408 | PIXEL_SPACING_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:126:9`!, |
| 409 | SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 410 | double dfPixelSpacing; |
| 411 | double dfLineSpacing; |
| 412 | char szPixelSpacing[33]; |
| 413 | char szLineSpacing[33]; |
| 414 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfPixelSpacing, 16, fp); |
| 415 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfLineSpacing, 16, fp); |
| 416 | snprintf(szPixelSpacing, sizeof(szPixelSpacing), "%-32.1f", |
| 417 | dfPixelSpacing); |
| 418 | snprintf(szLineSpacing, sizeof(szLineSpacing), "%-32.1f", |
| 419 | dfLineSpacing); |
| 420 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("PIXEL_SPACING", szPixelSpacing); |
| 421 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("LINE_SPACING", szPixelSpacing); |
| 422 | |
| 423 | /* Alphanumeric projection name */ |
| 424 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, |
| 425 | LEADER_FILE_DESCRIPTOR_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:118:9`! + DATA_SET_SUMMARY_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:119:9`! + |
| 426 | ALPHANUMERIC_PROJECTION_NAME_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:128:9`!, |
| 427 | SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 428 | char szProjName[33]; |
| 429 | READ_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:84:9`!(szProjName, 32, fp); |
| 430 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("PROJECTION_NAME", szProjName); |
| 431 | |
| 432 | /* Extract corner GCPs */ |
| 433 | poDS->nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount. = 4; |
| 434 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList. = |
| 435 | (GDAL_GCP *)CPLCalloc(sizeof(GDAL_GCP), poDS->nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount.); |
| 436 | GDALInitGCPs(poDS->nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount., poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.); |
| 437 | |
| 438 | /* setup the GCPs */ |
| 439 | int i; |
| 440 | for (i = 0; i < poDS->nGCPCountcxx . . $ PALSARJaxaDataset#nGCPCount.; i++) |
| 441 | { |
| 442 | char szID[30]; |
| 443 | snprintf(szID, sizeof(szID), "%d", i + 1); |
| 444 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[i].pszId); |
| 445 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[i].pszId = CPLStrdup(szID); |
| 446 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[i].dfGCPZ = 0.0; |
| 447 | } |
| 448 | |
| 449 | double dfTemp = 0.0; |
| 450 | /* seek to start of GCPs */ |
| 451 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, |
| 452 | LEADER_FILE_DESCRIPTOR_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:118:9`! + DATA_SET_SUMMARY_LENGTHcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:119:9`! + |
| 453 | TOP_LEFT_LAT_OFFSETcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:129:9`!, |
| 454 | SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 455 | |
| 456 | /* top-left GCP */ |
| 457 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 458 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[0].dfGCPY = dfTemp; |
| 459 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 460 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[0].dfGCPX = dfTemp; |
| 461 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[0].dfGCPLine = 0.5; |
| 462 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[0].dfGCPPixel = 0.5; |
| 463 | |
| 464 | /* top right GCP */ |
| 465 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 466 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[1].dfGCPY = dfTemp; |
| 467 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 468 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[1].dfGCPX = dfTemp; |
| 469 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[1].dfGCPLine = 0.5; |
| 470 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[1].dfGCPPixel = poDS->nRasterYSizecxx . . $ GDALDataset#nRasterYSize. - 0.5; |
| 471 | |
| 472 | /* bottom right GCP */ |
| 473 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 474 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[2].dfGCPY = dfTemp; |
| 475 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 476 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[2].dfGCPX = dfTemp; |
| 477 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[2].dfGCPLine = poDS->nRasterYSizecxx . . $ GDALDataset#nRasterYSize. - 0.5; |
| 478 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[2].dfGCPPixel = poDS->nRasterYSizecxx . . $ GDALDataset#nRasterYSize. - 0.5; |
| 479 | |
| 480 | /* bottom left GCP */ |
| 481 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 482 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[3].dfGCPY = dfTemp; |
| 483 | READ_CHAR_FLOATcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:62:9`!(dfTemp, 16, fp); |
| 484 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[3].dfGCPX = dfTemp; |
| 485 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[3].dfGCPLine = poDS->nRasterYSizecxx . . $ GDALDataset#nRasterYSize. - 0.5; |
| 486 | poDS->pasGCPListcxx . . $ PALSARJaxaDataset#pasGCPList.[3].dfGCPPixel = 0.5; |
| 487 | } |
| 488 | |
| 489 | /* some generic metadata items */ |
| 490 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("SENSOR_BAND", "L"); /* PALSAR is L-band */ |
| 491 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("RANGE_LOOKS", "1.0"); |
| 492 | |
| 493 | /* Check if this is a PolSAR dataset */ |
| 494 | if (poDS->GetRasterCountcxx . . $ GDALDataset#GetRasterCount(455f465bc33b4cdf).() == 4) |
| 495 | { |
| 496 | /* PALSAR data is only available from JAXA in Scattering Matrix form */ |
| 497 | poDS->SetMetadataItemcxx . . $ GDALPamDataset#SetMetadataItem(216fc8eb9053a851).("MATRIX_REPRESENTATION", "SCATTERING"); |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | /************************************************************************/ |
| 502 | /* Identify() */ |
| 503 | /************************************************************************/ |
| 504 | |
| 505 | static void ReadWordcxx . . $ ReadWord(66b127da452d0365).(VSILFILE *fp, int *pVal) |
| 506 | { |
| 507 | READ_WORDcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:31:9`!(fp, *pVal); |
| 508 | } |
| 509 | |
| 510 | static void ReadBytecxx . . $ ReadByte(66b127da452d0365).(VSILFILE *fp, int *pVal) |
| 511 | { |
| 512 | READ_BYTEcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:55:9`!(fp, *pVal); |
| 513 | } |
| 514 | |
| 515 | int PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::Identifycxx . . $ PALSARJaxaDataset#Identify(48f695ac6b30cd84).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo) |
| 516 | { |
| 517 | if (poOpenInfo->nHeaderBytescxx . . $ GDALOpenInfo#nHeaderBytes. < 360 || poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL. == nullptr) |
| 518 | return 0; |
| 519 | |
| 520 | /* First, check that this is a PALSAR image indeed */ |
| 521 | if (!STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!((char *)(poOpenInfo->pabyHeader + 60), "AL")) |
| 522 | { |
| 523 | return 0; |
| 524 | } |
| 525 | const stdcxx . . $ std/::string osBasename = CPLGetBasenameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.); |
| 526 | if (osBasename.size() < 9 || |
| 527 | !STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(osBasename.c_str() + 4, "ALPSR")) |
| 528 | { |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | /* Check that this is a volume directory file */ |
| 533 | int nRecordSeq = 0; |
| 534 | int nRecordSubtype = 0; |
| 535 | int nRecordType = 0; |
| 536 | int nSecondSubtype = 0; |
| 537 | int nThirdSubtype = 0; |
| 538 | int nLengthRecord = 0; |
| 539 | |
| 540 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 541 | |
| 542 | ReadWordcxx . . $ ReadWord(66b127da452d0365).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., &nRecordSeq); |
| 543 | ReadBytecxx . . $ ReadByte(66b127da452d0365).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., &nRecordSubtype); |
| 544 | ReadBytecxx . . $ ReadByte(66b127da452d0365).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., &nRecordType); |
| 545 | ReadBytecxx . . $ ReadByte(66b127da452d0365).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., &nSecondSubtype); |
| 546 | ReadBytecxx . . $ ReadByte(66b127da452d0365).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., &nThirdSubtype); |
| 547 | ReadWordcxx . . $ ReadWord(66b127da452d0365).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., &nLengthRecord); |
| 548 | |
| 549 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL., 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 550 | |
| 551 | /* Check that we have the right record */ |
| 552 | if (nRecordSeq == 1 && nRecordSubtype == 192 && nRecordType == 192 && |
| 553 | nSecondSubtype == 18 && nThirdSubtype == 18 && nLengthRecord == 360) |
| 554 | { |
| 555 | return 1; |
| 556 | } |
| 557 | |
| 558 | return 0; |
| 559 | } |
| 560 | |
| 561 | /************************************************************************/ |
| 562 | /* Open() */ |
| 563 | /************************************************************************/ |
| 564 | GDALDatasetcxx . . $ GDALDataset# *PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::Opencxx . . $ PALSARJaxaDataset#Open(905b7966ba8c1649).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo) |
| 565 | { |
| 566 | /* Check that this actually is a JAXA PALSAR product */ |
| 567 | if (!PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::Identifycxx . . $ PALSARJaxaDataset#Identify(48f695ac6b30cd84).(poOpenInfo)) |
| 568 | return nullptr; |
| 569 | |
| 570 | /* -------------------------------------------------------------------- */ |
| 571 | /* Confirm the requested access is supported. */ |
| 572 | /* -------------------------------------------------------------------- */ |
| 573 | if (poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. == GA_Update) |
| 574 | { |
| 575 | ReportUpdateNotSupportedByDrivercxx . . $ GDALDataset#ReportUpdateNotSupportedByDriver(85c52e162fed56f9).("JAXAPALSAR"); |
| 576 | return nullptr; |
| 577 | } |
| 578 | |
| 579 | PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset# *poDS = new PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#(); |
| 580 | |
| 581 | /* Get the suffix of the filename, we'll need this */ |
| 582 | char *pszSuffix = |
| 583 | VSIStrdup((char *)(CPLGetFilename(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.) + 3)); |
| 584 | |
| 585 | /* Try to read each of the polarizations */ |
| 586 | const size_t nImgFileLen = |
| 587 | CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).size() + strlen(pszSuffix) + |
| 588 | 8; |
| 589 | char *pszImgFile = (char *)CPLMalloc(nImgFileLen); |
| 590 | |
| 591 | int nBandNum = 1; |
| 592 | |
| 593 | /* HH */ |
| 594 | snprintf(pszImgFile, nImgFileLen, "%s%sIMG-HH%s", |
| 595 | CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).c_str(), SEP_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:26:9`!, |
| 596 | pszSuffix); |
| 597 | VSILFILE *fpHH = VSIFOpenL(pszImgFile, "rb"); |
| 598 | if (fpHH != nullptr) |
| 599 | { |
| 600 | poDS->SetBandcxx . . $ GDALDataset#SetBand(f7464fdc0fe5b8c5).(nBandNum, new PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#PALSARJaxaRasterBand(cf9a3409ea7c0cd2).(poDS, 0, fpHH)); |
| 601 | nBandNum++; |
| 602 | } |
| 603 | |
| 604 | /* HV */ |
| 605 | snprintf(pszImgFile, nImgFileLen, "%s%sIMG-HV%s", |
| 606 | CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).c_str(), SEP_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:26:9`!, |
| 607 | pszSuffix); |
| 608 | VSILFILE *fpHV = VSIFOpenL(pszImgFile, "rb"); |
| 609 | if (fpHV != nullptr) |
| 610 | { |
| 611 | poDS->SetBandcxx . . $ GDALDataset#SetBand(f7464fdc0fe5b8c5).(nBandNum, new PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#PALSARJaxaRasterBand(cf9a3409ea7c0cd2).(poDS, 1, fpHV)); |
| 612 | nBandNum++; |
| 613 | } |
| 614 | |
| 615 | /* VH */ |
| 616 | snprintf(pszImgFile, nImgFileLen, "%s%sIMG-VH%s", |
| 617 | CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).c_str(), SEP_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:26:9`!, |
| 618 | pszSuffix); |
| 619 | VSILFILE *fpVH = VSIFOpenL(pszImgFile, "rb"); |
| 620 | if (fpVH != nullptr) |
| 621 | { |
| 622 | poDS->SetBandcxx . . $ GDALDataset#SetBand(f7464fdc0fe5b8c5).(nBandNum, new PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#PALSARJaxaRasterBand(cf9a3409ea7c0cd2).(poDS, 2, fpVH)); |
| 623 | nBandNum++; |
| 624 | } |
| 625 | |
| 626 | /* VV */ |
| 627 | snprintf(pszImgFile, nImgFileLen, "%s%sIMG-VV%s", |
| 628 | CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).c_str(), SEP_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:26:9`!, |
| 629 | pszSuffix); |
| 630 | VSILFILE *fpVV = VSIFOpenL(pszImgFile, "rb"); |
| 631 | if (fpVV != nullptr) |
| 632 | { |
| 633 | poDS->SetBandcxx . . $ GDALDataset#SetBand(f7464fdc0fe5b8c5).(nBandNum, new PALSARJaxaRasterBandcxx . . $ PALSARJaxaRasterBand#PALSARJaxaRasterBand(cf9a3409ea7c0cd2).(poDS, 3, fpVV)); |
| 634 | /* nBandNum++; */ |
| 635 | } |
| 636 | |
| 637 | VSIFree(pszImgFile); |
| 638 | |
| 639 | /* did we get at least one band? */ |
| 640 | if (fpVV == nullptr && fpVH == nullptr && fpHV == nullptr && |
| 641 | fpHH == nullptr) |
| 642 | { |
| 643 | CPLError( |
| 644 | CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 645 | "Unable to find any image data. Aborting opening as PALSAR image."); |
| 646 | delete poDS; |
| 647 | VSIFree(pszSuffix); |
| 648 | return nullptr; |
| 649 | } |
| 650 | |
| 651 | /* Level 1.0 products are not supported */ |
| 652 | if (poDS->nFileTypecxx . . $ PALSARJaxaDataset#nFileType. == level_10cxx . . $ gdal/PSALSARJaxa/level_10.) |
| 653 | { |
| 654 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 655 | "ALOS PALSAR Level 1.0 products are not supported. Aborting " |
| 656 | "opening as PALSAR image."); |
| 657 | delete poDS; |
| 658 | VSIFree(pszSuffix); |
| 659 | return nullptr; |
| 660 | } |
| 661 | |
| 662 | /* read metadata from Leader file. */ |
| 663 | const size_t nLeaderFilenameLen = |
| 664 | strlen(CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).c_str()) + |
| 665 | strlen(pszSuffix) + 5; |
| 666 | char *pszLeaderFilename = (char *)CPLMalloc(nLeaderFilenameLen); |
| 667 | snprintf(pszLeaderFilename, nLeaderFilenameLen, "%s%sLED%s", |
| 668 | CPLGetDirnameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.).c_str(), SEP_STRINGcxx . . $ `frmts/jaxapalsar/jaxapalsardataset.cpp:26:9`!, |
| 669 | pszSuffix); |
| 670 | |
| 671 | VSILFILE *fpLeader = VSIFOpenL(pszLeaderFilename, "rb"); |
| 672 | /* check if the leader is actually present */ |
| 673 | if (fpLeader != nullptr) |
| 674 | { |
| 675 | ReadMetadatacxx . . $ PALSARJaxaDataset#ReadMetadata(400e65ef57299c0f).(poDS, fpLeader); |
| 676 | VSIFCloseL(fpLeader); |
| 677 | } |
| 678 | |
| 679 | VSIFree(pszLeaderFilename); |
| 680 | |
| 681 | VSIFree(pszSuffix); |
| 682 | |
| 683 | /* -------------------------------------------------------------------- */ |
| 684 | /* Initialize any PAM information. */ |
| 685 | /* -------------------------------------------------------------------- */ |
| 686 | poDS->SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.); |
| 687 | poDS->TryLoadXMLcxx . . $ GDALPamDataset#TryLoadXML(3a22ad7ac1be656d).(); |
| 688 | |
| 689 | /* -------------------------------------------------------------------- */ |
| 690 | /* Check for overviews. */ |
| 691 | /* -------------------------------------------------------------------- */ |
| 692 | poDS->oOvManagercxx . . $ GDALDataset#oOvManager..Initializecxx . . $ GDALDefaultOverviews#Initialize(96d7e00266b2f754).(poDS, poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.); |
| 693 | |
| 694 | return poDS; |
| 695 | } |
| 696 | |
| 697 | /************************************************************************/ |
| 698 | /* GDALRegister_PALSARJaxa() */ |
| 699 | /************************************************************************/ |
| 700 | |
| 701 | void GDALRegister_PALSARJaxacxx . . $ GDALRegister_PALSARJaxa(49f6e7a06ebc5aa8).() |
| 702 | |
| 703 | { |
| 704 | if (GDALGetDriverByName("JAXAPALSAR") != nullptr) |
| 705 | return; |
| 706 | |
| 707 | GDALDrivercxx . . $ GDALDriver# *poDriver = new GDALDrivercxx . . $ GDALDriver#GDALDriver(49f6e7a06ebc5aa8).(); |
| 708 | |
| 709 | poDriver->SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).("JAXAPALSAR"); |
| 710 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_RASTERcxx . . $ `gcore/gdal.h:678:9`!, "YES"); |
| 711 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_LONGNAMEcxx . . $ `gcore/gdal.h:443:9`!, |
| 712 | "JAXA PALSAR Product Reader (Level 1.1/1.5)"); |
| 713 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_HELPTOPICcxx . . $ `gcore/gdal.h:446:9`!, "drivers/raster/palsar.html"); |
| 714 | |
| 715 | poDriver->pfnOpencxx . . $ GDALDriver#pfnOpen. = PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::Opencxx . . $ PALSARJaxaDataset#Open(905b7966ba8c1649).; |
| 716 | poDriver->pfnIdentifycxx . . $ GDALDriver#pfnIdentify. = PALSARJaxaDatasetcxx . . $ PALSARJaxaDataset#::Identifycxx . . $ PALSARJaxaDataset#Identify(48f695ac6b30cd84).; |
| 717 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_VIRTUALIOcxx . . $ `gcore/gdal.h:674:9`!, "YES"); |
| 718 | |
| 719 | GetGDALDriverManager()->RegisterDrivercxx . . $ GDALDriverManager#RegisterDriver(ed1dabcc01594d64).(poDriver); |
| 720 | } |