| 126 | } |
| 127 | |
| 128 | BOOL LASreaderStored::reopen() |
| 129 | { |
| 130 | if (streaminarray) |
| 131 | { |
| 132 | streaminarray->seek(0); |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | if (streamoutarray == 0) |
| 137 | { |
| 138 | laserror("no streamoutarray"); |
| 139 | return FALSE; |
| 140 | } |
| 141 | |
| 142 | if (streamoutarray->getSize() == 0) |
| 143 | { |
| 144 | laserror("nothing stored in streamoutarray"); |
| 145 | return FALSE; |
| 146 | } |
| 147 | |
| 148 | if (Endian::IS_LITTLE_ENDIAN) |
| 149 | streaminarray = new ByteStreamInArrayLE(streamoutarray->takeData(), streamoutarray->getSize()); |
| 150 | else |
| 151 | streaminarray = new ByteStreamInArrayBE(streamoutarray->takeData(), streamoutarray->getSize()); |
| 152 | |
| 153 | if (streaminarray == 0) |
| 154 | { |
| 155 | laserror("creating streaminarray"); |
| 156 | return FALSE; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // create the LASreader |
| 161 | |
| 162 | if (lasreader) delete lasreader; |
| 163 | lasreader = 0; |
| 164 | |
| 165 | LASreaderLAS* lasreaderlas = new LASreaderLAS(opener); |
| 166 | |
| 167 | if (lasreaderlas == 0) |
| 168 | { |
| 169 | laserror("allocating lasreaderlas"); |
| 170 | return FALSE; |
| 171 | } |
| 172 | |
| 173 | if (!lasreaderlas->open(streaminarray)) |
| 174 | { |
| 175 | delete lasreaderlas; |
| 176 | lasreaderlas = 0; |
| 177 | laserror("opening lasreaderlas from streaminarray"); |
| 178 | return FALSE; |
| 179 | } |
| 180 | |
| 181 | lasreaderlas->set_delete_stream(FALSE); |
| 182 | |
| 183 | lasreader = lasreaderlas; |
| 184 | |
| 185 | header = lasreader->header; |