[Liblas-commits] r1047 - in trunk: src test/data

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Feb 18 23:17:07 EST 2009


Author: hobu
Date: Wed Feb 18 23:17:06 2009
New Revision: 1047
URL: http://liblas.org/changeset/1047

Log:
fix up SRS handling of ASCII keys. libgeotiff's simple keys stuff was at fault

Modified:
   trunk/src/lasheader.cpp
   trunk/src/lassrs.cpp
   trunk/test/data/1.0_0.las
   trunk/test/data/1.0_1.las
   trunk/test/data/1.1_0.las
   trunk/test/data/1.1_1.las
   trunk/test/data/1.2_0.las
   trunk/test/data/1.2_1.las
   trunk/test/data/1.2_2.las
   trunk/test/data/1.2_3.las

Modified: trunk/src/lasheader.cpp
==============================================================================
--- trunk/src/lasheader.cpp	(original)
+++ trunk/src/lasheader.cpp	Wed Feb 18 23:17:06 2009
@@ -777,7 +777,6 @@
     m_srs.ResetVLRs();
     
     std::vector<LASVLR> vlrs = m_srs.GetVLRs();
-    printf("vlrs size: %d", vlrs.size());
 
     ClearGeoKeyVLRs();
 

Modified: trunk/src/lassrs.cpp
==============================================================================
--- trunk/src/lassrs.cpp	(original)
+++ trunk/src/lassrs.cpp	Wed Feb 18 23:17:06 2009
@@ -154,11 +154,9 @@
     if (!m_gtiff) throw std::invalid_argument("m_gtiff was null");
 
     //GTIFF_GEOKEYDIRECTORY == 34735
-    ret = ST_GetKey(m_tiff, GTIFF_GEOKEYDIRECTORY, &kcount, &ktype, (void**)&kdata);
+    ret = ST_GetKey(m_tiff, 34735, &kcount, &ktype, (void**)&kdata);
     if (ret)
     {    
-        printf("ret passed for 34735\n");
-                 printf("kcount: %d ktype: %d\n ", kcount, ktype);
         LASVLR record;
         int i = 0;
         record.SetRecordId(34735);
@@ -185,12 +183,10 @@
         m_vlrs.push_back(record);
     }
 
-    // FIXME We don't handle ASCII keys yet
     // GTIFF_ASCIIPARAMS == 34737
-    ret = ST_GetKey(m_tiff, GTIFF_ASCIIPARAMS, &acount, &atype, (void**)&adata);
-    if (ret) {
-        printf("crap, we have ASCII records!!!\n");
-                
+    ret = ST_GetKey(m_tiff, 34737, &acount, &atype, (void**)&adata);
+    if (ret) 
+    {                    
          LASVLR record;
          int i = 0;
          record.SetRecordId(34737);
@@ -201,7 +197,6 @@
          record.SetRecordLength(length);
          
          // Copy the data into the data vector
-         printf("acount: %d atype: %d data %s\n ", acount, atype, (char*)adata);
          for (i=0; i<acount;i++) {
              avalue = adata[i];
              
@@ -224,11 +219,8 @@
 
     // GTIFF_DOUBLEPARAMS == 34736
     ret = ST_GetKey(m_tiff, 34736, &dcount, &dtype, (void**)&ddata);
-
     if (ret)
     {    
-        printf("ret passed for 34736\n");
-   
         LASVLR record;
         int i = 0;
         record.SetRecordId(34736);
@@ -254,14 +246,11 @@
             data.push_back(v[5]);
             data.push_back(v[6]);
             data.push_back(v[7]);   
-        }
-        
+        }        
         record.SetData(data);
         m_vlrs.push_back(record);
-
     }
     
-    printf("reset vlrs size: %d\n", m_vlrs.size());
 #endif // ndef HAVE_LIBGEOTIFF
 
 }
@@ -273,11 +262,9 @@
     // FIXME this is a bug.
     // if (m_gtiff) return m_gtiff;
     
