[Liblas-commits] hg: fix for closing files under USE_BOOST_IO (for Maury)

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Feb 16 16:20:51 EST 2011


details:   http://hg.liblas.orghg/rev/6511163e5ba1
changeset: 2861:6511163e5ba1
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Feb 16 13:20:16 2011 -0800
description:
fix for closing files under USE_BOOST_IO (for Maury)
Subject: hg: merge

details:   http://hg.liblas.orghg/rev/2aa0f7838c0a
changeset: 2862:2aa0f7838c0a
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Feb 16 13:20:44 2011 -0800
description:
merge

diffstat:

 apps/lasinfo.cpp             |   2 +-
 doc/development/index.txt    |   1 +
 doc/development/wkt.txt      |  99 ++++++++++++++++++++++++++++++++++++++++++++
 include/liblas/liblas.hpp    |  18 ++++++++
 src/detail/reader/reader.cpp |   3 +-
 5 files changed, 121 insertions(+), 2 deletions(-)

diffs (184 lines):

diff -r ac359ef58925 -r 2aa0f7838c0a apps/lasinfo.cpp
--- a/apps/lasinfo.cpp	Mon Feb 14 09:11:00 2011 -0800
+++ b/apps/lasinfo.cpp	Wed Feb 16 13:20:44 2011 -0800
@@ -236,7 +236,7 @@
                             verbose
                             );
 
-        liblas::Header const& header = reader.GetHeader();
+        header = reader.GetHeader();
 
         // Add the header to the summary so we can get more detailed 
         // info
diff -r ac359ef58925 -r 2aa0f7838c0a doc/development/index.txt
--- a/doc/development/index.txt	Mon Feb 14 09:11:00 2011 -0800
+++ b/doc/development/index.txt	Wed Feb 16 13:20:44 2011 -0800
@@ -18,6 +18,7 @@
    Motivation <http://www.youtube.com/watch?v=u6XAPnuFjJc>
    2010 Annual Report <annual_report_2010>
    RFCs <rfc/index>
+   LAS 1.4 WKT Proposal <wkt>
 
 
 Authors
