[Liblas-commits] hg-main-tree: make it GDAL's problem to check for SRS equality i...

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Jun 14 11:58:44 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/3b1897f0d597
changeset: 783:3b1897f0d597
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Jun 14 10:58:38 2011 -0500
description:
make it GDAL's problem to check for SRS equality instead of checking fragil WKT output

diffstat:

 include/pdal/SpatialReference.hpp  |   2 ++
 src/SpatialReference.cpp           |  19 +++++++++++++++++++
 test/unit/SpatialReferenceTest.cpp |  12 ++++++++----
 3 files changed, 29 insertions(+), 4 deletions(-)

diffs (63 lines):

diff -r 7a0582360b42 -r 3b1897f0d597 include/pdal/SpatialReference.hpp
--- a/include/pdal/SpatialReference.hpp	Tue Jun 14 10:39:52 2011 -0500
+++ b/include/pdal/SpatialReference.hpp	Tue Jun 14 10:58:38 2011 -0500
@@ -66,6 +66,8 @@
 
     /// Assignment operator.
     SpatialReference& operator=(SpatialReference const& rhs);
+    
+    bool operator==(const SpatialReference& other) const;
 
     /// Returns the OGC WKT describing Spatial Reference System.
     /// If GDAL is linked, it uses GDAL's operations and methods to determine 
diff -r 7a0582360b42 -r 3b1897f0d597 src/SpatialReference.cpp
--- a/src/SpatialReference.cpp	Tue Jun 14 10:39:52 2011 -0500
+++ b/src/SpatialReference.cpp	Tue Jun 14 10:58:38 2011 -0500
@@ -260,6 +260,25 @@
     
 }
 
+bool SpatialReference::operator==(const SpatialReference& input) const
+{
+#ifdef PDAL_SRS_ENABLED
+
+    OGRSpatialReferenceH current = OSRNewSpatialReference(getWKT(eCompoundOK, false).c_str());
+    OGRSpatialReferenceH other = OSRNewSpatialReference(input.getWKT(eCompoundOK, false).c_str());
+
+    int output = OSRIsSame(current, other);
+
+    OSRDestroySpatialReference( current );
+    OSRDestroySpatialReference( other );
+    
+    return bool(output);
+    
+#else
+    throw pdal_error ("SpatialReference equality testing not available without GDAL+libgeotiff support");
+#endif
+
+}
 
 std::ostream& operator<<(std::ostream& ostr, const SpatialReference& srs)
 {
diff -r 7a0582360b42 -r 3b1897f0d597 test/unit/SpatialReferenceTest.cpp
--- a/test/unit/SpatialReferenceTest.cpp	Tue Jun 14 10:39:52 2011 -0500
+++ b/test/unit/SpatialReferenceTest.cpp	Tue Jun 14 10:58:38 2011 -0500
@@ -190,10 +190,14 @@
         pdal::SpatialReference ref2;
         pdal::drivers::las::VariableLengthRecord::setSRSFromVLRs(vlrs, ref2);
 
-        const std::string wkt2 = "COMPD_CS[\"unknown\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]],VERT_CS[\"NAVD88 height\",VERT_DATUM[\"North American Vertical Datum 1988\",2005,AUTHORITY[\"EPSG\",\"5103\"],EXTENSION[\"PROJ4_GRIDS\",\"g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5703\"]]]";
-
-        const std::string wkt2_ret = ref2.getWKT(pdal::SpatialReference::eCompoundOK);
-        BOOST_CHECK(wkt2_ret == wkt2);
+        const std::string wkt3 = "COMPD_CS[\"unknown\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]],VERT_CS[\"NAVD88 height\",VERT_DATUM[\"North American Vertical Datum 1988\",2005,AUTHORITY[\"EPSG\",\"5103\"],EXTENSION[\"PROJ4_GRIDS\",\"g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5703\"]]]";
+        pdal::SpatialReference ref3;
+        ref3.setWKT(wkt3);
+        
+        BOOST_CHECK_EQUAL(ref3, ref2);
+        
+        // const std::string wkt2_ret = ref2.getWKT(pdal::SpatialReference::eCompoundOK);
+        // BOOST_CHECK_EQUAL(wkt2_ret,wkt3);
     }
 
     return;


More information about the Liblas-commits mailing list