-    if (m_tiff) printf("hey, we already had an m_tiff!!!\n");
     m_tiff = ST_Create();
     std::string const uid("LASF_Projection");
     
-    printf("m_vlrs.size() : %d ", m_vlrs.size());
     for (uint16_t i = 0; i < m_vlrs.size(); ++i)
     {
         LASVLR record = m_vlrs[i];
@@ -297,22 +284,15 @@
         if (uid == record.GetUserId(true).c_str() && 34737 == record.GetRecordId())
         {
             int count = data.size()/sizeof(uint8_t);
-            printf("ascii record count: %d\n", count);
             ST_SetKey(m_tiff, record.GetRecordId(), count, STT_ASCII, &(data[0]));
         }
     }
 
-    // if (m_tiff->key_count)
-    // {
-        m_gtiff = GTIFNewSimpleTags(m_tiff);
-        if (!m_gtiff) throw std::runtime_error("The geotiff keys could not read from VLR records");
-        return m_gtiff;
-    // } 
-    // else {
-    //     ST_Destroy(m_tiff);
-    //     m_tiff = NULL;
-    //     return NULL;
-    // }
+    m_gtiff = GTIFNewSimpleTags(m_tiff);
+    if (!m_gtiff) 
+        throw std::runtime_error("The geotiff keys could not read from VLR records");
+    return m_gtiff;
+
 #endif
 
     return NULL;
@@ -326,7 +306,7 @@
 #ifdef HAVE_GDAL
     GTIFDefn sGTIFDefn;
     char* pszWKT = NULL;
-    // if (!m_gtiff) return std::string("");
+    if (!m_gtiff) return std::string("");
     if( GTIFGetDefn( m_gtiff, &sGTIFDefn ) ) {
         pszWKT = GTIFGetOGISDefn( m_gtiff, &sGTIFDefn );
         if (pszWKT) {
@@ -347,7 +327,8 @@
     
     int ret = 0;
     ret = GTIFSetFromOGISDefn( m_gtiff, v.c_str() );
-    if (!ret) throw std::invalid_argument("could not set m_gtiff from WKT");
+    if (!ret) 
+        throw std::invalid_argument("could not set m_gtiff from WKT");
     ret = GTIFWriteKeys(m_gtiff);
     if (!ret) 
     {
@@ -367,7 +348,6 @@
     
     std::string wkt = GetWKT();
     const char* poWKT = wkt.c_str();
-    printf("wkt: %s", poWKT);
     
     OGRSpatialReference* poSRS = new OGRSpatialReference();
     if( poSRS->importFromWkt((char **) &poWKT) != OGRERR_NONE )
@@ -412,12 +392,8 @@
 
 #ifdef HAVE_GDAL
 
-    printf("Setting proj4 with gdal\n");
-
-    // std::string wkt = GetWKT();
     char* poWKT = NULL;
     const char* poProj4 = v.c_str();
-    printf("proj4: %s\n", poProj4);
     OGRSpatialReference* poSRS = new OGRSpatialReference();
     if( poSRS->importFromProj4((char *) poProj4) != OGRERR_NONE )
     {
@@ -447,17 +423,14 @@
         char* proj4def = GTIFGetProj4Defn(&defn);
         std::string tmp(proj4def);
         std::free(proj4def);
-        printf("current proj4 string: %s", proj4def);
     }
     
-        // printf("GetWKT(): %s\n", GetWKT().c_str());
 #endif
 
 // if we have libgeotiff but not GDAL, we'll use the 
 // simple method in libgeotiff
 #ifdef HAVE_LIBGEOTIFF
 #ifndef HAVE_GDAL
-    printf("Setting proj4 with geotiff\n");
 
     int ret = 0;
     ret = GTIFSetFromProj4( m_gtiff, v.c_str());

Modified: trunk/test/data/1.0_0.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.0_1.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.1_0.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.1_1.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.2_0.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.2_1.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.2_2.las
==============================================================================
Binary files. No diff available.

Modified: trunk/test/data/1.2_3.las
==============================================================================
Binary files. No diff available.


More information about the Liblas-commits mailing list