[Liblas-commits] hg: 5 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Apr 8 09:08:37 EDT 2010
changeset 0bd9ff5346c4 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0bd9ff5346c4
summary: switch to using PointFormat exclusively to manage point size and configuration
changeset 7a85b3137403 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7a85b3137403
summary: more docs
changeset 32c5be310102 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=32c5be310102
summary: more docs
changeset a19a7c05ab22 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=a19a7c05ab22
summary: don't depend on ctypes return being None
changeset 5d81f6a34091 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5d81f6a34091
summary: cache PointFormat for header
diffstat:
include/liblas/detail/reader/point.hpp | 1 +
include/liblas/lasformat.hpp | 51 ------------------------
python/liblas/file.py | 7 +-
python/liblas/format.py | 5 +-
python/liblas/header.py | 12 +++-
python/liblas/srs.py | 36 ++++++++++++++++-
src/detail/reader/point.cpp | 18 ++++----
src/lasformat.cpp | 70 +++++++++++++++++++++++++++------
src/lasheader.cpp | 71 ++++++++++++++++++---------------
9 files changed, 157 insertions(+), 114 deletions(-)
diffs (truncated from 564 to 300 lines):
diff -r a6eb8704978d -r 5d81f6a34091 include/liblas/detail/reader/point.hpp
--- a/include/liblas/detail/reader/point.hpp Wed Apr 07 14:51:29 2010 -0500
+++ b/include/liblas/detail/reader/point.hpp Thu Apr 08 08:02:16 2010 -0500
@@ -92,6 +92,7 @@
liblas::Point m_point;
OGRCoordinateTransformationH m_transform;
+ PointFormat m_format;
void project();
void setup();
diff -r a6eb8704978d -r 5d81f6a34091 include/liblas/lasformat.hpp
--- a/include/liblas/lasformat.hpp Wed Apr 07 14:51:29 2010 -0500
+++ b/include/liblas/lasformat.hpp Thu Apr 08 08:02:16 2010 -0500
@@ -67,7 +67,6 @@
bool bTime);
PointFormat& operator=(PointFormat const& rhs);
PointFormat(PointFormat const& other);
- PointFormat();
~PointFormat() {};
@@ -106,57 +105,7 @@
liblas::uint16_t calculate_base_size();
};
-inline uint16_t PointFormat::GetByteSize() const
-{
- return m_size;
-}
-inline void PointFormat::SetByteSize(uint16_t const& value)
-{
- updatesize(value);
-}
-
-inline uint8_t PointFormat::GetVersionMajor() const
-{
- return m_versionmajor;
-}
-
-inline void PointFormat::SetVersionMajor(uint8_t const& value)
-{
- m_versionmajor = value;
-}
-
-inline uint8_t PointFormat::GetVersionMinor() const
-{
- return m_versionminor;
-}
-
-inline void PointFormat::SetVersionMinor(uint8_t const& value)
-{
- m_versionminor = value;
-}
-
-inline bool PointFormat::HasColor() const
-{
- return m_hasColor;
-}
-
-inline void PointFormat::Color(bool const& value)
-{
- m_hasColor = value;
- updatesize();
-}
-
-inline bool PointFormat::HasTime() const
-{
- return m_hasTime;
-}
-
-inline void PointFormat::Time(bool const& value)
-{
- m_hasTime = value;
- updatesize();
-}
} // namespace liblas
diff -r a6eb8704978d -r 5d81f6a34091 python/liblas/file.py
--- a/python/liblas/file.py Wed Apr 07 14:51:29 2010 -0500
+++ b/python/liblas/file.py Thu Apr 08 08:02:16 2010 -0500
@@ -111,7 +111,7 @@
"""
if self._mode == 'r' or self._mode =='rb':
- if not self._header:
+ if self._header == None:
self.handle = core.las.LASReader_Create(self.filename)
self._header = lasheader.Header(handle = core.las.LASReader_GetHeader(self.handle))
else:
@@ -126,7 +126,8 @@
core.las.LASReader_SetOutputSRS(self.handle, self.out_srs.handle)
if self._mode == 'w' and '+' not in self._mode:
- if not self._header:
+
+ if self._header == None:
self._header = lasheader.Header(handle = core.las.LASHeader_Create())
self.handle = core.las.LASWriter_Create(self.filename, self._header.handle, 1)
self.mode = 1
@@ -138,7 +139,7 @@
core.las.LASWriter_SetOutputSRS(self.handle, self.out_srs.handle)
if '+' in self._mode and 'r' not in self._mode:
- if not self._header:
+ if self._header == None:
reader = core.las.LASReader_Create(self.filename)
self._header = lasheader.Header(handle = core.las.LASReader_GetHeader(reader))
core.las.LASReader_Destroy(reader)
diff -r a6eb8704978d -r 5d81f6a34091 python/liblas/format.py
--- a/python/liblas/format.py Wed Apr 07 14:51:29 2010 -0500
+++ b/python/liblas/format.py Thu Apr 08 08:02:16 2010 -0500
@@ -43,9 +43,12 @@
import core
class Format(object):
+ """:class:`liblas.format.Format` is an object that keeps track of the point
+ format sizes and what data elements the point formats have (color, time, etc),
+ as well as accounting for their size in bytes. """
def __init__(self, major=1, minor=2, time=False, color = False, size=0, handle=None):
"""
- :keyword major: Major version value (practically always 1 for libLAS)
+ :keyword major: Major version value (always 1 for libLAS)
:type major: integer
:keyword minor: Minor version value (no validation done)
:type minor: integer
diff -r a6eb8704978d -r 5d81f6a34091 python/liblas/header.py
--- a/python/liblas/header.py Wed Apr 07 14:51:29 2010 -0500
+++ b/python/liblas/header.py Thu Apr 08 08:02:16 2010 -0500
@@ -167,10 +167,12 @@
def get_majorversion(self):
"""Returns the major version for the file. Expect this value to always be 1"""
- return core.las.LASHeader_GetVersionMajor(self.handle)
+ return self.format.major
def set_majorversion(self, value):
"""Sets the major version for the file. Only the value 1 is accepted at this time"""
- return core.las.LASHeader_SetVersionMajor(self.handle, value)
+ f = self.format
+ f.major = value
+ self.format = f
doc = """Major version number for the file. For all practical purposes, \
this is always '1'"""
major_version = property(get_majorversion, set_majorversion, None, doc)
@@ -179,10 +181,12 @@
def get_minorversion(self):
"""Returns the minor version of the file. Expect this value to always be 0, 1, or 2"""
- return core.las.LASHeader_GetVersionMinor(self.handle)
+ return self.format.minor
def set_minorversion(self, value):
"""Sets the minor version of the file. The value should be 0 for 1.0 LAS files, 1 for 1.1 LAS files ..."""
- return core.las.LASHeader_SetVersionMinor(self.handle, value)
+ f = self.format
+ f.minor = value
+ self.format = f
doc = """Minor version for the file. [0, 1, 2] are currently supported."""
minor_version = property(get_minorversion, set_minorversion, None, doc)
version_minor = minor_version
diff -r a6eb8704978d -r 5d81f6a34091 python/liblas/srs.py
--- a/python/liblas/srs.py Wed Apr 07 14:51:29 2010 -0500
+++ b/python/liblas/srs.py Thu Apr 08 08:02:16 2010 -0500
@@ -45,7 +45,19 @@
import vlr
class SRS(object):
+ """While the ASPRS specification mandates using GeoTIFF keys for its \
+ coordinate system description, these are unwieldy to use in an application.
+ libLAS provides the most featureful access when by linking GDAL_. The
+ :obj:`liblas.srs.SRS` object can be set on the :obj:`liblas.header.Header`
+ or it may be set on the :obj:`liblas.file.File` in various ways of
+ controlling reprojection of input or output. """
def __init__(self, owned=True, handle=None):
+ """
+ :keyword owned: flag to denote whether or not the VLR owns itself
+ :keyword handle: raw ctypes object
+
+
+ """
if handle:
self.handle = handle
else:
@@ -59,25 +71,47 @@
def set_verticalcs( self, verticalCSType, citation = '',
verticalDatum = -1,
verticalUnits = 9001 ):
+ """Sets the vertical coordinate system using geotiff key values. This operation
+should normally be done after setting the horizontal portion of the coordinate
+system with something like :meth:`set_wkt`, :meth:`set_proj4`, or :meth:`set_userinput`
+
+ :arg verticalCSType: An EPSG vertical coordinate system code, \
+ normally in the range 5600 to 5799, or -1 if one is not available.
+ :keyword citation: a textual description of the vertical coordinate \
+ system or an empty string if nothing is available.
+ :keyword verticalDatum: the EPSG vertical datum code, often in the range \
+ 5100 to 5299 - implied by verticalCSType if that is provided, or -1 if \
+ no value is available.
+ :keyword verticalUnits: the EPSG vertical units code, often 9001 for Metre.
+ """
return core.las.LASSRS_SetVerticalCS( self.handle, verticalCSType,
citation, verticalDatum,
verticalUnits )
def get_wkt(self):
+ """Returns the horizontal-only WKT for the SRS"""
return core.las.LASSRS_GetWKT(self.handle)
def get_wkt_compoundok(self):
+ """Gets the WKT for the SRS with COMP_CS elements describing the vertical datum and other extra information"""
return core.las.LASSRS_GetWKT_CompoundOK(self.handle)
def set_wkt(self, value):
+ """Sets the wkt for the SRS. An exception will be thrown if the WKT is
+ invalid, GDAL can't ingest it, or GDAL_ is not linked into libLAS"""
return core.las.LASSRS_SetWKT(self.handle, value)
- wkt = property(get_wkt, set_wkt)
+ doc = "WKT description of the SRS"
+ wkt = property(get_wkt, set_wkt, None, doc)
def set_userinput(self, value):
+ """Sets the SRS description using GDAL_'s SetFromUserInput_ method"""
return core.las.LASSRS_SetFromUserInput(self.handle, value)
def get_proj4(self):
+ """Returns a Proj.4_ string that describes the SRS"""
return core.las.LASSRS_GetProj4(self.handle)
def set_proj4(self, value):
+ """Sets the SRS description with a given Proj.4_ string"""
return core.las.LASSRS_SetProj4(self.handle, value)
+ doc = "Proj.4_ description of the SRS"
proj4 = property(get_proj4, set_proj4)
def AddVLR(self, vlr):
diff -r a6eb8704978d -r 5d81f6a34091 src/detail/reader/point.cpp
--- a/src/detail/reader/point.cpp Wed Apr 07 14:51:29 2010 -0500
+++ b/src/detail/reader/point.cpp Thu Apr 08 08:02:16 2010 -0500
@@ -54,7 +54,7 @@
}
Point::Point(std::istream& ifs, const liblas::Header& header) :
- m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(0)
+ m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(0),m_format(header.GetPointFormat())
{
setup();
}
@@ -62,7 +62,7 @@
Point::Point( std::istream& ifs,
const liblas::Header& header,
OGRCoordinateTransformationH transform) :
- m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(transform)
+ m_ifs(ifs), m_header(header), m_point(liblas::Point()), m_transform(transform), m_format(header.GetPointFormat())
{
setup();
}
@@ -92,7 +92,7 @@
// TODO: Replace with compile-time assert
assert(liblas::ePointSize0 == sizeof(record));
- const PointFormat& format = m_header.GetPointFormat();
+ // const PointFormat& format = m_header.GetPointFormat();
try
{
@@ -108,14 +108,14 @@
// Reader::FillPoint(record, m_point, m_header);
m_point.SetCoordinates(m_header, m_point.GetX(), m_point.GetY(), m_point.GetZ());
- if (format.HasTime())
+ if (m_format.HasTime())
{
detail::read_n(gpst, m_ifs, sizeof(double));
m_point.SetTime(gpst);
bytesread += sizeof(double);
- if (format.HasColor())
+ if (m_format.HasColor())
{
detail::read_n(red, m_ifs, sizeof(uint16_t));
detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -127,7 +127,7 @@
bytesread += 3 * sizeof(uint16_t);
}
} else {
- if (format.HasColor())
+ if (m_format.HasColor())
{
detail::read_n(red, m_ifs, sizeof(uint16_t));
detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -140,16 +140,16 @@
}
}
- if (bytesread != format.GetByteSize()) {
+ if (bytesread != m_format.GetByteSize()) {
std::ostringstream msg;
msg << "The number of bytes that were read ("<< bytesread <<") does not "
"match the number of bytes the point's format "
"says it should have (" <<
- format.GetByteSize() << ")";
More information about the Liblas-commits
mailing list