Changeset 654:39a2acc6caa2
- Timestamp:
- 05/16/08 22:24:46 (2 years ago)
- Branch:
- default
- Convert:
- svn:1766ff46-f334-0410-ab20-d63176f87757/trunk@721
- Files:
-
- 11 edited
-
apps/lascommon.c (modified) (4 diffs)
-
include/liblas/capi/liblas.h (modified) (1 diff)
-
include/liblas/detail/reader.hpp (modified) (1 diff)
-
include/liblas/detail/reader10.hpp (modified) (1 diff)
-
include/liblas/detail/reader11.hpp (modified) (1 diff)
-
include/liblas/lasheader.hpp (modified) (2 diffs)
-
src/detail/reader10.cpp (modified) (2 diffs)
-
src/detail/reader11.cpp (modified) (2 diffs)
-
src/las_c_api.cpp (modified) (1 diff)
-
src/lasheader.cpp (modified) (5 diffs)
-
src/lasreader.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
apps/lascommon.c
r574 r654 338 338 char *pszSystemId = NULL; 339 339 char *pszSoftwareId = NULL; 340 char *pszProj4 = NULL; 340 341 341 342 pszSignature = LASHeader_GetFileSignature(header); … … 343 344 pszSystemId = LASHeader_GetSystemId(header); 344 345 pszSoftwareId = LASHeader_GetSoftwareId(header); 345 346 pszProj4 = LASHeader_GetProj4(header); 347 346 348 fprintf(stderr, "\n---------------------------------------------------------\n"); 347 349 fprintf(stderr, " Header Summary\n"); … … 422 424 LASHeader_GetMaxY(header), 423 425 LASHeader_GetMaxZ(header)); 426 427 fprintf(stderr, " Spatial Reference %s\n", 428 pszProj4); 424 429 425 430 free(pszSignature); … … 427 432 free(pszSystemId); 428 433 free(pszSoftwareId); 429 434 free(pszProj4); 430 435 } 431 436 -
include/liblas/capi/liblas.h
r647 r654 743 743 LAS_DLL LASError LASHeader_SetMax(LASHeaderH hHeader, double x, double y, double z); 744 744 745 /** Returns the proj.4 string describing the spatial reference of the 746 * header if it is available 747 * @param hHeader LASHeaderH instance 748 * @return the proj.4 string or NULL if none is available. The caller 749 * owns the string. 750 */ 751 LAS_DLL char* LASHeader_GetProj4(LASHeaderH hHeader); 752 753 /** Sets the proj4 stirng describing the spatial reference of the header. 754 * @param hHeader LASHeaderH instance 755 * @param value the proj4 string to set for the header 756 * @return LASError enum 757 */ 758 LAS_DLL LASError LASHeader_SetProj4(LASHeaderH hHeader, const char* value); 759 745 760 /****************************************************************************/ 746 761 /* Writer Operations */ -
include/liblas/detail/reader.hpp
r641 r654 65 65 virtual bool ReadPointAt(std::size_t n, PointRecord& record, double& time) = 0; 66 66 virtual bool ReadVLR(LASHeader& header) = 0; 67 virtual bool ReadGeoreference(LASHeader& header) = 0; 67 68 68 69 virtual std::istream& GetStream() = 0; -
include/liblas/detail/reader10.hpp
r641 r654 59 59 std::size_t GetVersion() const; 60 60 bool ReadHeader(LASHeader& header); 61 bool ReadGeoreference(LASHeader const& header); // TODO: Under construction62 61 bool ReadNextPoint(PointRecord& record); 63 62 bool ReadNextPoint(PointRecord& record, double& time); 64 63 bool ReadPointAt(std::size_t n, PointRecord& record); 65 64 bool ReadPointAt(std::size_t n, PointRecord& record, double& time); 65 66 66 bool ReadVLR(LASHeader& header); 67 bool ReadGeoreference(LASHeader& header); 67 68 68 69 std::istream& GetStream(); -
include/liblas/detail/reader11.hpp
r641 r654 63 63 bool ReadPointAt(std::size_t n, PointRecord& record); 64 64 bool ReadPointAt(std::size_t n, PointRecord& record, double& time); 65 66 bool ReadGeoreference(LASHeader& header); 65 67 bool ReadVLR(LASHeader& header); 66 68 -
include/liblas/lasheader.hpp
r646 r654 292 292 void SetMin(double x, double y, double z); 293 293 294 /// Adds a variable length record to the header 294 295 void AddVLR(LASVLR const& v); 296 297 /// Returns a VLR 295 298 LASVLR const& GetVLR(uint32_t index) const; 299 300 /// Removes a VLR from the the header 296 301 void DeleteVLR(uint32_t index); 302 303 /// Fetch the Georeference as a proj.4 string 304 std::string GetProj4() const; 305 306 /// Set the Georeference as a proj.4 string 307 void SetProj4(std::string const& v); 297 308 298 309 private: … … 349 360 PointExtents m_extents; 350 361 std::vector<LASVLR> m_vlrs; 362 std::string m_proj4; 351 363 }; 352 364 -
src/detail/reader10.cpp
r652 r654 244 244 // TODO: Under construction 245 245 // Testing reading of VLRecords with GeoKeys 246 ReadGeoreference(header);247 246 return true; 248 247 } 249 bool ReaderImpl::ReadGeoreference(LASHeader const& header)248 bool ReaderImpl::ReadGeoreference(LASHeader& header) 250 249 { 251 250 #ifndef HAVE_LIBGEOTIFF … … 284 283 } 285 284 286 GTIF *gtif = GTIFNewSimpleTags( st ); 287 GTIFDefn defn; 288 if (GTIFGetDefn(gtif, &defn)) 289 { 290 printf( "char PROJ.4 Definition: %s\n", GTIFGetProj4Defn(&defn)); 291 } 292 GTIFFree( gtif ); 293 ST_Destroy( st ); 294 295 return true; 285 if (st->key_count) { 286 GTIF *gtif = GTIFNewSimpleTags( st ); 287 GTIFDefn defn; 288 if (GTIFGetDefn(gtif, &defn)) 289 { 290 header.SetProj4(std::string(GTIFGetProj4Defn(&defn))); 291 } 292 GTIFFree( gtif ); 293 ST_Destroy( st ); 294 return true; 295 } else { 296 return false; 297 } 296 298 #endif /* def HAVE_LIBGEOTIFF */ 297 299 } -
src/detail/reader11.cpp
r652 r654 47 47 #include <liblas/lasrecordheader.hpp> 48 48 49 50 #ifdef HAVE_LIBGEOTIFF 51 #include <geotiff.h> 52 #include <geo_simpletags.h> 53 #include "geo_normalize.h" 54 #include "geo_simpletags.h" 55 #include "geovalues.h" 56 #endif /* HAVE_LIBGEOTIFF */ 57 49 58 // std 50 59 #include <fstream> … … 328 337 } 329 338 339 bool ReaderImpl::ReadGeoreference(LASHeader& header) 340 { 341 #ifndef HAVE_LIBGEOTIFF 342 UNREFERENCED_PARAMETER(header); 343 return false; 344 #else 345 // TODO: Under construction 346 347 std::string const uid("LASF_Projection"); 348 ST_TIFF *st = ST_Create(); 349 350 for (uint16_t i = 0; i < header.GetRecordsCount(); ++i) 351 { 352 LASVLR record = header.GetVLR(i); 353 std::vector<uint8_t> data = record.GetData(); 354 if (uid == record.GetUserId(true).c_str() && 34735 == record.GetRecordId()) 355 { 356 int16_t count = data.size()/sizeof(int16_t); 357 ST_SetKey( st, record.GetRecordId(), count, STT_SHORT, 358 &(data[0]) ); 359 } 360 361 if (uid == record.GetUserId(true).c_str() && 34736 == record.GetRecordId()) 362 { 363 int count = data.size() / sizeof(double); 364 ST_SetKey( st, record.GetRecordId(), count, STT_DOUBLE, 365 &(data[0]) ); 366 } 367 368 if (uid == record.GetUserId(true).c_str() && 34737 == record.GetRecordId()) 369 { 370 uint8_t count = data.size()/sizeof(uint8_t); 371 ST_SetKey( st, record.GetRecordId(), count, STT_ASCII, 372 &(data[0]) ); 373 } 374 } 375 376 if (st->key_count) { 377 GTIF *gtif = GTIFNewSimpleTags( st ); 378 GTIFDefn defn; 379 if (GTIFGetDefn(gtif, &defn)) 380 { 381 header.SetProj4(std::string(GTIFGetProj4Defn(&defn))); 382 } 383 GTIFFree( gtif ); 384 ST_Destroy( st ); 385 return true; 386 } else { 387 return false; 388 } 389 #endif /* def HAVE_LIBGEOTIFF */ 390 } 391 330 392 }}} // namespace liblas::detail::v11 -
src/las_c_api.cpp
r649 r654 1141 1141 return LE_None; 1142 1142 } 1143 1144 LAS_DLL char* LASHeader_GetProj4(LASHeaderH hHeader) 1145 { 1146 VALIDATE_POINTER1(hHeader, "LASHeader_GetProj4", NULL); 1147 LASHeader* header = (LASHeader*)hHeader; 1148 1149 return strdup((header)->GetProj4().c_str()); 1150 1151 } 1152 LAS_DLL LASErrorEnum LASHeader_SetProj4(LASHeaderH hHeader, const char* value) 1153 { 1154 VALIDATE_POINTER1(hHeader, "LASHeader_SetProj4", LE_Failure); 1155 VALIDATE_POINTER1(value, "LASHeader_SetProj4", LE_Failure); 1156 1157 try { 1158 ((LASHeader*) hHeader)->SetProj4(value); 1159 } 1160 catch (std::exception const& e) { 1161 LASError_PushError(LE_Failure, e.what(), "LASHeader_SetProj4"); 1162 return LE_Failure; 1163 } 1164 1165 return LE_None; 1166 } 1167 1168 1143 1169 LAS_DLL LASWriterH LASWriter_Create(const char* filename, const LASHeaderH hHeader, int mode) { 1144 1170 VALIDATE_POINTER1(hHeader, "LASWriter_Create", NULL); -
src/lasheader.cpp
r653 r654 84 84 m_scales(other.m_scales), 85 85 m_offsets(other.m_offsets), 86 87 m_ extents(other.m_extents)86 m_extents(other.m_extents), 87 m_proj4(other.m_proj4) 88 88 { 89 89 void* p = 0; … … 141 141 m_offsets = rhs.m_offsets; 142 142 m_extents = rhs.m_extents; 143 m_proj4 = rhs.m_proj4; 143 144 } 144 145 return *this; … … 172 173 if (m_offsets != other.m_offsets) return false; 173 174 if (m_extents != other.m_extents) return false; 175 if (m_proj4 != other.m_proj4) return false; 174 176 175 177 return true; … … 507 509 } 508 510 509 LASVLR const& LASHeader::GetVLR(uint32_t index) const { 511 LASVLR const& LASHeader::GetVLR(uint32_t index) const 512 { 510 513 return m_vlrs[index]; 511 514 } 512 515 513 void LASHeader::DeleteVLR(uint32_t index) { 516 void LASHeader::DeleteVLR(uint32_t index) 517 { 514 518 515 519 if (index >= m_vlrs.size()) … … 520 524 521 525 } 526 527 /// Fetch the Georeference as a proj.4 string 528 std::string LASHeader::GetProj4() const 529 { 530 return m_proj4; 531 } 532 533 void LASHeader::SetProj4(std::string const& v) 534 { 535 m_proj4 = v; 536 } 522 537 void LASHeader::Init() 523 538 { -
src/lasreader.cpp
r641 r654 153 153 throw std::runtime_error("public vlr header block reading failure"); 154 154 155 m_pimpl->ReadGeoreference(m_header); 156 155 157 } 156 158
Note: See TracChangeset
for help on using the changeset viewer.
