[Liblas-commits] hg-main-tree: checkpoint -- removing geotiff support inside srs ...

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Apr 26 17:59:55 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/75cb3fb221b3
changeset: 666:75cb3fb221b3
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Apr 26 14:24:47 2011 -0700
description:
checkpoint -- removing geotiff support inside srs class
Subject: hg-main-tree: I keep forgetting to delete the iters -- bad design?

details:   http://hg.libpc.orghg-main-tree/rev/ebb3c7650fc6
changeset: 667:ebb3c7650fc6
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Apr 26 14:31:12 2011 -0700
description:
I keep forgetting to delete the iters -- bad design?
Subject: hg-main-tree: moved string trim function into Utils

details:   http://hg.libpc.orghg-main-tree/rev/6ec1b8c31da2
changeset: 668:6ec1b8c31da2
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Apr 26 14:37:02 2011 -0700
description:
moved string trim function into Utils
Subject: hg-main-tree: isolated out geotiff stuff; 4 fails left

details:   http://hg.libpc.orghg-main-tree/rev/bbfc7d7ce05f
changeset: 669:bbfc7d7ce05f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Apr 26 14:59:47 2011 -0700
description:
isolated out geotiff stuff; 4 fails left

diffstat:

 include/libpc/SpatialReference.hpp                 |   82 ----
 include/libpc/Utils.hpp                            |    2 +
 include/libpc/drivers/las/VariableLengthRecord.hpp |    8 +-
 libpc_defines.h.in                                 |   13 +
 src/CMakeLists.txt                                 |    2 +
 src/SpatialReference.cpp                           |  386 +------------------
 src/Utils.cpp                                      |   16 +
 src/drivers/las/GeotiffSupport.cpp                 |  402 +++++++++++++++++++++
 src/drivers/las/GeotiffSupport.hpp                 |   81 ++++
 src/drivers/las/VariableLengthRecord.cpp           |   60 ++-
 test/unit/ReprojectionFilterTest.cpp               |    2 +
 test/unit/SpatialReferenceTest.cpp                 |   76 +-
 12 files changed, 630 insertions(+), 500 deletions(-)

diffs (truncated from 1568 to 300 lines):

diff -r 1ac969da44f7 -r bbfc7d7ce05f include/libpc/SpatialReference.hpp
--- a/include/libpc/SpatialReference.hpp	Tue Apr 26 12:35:27 2011 -0700
+++ b/include/libpc/SpatialReference.hpp	Tue Apr 26 14:59:47 2011 -0700
@@ -37,26 +37,7 @@
 
 #include <libpc/libpc.hpp>
 
-// We have two modes: with GDAL and geotiff, SRS is enabled -- otherwise, it's disabled
-// we use one macro to simplify the control
-#if defined(LIBPC_HAVE_GDAL) && defined(LIBPC_HAVE_LIBGEOTIFF)
-#define LIBPC_SRS_ENABLED
-#endif
-
 #include <boost/property_tree/ptree.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <string>
-#include <ostream>
-
-// Fake out the compiler if we don't have libgeotiff includes already
-#if !defined(__geotiff_h_)
-typedef struct GTIFS *GTIF;
-#endif
-#if !defined(__geo_simpletags_h_)
-typedef struct ST_TIFFS *ST_TIFF;
-#endif
-
 
 namespace libpc
 {
@@ -70,7 +51,6 @@
         eCompoundOK = 2
     };
 
-
     /// Default constructor.
     SpatialReference();
 
@@ -83,10 +63,6 @@
 
     /// Assignment operator.
     SpatialReference& operator=(SpatialReference const& rhs);
-    
-    /// Returns a pointer to the internal GTIF*.  Only available if 
-    /// you have libgeotiff linked in.
-    void rebuildGTIF();
 
     /// Returns the OGC WKT describing Spatial Reference System.
     /// If GDAL is linked, it uses GDAL's operations and methods to determine 
@@ -104,23 +80,6 @@
     /// \param v - a string containing the WKT string.  
     void setWKT(std::string const& v);
 
