Changeset 652:34ac9fdad9dc
- Timestamp:
- 05/16/08 15:58:00 (2 years ago)
- Branch:
- default
- Convert:
- svn:1766ff46-f334-0410-ab20-d63176f87757/trunk@719
- Files:
-
- 8 edited
-
include/liblas/detail/writer.hpp (modified) (1 diff)
-
include/liblas/detail/writer10.hpp (modified) (1 diff)
-
include/liblas/detail/writer11.hpp (modified) (1 diff)
-
src/detail/reader10.cpp (modified) (6 diffs)
-
src/detail/reader11.cpp (modified) (1 diff)
-
src/detail/writer10.cpp (modified) (4 diffs)
-
src/detail/writer11.cpp (modified) (3 diffs)
-
src/lasheader.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
include/liblas/detail/writer.hpp
r586 r652 60 60 virtual void WritePointRecord(PointRecord const& record) = 0; 61 61 virtual void WritePointRecord(PointRecord const& record, double const& time) = 0; 62 63 virtual void WriteVLR(LASHeader const& header) = 0; 62 64 63 65 // TODO: fix constness -
include/liblas/detail/writer10.hpp
r586 r652 64 64 void WritePointRecord(PointRecord const& record, double const& time); 65 65 66 void WriteVLR(LASHeader const& header); 66 67 // TODO: fix constness 67 68 std::ostream& GetStream(); -
include/liblas/detail/writer11.hpp
r586 r652 63 63 void WritePointRecord(PointRecord const& record); 64 64 void WritePointRecord(PointRecord const& record, double const& time); 65 65 66 void WriteVLR(LASHeader const& header); 66 67 // TODO: fix constness 67 68 std::ostream& GetStream(); -
src/detail/reader10.cpp
r649 r652 220 220 221 221 m_ifs.seekg(header.GetHeaderSize(), std::ios::beg); 222 222 223 223 for (uint32_t i = 0; i < header.GetRecordsCount(); ++i) 224 224 { … … 245 245 // Testing reading of VLRecords with GeoKeys 246 246 ReadGeoreference(header); 247 248 247 return true; 249 248 } … … 255 254 #else 256 255 // TODO: Under construction 257 VLRHeader vlrh = { 0 }; 256 258 257 std::string const uid("LASF_Projection"); 259 258 ST_TIFF *st = ST_Create(); 260 259 261 // m_ifs.seekg(header.GetHeaderSize(), std::ios::beg);262 263 printf("Records count: %d\n", (int)header.GetRecordsCount());264 265 260 for (uint16_t i = 0; i < header.GetRecordsCount(); ++i) 266 261 { 267 262 LASVLR record = header.GetVLR(i); 268 263 std::vector<uint8_t> data = record.GetData(); 269 270 printf("record.GetUserId(): '%s' record.GetRecordId: %d\n", record.GetUserId(true).c_str(), record.GetRecordId());271 264 if (uid == record.GetUserId(true).c_str() && 34735 == record.GetRecordId()) 272 265 { 273 printf("uid == record.GetUserId(true).c_str() && 34735 == record.GetRecordId()\n");274 275 266 int16_t count = data.size()/sizeof(int16_t); 276 277 printf("count for int16_t: %d\n", count);278 279 267 ST_SetKey( st, record.GetRecordId(), count, STT_SHORT, 280 268 &(data[0]) ); … … 283 271 if (uid == record.GetUserId(true).c_str() && 34736 == record.GetRecordId()) 284 272 { 285 printf("uid == record.GetUserId(true).c_str() && 34736 == record.GetRecordId()\n");286 287 273 int count = data.size() / sizeof(double); 288 printf("count for int: %d\n", count);289 290 274 ST_SetKey( st, record.GetRecordId(), count, STT_DOUBLE, 291 275 &(data[0]) ); … … 294 278 if (uid == record.GetUserId(true).c_str() && 34737 == record.GetRecordId()) 295 279 { 296 printf("uid == record.GetUserId(true).c_str() && 34737 == record.GetRecordId()\n");297 298 280 uint8_t count = data.size()/sizeof(uint8_t); 299 300 printf("count for string: %d data.size(): %d", count, (int)data.size());301 281 ST_SetKey( st, record.GetRecordId(), count, STT_ASCII, 302 282 &(data[0]) ); … … 305 285 306 286 GTIF *gtif = GTIFNewSimpleTags( st ); 307 308 //GTIFPrint(gtif,0,0);309 310 287 GTIFDefn defn; 311 288 if (GTIFGetDefn(gtif, &defn)) -
src/detail/reader11.cpp
r649 r652 297 297 } 298 298 299 bool ReaderImpl::ReadVLR(LASHeader& header) 300 { 301 // TODO: To be implemented 299 bool ReaderImpl::ReadVLR(LASHeader& header) { 300 302 301 VLRHeader vlrh = { 0 }; 303 LASVLR vlr; 304 305 // TODO: To be removed, when objects are used 306 UNREFERENCED_PARAMETER(header); 307 UNREFERENCED_PARAMETER(vlrh); 308 UNREFERENCED_PARAMETER(vlr); 302 303 m_ifs.seekg(header.GetHeaderSize(), std::ios::beg); 304 305 for (uint32_t i = 0; i < header.GetRecordsCount(); ++i) 306 { 307 read_n(vlrh, m_ifs, sizeof(VLRHeader)); 308 309 int16_t count = vlrh.recordLengthAfterHeader; 310 311 std::vector<uint8_t> data; 312 data.resize( count ); 313 314 read_n(data.front(), m_ifs, count ); 315 316 LASVLR vlr; 317 vlr.SetReserved(vlrh.reserved); 318 vlr.SetUserId(std::string(vlrh.userId)); 319 vlr.SetDescription(std::string(vlrh.description)); 320 vlr.SetRecordLength(vlrh.recordLengthAfterHeader); 321 vlr.SetRecordId(vlrh.recordId); 322 vlr.SetData(data); 323 324 header.AddVLR(vlr); 325 } 309 326 310 327 return true; -
src/detail/writer10.cpp
r588 r652 149 149 150 150 // 14. Offset to data 151 // At this point, no variable length records are written, so 152 // data offset is equal to (header size + data start signature size): 153 // 227 + 2 = 229 154 // TODO: This value must be updated after new variable length record is added. 155 uint32_t const dataSignatureSize = 2; 156 n4 = header.GetHeaderSize() + dataSignatureSize; 157 assert(229 <= n4); 151 n4 = header.GetDataOffset(); 158 152 detail::write_n(m_ofs, n4, sizeof(n4)); 159 153 … … 205 199 detail::write_n(m_ofs, header.GetMaxZ(), sizeof(double)); 206 200 detail::write_n(m_ofs, header.GetMinZ(), sizeof(double)); 207 201 202 WriteVLR(header); 203 204 uint8_t const sgn1 = 0xCC; 205 uint8_t const sgn2 = 0xDD; 206 detail::write_n(m_ofs, sgn1, sizeof(uint8_t)); 207 detail::write_n(m_ofs, sgn2, sizeof(uint8_t)); 208 208 209 // If we already have points, we're going to put it at the end of the file. 209 210 // If we don't have any points, we're going to leave it where it is. … … 228 229 void WriterImpl::WritePointRecord(detail::PointRecord const& record) 229 230 { 230 // Write point data record format 0231 if (0 == m_pointCount)232 {233 // Two bytes of point data start signature, required by LAS 1.0234 uint8_t const sgn1 = 0xCC;235 uint8_t const sgn2 = 0xDD;236 detail::write_n(m_ofs, sgn1, sizeof(uint8_t));237 detail::write_n(m_ofs, sgn2, sizeof(uint8_t));238 }239 231 240 232 // TODO: Static assert would be better … … 257 249 } 258 250 251 void WriterImpl::WriteVLR(LASHeader const& header) 252 { 253 254 m_ofs.seekp(header.GetHeaderSize(), std::ios::beg); 255 256 for (uint32_t i = 0; i < header.GetRecordsCount(); ++i) 257 { 258 259 LASVLR vlr = header.GetVLR(i); 260 261 detail::write_n(m_ofs, vlr.GetReserved(), sizeof(uint16_t)); 262 detail::write_n(m_ofs, vlr.GetUserId(true).c_str(), 16); 263 detail::write_n(m_ofs, vlr.GetRecordId(), sizeof(uint16_t)); 264 detail::write_n(m_ofs, vlr.GetRecordLength(), sizeof(uint16_t)); 265 detail::write_n(m_ofs, vlr.GetDescription(true).c_str(), 32); 266 std::vector<uint8_t> data = vlr.GetData(); 267 detail::write_n(m_ofs, data.front(), data.size()); 268 } 269 270 } 259 271 std::ostream& WriterImpl::GetStream() 260 272 { -
src/detail/writer11.cpp
r588 r652 155 155 // so data offset is equal to header size (227) 156 156 // TODO: This value must be updated after new variable length record is added. 157 n4 = header.Get HeaderSize();157 n4 = header.GetDataOffset(); 158 158 detail::write_n(m_ofs, n4, sizeof(n4)); 159 159 … … 206 206 detail::write_n(m_ofs, header.GetMinZ(), sizeof(double)); 207 207 208 WriteVLR(header); 209 208 210 // If we already have points, we're going to put it at the end of the file. 209 211 // If we don't have any points, we're going to leave it where it is. 210 212 if (m_pointCount != 0) 211 213 m_ofs.seekp(0, std::ios::end); 214 215 212 216 } 213 217 … … 246 250 } 247 251 252 void WriterImpl::WriteVLR(LASHeader const& header) 253 { 254 printf("Writing VLR records in writer11.cpp... \n"); 255 256 m_ofs.seekp(header.GetHeaderSize(), std::ios::beg); 257 258 for (uint32_t i = 0; i < header.GetRecordsCount(); ++i) 259 { 260 261 LASVLR vlr = header.GetVLR(i); 262 263 detail::write_n(m_ofs, vlr.GetReserved(), sizeof(uint16_t)); 264 detail::write_n(m_ofs, vlr.GetUserId(true).c_str(), 16); 265 detail::write_n(m_ofs, vlr.GetRecordId(), sizeof(uint16_t)); 266 detail::write_n(m_ofs, vlr.GetRecordLength(), sizeof(uint16_t)); 267 detail::write_n(m_ofs, vlr.GetDescription(true).c_str(), 32); 268 std::vector<uint8_t> data = vlr.GetData(); 269 detail::write_n(m_ofs, data.front(), data.size()); 270 } 271 272 } 273 248 274 std::ostream& WriterImpl::GetStream() 249 275 { -
src/lasheader.cpp
r649 r652 129 129 m_dataOffset = rhs.m_dataOffset; 130 130 m_recordsCount = rhs.m_recordsCount; 131 // m_recordsCount = 0; 131 132 m_dataFormatId = rhs.m_dataFormatId; 132 133 m_dataRecordLen = rhs.m_dataRecordLen; … … 498 499 { 499 500 m_vlrs.push_back(v); 500 m_dataRecordLen = static_cast<uint16_t>(m_vlrs.size()); 501 uint32_t size; 502 if (m_vlrs.size() > m_recordsCount ) { 503 m_recordsCount = m_vlrs.size(); 504 size = GetDataOffset() + 2 + 16 + 2 + 2 + 32 + v.GetData().size()*sizeof(uint8_t); 505 SetDataOffset(size); 506 } 501 507 } 502 508 … … 511 517 512 518 m_vlrs.erase(m_vlrs.begin() + index); 513 m_ dataRecordLen = static_cast<uint16_t>(m_vlrs.size());519 m_recordsCount = m_vlrs.size(); 514 520 515 521 }
Note: See TracChangeset
for help on using the changeset viewer.