diff -r ac359ef58925 -r 2aa0f7838c0a doc/development/wkt.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/development/wkt.txt	Wed Feb 16 13:20:44 2011 -0800
@@ -0,0 +1,99 @@
+.. _srs_wkt:
+
+******************************************************************************
+Georeferencing LAS files with LAS 1.4
+******************************************************************************
+
+
+:Author: Howard Butler
+:Contact: hobu.inc at gmail dot com
+:Date: 2/16/2011
+
+Summary
+------------------------------------------------------------------------------
+
+This document proposes how to handle describing spatial reference systems 
+in `ASPRS LAS`_ 1.4. LAS 1.4 prescribes that software developers add and 
+prefer to use OGC WKT coordinate system description in the form of VLR 
+records in LAS files.  Softwares can choose to continue to write GeoTIFF keys 
+to support older applications, but they should prefer the OGC WKT if it is 
+found in the file.
+
+Rationale
+------------------------------------------------------------------------------
+
+LAS 1.3 and below have used `GeoTIFF`_ keys as described by the `GeoTIFF
+specification`_, but use of the GeoTIFF keys within LAS has a number of
+deficiencies:
+
+* GeoTIFF is typically tied to the `EPSG database`_ and does not provide
+  simple mechanisms for extended definitions.
+* Only a few softwares provide support for working with GeoTIFF keys directly.
+* The GeoTIFF specification has no organization backing its continued
+  development.
+* GeoTIFF does not offer a mechanism to represent transformations between
+  datums, while OGC WKT offers the TOWGS84[] mechanism
+
+OGC WKT
+------------------------------------------------------------------------------
+
+The `OGC Simple Feature Access`_ specification provides the "Well-known Text
+Representation of Spatial Reference Systems" (WKT) language in section nine.
+WKT is much more expressive than GeoTIFF keys, has an organization providing
+institutional heft and progress behind it, and a number of open source and
+commercial softwares are available to support parsing and interpreting WKT
+output.
+
+There are a few dialects of WKT of which to be aware. The most common dialect
+is the "ESRI WKT" dialect, which does not include TOWGS84 and authority nodes,
+but there are others including "GDAL", "CSMap", "Oracle 9", "Oracle 10", and
+"GeoTools." It should be assumed that all WKT provided in LAS files should be
+of a dialect that is not the "ESRI WKT" dialect, which lacks some important
+features -- notably TOWGS84 and AUTHORITY nodes. If you have questions about
+how to produce WKT, please participate on the `MetaCRS`_ mailing list.
+Examples of WKT may also be found on the http://spatialreference.org website.
+
+.. _`OGC Simple Feature Access`: http://www.opengeospatial.org/standards/sfa
+.. _`MetaCRS`: http://trac.osgeo.org/metacrs/
+
+Transition
+------------------------------------------------------------------------------
+
+Older softwares may want to continue to use GeoTIFF keys, and it is not
+desirable to have an abrupt discontinuity in the description of coordinate
+systems for LAS data. Additionally, while many softwares may not need the
+features of OGC WKT, its usage represents the strongest case for
+interoperability with other software -- especially software in the GIS and CAD
+domains that take advantage of the OGC WKT specification.
+
+Softwares that currently write GeoTIFF VLR records into LAS files can continue
+to do so in LAS 1.4. It is acceptable to write *only* GeoTIFF VLR records into
+an LAS file, while softwares that choose to write OGC WKT VLRs should also
+write GeoTIFF VLRs to promote backward compatibility. If a file is found to
+have both OGC WKT and GeoTIFF VLRs, the OGC WKT description, which is more
+expressive, should be preferred if possible.
+
+Implementation
+------------------------------------------------------------------------------
+
+OGC WKT strings shall be provided in a VLR with the following attributes:
+
+* User ID: LASF_Projection
+* Record ID: 2112
+
+The following conditions should also apply:
+
+* Because VLRs can only be 65536 bytes size, an OGC WKT string in a VLR data block 
+  is functionally limited to 64K in size.
+* The OGC WKT VLR data shall be a null-terminated string.
+* The OGC WKT VLR data shall be considered UTF-8.
+* The OGC WKT VLR data shall be considered ``C`` locale-based, and no 
+  localization of the numeric strings within the WKT should be performed.
+
+
+
+.. _`ASPRS LAS`: http://www.asprs.org/society/committees/standards/lidar_exchange_format.html
+.. _`GeoTIFF specification`: ftp://ftp.remotesensing.org/pub/geotiff/spec/geotiff.rtf
+.. _`GeoTIFF`: http://trac.osgeo.org/geotiff/
+.. _`EPSG database`: http://www.epsg-registry.org/
+
diff -r ac359ef58925 -r 2aa0f7838c0a include/liblas/liblas.hpp
--- a/include/liblas/liblas.hpp	Mon Feb 14 09:11:00 2011 -0800
+++ b/include/liblas/liblas.hpp	Wed Feb 16 13:20:44 2011 -0800
@@ -166,11 +166,20 @@
     // An ofstream is closeable and deletable, but 
     // an ostream like &std::cout isn't.
     if (!ofs) return;
+#ifdef USE_BOOST_IO
+    namespace io = boost::iostreams;
+    if (static_cast<io::stream<io::file_sink>&>(*ofs))
+    {
+        static_cast<io::stream<io::file_sink>&>(*ofs).close();
+        delete ofs;
+    }
+#else
     if (static_cast<std::ofstream&>(*ofs))
     {
         static_cast<std::ofstream&>(*ofs).close();
         delete ofs;
     }
+#endif
 }
 
 inline void Cleanup(std::istream* ifs)
@@ -178,11 +187,20 @@
     // An ifstream is closeable and deletable, but 
     // an istream like &std::cin isn't.
     if (!ifs) return;
+#ifdef USE_BOOST_IO
+    namespace io = boost::iostreams;
+    if (static_cast<io::stream<io::file_source>&>(*ifs))
+    {
+        static_cast<io::stream<io::file_source>&>(*ifs).close();
+        delete ifs;
+    }
+#else
     if (static_cast<std::ifstream&>(*ifs))
     {
         static_cast<std::ifstream&>(*ifs).close();
         delete ifs;
     }
+#endif
 }
 
 class ReaderI
diff -r ac359ef58925 -r 2aa0f7838c0a src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp	Mon Feb 14 09:11:00 2011 -0800
+++ b/src/detail/reader/reader.cpp	Wed Feb 16 13:20:44 2011 -0800
@@ -172,7 +172,8 @@
     } catch (std::runtime_error&)
     {
         // If the stream is no good anymore, we're done reading points
-        return;
+        throw std::out_of_range("ReadNextPoint: file has no more points to read, end of file reached");
+
     }
 
     // Filter the points and continue reading until we either find 


More information about the Liblas-commits mailing list