-    /// Sets the vertical coordinate system using geotiff key values.
-    /// This operation should normally be done after setting the horizontal
-    /// portion of the coordinate system with something like SetWKT(), 
-    /// SetProj4(), SetGTIF() or SetFromUserInput()
-    /// \param verticalCSType - An EPSG vertical coordinate system code, 
-    /// normally in the range 5600 to 5799, or -1 if one is not available.
-    /// \param citation - a textual description of the vertical coordinate 
-    /// system or an empty string if nothing is available.
-    /// \param verticalDatum - the EPSG vertical datum code, often in the 
-    /// range 5100 to 5299 - implied by verticalCSType if that is provided, or 
-    /// -1 if no value is available.
-    /// \param verticalUnits - the EPSG vertical units code, often 9001 for Metre.
-    void setVerticalCS(boost::int32_t verticalCSType, 
-                       std::string const& citation = std::string(0),
-                       boost::int32_t verticalDatum = -1,
-                       boost::int32_t verticalUnits = 9001);
-
     /// Sets the SRS using GDAL's SetFromUserInput function. If GDAL is not linked, this 
     /// operation has no effect.
     /// \param v - a string containing the definition (filename, proj4, wkt, etc).  
@@ -143,30 +102,7 @@
     
     boost::property_tree::ptree getPTree() const;    
 
-    enum GeotiffKeyType
-    {
-        Geotiff_KeyType_SHORT=1,
-        Geotiff_KeyType_DOUBLE=2,
-        Geotiff_KeyType_ASCII=3
-    };
-    int geotiff_ST_SetKey(int tag, int count, GeotiffKeyType geotiff_key_type, void *data);
-    void geotiff_SetTags();
-    void geotiff_ResetTags();
-    int geotiff_ST_GetKey(int tag, int *count, int *st_key_type, void **data_ptr) const;
-
 private:
-    std::string getGTIFFText() const;
-
-    class TiffStuff
-    {
-    public:
-        TiffStuff();
-        ~TiffStuff();
-        GTIF*       m_gtiff;
-        ST_TIFF*    m_tiff;
-    };
-    boost::shared_ptr<TiffStuff> m_tiffstuff;
-
     std::string m_wkt;
 };
 
@@ -175,22 +111,4 @@
 
 } // namespace libpc
 
-
-LIBPC_C_START
-#ifdef __geotiff_h_
-
-#ifdef GEO_NORMALIZE_H_INCLUDED
-char LIBPC_DLL * GTIFGetOGISDefn(GTIF*, GTIFDefn*);
 #endif
-
-int LIBPC_DLL GTIFSetFromOGISDefn(GTIF*, const char*);
-void SetLinearUnitCitation(GTIF* psGTIF, char* pszLinearUOMName);
-
-#ifdef _OGR_SRS_API_H_INCLUDED
-void SetGeogCSCitation(GTIF* psGTIF, OGRSpatialReference* poSRS, char* angUnitName, int nDatum, short nSpheroid);
-#endif // defined _OGR_SRS_API_H_INCLUDED
-
-#endif // defined __geotiff_h_
-LIBPC_C_END
-
-#endif
diff -r 1ac969da44f7 -r bbfc7d7ce05f include/libpc/Utils.hpp
--- a/include/libpc/Utils.hpp	Tue Apr 26 12:35:27 2011 -0700
+++ b/include/libpc/Utils.hpp	Tue Apr 26 14:59:47 2011 -0700
@@ -159,6 +159,8 @@
     // if char found, eats it and returns true; otherwise, don't eat it and then return false
     static bool eatcharacter(std::istream& s, char x);
 
+    static std::string trim(const std::string& str);
+
 private:
     template<typename T>
     static inline char* as_buffer(T& data)
diff -r 1ac969da44f7 -r bbfc7d7ce05f include/libpc/drivers/las/VariableLengthRecord.hpp
--- a/include/libpc/drivers/las/VariableLengthRecord.hpp	Tue Apr 26 12:35:27 2011 -0700
+++ b/include/libpc/drivers/las/VariableLengthRecord.hpp	Tue Apr 26 14:59:47 2011 -0700
@@ -37,9 +37,7 @@
 
 #include <libpc/libpc.hpp>
 
-#include <libpc/MetadataRecord.hpp>
-
-#include <iostream>
+#include <string>
 #include <vector>
 
 namespace libpc {
@@ -85,8 +83,8 @@
 
     static const int s_headerLength = 54;
 
-    static void setSRSFromVLRs_X(const std::vector<VariableLengthRecord>& vlrs, SpatialReference& srs);
-    static void setVLRsFromSRS_X(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs);
+    static void setSRSFromVLRs(const std::vector<VariableLengthRecord>& vlrs, SpatialReference& srs);
+    static void setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs);
 
     static std::string bytes2string(boost::uint8_t* bytes, boost::uint32_t len);
 
