[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jun 30 16:03:31 EDT 2010
changeset 7ad32cb081f1 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7ad32cb081f1
summary: prevent leak when multiple WriteHeader calls happen
changeset 550e985548eb in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=550e985548eb
summary: clean up unused code and finish removing reprojection machinery for #184 to the detail::writer
diffstat:
include/liblas/detail/writer/point.hpp | 21 +-----------
src/detail/writer/point.cpp | 54 +---------------------------------
src/detail/writer/writer.cpp | 7 +++-
3 files changed, 9 insertions(+), 73 deletions(-)
diffs (160 lines):
diff -r abe68fe6a1a4 -r 550e985548eb include/liblas/detail/writer/point.hpp
--- a/include/liblas/detail/writer/point.hpp Wed Jun 30 13:00:33 2010 -0500
+++ b/include/liblas/detail/writer/point.hpp Wed Jun 30 15:03:24 2010 -0500
@@ -42,23 +42,14 @@
#ifndef LIBLAS_DETAIL_WRITER_POINT_HPP_INCLUDED
#define LIBLAS_DETAIL_WRITER_POINT_HPP_INCLUDED
-#include <liblas/lasspatialreference.hpp>
#include <liblas/detail/fwd.hpp>
#include <liblas/laspoint.hpp>
#include <liblas/lasformat.hpp>
-
+#include <liblas/lasheader.hpp>
#include <liblas/detail/utility.hpp>
-
-#include <liblas/lasheader.hpp>
-
#include <liblas/detail/writer/base.hpp>
-#ifndef HAVE_GDAL
- typedef struct OGRCoordinateTransformationHS *OGRCoordinateTransformationH;
- typedef struct OGRSpatialReferenceHS *OGRSpatialReferenceH;
-#endif
-
// std
#include <iosfwd>
@@ -71,10 +62,6 @@
typedef WriterBase Base;
Point(std::ostream& ofs, liblas::uint32_t& count, liblas::Header const& header);
- Point( std::ostream& ofs,
- liblas::uint32_t& count,
- liblas::Header const& header,
- OGRCoordinateTransformationH transform);
virtual ~Point();
const liblas::Point& GetPoint() const { return m_point; }
@@ -92,20 +79,16 @@
Point(Point const& other);
Point& operator=(Point const& rhs);
-
-
std::ostream& m_ofs;
const liblas::Header& m_header;
liblas::Point m_point;
- OGRCoordinateTransformationH m_transform;
-
+
PointRecord m_record;
PointFormat m_format;
liblas::uint8_t* m_blanks;
- void project();
void setup();
void fill();
};
diff -r abe68fe6a1a4 -r 550e985548eb src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp Wed Jun 30 13:00:33 2010 -0500
+++ b/src/detail/writer/point.cpp Wed Jun 30 15:03:24 2010 -0500
@@ -86,30 +86,13 @@
Base(ofs, count),
m_ofs(ofs),
m_header(header),
- m_point(liblas::Point()),
- m_transform(0),
+ m_point(liblas::Point()),
m_format(header.GetPointFormat()),
m_blanks(0)
{
setup();
}
-Point::Point( std::ostream& ofs,
- liblas::uint32_t& count,
- const liblas::Header& header,
- OGRCoordinateTransformationH transform) :
- Base(ofs, count),
- m_ofs(ofs),
- m_header(header),
- m_point(liblas::Point()),
- m_transform(transform),
- m_format(header.GetPointFormat()),
- m_blanks(0)
-
-{
- setup();
-}
-
Point::~Point()
{
if (m_blanks != 0)
@@ -198,46 +181,11 @@
}
}
-void Point::project()
-{
-#ifdef HAVE_GDAL
-
- int ret = 0;
- liblas::Point& p = m_point;
-
- double x = p.GetX();
- double y = p.GetY();
- double z = p.GetZ();
-
- ret = OCTTransform(m_transform, 1, &x, &y, &z);
-
- if (!ret) {
- std::ostringstream msg;
- msg << "Could not project point for Writer::" << CPLGetLastErrorMsg() << ret;
- std::string message(msg.str());
- throw std::runtime_error(message);
- }
-
- p.SetX(x);
- p.SetY(y);
- p.SetZ(z);
-#endif
-}
void Point::fill()
{
liblas::Point& p = m_point;
- if (m_transform) {
-
- project();
- // m_record.y = static_cast<int32_t>((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY());
- // m_record.z = static_cast<int32_t>((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ());
- } // else {
- // m_record.x = static_cast<int32_t>((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX());
- // m_record.y = static_cast<int32_t>((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY());
- // m_record.z = static_cast<int32_t>((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ());
- // }
m_record.x = static_cast<int32_t>(sround(((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX())));
m_record.y = static_cast<int32_t>(sround(((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY())));
m_record.z = static_cast<int32_t>(sround(((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ())));
diff -r abe68fe6a1a4 -r 550e985548eb src/detail/writer/writer.cpp
--- a/src/detail/writer/writer.cpp Wed Jun 30 13:00:33 2010 -0500
+++ b/src/detail/writer/writer.cpp Wed Jun 30 15:03:24 2010 -0500
@@ -66,7 +66,12 @@
liblas::Header const& WriterImpl::WriteHeader(liblas::Header const& header)
{
- m_header_writer = new detail::writer::Header(m_ofs,m_pointCount, header );
+ if (m_header_writer == 0) {
+ m_header_writer = new detail::writer::Header(m_ofs,m_pointCount, header );
+ } else {
+ delete m_header_writer;
+ m_header_writer = new detail::writer::Header(m_ofs,m_pointCount, header );
+ }
m_header_writer->write();
return m_header_writer->GetHeader();
}
More information about the Liblas-commits
mailing list