[Liblas-commits] hg: silence a number of const warnings. I'm not so happy about ...

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jan 3 12:26:21 EST 2011


details:   http://hg.liblas.orghg/rev/1136cca0edb7
changeset: 2667:1136cca0edb7
user:      Howard Butler <hobu.inc at gmail.com>
date:      Mon Jan 03 11:25:58 2011 -0600
description:
silence a number of const warnings.  I'm not so happy about the GTIFF/ST_TIFF ones, but i'm unsure what to do.  We could make a copy, I guess

diffstat:

 include/liblas/spatialreference.hpp |  2 +-
 src/c_api.cpp                       |  7 ++++++-
 src/spatialreference.cpp            |  8 ++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diffs (68 lines):

diff -r 93097e6f160b -r 1136cca0edb7 include/liblas/spatialreference.hpp
--- a/include/liblas/spatialreference.hpp	Mon Jan 03 10:13:03 2011 -0600
+++ b/include/liblas/spatialreference.hpp	Mon Jan 03 11:25:58 2011 -0600
@@ -101,7 +101,7 @@
     /// you have libgeotiff linked in.
     const GTIF* GetGTIF();
 
-    void SetGTIF(const GTIF* pgtiff, const ST_TIFF* ptiff);
+    void SetGTIF(GTIF* pgtiff, ST_TIFF* ptiff);
 
     /// Returns the OGC WKT describing Spatial Reference System.
     /// If GDAL is linked, it uses GDAL's operations and methods to determine 
diff -r 93097e6f160b -r 1136cca0edb7 src/c_api.cpp
--- a/src/c_api.cpp	Mon Jan 03 10:13:03 2011 -0600
+++ b/src/c_api.cpp	Mon Jan 03 11:25:58 2011 -0600
@@ -1900,7 +1900,12 @@
     VALIDATE_LAS_POINTER1(pgtiff, "LASSRS_SetGTIF", LE_Failure);
     VALIDATE_LAS_POINTER1(ptiff, "LASSRS_SetGTIF", LE_Failure);
     try {
-        ((liblas::SpatialReference*) hSRS)->SetGTIF((const GTIF*)pgtiff, (const ST_TIFF*) ptiff);
+        const GTIF* cgtiff = static_cast<const GTIF*>(pgtiff);
+        const ST_TIFF* ctiff = static_cast<const ST_TIFF*>(ptiff);
+        GTIF* gtiff = const_cast<GTIF*>(cgtiff);
+        ST_TIFF* tiff = const_cast<ST_TIFF*>(ctiff);
+        
+        ((liblas::SpatialReference*) hSRS)->SetGTIF(gtiff, tiff);
     }
     catch (std::exception const& e) {
         LASError_PushError(LE_Failure, e.what(), "LASSRS_SetGTIF");
diff -r 93097e6f160b -r 1136cca0edb7 src/spatialreference.cpp
--- a/src/spatialreference.cpp	Mon Jan 03 10:13:03 2011 -0600
+++ b/src/spatialreference.cpp	Mon Jan 03 11:25:58 2011 -0600
@@ -437,7 +437,7 @@
     }
 }
 
-void SpatialReference::SetGTIF(const GTIF* pgtiff, const ST_TIFF* ptiff) 
+void SpatialReference::SetGTIF(GTIF* pgtiff, ST_TIFF* ptiff) 
 {
     m_gtiff = (GTIF*)pgtiff;
     m_tiff = (ST_TIFF*)ptiff;
@@ -635,7 +635,7 @@
     
     // OGRSpatialReference* poSRS = (OGRSpatialReference*) OSRNewSpatialReference(NULL);
     OGRSpatialReference srs(NULL);
-    if (OGRERR_NONE != srs.SetFromUserInput((char *) input))
+    if (OGRERR_NONE != srs.SetFromUserInput(const_cast<char *> (input)))
     {
         throw std::invalid_argument("could not import coordinate system into OSRSpatialReference SetFromUserInput");
     }
@@ -733,7 +733,7 @@
     const char* poWKT = wkt.c_str();
     
     OGRSpatialReference srs(NULL);
-    if (OGRERR_NONE != srs.importFromWkt((char **) &poWKT))
+    if (OGRERR_NONE != srs.importFromWkt(const_cast<char **> (&poWKT)))
     {
         return std::string();
     }
@@ -780,7 +780,7 @@
     const char* poProj4 = v.c_str();
 
     OGRSpatialReference srs(NULL);
-    if (OGRERR_NONE != srs.importFromProj4((char *) poProj4))
+    if (OGRERR_NONE != srs.importFromProj4(const_cast<char *>(poProj4)))
     {
         throw std::invalid_argument("could not import proj4 into OSRSpatialReference SetProj4");
     }


More information about the Liblas-commits mailing list