[Liblas-commits] hg: strip bogus zero geokeys away when reading from VLR

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Jan 8 16:48:03 EST 2010


changeset 7a23780d2a0d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7a23780d2a0d
summary: strip bogus zero geokeys away when reading from VLR

diffstat:

 src/lasspatialreference.cpp |  15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r f42133fe6313 -r 7a23780d2a0d src/lasspatialreference.cpp
--- a/src/lasspatialreference.cpp	Fri Jan 08 00:58:41 2010 +0000
+++ b/src/lasspatialreference.cpp	Fri Jan 08 16:42:57 2010 -0500
@@ -328,7 +328,20 @@
         if (uid == record.GetUserId(true).c_str() && 34735 == record.GetRecordId())
         {
             int count = data.size()/sizeof(int16_t);
-            ST_SetKey(m_tiff, record.GetRecordId(), count, STT_SHORT, &(data[0]));
+            short *data_s = (short *) &(data[0]);
+
+            // discard invalid "zero" geotags some software emits.
+            while( count > 4 
+                   && data_s[count-1] == 0
+                   && data_s[count-2] == 0
+                   && data_s[count-3] == 0
+                   && data_s[count-4] == 0 )
+            {
+                count -= 4;
+                data_s[3] -= 1;
+            }
+
+            ST_SetKey(m_tiff, record.GetRecordId(), count, STT_SHORT, data_s );
         }
 
         if (uid == record.GetUserId(true).c_str() && 34736 == record.GetRecordId())


More information about the Liblas-commits mailing list