[Liblas-commits] hg: add an operator<< for liblas::SpatialReference

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Jun 21 11:48:40 EDT 2011


details:   http://hg.liblas.orghg/rev/eea84320a6aa
changeset: 2967:eea84320a6aa
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Jun 21 10:48:34 2011 -0500
description:
add an operator<< for liblas::SpatialReference

diffstat:

 include/liblas/spatialreference.hpp |   2 ++
 src/spatialreference.cpp            |  16 ++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diffs (44 lines):

diff -r 51059fa1be81 -r eea84320a6aa include/liblas/spatialreference.hpp
--- a/include/liblas/spatialreference.hpp	Tue Jun 21 10:13:02 2011 -0500
+++ b/include/liblas/spatialreference.hpp	Tue Jun 21 10:48:34 2011 -0500
@@ -196,6 +196,8 @@
 
 } // namespace liblas
 
+LAS_DLL std::ostream& operator<<(std::ostream& ostr, const liblas::SpatialReference& srs);
+
 LAS_C_START
 #if defined(__geotiff_h_)
 #if defined(GEO_NORMALIZE_H_INCLUDED)
diff -r 51059fa1be81 -r eea84320a6aa src/spatialreference.cpp
--- a/src/spatialreference.cpp	Tue Jun 21 10:13:02 2011 -0500
+++ b/src/spatialreference.cpp	Tue Jun 21 10:48:34 2011 -0500
@@ -69,6 +69,7 @@
 
 #include <liblas/spatialreference.hpp>
 #include <liblas/detail/private_utility.hpp>
+#include <liblas/external/property_tree/xml_parser.hpp>
 // boost
 #include <boost/concept_check.hpp>
 #include <boost/cstdint.hpp>
@@ -923,5 +924,20 @@
 #endif
 }
 
+std::ostream& operator<<(std::ostream& ostr, const liblas::SpatialReference& srs)
+{
+
+#ifdef HAVE_GDAL 
+    liblas::property_tree::ptree tree;
+    std::string name ("spatialreference");
+    tree.put_child(name, srs.GetPTree());
+    liblas::property_tree::write_xml(ostr, tree);
+    return ostr;
+
+#else
+    throw std::runtime_error("SpatialReference io operator<< is not available without GDAL+libgeotiff support");
+#endif
+}
+
 } // namespace liblas
 


More information about the Liblas-commits mailing list