[Liblas-commits] r1023 - in trunk: include/liblas
include/liblas/detail src src/detail
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Feb 16 00:40:12 EST 2009
Author: hobu
Date: Mon Feb 16 00:40:10 2009
New Revision: 1023
URL: http://liblas.org/changeset/1023
Log:
some improvement on srs stuff
Modified:
trunk/include/liblas/detail/utility.hpp
trunk/include/liblas/lassrs.hpp
trunk/src/detail/reader.cpp
trunk/src/lassrs.cpp
Modified: trunk/include/liblas/detail/utility.hpp
==============================================================================
--- trunk/include/liblas/detail/utility.hpp (original)
+++ trunk/include/liblas/detail/utility.hpp Mon Feb 16 00:40:10 2009
@@ -89,7 +89,7 @@
if (&rhs != this)
{
p_ = rhs.p_;
- del_ = NULL;
+ del_ = rhs.del_;
}
return *this;
}
Modified: trunk/include/liblas/lassrs.hpp
==============================================================================
--- trunk/include/liblas/lassrs.hpp (original)
+++ trunk/include/liblas/lassrs.hpp Mon Feb 16 00:40:10 2009
@@ -90,10 +90,12 @@
LASSRS();
+ ~LASSRS();
LASSRS(const std::vector<LASVLR>& vlrs);
///LASSRS(LASSRS const& other);
LASSRS& operator=(LASSRS const& rhs);
- //
+
+ GTIF* GetGTIF();
std::string GetWKT() const;
void SetWKT(std::string const& v);
@@ -105,10 +107,14 @@
LASSRS(LASSRS const& other);
-
- std::string m_wkt;
- std::string m_proj4;
- detail::raii_wrapper<ST_TIFF> m_tiff;
+ GTIF* m_gtiff;
+ ST_TIFF* m_tiff;
+
+ std::vector<LASVLR> m_vlrs;
+ //
+ // std::string m_wkt;
+ // std::string m_proj4;
+ //detail::raii_wrapper<ST_TIFF> m_tiff;
// detail::raii_wrapper<GTIF> m_gtiff;
Modified: trunk/src/detail/reader.cpp
==============================================================================
--- trunk/src/detail/reader.cpp (original)
+++ trunk/src/detail/reader.cpp Mon Feb 16 00:40:10 2009
@@ -60,7 +60,6 @@
#include <cassert>
#include <cstdlib> // std::size_t
#include <stdexcept>
-#include <iostream>
namespace liblas { namespace detail {
@@ -140,17 +139,15 @@
LASVLR record = header.GetVLR(i);
vlrs.push_back(record);
}
- LASSRS* ref = new LASSRS(vlrs);
LASSRS srs(vlrs);
header.SetSRS(srs);
- header.SetProj4(ref->GetProj4());
+ header.SetProj4(srs.GetProj4());
- std::cout << ref->GetWKT() << std::endl;
+ // std::cout << srs.GetWKT() << std::endl;
- delete ref;
return true;
Modified: trunk/src/lassrs.cpp
==============================================================================
--- trunk/src/lassrs.cpp (original)
+++ trunk/src/lassrs.cpp Mon Feb 16 00:40:10 2009
@@ -44,62 +44,86 @@
#include <iostream>
namespace liblas {
-LASSRS::LASSRS() :
- m_tiff(ST_Create(), ST_Destroy)
+LASSRS::LASSRS()
+
{
}
-LASSRS::LASSRS(const std::vector<LASVLR>& vlrs) :
- m_tiff(ST_Create(), ST_Destroy)
+LASSRS::~LASSRS()
+
+{
+ // FIXME: this needs to be cleaned up
+
+ // if (m_gtiff)
+ // {
+ // GTIFFree(m_gtiff);
+ // m_gtiff = NULL;
+ // }
+ // if (m_tiff)
+ // {
+ // ST_Destroy(m_tiff);
+ // m_tiff = NULL;
+ // }
+
+
+}
+LASSRS::LASSRS(const std::vector<LASVLR>& vlrs) :m_vlrs(vlrs)
{
+ m_tiff = NULL;
+ m_gtiff = NULL;
+ GetGTIF();
+}
+GTIF* LASSRS::GetGTIF(){
+
+ m_tiff = ST_Create();
std::string const uid("LASF_Projection");
- for (uint16_t i = 0; i < vlrs.size(); ++i)
+ for (uint16_t i = 0; i < m_vlrs.size(); ++i)
{
- LASVLR record = vlrs[i];
+ LASVLR record = m_vlrs[i];
std::vector<uint8_t> data = record.GetData();
if (uid == record.GetUserId(true).c_str() && 34735 == record.GetRecordId())
{
int count = data.size()/sizeof(int16_t);
- ST_SetKey(m_tiff.get(), record.GetRecordId(), count, STT_SHORT, &(data[0]));
+ ST_SetKey(m_tiff, record.GetRecordId(), count, STT_SHORT, &(data[0]));
}
if (uid == record.GetUserId(true).c_str() && 34736 == record.GetRecordId())
{
int count = data.size() / sizeof(double);
- ST_SetKey(m_tiff.get(), record.GetRecordId(), count, STT_DOUBLE, &(data[0]));
+ ST_SetKey(m_tiff, record.GetRecordId(), count, STT_DOUBLE, &(data[0]));
}
if (uid == record.GetUserId(true).c_str() && 34737 == record.GetRecordId())
{
int count = data.size()/sizeof(uint8_t);
- ST_SetKey(m_tiff.get(), record.GetRecordId(), count, STT_ASCII, &(data[0]));
+ ST_SetKey(m_tiff, record.GetRecordId(), count, STT_ASCII, &(data[0]));
}
}
-
+
+
+ if (m_tiff->key_count)
+ {
+ m_gtiff = GTIFNewSimpleTags(m_tiff);
+ return m_gtiff;
+ }
+ else {
+ ST_Destroy(m_tiff);
+ m_tiff = NULL;
+ return NULL;
+ }
}
bool LASSRS::HasKeys()
{
- return (m_tiff.get()->key_count > 0);
+ return (m_tiff->key_count > 0);
}
-// LASSRS::LASSRS()
-// {
-// // m_tiff = NULL;
-// // m_gtiff = NULL;
-// }
-// LASSRS::LASSRS(LASSRS const& other) :
-// m_tiff(other.m_tiff),
-// m_gtiff(other.m_gtiff)
-// {
-//
-// }
-//
+
LASSRS& LASSRS::operator=(LASSRS const& rhs)
{
if (&rhs != this)
@@ -114,9 +138,8 @@
{
GTIFDefn sGTIFDefn;
char* pszWKT = NULL;
- detail::raii_wrapper<GTIF> m_gtiff(GTIFNewSimpleTags(m_tiff.get()), GTIFFree);
- if( GTIFGetDefn( m_gtiff.get(), &sGTIFDefn ) ) {
- pszWKT = GTIFGetOGISDefn( m_gtiff.get(), &sGTIFDefn );
+ if( GTIFGetDefn( m_gtiff, &sGTIFDefn ) ) {
+ pszWKT = GTIFGetOGISDefn( m_gtiff, &sGTIFDefn );
if (pszWKT) {
std::string tmp(pszWKT);
std::free(pszWKT);
@@ -129,15 +152,15 @@
void LASSRS::SetWKT(std::string const& v)
{
- m_wkt = v;
+ // m_wkt = v;
}
std::string LASSRS::GetProj4() const
{
GTIFDefn defn;
- detail::raii_wrapper<GTIF> m_gtiff(GTIFNewSimpleTags(m_tiff.get()), GTIFFree);
- if (GTIFGetDefn(m_gtiff.get(), &defn))
+
+ if (m_gtiff && GTIFGetDefn(m_gtiff, &defn))
{
char* proj4def = GTIFGetProj4Defn(&defn);
std::string tmp(proj4def);
More information about the Liblas-commits
mailing list