[Liblas-commits] hg-main-tree: provide the ability to override the
pc_other_attrs...
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Apr 22 13:41:02 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/86a79beb04fd
changeset: 625:86a79beb04fd
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 22 12:40:43 2011 -0500
description:
provide the ability to override the pc_other_attrs column with a point_schema_override option
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/4093dadd1fbb
changeset: 626:4093dadd1fbb
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 22 12:40:52 2011 -0500
description:
merge
diffstat:
include/libpc/SpatialReference.hpp | 79 ++--------
include/libpc/drivers/las/VariableLengthRecord.hpp | 14 +-
src/SpatialReference.cpp | 150 ++++++++++----------
src/Stage.cpp | 2 +-
src/drivers/las/VariableLengthRecord.cpp | 113 +++++++++++++++
src/drivers/oci/Writer.cpp | 56 ++++++-
src/drivers/oci/common.cpp | 1 +
test/unit/OCITest.cpp | 3 +-
test/unit/SpatialReferenceTest.cpp | 84 ++++++++---
9 files changed, 323 insertions(+), 179 deletions(-)
diffs (truncated from 875 to 300 lines):
diff -r 7f5b92036a77 -r 4093dadd1fbb include/libpc/SpatialReference.hpp
--- a/include/libpc/SpatialReference.hpp Fri Apr 22 11:10:24 2011 -0500
+++ b/include/libpc/SpatialReference.hpp Fri Apr 22 12:40:52 2011 -0500
@@ -85,9 +85,9 @@
/// Returns a pointer to the internal GTIF*. Only available if
/// you have libgeotiff linked in.
- const GTIF* GetGTIF();
+ const GTIF* getGTIF();
- void SetGTIF(GTIF* pgtiff, ST_TIFF* ptiff);
+ void setGTIF(GTIF* pgtiff, ST_TIFF* ptiff);
/// Returns the OGC WKT describing Spatial Reference System.
/// If GDAL is linked, it uses GDAL's operations and methods to determine
@@ -97,13 +97,13 @@
/// eCompoundOK indicating the the returned WKT may be a compound
/// coordinate system if there is vertical coordinate system info
/// available.
- std::string GetWKT(WKTModeFlag mode_flag = eHorizontalOnly) const;
- std::string GetWKT(WKTModeFlag mode_flag, bool pretty) const;
+ std::string getWKT(WKTModeFlag mode_flag = eHorizontalOnly) const;
+ std::string getWKT(WKTModeFlag mode_flag, bool pretty) const;
/// Sets the SRS using GDAL's OGC WKT. If GDAL is not linked, this
/// operation has no effect.
/// \param v - a string containing the WKT string.
- void SetWKT(std::string const& v);
+ void setWKT(std::string const& v);
/// Sets the vertical coordinate system using geotiff key values.
/// This operation should normally be done after setting the horizontal
@@ -117,7 +117,7 @@
/// range 5100 to 5299 - implied by verticalCSType if that is provided, or
/// -1 if no value is available.
/// \param verticalUnits - the EPSG vertical units code, often 9001 for Metre.
- void SetVerticalCS(boost::int32_t verticalCSType,
+ void setVerticalCS(boost::int32_t verticalCSType,
std::string const& citation = std::string(0),
boost::int32_t verticalDatum = -1,
boost::int32_t verticalUnits = 9001);
@@ -125,14 +125,14 @@
/// Sets the SRS using GDAL's SetFromUserInput function. If GDAL is not linked, this
/// operation has no effect.
/// \param v - a string containing the definition (filename, proj4, wkt, etc).
- void SetFromUserInput(std::string const& v);
+ void setFromUserInput(std::string const& v);
/// Returns the Proj.4 string describing the Spatial Reference System.
/// If GDAL is linked, it uses GDAL's operations and methods to determine
/// the Proj.4 string -- otherwise, if libgeotiff is linked, it uses
/// that. Note that GDAL's operations are much more mature and
/// support more coordinate systems and descriptions.
- std::string GetProj4() const;
+ std::string getProj4() const;
/// Sets the Proj.4 string describing the Spatial Reference System.
/// If GDAL is linked, it uses GDAL's operations and methods to determine
@@ -140,9 +140,19 @@
/// that. Note that GDAL's operations are much more mature and
/// support more coordinate systems and descriptions.
/// \param v - a string containing the Proj.4 string.
- void SetProj4(std::string const& v);
+ void setProj4(std::string const& v);
- boost::property_tree::ptree GetPTree() const;
+ boost::property_tree::ptree getPTree() const;
+
+ enum GeotiffKeyType
+ {
+ Geotiff_KeyType_SHORT=1,
+ Geotiff_KeyType_DOUBLE=2,
+ Geotiff_KeyType_ASCII=3
+ };
+ int geotiff_ST_SetKey(int tag, int count, GeotiffKeyType geotiff_key_type, void *data);
+ void geotiff_SetTags();
+ void geotiff_ResetTags();
private:
@@ -152,8 +162,7 @@
std::string m_wkt;
- std::string GetGTIFFText() const;
-
+ std::string getGTIFFText() const;
};
@@ -179,50 +188,4 @@
#endif // defined __geotiff_h_
LIBPC_C_END
-
#endif
-
-
-#if 0
-#include <liblas/detail/fwd.hpp>
-#include <liblas/detail/private_utility.hpp>
-#include <liblas/variablerecord.hpp>
-#include <liblas/exception.hpp>
-#include <liblas/capi/las_config.h>
-#include <liblas/export.hpp>
-#include <liblas/external/property_tree/ptree.hpp>
-#include <stdexcept> // std::out_of_range
-#include <cstdlib> // std::size_t
-#include <string>
-
- enum GeoVLRType
- {
- eGeoTIFF = 1,
- eOGRWKT = 2
- };
-
- /// Set the LASVLRs for the SpatialReference. SetVLRs will only copy
- /// VLR records that pertain to the GeoTIFF keys, and extraneous
- /// VLR records will not be copied.
- /// \param vlrs - A list of VLRs that contains VLRs describing GeoTIFF keys
- void SetVLRs(std::vector<VariableRecord> const& vlrs);
-
- /// Add a VLR representing GeoTIFF keys to the SRS
- void AddVLR(VariableRecord const& vlr);
-
- /// Return a copy of the LASVLRs that SpatialReference maintains
- std::vector<VariableRecord> GetVLRs() const;
-
- void ClearVLRs( GeoVLRType eType );
-
- std::vector<VariableRecord> m_vlrs;
- bool IsGeoVLR(VariableRecord const& vlr) const;
-
- /// Reset the VLRs of the SpatialReference using the existing GTIF* and ST_TIF*
- /// Until this method is called,
- /// the SpatialReference will only contain a SRS description using the VLRs
- /// that it was first instantiated with. SetWKT and SetProj4 can
- /// be used to change the GTIF*
- void ResetVLRs();
-
-#endif
diff -r 7f5b92036a77 -r 4093dadd1fbb include/libpc/drivers/las/VariableLengthRecord.hpp
--- a/include/libpc/drivers/las/VariableLengthRecord.hpp Fri Apr 22 11:10:24 2011 -0500
+++ b/include/libpc/drivers/las/VariableLengthRecord.hpp Fri Apr 22 12:40:52 2011 -0500
@@ -40,6 +40,11 @@
#include <libpc/MetadataRecord.hpp>
#include <iostream>
+#include <vector>
+
+namespace libpc {
+ class SpatialReference;
+}
namespace libpc { namespace drivers { namespace las {
@@ -61,6 +66,11 @@
boost::uint16_t getRecordId() const { return m_recordId; }
boost::uint8_t* getDescription() const { return (boost::uint8_t*)m_description; }
+ static void setSRS(const std::vector<VariableLengthRecord>& vlrs, SpatialReference& srs);
+ bool VariableLengthRecord::isGeoVLR() const;
+
+ bool compareUserId(const std::string& str) const;
+
bool operator==(const VariableLengthRecord&) const;
VariableLengthRecord& operator=(const VariableLengthRecord&);
@@ -68,9 +78,9 @@
private:
boost::uint16_t m_reserved;
- boost::uint8_t* m_userId; // always 16 bytes
+ boost::uint8_t* m_userId; // always 16 bytes // BUG: make this a std::string?
boost::uint16_t m_recordId;
- boost::uint8_t* m_description; // always 32 bytes
+ boost::uint8_t* m_description; // always 32 bytes // BUG: make this a std::string?
};
diff -r 7f5b92036a77 -r 4093dadd1fbb src/SpatialReference.cpp
--- a/src/SpatialReference.cpp Fri Apr 22 11:10:24 2011 -0500
+++ b/src/SpatialReference.cpp Fri Apr 22 12:40:52 2011 -0500
@@ -90,7 +90,7 @@
, m_wkt(other.m_wkt)
{
////////////////////////////////////////////////////////////SetVLRs(other.GetVLRs());
- GetGTIF();
+ getGTIF();
}
@@ -99,7 +99,7 @@
if (&rhs != this)
{
////////////////////////////////////////////////SetVLRs(rhs.GetVLRs());
- GetGTIF();
+ getGTIF();
m_wkt = rhs.m_wkt;
}
return *this;
@@ -123,7 +123,7 @@
}
-void SpatialReference::SetGTIF(GTIF* pgtiff, ST_TIFF* ptiff)
+void SpatialReference::setGTIF(GTIF* pgtiff, ST_TIFF* ptiff)
{
m_gtiff = (GTIF*)pgtiff;
m_tiff = (ST_TIFF*)ptiff;
@@ -133,7 +133,7 @@
}
-const GTIF* SpatialReference::GetGTIF()
+const GTIF* SpatialReference::getGTIF()
{
#ifndef LIBPC_SRS_ENABLED
return 0;
@@ -204,14 +204,52 @@
}
-std::string SpatialReference::GetWKT( WKTModeFlag mode_flag) const
+int SpatialReference::geotiff_ST_SetKey(int tag, int count, GeotiffKeyType geotiff_key_type, void *data)
{
- return GetWKT(mode_flag, false);
+ return ST_SetKey(m_tiff, tag, count, (int)geotiff_key_type, data);
}
+void SpatialReference::geotiff_SetTags()
+{
+ m_gtiff = GTIFNewSimpleTags(m_tiff);
+ if (!m_gtiff)
+ throw std::runtime_error("The geotiff keys could not be read from VLR records");
+ return;
+}
+
+
+void SpatialReference::geotiff_ResetTags()
+{
+ // If we already have m_gtiff and m_tiff, that is because we have
+ // already called GetGTIF once before. VLRs ultimately drive how the
+ // SpatialReference is defined, not the GeoTIFF keys.
+ if (m_tiff != 0 )
+ {
+ ST_Destroy(m_tiff);
+ m_tiff = 0;
+ }
+
+ if (m_gtiff != 0 )
+ {
+ GTIFFree(m_gtiff);
+ m_gtiff = 0;
+ }
+
+ m_tiff = ST_Create();
+
+ return;
+}
+
+
+std::string SpatialReference::getWKT( WKTModeFlag mode_flag) const
+{
+ return getWKT(mode_flag, false);
+}
+
+
/// Fetch the SRS as WKT
-std::string SpatialReference::GetWKT(WKTModeFlag mode_flag , bool pretty) const
+std::string SpatialReference::getWKT(WKTModeFlag mode_flag , bool pretty) const
{
#ifndef LIBPC_SRS_ENABLED
boost::ignore_unused_variable_warning(mode_flag);
@@ -311,7 +349,7 @@
}
-void SpatialReference::SetFromUserInput(std::string const& v)
+void SpatialReference::setFromUserInput(std::string const& v)
{
#ifdef LIBPC_SRS_ENABLED
@@ -320,7 +358,8 @@
// OGRSpatialReference* poSRS = (OGRSpatialReference*) OSRNewSpatialReference(NULL);
OGRSpatialReference srs(NULL);
- if (OGRERR_NONE != srs.SetFromUserInput(const_cast<char *> (input)))
+ OGRErr err = srs.SetFromUserInput(const_cast<char *> (input));
+ if (err != OGRERR_NONE)
{
throw std::invalid_argument("could not import coordinate system into OSRSpatialReference SetFromUserInput");
}
@@ -330,7 +369,7 @@
std::string tmp(poWKT);
CPLFree(poWKT);
- SetWKT(tmp);
+ setWKT(tmp);
More information about the Liblas-commits
mailing list