[Liblas-commits] hg-main-tree: minor SRS tweaking/debugging;
lit up reproj filter
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Apr 26 15:35:39 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/1ac969da44f7
changeset: 665:1ac969da44f7
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Apr 26 12:35:27 2011 -0700
description:
minor SRS tweaking/debugging; lit up reproj filter
diffstat:
include/libpc/SpatialReference.hpp | 7 +-
include/libpc/filters/ReprojectionFilter.hpp | 22 ++-
src/SpatialReference.cpp | 49 +----
src/drivers/las/LasHeaderWriter.cpp | 7 +-
src/drivers/las/VariableLengthRecord.cpp | 21 --
src/drivers/las/Writer.cpp | 3 +-
src/filters/ReprojectionFilter.cpp | 161 ++++++++++++++++++-
test/unit/CMakeLists.txt | 1 +
test/unit/LasWriterTest.cpp | 2 +-
test/unit/LiblasWriterTest.cpp | 2 +-
test/unit/ReprojectionFilterTest.cpp | 182 ++++++++++++++++++++++
test/unit/SpatialReferenceTest.cpp | 218 ++++++++++----------------
12 files changed, 454 insertions(+), 221 deletions(-)
diffs (truncated from 1046 to 300 lines):
diff -r 2e79c922a0ce -r 1ac969da44f7 include/libpc/SpatialReference.hpp
--- a/include/libpc/SpatialReference.hpp Tue Apr 26 10:57:16 2011 -0700
+++ b/include/libpc/SpatialReference.hpp Tue Apr 26 12:35:27 2011 -0700
@@ -86,7 +86,7 @@
/// Returns a pointer to the internal GTIF*. Only available if
/// you have libgeotiff linked in.
- void rebuildGTIFFromVLRs();
+ void rebuildGTIF();
/// Returns the OGC WKT describing Spatial Reference System.
/// If GDAL is linked, it uses GDAL's operations and methods to determine
@@ -155,6 +155,7 @@
int geotiff_ST_GetKey(int tag, int *count, int *st_key_type, void **data_ptr) const;
private:
+ std::string getGTIFFText() const;
class TiffStuff
{
@@ -167,12 +168,10 @@
boost::shared_ptr<TiffStuff> m_tiffstuff;
std::string m_wkt;
-
- std::string getGTIFFText() const;
};
-std::ostream& operator<<(std::ostream& ostr, const SpatialReference& srs);
+extern LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const SpatialReference& srs);
} // namespace libpc
diff -r 2e79c922a0ce -r 1ac969da44f7 include/libpc/filters/ReprojectionFilter.hpp
--- a/include/libpc/filters/ReprojectionFilter.hpp Tue Apr 26 10:57:16 2011 -0700
+++ b/include/libpc/filters/ReprojectionFilter.hpp Tue Apr 26 12:35:27 2011 -0700
@@ -36,11 +36,10 @@
#define INCLUDED_FILTERS_REPROJECTIONFILTER_HPP
#include <libpc/libpc.hpp>
-//#include <boost/cstdint.hpp>
-//
-//#include <libpc/export.hpp>
+
+#include <boost/shared_ptr.hpp>
+
#include <libpc/Filter.hpp>
-//#include <libpc/FilterIterator.hpp>
namespace libpc
{
@@ -54,7 +53,9 @@
class LIBPC_DLL ReprojectionFilter : public Filter
{
public:
- ReprojectionFilter(const Stage& prevStage);
+ ReprojectionFilter(const Stage& prevStage,
+ const SpatialReference& inSRS,
+ const SpatialReference& outSRS);
const std::string& getDescription() const;
const std::string& getName() const;
@@ -73,6 +74,17 @@
private:
void checkImpedance();
+ void initialize();
+ void transform(double& x, double& y, double& z) const;
+
+ SpatialReference m_inSRS;
+ SpatialReference m_outSRS;
+
+ typedef boost::shared_ptr<void> ReferencePtr;
+ typedef boost::shared_ptr<void> TransformPtr;
+ ReferencePtr m_in_ref_ptr;
+ ReferencePtr m_out_ref_ptr;
+ TransformPtr m_transform_ptr;
ReprojectionFilter& operator=(const ReprojectionFilter&); // not implemented
ReprojectionFilter(const ReprojectionFilter&); // not implemented
diff -r 2e79c922a0ce -r 1ac969da44f7 src/SpatialReference.cpp
--- a/src/SpatialReference.cpp Tue Apr 26 10:57:16 2011 -0700
+++ b/src/SpatialReference.cpp Tue Apr 26 12:35:27 2011 -0700
@@ -128,7 +128,7 @@
}
-void SpatialReference::rebuildGTIFFromVLRs()
+void SpatialReference::rebuildGTIF()
{
#ifndef LIBPC_SRS_ENABLED
return 0;
@@ -151,7 +151,7 @@
m_tiffstuff->m_tiff = ST_Create();
- //////// here it used to read in the VLRs ////////
+ // (here it used to read in the VLRs)
m_tiffstuff->m_gtiff = GTIFNewSimpleTags(m_tiffstuff->m_tiff);
if (!m_tiffstuff->m_gtiff)
@@ -350,7 +350,7 @@
if (!m_tiffstuff->m_gtiff)
{
- rebuildGTIFFromVLRs();
+ rebuildGTIF();
}
#ifdef LIBPC_SRS_ENABLED
@@ -370,7 +370,7 @@
boost::ignore_unused_variable_warning(v);
#endif
- ////////////////////////////////ResetVLRs();
+ return;
}
@@ -381,7 +381,7 @@
{
if (!m_tiffstuff->m_gtiff)
{
- rebuildGTIFFromVLRs();
+ rebuildGTIF();
}
#ifdef LIBPC_SRS_ENABLED
@@ -410,13 +410,14 @@
// Clear WKT so it gets regenerated
m_wkt = std::string("");
- ///////////////////////////////ResetVLRs();
#else
boost::ignore_unused_variable_warning(citation);
boost::ignore_unused_variable_warning(verticalUnits);
boost::ignore_unused_variable_warning(verticalDatum);
boost::ignore_unused_variable_warning(verticalCSType);
#endif
+
+ return;
}
@@ -452,7 +453,7 @@
{
if (!m_tiffstuff->m_gtiff)
{
- rebuildGTIFFromVLRs();
+ rebuildGTIF();
}
#ifdef LIBPC_SRS_ENABLED
@@ -495,7 +496,7 @@
boost::ignore_unused_variable_warning(v);
#endif
- ////////////////////////////////ResetVLRs();
+ return;
}
@@ -571,7 +572,6 @@
}
-
std::string SpatialReference::getGTIFFText() const
{
#ifndef LIBPC_SRS_ENABLED
@@ -598,34 +598,3 @@
} // namespace libpc
-
-
-
-#if 0
-
-
-
-/// Keep a copy of the VLRs that are related to GeoTIFF SRS information.
-void SpatialReference::SetVLRs(std::vector<VariableRecord> const& vlrs)
-{
-
- std::string const uid("LASF_Projection");
-
- // Wipe out any existing VLRs that might exist on the SpatialReference
- m_vlrs.clear();
-
- // We only copy VLR records from the list which are related to GeoTIFF keys.
- // They must have an id of "LASF_Projection" and a record id that's related.
- std::vector<VariableRecord>::const_iterator it;
- for (it = vlrs.begin(); it != vlrs.end(); ++it)
- {
- VariableRecord const& vlr = *it;
- if (IsGeoVLR(vlr))
- {
- m_vlrs.push_back(vlr);
- }
- }
-}
-
-
-#endif
\ No newline at end of file
diff -r 2e79c922a0ce -r 1ac969da44f7 src/drivers/las/LasHeaderWriter.cpp
--- a/src/drivers/las/LasHeaderWriter.cpp Tue Apr 26 10:57:16 2011 -0700
+++ b/src/drivers/las/LasHeaderWriter.cpp Tue Apr 26 12:35:27 2011 -0700
@@ -60,7 +60,6 @@
}
-
void LasHeaderWriter::write()
{
using namespace std;
@@ -271,6 +270,7 @@
return;
}
+
void LasHeaderWriter::WriteVLRs()
{
// Seek to the end of the public header block (beginning of the VLRs)
@@ -315,6 +315,7 @@
return;
}
+
std::size_t LasHeaderWriter::GetRequiredHeaderSize() const
{
// if the VLRs won't fit because the data offset is too
@@ -334,6 +335,7 @@
}
+
void LasHeaderWriter::WriteLAS10PadSignature()
{
// Only write pad signature bytes for LAS 1.0 files. Any other files
@@ -353,8 +355,7 @@
oss << "for the VLRs is " << GetRequiredHeaderSize();
throw std::runtime_error(oss.str());
}
-
-
+
// step back two bytes to write the pad bytes. We should have already
// determined by this point if a) they will fit b) they won't overwrite
// exiting real data
diff -r 2e79c922a0ce -r 1ac969da44f7 src/drivers/las/VariableLengthRecord.cpp
--- a/src/drivers/las/VariableLengthRecord.cpp Tue Apr 26 10:57:16 2011 -0700
+++ b/src/drivers/las/VariableLengthRecord.cpp Tue Apr 26 12:35:27 2011 -0700
@@ -240,8 +240,6 @@
void VariableLengthRecord::setVLRsFromSRS_X(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs)
{
- //vlrs.clear();
-
#ifdef LIBPC_SRS_ENABLED
int ret = 0;
@@ -425,29 +423,10 @@
}
}
-// if( eType == eOGRWKT )
-// m_wkt = "";
-// else if( eType == eGeoTIFF )
-// {
-//#ifdef HAVE_LIBGEOTIFF
-// if (m_gtiff != 0)
-// {
-// GTIFFree(m_gtiff);
-// m_gtiff = 0;
-// }
-// if (m_tiff != 0)
-// {
-// ST_Destroy(m_tiff);
-// m_tiff = 0;
-// }
-//#endif
-// }
-
return;
}
-
bool VariableLengthRecord::isGeoVLR() const
{
std::string const las_projid("LASF_Projection");
diff -r 2e79c922a0ce -r 1ac969da44f7 src/drivers/las/Writer.cpp
--- a/src/drivers/las/Writer.cpp Tue Apr 26 10:57:16 2011 -0700
+++ b/src/drivers/las/Writer.cpp Tue Apr 26 12:35:27 2011 -0700
@@ -52,7 +52,6 @@
namespace libpc { namespace drivers { namespace las {
More information about the Liblas-commits
mailing list