From f75547021daf94226d4963b17c2ec2d0fe524a60 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 24 Jun 2013 13:47:37 -0700 Subject: [PATCH 1/3] Accept user offsets in the *output* SRS --- src/filters/InPlaceReprojection.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/filters/InPlaceReprojection.cpp b/src/filters/InPlaceReprojection.cpp index 86ce598d5d..599d1886da 100644 --- a/src/filters/InPlaceReprojection.cpp +++ b/src/filters/InPlaceReprojection.cpp @@ -248,21 +248,29 @@ Schema InPlaceReprojection::alterSchema(Schema& schema) log()->get(logDEBUG3) << "Fetched x_name: " << dimX; log()->get(logDEBUG3) << "Fetched y_name: " << dimY; log()->get(logDEBUG3) << "Fetched z_name: " << dimZ; - - double offset_x = getOptions().getValueOrDefault("offset_x", dimX.getNumericOffset()); - double offset_y = getOptions().getValueOrDefault("offset_y", dimY.getNumericOffset()); - double offset_z = getOptions().getValueOrDefault("offset_z", dimZ.getNumericOffset()); + /* Start with the incoming dimension offsets */ + double offset_x = dimX.getNumericOffset(); + double offset_y = dimY.getNumericOffset(); + double offset_z = dimZ.getNumericOffset(); + + /* Reproject incoming offsets to new coordinate system */ log()->floatPrecision(8); - log()->get(logDEBUG2) << "original offset x,y: " << offset_x <<"," << offset_y << std::endl; reprojectOffsets(offset_x, offset_y, offset_z); log()->get(logDEBUG2) << "reprojected offset x,y: " << offset_x <<"," << offset_y << std::endl; + /* If user-specified offsets exist, use those instead of the reprojected offsets */ + offset_x = getOptions().getValueOrDefault("offset_x", offset_x); + offset_y = getOptions().getValueOrDefault("offset_y", offset_y); + offset_z = getOptions().getValueOrDefault("offset_z", offset_z); + + /* Read any user-specified scales */ double scale_x = getOptions().getValueOrDefault("scale_x", dimX.getNumericScale()); double scale_y = getOptions().getValueOrDefault("scale_y", dimY.getNumericScale()); double scale_z = getOptions().getValueOrDefault("scale_z", dimZ.getNumericScale()); + /* Apply scaling/offset to output schema */ setDimension(x_name, m_old_x_id, m_new_x_id, schema, scale_x, offset_x); setDimension(y_name, m_old_y_id, m_new_y_id, schema, scale_y, offset_y); setDimension(z_name, m_old_z_id, m_new_z_id, schema, scale_z, offset_z); From 682c2e18ea379119ecd9faf475838f4c592e10ca Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 24 Jun 2013 14:18:53 -0700 Subject: [PATCH 2/3] Fix for #142, actually use the z_offset reference if requested --- src/filters/InPlaceReprojection.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/filters/InPlaceReprojection.cpp b/src/filters/InPlaceReprojection.cpp index 86ce598d5d..3f7c0b1d86 100644 --- a/src/filters/InPlaceReprojection.cpp +++ b/src/filters/InPlaceReprojection.cpp @@ -206,17 +206,17 @@ void InPlaceReprojection::setDimension( std::string const& name, void InPlaceReprojection::reprojectOffsets( double& offset_x, double& offset_y, - double& ) + double& offset_z) { #ifdef PDAL_HAVE_GDAL int ret = 0; - double dummy_x(0.0); + double dummy_z(0.0); bool doOffsetZ = getOptions().getValueOrDefault("do_offset_z", false); - double* x = doOffsetZ ? &offset_x : &dummy_x; - ret = OCTTransform(m_transform_ptr.get(), 1, &offset_x, &offset_y, x); + double* z = doOffsetZ ? &offset_z : &dummy_z; + ret = OCTTransform(m_transform_ptr.get(), 1, &offset_x, &offset_y, z); if (!ret) { std::ostringstream msg; From 2ad737a3ec7cd4c82b83d3427ab8c40d69090702 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 25 Jun 2013 09:49:24 -0500 Subject: [PATCH 3/3] declare buffer as const --- src/drivers/nitf/Writer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/nitf/Writer.cpp b/src/drivers/nitf/Writer.cpp index c10fb76732..5cbbf06afc 100644 --- a/src/drivers/nitf/Writer.cpp +++ b/src/drivers/nitf/Writer.cpp @@ -219,10 +219,10 @@ void Writer::writeEnd(boost::uint64_t actualNumPointsWritten) ); subheader.getImageId().set("None"); // 64 char string - char* buffer = "0000000000000000000000000000000000000000000000000000000000000000"; + const char* buffer = "0000000000000000000000000000000000000000000000000000000000000000"; ::nitf::BandSource* band = - new ::nitf::MemorySource( buffer, + new ::nitf::MemorySource( (char*) buffer, strlen(buffer) /* memory size */, 0 /* starting offset */, 1 /* bytes per pixel */,