| 72 | |
| 73 | |
| 74 | void NitfFileReader::open() |
| 75 | { |
| 76 | if (nitf::Reader::getNITFVersion(m_filename.c_str()) == NITF_VER_UNKNOWN) |
| 77 | throw error("Unable to determine NITF file version"); |
| 78 | |
| 79 | // read the major NITF data structures, courtesy Nitro |
| 80 | try |
| 81 | { |
| 82 | m_io.reset(new nitf::IOHandle(m_filename)); |
| 83 | } |
| 84 | catch (nitf::NITFException& e) |
| 85 | { |
| 86 | throw error("unable to open NITF file (" + e.getMessage() + ")"); |
| 87 | } |
| 88 | try |
| 89 | { |
| 90 | nitf::Reader reader; |
| 91 | m_record = reader.read(*m_io); |
| 92 | } |
| 93 | catch (nitf::NITFException& e) |
| 94 | { |
| 95 | throw error("unable to read NITF file (" + e.getMessage() + ")"); |
| 96 | } |
| 97 | |
| 98 | // find the image segment corresponding the the lidar data, if any |
| 99 | // NOTE: We don't DO anything with the image segment, we just check |
| 100 | // that it exists. |
| 101 | const bool imageOK = locateLidarImageSegment(); |
| 102 | if (REQUIRE_LIDAR_SEGMENTS && !imageOK) |
| 103 | { |
| 104 | throw error("Unable to find lidar-compatible image " |
| 105 | "segment in NITF file"); |
| 106 | } |
| 107 | |
| 108 | // find the LAS data hidden in a DE field, if any |
| 109 | const bool dataOK = locateLidarDataSegment(); |
| 110 | if (REQUIRE_LIDAR_SEGMENTS && !dataOK) |
| 111 | { |
| 112 | throw error("Unable to find LIDARA data extension segment " |
| 113 | "in NITF file"); |
| 114 | } |
| 115 | |
| 116 | m_validLidarSegments = dataOK && imageOK; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | void NitfFileReader::close() |
no test coverage detected