[Liblas-commits] hg: 3 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Oct 13 14:49:05 EDT 2009
changeset c95a65fbd674 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=c95a65fbd674
summary: add start of las_summary python example
changeset d64cffc97cf6 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=d64cffc97cf6
summary: get the file lists
changeset 8daffe9742d1 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=8daffe9742d1
summary: don't try to read off the end if we're reading a file that is only header
diffstat:
apps/las2oci.cpp | 20 ++++++
python/examples/las_summary.py | 117 +++++++++++++++++++++++++++++++++++++++
src/detail/reader.cpp | 17 ++++-
3 files changed, 150 insertions(+), 4 deletions(-)
diffs (182 lines):
diff -r ad18d8e2a303 -r 8daffe9742d1 apps/las2oci.cpp
--- a/apps/las2oci.cpp Sun Oct 11 22:28:16 2009 +0100
+++ b/apps/las2oci.cpp Tue Oct 13 13:46:24 2009 -0500
@@ -763,3 +763,23 @@
}
+//
+// select t.x, t.y, t.id from (
+// select
+//
+// sdo_pc_pkg.to_geometry(
+// a.points, -- point LOB
+// a.num_points, -- # of points in the LOB
+// 2, -- total dimensionality
+// 8265 -- SRID
+// ) shape from line_27006_reproj a
+// --)
+// )c , TABLE(SDO_UTIL.GETVERTICES(c.shape)) t
+// select sdo_pc_pkg.to_geometry(
+// a.points, -- point LOB
+// a.num_points, -- # of points in the LOB
+// 2, -- total dimensionality
+// 8265 -- SRID
+// ) shape from line_27006_reproj a
+// where rownum < 10
+
\ No newline at end of file
diff -r ad18d8e2a303 -r 8daffe9742d1 python/examples/las_summary.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/examples/las_summary.py Tue Oct 13 13:46:24 2009 -0500
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+
+from liblas import file as lasfile
+from liblas import header
+
+import glob
+
+import os, sys
+
+class Summary(object):
+
+ def construct_parser(self):
+ from optparse import OptionParser, OptionGroup
+ usage = "usage: %prog [options] arg"
+ parser = OptionParser(usage)
+ g = OptionGroup(parser, "Base options", "Basic Translation Options")
+ g.add_option("-i", "--input", dest="input",
+ help="Input directory", metavar="INPUT")
+ g.add_option("-o", "--output", dest='output',
+ help="ReSTructured text file to write for output", metavar="OUTPUT")
+ g.add_option("-r", "--recursive",
+ action="store_true", dest="recursive",
+ help="recurse down the directory")
+
+ g.add_option("-u", "--url", dest='url',
+ help="URL to base for links to files", metavar="URL")
+
+ g.add_option("-q", "--quiet",
+ action="store_false", dest="verbose", default=False,
+ help="Don't say what we're doing on stdout")
+
+ parser.add_option_group(g)
+
+ if self.opts:
+ g = OptionGroup(parser, "Special Options", "Special options")
+ for o in self.opts:
+ g.add_option(o)
+ parser.add_option_group(g)
+
+ parser.set_defaults(verbose=True, recursive=False)
+
+ self.parser = parser
+
+ def __init__(self, arguments, options=None):
+ self.input = None
+ self.output = None
+
+ self.opts = options
+ self.construct_parser()
+ self.options, self.args = self.parser.parse_args(args=arguments)
+
+ if self.args:
+ self.options.input = self.args[0]
+ if not self.options.output:
+ try:
+ self.options.output = self.args[1]
+ except IndexError:
+ self.options.output = 'output.txt'
+ print self.options, self.args
+
+
+ def list_files(self):
+ def get_files(path):
+ output = []
+ fn = path+"/*.LAS"
+ output = glob.glob(fn)
+ fn = path+"/*.las"
+ output.extend(glob.glob(fn))
+ return output
+
+ if self.options.input:
+ self.options.input = os.path.abspath(self.options.input)
+ if not os.path.isdir(self.options.input):
+ raise self.parser.error("Inputted path '%s' was not a directory" % self.options.input)
+ else:
+ raise self.parser.error("No input directory was specified")
+
+ if self.options.recursive:
+ directories = {}
+ for root, dirs, files in os.walk(self.options.input):
+ directories[root] = root
+ for d in dirs:
+ directories[os.path.join(root, d)] = os.path.join(root, d)
+
+ self.files = []
+ for d in directories:
+ print d
+ files = get_files(d)
+ print files
+ if files:
+ self.files.extend(files)
+
+ else:
+ get_files(self.options.input)
+
+ print self.files
+
+ def process(self):
+ self.list_files()
+ return None
+
+def main():
+ import optparse
+
+ options = []
+# o = optparse.make_option("-r", "--remainder", dest="remainder",
+# type="choice",default='end',
+# help="""what to do with the remainder -- place it at the beginning,
+# place it at the end, or evenly distribute it across the segment""",
+# choices=['end','begin','uniform'])
+# options.append(o)
+
+ d = Summary(sys.argv[1:], options=options)
+ d.process()
+
+if __name__=='__main__':
+ main()
\ No newline at end of file
diff -r ad18d8e2a303 -r 8daffe9742d1 src/detail/reader.cpp
--- a/src/detail/reader.cpp Sun Oct 11 22:28:16 2009 +0100
+++ b/src/detail/reader.cpp Tue Oct 13 13:46:24 2009 -0500
@@ -283,15 +283,24 @@
uint8_t pad2 = 0x0;
std::streamsize const current_pos = m_ifs.tellg();
-
- detail::read_n(pad1, m_ifs, sizeof(uint8_t));
- detail::read_n(pad2, m_ifs, sizeof(uint8_t));
+ // If our little test reads off the end, we'll try to put the
+ // borken dishes back up in the cabinet
+ try {
+ detail::read_n(pad1, m_ifs, sizeof(uint8_t));
+ detail::read_n(pad2, m_ifs, sizeof(uint8_t));
+ } catch (std::out_of_range& e) {
+ m_ifs.seekg(current_pos, std::ios::beg);
+ return false;
+ } catch (std::runtime_error& e) {
+ m_ifs.seekg(current_pos, std::ios::beg);
+ return false;
+ }
LIBLAS_SWAP_BYTES(pad1);
LIBLAS_SWAP_BYTES(pad2);
// Put the stream back where we found it
- m_ifs.seekg(current_pos, std::ios::beg);
+ m_ifs.seekg(current_pos, std::ios::beg);
// FIXME: we have to worry about swapping issues
// but some people write the pad bytes backwards
More information about the Liblas-commits
mailing list