[Liblas-commits] hg-main-tree: added control of writer to emit
compound wkts
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Apr 27 14:48:22 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/8a7143e61209
changeset: 680:8a7143e61209
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Apr 27 11:48:14 2011 -0700
description:
added control of writer to emit compound wkts
diffstat:
include/libpc/SpatialReference.hpp | 3 ++
include/libpc/drivers/las/VariableLengthRecord.hpp | 9 ++---
src/SpatialReference.cpp | 8 +++++
src/drivers/las/LasHeaderWriter.cpp | 3 +-
src/drivers/las/LasHeaderWriter.hpp | 5 +++
src/drivers/las/VariableLengthRecord.cpp | 8 ++--
test/unit/SpatialReferenceTest.cpp | 31 +++++++++++++++++++--
7 files changed, 54 insertions(+), 13 deletions(-)
diffs (208 lines):
diff -r c1b03f8ef183 -r 8a7143e61209 include/libpc/SpatialReference.hpp
--- a/include/libpc/SpatialReference.hpp Wed Apr 27 11:15:35 2011 -0700
+++ b/include/libpc/SpatialReference.hpp Wed Apr 27 11:48:14 2011 -0700
@@ -54,6 +54,9 @@
/// Default constructor.
SpatialReference();
+ // calls setFromUserInput() with the given string
+ SpatialReference(const std::string& userInput);
+
/// Destructor.
/// If libgeotiff is enabled, deallocates libtiff and libgeotiff objects used internally.
~SpatialReference();
diff -r c1b03f8ef183 -r 8a7143e61209 include/libpc/drivers/las/VariableLengthRecord.hpp
--- a/include/libpc/drivers/las/VariableLengthRecord.hpp Wed Apr 27 11:15:35 2011 -0700
+++ b/include/libpc/drivers/las/VariableLengthRecord.hpp Wed Apr 27 11:48:14 2011 -0700
@@ -40,9 +40,8 @@
#include <string>
#include <vector>
-namespace libpc {
- class SpatialReference;
-}
+#include <libpc/SpatialReference.hpp>
+
namespace libpc { namespace drivers { namespace las {
@@ -85,7 +84,7 @@
static const int s_headerLength = 54;
static void setSRSFromVLRs(const std::vector<VariableLengthRecord>& vlrs, SpatialReference& srs);
- static void setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs);
+ static void setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs, SpatialReference::WKTModeFlag modeFlag);
static std::string bytes2string(const boost::uint8_t* bytes, boost::uint32_t len);
@@ -121,7 +120,7 @@
boost::uint32_t count() const;
void constructSRS(SpatialReference&) const;
- void addVLRsFromSRS(const SpatialReference& srs);
+ void addVLRsFromSRS(const SpatialReference& srs, SpatialReference::WKTModeFlag modeFlag);
private:
std::vector<VariableLengthRecord> m_list;
diff -r c1b03f8ef183 -r 8a7143e61209 src/SpatialReference.cpp
--- a/src/SpatialReference.cpp Wed Apr 27 11:15:35 2011 -0700
+++ b/src/SpatialReference.cpp Wed Apr 27 11:48:14 2011 -0700
@@ -52,6 +52,14 @@
}
+SpatialReference::SpatialReference(const std::string& s)
+ : m_wkt("")
+{
+ this->setFromUserInput(s);
+ return;
+}
+
+
SpatialReference::SpatialReference(SpatialReference const& rhs)
: m_wkt(rhs.m_wkt)
{
diff -r c1b03f8ef183 -r 8a7143e61209 src/drivers/las/LasHeaderWriter.cpp
--- a/src/drivers/las/LasHeaderWriter.cpp Wed Apr 27 11:15:35 2011 -0700
+++ b/src/drivers/las/LasHeaderWriter.cpp Wed Apr 27 11:48:14 2011 -0700
@@ -55,6 +55,7 @@
LasHeaderWriter::LasHeaderWriter(LasHeader& header, std::ostream& ostream)
: m_header(header)
, m_ostream(ostream)
+ , m_wktModeFlag(SpatialReference::eCompoundOK)
{
return;
}
@@ -91,7 +92,7 @@
m_header.getVLRs().remove("LASF_Projection", 34736);
m_header.getVLRs().remove("LASF_Projection", 34737);
- m_header.getVLRs().addVLRsFromSRS(m_header.getSpatialReference());
+ m_header.getVLRs().addVLRsFromSRS(m_header.getSpatialReference(), m_wktModeFlag);
}
{
diff -r c1b03f8ef183 -r 8a7143e61209 src/drivers/las/LasHeaderWriter.hpp
--- a/src/drivers/las/LasHeaderWriter.hpp Wed Apr 27 11:15:35 2011 -0700
+++ b/src/drivers/las/LasHeaderWriter.hpp Wed Apr 27 11:48:14 2011 -0700
@@ -46,6 +46,8 @@
#include <libpc/libpc.hpp>
#include <iosfwd>
+#include <libpc/SpatialReference.hpp>
+
namespace libpc { namespace drivers { namespace las {
class LasHeader;
@@ -56,6 +58,8 @@
LasHeaderWriter(LasHeader& header, std::ostream&);
void write();
+ // default is eCompoundOK
+ void setWktModeFlag(SpatialReference::WKTModeFlag);
private:
void WriteLAS10PadSignature();
@@ -64,6 +68,7 @@
LasHeader& m_header; // note this is not const
std::ostream& m_ostream;
+ SpatialReference::WKTModeFlag m_wktModeFlag;
LasHeaderWriter& operator=(const LasHeaderWriter&); // nope
LasHeaderWriter(const LasHeaderWriter&); // nope
diff -r c1b03f8ef183 -r 8a7143e61209 src/drivers/las/VariableLengthRecord.cpp
--- a/src/drivers/las/VariableLengthRecord.cpp Wed Apr 27 11:15:35 2011 -0700
+++ b/src/drivers/las/VariableLengthRecord.cpp Wed Apr 27 11:48:14 2011 -0700
@@ -317,7 +317,7 @@
}
-void VariableLengthRecord::setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs)
+void VariableLengthRecord::setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs, SpatialReference::WKTModeFlag modeFlag)
{
#ifdef LIBPC_SRS_ENABLED
@@ -337,7 +337,7 @@
GeotiffSupport geotiff;
{
- const std::string wkt = srs.getWKT(SpatialReference::eCompoundOK, false);
+ const std::string wkt = srs.getWKT(modeFlag, false);
geotiff.setWkt(wkt);
}
@@ -603,9 +603,9 @@
}
-void VLRList::addVLRsFromSRS(const SpatialReference& srs)
+void VLRList::addVLRsFromSRS(const SpatialReference& srs, SpatialReference::WKTModeFlag modeFlag)
{
- VariableLengthRecord::setVLRsFromSRS(srs, m_list);
+ VariableLengthRecord::setVLRsFromSRS(srs, m_list, modeFlag);
}
} } } // namespaces
diff -r c1b03f8ef183 -r 8a7143e61209 test/unit/SpatialReferenceTest.cpp
--- a/test/unit/SpatialReferenceTest.cpp Wed Apr 27 11:15:35 2011 -0700
+++ b/test/unit/SpatialReferenceTest.cpp Wed Apr 27 11:48:14 2011 -0700
@@ -155,7 +155,7 @@
ref.setFromUserInput(code);
std::vector<libpc::drivers::las::VariableLengthRecord> vlrs;
- libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(ref, vlrs);
+ libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(ref, vlrs, libpc::SpatialReference::eCompoundOK);
BOOST_CHECK(vlrs.size() == boost::uint32_t(4));
BOOST_CHECK(vlrs[0].getLength() == boost::uint32_t(64));
@@ -178,7 +178,7 @@
std::vector<libpc::drivers::las::VariableLengthRecord> vlrs;
{
- libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(ref, vlrs);
+ libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(ref, vlrs, libpc::SpatialReference::eCompoundOK);
BOOST_CHECK(vlrs.size() == 4);
BOOST_CHECK(vlrs[0].getLength() == boost::uint32_t(96));
}
@@ -200,6 +200,31 @@
}
+BOOST_AUTO_TEST_CASE(test_vertical_datum_notcompound)
+{
+ const std::string wkt = "COMPD_CS[\"WGS 84 + VERT_CS\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],VERT_CS[\"NAVD88 height\",VERT_DATUM[\"North American Vertical Datum 1988\",2005,AUTHORITY[\"EPSG\",\"5103\"],EXTENSION[\"PROJ4_GRIDS\",\"g2003conus.gtx\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5703\"]]]";
+ const libpc::SpatialReference srs(wkt);
+
+ std::vector<libpc::drivers::las::VariableLengthRecord> vlrs_compound;
+ std::vector<libpc::drivers::las::VariableLengthRecord> vlrs_horizonly;
+
+ libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(srs, vlrs_compound, libpc::SpatialReference::eCompoundOK);
+ libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(srs, vlrs_horizonly, libpc::SpatialReference::eHorizontalOnly);
+
+ BOOST_CHECK(vlrs_compound.size() == 4);
+ BOOST_CHECK(vlrs_horizonly.size() == 4);
+ BOOST_CHECK(vlrs_compound[0].getLength() == 96);
+ BOOST_CHECK(vlrs_compound[1].getLength() == 16);
+ BOOST_CHECK(vlrs_compound[2].getLength() == 21);
+ BOOST_CHECK(vlrs_compound[3].getLength() == 511);
+ BOOST_CHECK(vlrs_horizonly[0].getLength() == 64);
+ BOOST_CHECK(vlrs_horizonly[1].getLength() == 16);
+ BOOST_CHECK(vlrs_horizonly[2].getLength() == 7);
+ BOOST_CHECK(vlrs_horizonly[3].getLength() == 511);
+
+ return;
+}
+
// Try writing a compound coordinate system to file and ensure we get back
// WKT with the geoidgrids (from the WKT VLR).
BOOST_AUTO_TEST_CASE(test_vertical_datums)
@@ -267,7 +292,7 @@
}
{
std::vector<libpc::drivers::las::VariableLengthRecord> vlrs;
- libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(ref, vlrs);
+ libpc::drivers::las::VariableLengthRecord::setVLRsFromSRS(ref, vlrs, libpc::SpatialReference::eCompoundOK);
BOOST_CHECK(vlrs.size() == 4);
libpc::drivers::las::VariableLengthRecord::clearVLRs(libpc::drivers::las::VariableLengthRecord::eGeoTIFF, vlrs);
BOOST_CHECK(vlrs.size() == 1);
More information about the Liblas-commits
mailing list