[Liblas-commits] hg: start on replacing liblas::Header with
liblas::HeaderPtr in ...
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Feb 18 14:35:32 EST 2011
details: http://hg.liblas.orghg/rev/c08b22e3f413
changeset: 2870:c08b22e3f413
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Feb 18 11:47:13 2011 -0600
description:
start on replacing liblas::Header with liblas::HeaderPtr in C API
Subject: hg: make LASHeaderH backed by a heap-allocated liblas::HeaderPtr*
details: http://hg.liblas.orghg/rev/359fd85a521d
changeset: 2871:359fd85a521d
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Feb 18 13:34:35 2011 -0600
description:
make LASHeaderH backed by a heap-allocated liblas::HeaderPtr*
diffstat:
python/tests/Header.txt | 2 +-
src/c_api.cpp | 370 ++++++++++++++++++++++++-----------------------
2 files changed, 188 insertions(+), 184 deletions(-)
diffs (truncated from 870 to 300 lines):
diff -r 745106b04cc4 -r 359fd85a521d python/tests/Header.txt
--- a/python/tests/Header.txt Fri Feb 18 10:25:18 2011 -0600
+++ b/python/tests/Header.txt Fri Feb 18 13:34:35 2011 -0600
@@ -48,7 +48,7 @@
datetime.datetime(2008, 3, 19, 0, 0)
>>> h.software_id
- 'libLAS 1.6.0b4'
+ 'libLAS 1.6.0'
>>> h.software_id = 'hobu'
>>> h.software_id
'hobu'
diff -r 745106b04cc4 -r 359fd85a521d src/c_api.cpp
--- a/src/c_api.cpp Fri Feb 18 10:25:18 2011 -0600
+++ b/src/c_api.cpp Fri Feb 18 13:34:35 2011 -0600
@@ -59,7 +59,7 @@
typedef struct LASWriterHS *LASWriterH;
typedef struct LASReaderHS *LASReaderH;
typedef struct LASPointHS *LASPointH;
-typedef struct LASHeaderHS *LASHeaderH;
+typedef liblas::HeaderPtr* LASHeaderH;
typedef struct LASGuidHS *LASGuidH;
typedef struct LASVLRHS *LASVLRH;
typedef struct LASColorHS *LASColorH;
@@ -247,7 +247,7 @@
{
VALIDATE_LAS_POINTER1(filename, "LASReader_CreateWithHeader", NULL);
- VALIDATE_LAS_POINTER1(hHeader, "LASReader_CreateWithHeader", NULL);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASReader_CreateWithHeader", NULL);
try {
@@ -259,12 +259,12 @@
// If the original data were compressed, we need to override whatever value
// our incoming header has for that value
- liblas::Header* header = ((liblas::Header*) hHeader);
+ liblas::HeaderPtr* header = ((liblas::HeaderPtr*) hHeader);
if (current_header.Compressed())
{
- header->SetCompressed(true);
+ header->get()->SetCompressed(true);
}
- reader->SetHeader(*header);
+ reader->SetHeader(*header->get());
readers.insert(std::pair<liblas::Reader*, std::istream*>(reader, istrm));
return (LASReaderH) reader;
@@ -283,8 +283,9 @@
VALIDATE_LAS_POINTER0(hHeader, "LASReader_SetHeader");
liblas::Reader* reader = (liblas::Reader*)hReader;
- liblas::Header* header = (liblas::Header*)hHeader;
- reader->SetHeader(*header);
+ liblas::HeaderPtr* header = (liblas::HeaderPtr*)hHeader;
+ if (header->get())
+ reader->SetHeader(*header->get());
}
LAS_DLL void LASReader_Destroy(LASReaderH hReader)
@@ -392,17 +393,7 @@
}
-LAS_DLL LASHeaderH LASReader_GetHeader(const LASReaderH hReader)
-{
- VALIDATE_LAS_POINTER1(hReader, "LASReader_GetHeader", NULL);
-
- liblas::Header header = ((liblas::Reader*) hReader)->GetHeader();
- return (LASHeaderH) new liblas::Header( header );
-}
-
-
-
-LAS_DLL LASErrorEnum LASReader_SetInputSRS(LASHeaderH hReader, const LASSRSH hSRS) {
+LAS_DLL LASErrorEnum LASReader_SetInputSRS(LASReaderH hReader, const LASSRSH hSRS) {
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetInputSRS", LE_Failure);
VALIDATE_LAS_POINTER1(hSRS, "LASReader_SetInputSRS", LE_Failure);
@@ -423,7 +414,19 @@
}
-LAS_DLL LASErrorEnum LASReader_SetOutputSRS(LASHeaderH hReader, const LASSRSH hSRS) {
+LAS_DLL LASHeaderH LASReader_GetHeader(const LASReaderH hReader)
+{
+ VALIDATE_LAS_POINTER1(hReader, "LASReader_GetHeader", new liblas::HeaderPtr());
+
+ liblas::Header header = ((liblas::Reader*) hReader)->GetHeader();
+ return (LASHeaderH) new liblas::HeaderPtr(new liblas::Header(header));
+}
+
+
+
+
+
+LAS_DLL LASErrorEnum LASReader_SetOutputSRS(LASReaderH hReader, const LASSRSH hSRS) {
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetOutputSRS", LE_Failure);
VALIDATE_LAS_POINTER1(hSRS, "LASReader_SetOutputSRS", LE_Failure);
@@ -457,7 +460,7 @@
return LE_None;
}
-LAS_DLL LASErrorEnum LASReader_SetSRS(LASHeaderH hReader, const LASSRSH hSRS) {
+LAS_DLL LASErrorEnum LASReader_SetSRS(LASReaderH hReader, const LASSRSH hSRS) {
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetSRS", LE_Failure);
VALIDATE_LAS_POINTER1(hSRS, "LASReader_SetSRS", LE_Failure);
@@ -466,7 +469,7 @@
}
LAS_DLL LASHeaderH LASHeader_Create(void) {
- return (LASHeaderH) new liblas::Header();
+ return (LASHeaderH) new liblas::HeaderPtr(new liblas::Header());
}
LAS_DLL LASPointH LASPoint_Create(void) {
@@ -479,16 +482,16 @@
LAS_DLL LASHeaderH LASPoint_GetHeader(const LASPointH hPoint)
{
- VALIDATE_LAS_POINTER1(hPoint , "LASPoint_GetHeader", NULL);
+ VALIDATE_LAS_POINTER1(hPoint , "LASPoint_GetHeader", new liblas::HeaderPtr());
liblas::Point const& p= *((liblas::Point*) hPoint);
liblas::HeaderPtr h = p.GetHeaderPtr();
if (h.get())
{
- return (LASHeaderH) new liblas::Header( *h.get() );
+ return (LASHeaderH) new liblas::HeaderPtr(h);
} else
{
- return (LASHeaderH) new liblas::Header((liblas::DefaultHeader::get()));
+ return (LASHeaderH) new liblas::HeaderPtr( new liblas::Header(*h.get()) );
}
}
@@ -500,9 +503,8 @@
VALIDATE_LAS_POINTER0(hHeader, "LASPoint_SetHeader");
liblas::Point* point = (liblas::Point*)hPoint;
- liblas::Header* header = (liblas::Header*)hHeader;
- liblas::HeaderPtr h = liblas::HeaderPtr(new liblas::Header(*header));
- point->SetHeaderPtr(h);
+ liblas::HeaderPtr* header = (liblas::HeaderPtr*)hHeader;
+ point->SetHeaderPtr(*header);
}
LAS_DLL LASErrorEnum LASPoint_SetData(LASPointH hPoint, unsigned char* data) {
@@ -1040,53 +1042,53 @@
LAS_DLL char* LASHeader_GetFileSignature(const LASHeaderH hHeader) {
// caller owns it
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetFileSignature", NULL);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetFileSignature", NULL);
- std::string signature = ((liblas::Header*) hHeader)->GetFileSignature();
+ std::string signature = ((liblas::HeaderPtr*) hHeader)->get()->GetFileSignature();
return LASCopyString(signature.c_str());
}
LAS_DLL boost::uint16_t LASHeader_GetFileSourceId(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetFileSourceId", 0);
-
- unsigned short value = ((liblas::Header*) hHeader)->GetFileSourceId();
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetFileSourceId", 0);
+
+ unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetFileSourceId();
return value;
}
LAS_DLL LASErrorEnum LASHeader_SetFileSourceId(LASHeaderH hHeader, boost::uint16_t value) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetFileSourceId", LE_Failure);
- ((liblas::Header*) hHeader)->SetFileSourceId(value);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetFileSourceId", LE_Failure);
+ ((liblas::HeaderPtr*) hHeader)->get()->SetFileSourceId(value);
return LE_None;
}
LAS_DLL boost::uint16_t LASHeader_GetReserved(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetReserved", 0);
-
- unsigned short value = ((liblas::Header*) hHeader)->GetReserved();
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetReserved", 0);
+
+ unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetReserved();
return value;
}
LAS_DLL LASErrorEnum LASHeader_SetReserved(LASHeaderH hHeader, boost::uint16_t value) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetReserved", LE_Failure);
- ((liblas::Header*) hHeader)->SetReserved(value);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetReserved", LE_Failure);
+ ((liblas::HeaderPtr*) hHeader)->get()->SetReserved(value);
return LE_None;
}
LAS_DLL char* LASHeader_GetProjectId(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetProjectId", 0);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetProjectId", 0);
- liblas::guid id = ((liblas::Header*) hHeader)->GetProjectId();
+ liblas::guid id = ((liblas::HeaderPtr*) hHeader)->get()->GetProjectId();
return LASCopyString(id.to_string().c_str());
}
LAS_DLL LASErrorEnum LASHeader_SetProjectId(LASHeaderH hHeader, const char* value) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetProjectId", LE_Failure);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetProjectId", LE_Failure);
try {
liblas::guid id;
id = liblas::guid(value);
- ((liblas::Header*) hHeader)->SetProjectId(id);
+ ((liblas::HeaderPtr*) hHeader)->get()->SetProjectId(id);
} catch (std::exception const& e)
{
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetGUID");
@@ -1097,17 +1099,17 @@
}
LAS_DLL boost::uint8_t LASHeader_GetVersionMajor(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetVersionMajor", 0);
-
- long value = ((liblas::Header*) hHeader)->GetVersionMajor();
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetVersionMajor", 0);
+
+ long value = ((liblas::HeaderPtr*) hHeader)->get()->GetVersionMajor();
return boost::uint8_t(value);
}
LAS_DLL LASErrorEnum LASHeader_SetVersionMajor(LASHeaderH hHeader, boost::uint8_t value) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetVersionMajor", LE_Failure);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetVersionMajor", LE_Failure);
try {
- ((liblas::Header*) hHeader)->SetVersionMajor(value);
+ ((liblas::HeaderPtr*) hHeader)->get()->SetVersionMajor(value);
} catch (std::exception const& e)
{
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetVersionMajor");
@@ -1118,18 +1120,18 @@
}
LAS_DLL boost::uint8_t LASHeader_GetVersionMinor(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetVersionMinor", 0);
-
- long value = ((liblas::Header*) hHeader)->GetVersionMinor();
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetVersionMinor", 0);
+
+ long value = ((liblas::HeaderPtr*) hHeader)->get()->GetVersionMinor();
return boost::uint8_t(value);
}
LAS_DLL LASErrorEnum LASHeader_SetVersionMinor(LASHeaderH hHeader, boost::uint8_t value) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetVersionMinor", LE_Failure);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetVersionMinor", LE_Failure);
// TODO: Maybe this should be a fatal error -- hobu
try {
- ((liblas::Header*) hHeader)->SetVersionMinor(value);
+ ((liblas::HeaderPtr*) hHeader)->get()->SetVersionMinor(value);
} catch (std::exception const& e)
{
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetVersionMinor");
@@ -1140,18 +1142,18 @@
}
LAS_DLL char* LASHeader_GetSystemId(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetSystemId", NULL);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetSystemId", NULL);
// caller owns it
- std::string sysid = ((liblas::Header*) hHeader)->GetSystemId();
+ std::string sysid = ((liblas::HeaderPtr*) hHeader)->get()->GetSystemId();
return LASCopyString(sysid.c_str());
}
LAS_DLL LASErrorEnum LASHeader_SetSystemId(LASHeaderH hHeader, const char* value) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetSystemId", LE_Failure);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetSystemId", LE_Failure);
try {
- ((liblas::Header*) hHeader)->SetSystemId(value);
+ ((liblas::HeaderPtr*) hHeader)->get()->SetSystemId(value);
} catch (std::exception const& e)
{
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetSystemId");
@@ -1162,18 +1164,18 @@
}
LAS_DLL char* LASHeader_GetSoftwareId(const LASHeaderH hHeader) {
- VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetSoftwareId", NULL);
+ VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetSoftwareId", NULL);
// caller owns it
- std::string softid = ((liblas::Header*) hHeader)->GetSoftwareId();
More information about the Liblas-commits
mailing list