[Liblas-commits] hg: 7 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Oct 7 12:30:09 EDT 2009
changeset 83fb11d21583 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=83fb11d21583
summary: header copying and ownership
changeset 42558825e919 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=42558825e919
summary: make sure to create the transform after setting SRSs
changeset 1778b1eb676c in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=1778b1eb676c
summary: more accurate comment
changeset ed5158128d19 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=ed5158128d19
summary: more srs testing
changeset 1e68497b2b03 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=1e68497b2b03
summary: set srs on writer, not reader
changeset f951f8393cca in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=f951f8393cca
summary: more accurate comment
changeset 5089f650f470 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=5089f650f470
summary: more precise test when checking if gtiff/tiff pointers exist
diffstat:
apps/las2las.c | 36 +++++++++++-------------------------
include/liblas/lasreader.hpp | 2 ++
python/liblas/header.py | 13 +++++++++----
python/tests/SRS.txt | 21 +++++++++++++++------
src/detail/writer.cpp | 5 ++++-
src/lasreader.cpp | 2 +-
src/lasspatialreference.cpp | 12 +++++-------
7 files changed, 47 insertions(+), 44 deletions(-)
diffs (239 lines):
diff -r 94416cbd4575 -r 5089f650f470 apps/las2las.c
--- a/apps/las2las.c Tue Oct 06 11:47:34 2009 -0500
+++ b/apps/las2las.c Wed Oct 07 11:27:24 2009 -0500
@@ -396,17 +396,6 @@
exit(1);
}
- if (in_srs != NULL) {
- LASReader_SetInputSRS(reader, in_srs);
- }
-
- if (out_srs != NULL) {
- if (verbose) {
- fprintf(stderr,
- "Setting LASReader_SetOutputSRS to %s", LASSRS_GetProj4(out_srs));
- }
- LASReader_SetOutputSRS(reader, out_srs);
- }
header = LASReader_GetHeader(reader);
if (!header) {
@@ -701,13 +690,6 @@
exit(1);
}
- if (in_srs != NULL) {
- LASReader_SetInputSRS(reader, in_srs);
- }
-
- if (out_srs != NULL) {
- LASReader_SetOutputSRS(reader, out_srs);
- }
header = LASReader_GetHeader(reader);
if (!header) {
@@ -814,6 +796,17 @@
exit(1);
}
+ if (in_srs != NULL) {
+ LASWriter_SetInputSRS(reader, in_srs);
+ }
+
+ if (out_srs != NULL) {
+ if (verbose) {
+ fprintf(stderr,
+ "Setting LASWriter_SetOutputSRS to %s", LASSRS_GetProj4(out_srs));
+ }
+ LASWriter_SetOutputSRS(reader, out_srs);
+ }
/*
if (!remove_extra_header)
@@ -843,13 +836,6 @@
exit(1);
}
- if (in_srs != NULL) {
- LASReader_SetInputSRS(reader, in_srs);
- }
-
- if (out_srs != NULL) {
- LASReader_SetOutputSRS(reader, out_srs);
- }
p = LASReader_GetNextPoint(reader);
if (!p) {
diff -r 94416cbd4575 -r 5089f650f470 include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp Tue Oct 06 11:47:34 2009 -0500
+++ b/include/liblas/lasreader.hpp Wed Oct 07 11:27:24 2009 -0500
@@ -150,6 +150,8 @@
LASPoint m_point;
std::vector<LASVariableRecord> m_vlrs;
+ // Set if the user provides a header to override the header as
+ // read from the istream
bool bCustomHeader;
};
diff -r 94416cbd4575 -r 5089f650f470 python/liblas/header.py
--- a/python/liblas/header.py Tue Oct 06 11:47:34 2009 -0500
+++ b/python/liblas/header.py Wed Oct 07 11:27:24 2009 -0500
@@ -54,14 +54,19 @@
elif (year % 4) == 0:
return False
return False
-
+
class Header(object):
- def __init__(self, owned=True, handle=None):
+ def __init__(self, owned=True, handle=None, copy=False):
if handle:
- self.handle = handle
+ if copy:
+ self.handle = core.las.LASHeader_Copy(handle)
+ self.owned = True
+ else:
+ self.handle = handle
+ self.owned = False
else:
self.handle = core.las.LASHeader_Create()
- self.owned = owned
+ self.owned = True
def __del__(self):
if self.owned:
if self.handle and core:
diff -r 94416cbd4575 -r 5089f650f470 python/tests/SRS.txt
--- a/python/tests/SRS.txt Tue Oct 06 11:47:34 2009 -0500
+++ b/python/tests/SRS.txt Wed Oct 07 11:27:24 2009 -0500
@@ -1,5 +1,7 @@
>>> from liblas import srs
>>> from liblas import point
+ >>> from liblas import header
+
>>> import liblas
>>> s = srs.SRS()
>>> s.proj4
@@ -79,6 +81,9 @@
# -93.3515625902 41.5771483954
+ >>> def new_offset(old_scale, new_scale, old_offset, x):
+ ... return (new_scale*(x - old_offset) - old_scale*x)/(-1.0*old_scale)
+
>>> utm_wkt = """PROJCS["NAD83 / UTM zone 15N",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4269"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-93],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","26915"]]"""
>>> dd_wkt = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]"""
@@ -88,16 +93,20 @@
>>> s_utm.wkt = utm_wkt
>>> f = file.File('../test/data/1.2_3.las',mode='r')
- >>> dd_header = f.header
- >>> utm_header = f.header
+ >>> dd_header = liblas.header.Header(handle=f.header.handle,copy=True)
+ >>> utm_header = liblas.header.Header(handle=f.header.handle,copy=True)
>>> del f
>>> utm_header.offset
[0.0, 0.0, 0.0]
- >>> utm_header.offset = [offset+1.0/0.000001 for offset in utm_header.offset]
- >>> utm_header.offset
+ >>> utm_header.scale
+ [0.01, 0.01, 0.01]
+
+# >>> new_offset(0.01, 0.0001, 0.0, 470692.44)
+# >>> utm_header.offset = [offset+1.0/0.000001 for offset in utm_header.offset]
+# >>> utm_header.offset
[1000000.0, 1000000.0, 1000000.0]
- >>> utm_header.scale = [0.000001,0.000001,0.000001]
+# >>> utm_header.scale = [0.000001,0.000001,0.000001]
>>> utm_header.srs = s_utm
>>> dd_header.scale = [0.000001,0.000001,0.000001]
@@ -107,7 +116,7 @@
>>> f.header.data_offset
438L
>>> f.header.scale
- [9.9999999999999995e-07, 9.9999999999999995e-07, 9.9999999999999995e-07]
+ [0.01, 0.01, 0.01]
>>> p = f.read(0)
>>> origx, origy = p.x, p.y
>>> origx, origy
diff -r 94416cbd4575 -r 5089f650f470 src/detail/writer.cpp
--- a/src/detail/writer.cpp Tue Oct 06 11:47:34 2009 -0500
+++ b/src/detail/writer.cpp Wed Oct 07 11:27:24 2009 -0500
@@ -168,16 +168,19 @@
void Writer::SetOutputSRS(const LASSpatialReference& srs )
{
m_out_srs = srs;
+ CreateTransform();
+
}
void Writer::SetSRS(const LASSpatialReference& srs )
{
- m_out_srs = srs;
+ SetOutputSRS(srs);
}
void Writer::SetInputSRS(const LASSpatialReference& srs )
{
m_in_srs = srs;
+ CreateTransform();
}
void Writer::CreateTransform()
diff -r 94416cbd4575 -r 5089f650f470 src/lasreader.cpp
--- a/src/lasreader.cpp Tue Oct 06 11:47:34 2009 -0500
+++ b/src/lasreader.cpp Wed Oct 07 11:27:24 2009 -0500
@@ -122,7 +122,7 @@
void LASReader::Init()
{
// Copy our existing header in case we have already set a custom
- // one. We will use this instead of the one from the file if
+ // one. We will use this instead of the one from the stream if
// the constructor with the header was used.
LASHeader custom_header(m_header);
diff -r 94416cbd4575 -r 5089f650f470 src/lasspatialreference.cpp
--- a/src/lasspatialreference.cpp Tue Oct 06 11:47:34 2009 -0500
+++ b/src/lasspatialreference.cpp Wed Oct 07 11:27:24 2009 -0500
@@ -61,7 +61,8 @@
{
if (&rhs != this)
{
- SetVLRs(rhs.GetVLRs());
+ std::vector<LASVariableRecord> vlrs = rhs.GetVLRs();
+ SetVLRs(vlrs);
GetGTIF();
}
return *this;
@@ -101,10 +102,7 @@
/// Keep a copy of the VLRs that are related to GeoTIFF SRS information.
void LASSpatialReference::SetVLRs(std::vector<LASVariableRecord> const& vlrs)
-{
-
- std::string const uid("LASF_Projection");
-
+{
// Wipe out any existing VLRs that might exist on the LASSpatialReference
m_vlrs.clear();
@@ -308,13 +306,13 @@
// If we already have m_gtiff and m_tiff, that is because we have
// already called GetGTIF once before. VLRs ultimately drive how the
// LASSpatialReference is defined, not the GeoTIFF keys.
- if (m_tiff)
+ if (m_tiff != 0)
{
ST_Destroy(m_tiff);
m_tiff = 0;
}
- if (m_gtiff)
+ if (m_gtiff != 0)
{
GTIFFree(m_gtiff);
m_gtiff = 0;
More information about the Liblas-commits
mailing list