diff -r 1ac969da44f7 -r bbfc7d7ce05f libpc_defines.h.in
--- a/libpc_defines.h.in	Tue Apr 26 12:35:27 2011 -0700
+++ b/libpc_defines.h.in	Tue Apr 26 14:59:47 2011 -0700
@@ -5,6 +5,8 @@
  *
  * Note this is a C-style header.  Do not use C++ syntax.
  */
+#ifndef LIBPC_DEFINES_H
+#define LIBPC_DEFINES_H
 
 /*
  * version settings
@@ -55,3 +57,14 @@
 #cmakedefine LIBPC_COMPILER_VC8
 #cmakedefine LIBPC_COMPILER_GCC
 #cmakedefine LIBPC_COMPILER_CLANG
+
+
+/*
+ * We have two modes: with GDAL and geotiff, SRS is enabled -- otherwise, it's disabled
+ * we use one macro to simplify the control
+ */
+#if defined(LIBPC_HAVE_GDAL) && defined(LIBPC_HAVE_LIBGEOTIFF)
+#define LIBPC_SRS_ENABLED
+#endif
+
+#endif
diff -r 1ac969da44f7 -r bbfc7d7ce05f src/CMakeLists.txt
--- a/src/CMakeLists.txt	Tue Apr 26 12:35:27 2011 -0700
+++ b/src/CMakeLists.txt	Tue Apr 26 14:59:47 2011 -0700
@@ -115,6 +115,7 @@
 #
 
 set (LIBPC_DRIVERS_LAS_HPP
+  ./drivers/las/GeotiffSupport.hpp
   ./drivers/las/LasHeaderReader.hpp
   ./drivers/las/LasHeaderWriter.hpp
   ./drivers/las/ZipPoint.hpp
@@ -129,6 +130,7 @@
 )
  
 set (LIBPC_DRIVERS_LAS_CPP
+  ./drivers/las/GeotiffSupport.cpp
   ./drivers/las/Header.cpp
   ./drivers/las/Iterator.cpp
   ./drivers/las/LasHeaderReader.cpp
diff -r 1ac969da44f7 -r bbfc7d7ce05f src/SpatialReference.cpp
--- a/src/SpatialReference.cpp	Tue Apr 26 12:35:27 2011 -0700
+++ b/src/SpatialReference.cpp	Tue Apr 26 14:59:47 2011 -0700
@@ -32,80 +32,28 @@
  * OF SUCH DAMAGE.
  ****************************************************************************/
 
-#include <libpc/libpc.hpp>
+#include <libpc/SpatialReference.hpp>
 
-// GDAL OSR
+// gdal
 #ifdef LIBPC_HAVE_GDAL
-#include <ogr_srs_api.h>
-#include <cpl_port.h>
-#include <geo_normalize.h>
-#include <geovalues.h>
 #include <ogr_spatialref.h>
-#include <gdal.h>
-#include <xtiffio.h>
-#include <cpl_multiproc.h>
+#include <cpl_conv.h>
 #endif
 
-// GeoTIFF
-#ifdef LIBPC_HAVE_LIBGEOTIFF
-#include <geotiff.h>
-#include <geo_simpletags.h>
-#include <geo_normalize.h>
-#include <geo_simpletags.h>
-#include <geovalues.h>
-#endif
-
-#include <libpc/SpatialReference.hpp>
-
-// boost
-#include <boost/concept_check.hpp>
-#include <boost/cstdint.hpp>
-
-// std
-#include <stdexcept>
-#include <string>
-#include <vector>
-
-#ifdef LIBPC_HAVE_GDAL
-#  include "cpl_conv.h"
-#endif
-
+#include <libpc/Utils.hpp>
 
 namespace libpc
 {
    
-SpatialReference::TiffStuff::TiffStuff()
-    : m_gtiff(0)
-    , m_tiff(0)
-{
-}
-SpatialReference::TiffStuff::~TiffStuff()
-{
-#ifdef LIBPC_SRS_ENABLED
-    if (m_gtiff != 0)
-    {
-        GTIFFree(m_gtiff);
-        m_gtiff = 0;
-    }
-    if (m_tiff != 0)
-    {
-        ST_Destroy(m_tiff);
-        m_tiff = 0;
-    }
-#endif
-}
-
 SpatialReference::SpatialReference()
-    : m_tiffstuff(new TiffStuff())
-    , m_wkt("")
+    : m_wkt("")
 {
     return;
 }
 
 
 SpatialReference::SpatialReference(SpatialReference const& rhs) 
-    : m_tiffstuff(rhs.m_tiffstuff)
-    , m_wkt(rhs.m_wkt)
+    : m_wkt(rhs.m_wkt)
 {
     return;
 }


More information about the Liblas-commits mailing list