[Liblas-commits] hg: write the points as we get them,
don't construct big lists o...
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Feb 21 13:54:35 EST 2011
details: http://hg.liblas.orghg/rev/631497eb51d2
changeset: 2877:631497eb51d2
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Feb 21 12:54:31 2011 -0600
description:
write the points as we get them, don't construct big lists of points
diffstat:
python/scripts/oci2las.py | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diffs (87 lines):
diff -r 71dbcdd687d9 -r 631497eb51d2 python/scripts/oci2las.py
--- a/python/scripts/oci2las.py Sun Feb 20 21:34:19 2011 -0600
+++ b/python/scripts/oci2las.py Mon Feb 21 12:54:31 2011 -0600
@@ -18,7 +18,6 @@
ptsize = struct.calcsize(format)
-
class Translator(object):
def construct_parser(self):
@@ -116,6 +115,7 @@
self.first_point = True
self.cloud_column = True
self.header = None
+ self.points = []
if self.options.srs:
self.srs = srs.SRS()
@@ -140,15 +140,23 @@
return False
- def get_points(self, num_points, blob):
- points = []
-
+ def write_points(self, num_points, blob):
+ if not self.points:
+ for i in xrange(num_points):
+ p = point.Point()
+ p.header = self.header
+ self.points.append(p)
+ if (num_points > len(self.points)):
+ for i in xrange(num_points):
+ p = point.Point()
+ p.header = self.header
+ self.points.append(p)
+
for i in xrange(num_points):
rng = ptsize*i,ptsize*(i+1)
d = struct.unpack(format,blob[ptsize*i:ptsize*(i+1)])
x, y, z, time, classification, blk_id, pt_id = d
- p = point.Point()
- p.header = self.header
+ p = self.points[i]
p.x = x; p.y = y; p.z = z
p.classification = int(classification)
p.raw_time = time
@@ -174,8 +182,7 @@
self.count += 1
- points.append(p)
- return points
+ self.output.write(p)
def summarize_files(self):
pass
@@ -199,10 +206,6 @@
output = lasfile.File(self.options.output,mode='w',header=self.header)
return output
- def write_points(self, points):
-
- for p in points:
- self.output.write(p)
def rewrite_header(self):
self.output.close()
@@ -286,7 +289,7 @@
for row in cur:
num_points = row[num_pts_index]
blob = row[blob_index].read()
- points.append(self.get_points(num_points, blob))
+ self.write_points(num_points, blob)
# try to set the SRS
if not self.srs:
for col in row:
@@ -302,8 +305,6 @@
if not self.srs:
self.srs = srs.SRS()
- for pts in points:
- self.write_points(pts)
self.rewrite_header()
More information about the Liblas-commits
mailing list