[Liblas-commits] libpc: add method for creating spatial index table
entry
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 9 15:04:48 EST 2011
details: http://hg.liblas.orglibpc/rev/ca3ff449d03a
changeset: 191:ca3ff449d03a
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Mar 09 14:04:43 2011 -0600
description:
add method for creating spatial index table entry
diffstat:
src/drivers/oci/writer.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++-
src/drivers/oci/writer.hpp | 2 +
2 files changed, 77 insertions(+), 2 deletions(-)
diffs (127 lines):
diff -r e236d82d7d90 -r ca3ff449d03a src/drivers/oci/writer.cpp
--- a/src/drivers/oci/writer.cpp Wed Mar 09 13:24:26 2011 -0600
+++ b/src/drivers/oci/writer.cpp Wed Mar 09 14:04:43 2011 -0600
@@ -92,6 +92,20 @@
return debug;
}
+bool Options::Is3d() const
+{
+ bool is3d = false;
+ try
+ {
+ is3d = m_tree.get<bool>("is3d");
+ }
+ catch (liblas::property_tree::ptree_bad_path const& e) {
+ ::boost::ignore_unused_variable_warning(e);
+
+ }
+ return is3d;
+}
+
Writer::Writer(Stage& prevStage, Options& options)
: Consumer(prevStage)
, m_stage(prevStage)
@@ -220,7 +234,7 @@
std::ostringstream oss;
std::string block_table_name = m_options.GetPTree().get<std::string>("block_table_name");
- bool is3d = m_options.GetPTree().get<bool>("is3d");
+ bool is3d = m_options.Is3d();
oss << "CREATE INDEX "<< block_table_name << "_cloud_idx on "
<< block_table_name << "(blk_extent) INDEXTYPE IS MDSYS.SPATIAL_INDEX";
@@ -240,6 +254,64 @@
}
+void Writer::CreateSDOEntry()
+{
+ boost::property_tree::ptree tree = m_options.GetPTree();
+ std::string block_table_name = tree.get<std::string>("block_table_name");
+
+ boost::uint32_t srid = tree.get<boost::uint32_t>("srid");
+ boost::uint32_t precision = tree.get<boost::uint32_t>("precision");
+
+ bool bUse3d = m_options.Is3d();
+
+
+ std::ostringstream oss;
+
+ std::ostringstream oss_geom;
+
+ oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ oss.precision(precision);
+
+ std::ostringstream s_srid;
+
+
+ if (srid == 0) {
+ s_srid << "NULL";
+ // bUse3d = true;
+ }
+ else {
+ s_srid << srid;
+ }
+
+ double tolerance = 0.05;
+ libpc::Bounds<double> e = m_bounds;
+
+ if (IsGeographic(srid)) {
+ e.setMinimum(0,-180.0); e.setMaximum(0,180.0);
+ e.setMinimum(1,-90.0); e.setMaximum(1,90.0);
+ e.setMinimum(2,0.0); e.setMaximum(2,20000.0);
+
+ tolerance = 0.000000005;
+ }
+
+
+ oss << "INSERT INTO user_sdo_geom_metadata VALUES ('" << block_table_name <<
+ "','blk_extent', MDSYS.SDO_DIM_ARRAY(";
+
+ oss << "MDSYS.SDO_DIM_ELEMENT('X', " << e.getMinimum(0) << "," << e.getMaximum(0) <<"," << tolerance << "),"
+ "MDSYS.SDO_DIM_ELEMENT('Y', " << e.getMinimum(1) << "," << e.getMaximum(1) <<"," << tolerance << ")";
+
+ if (bUse3d) {
+ oss << ",";
+ oss <<"MDSYS.SDO_DIM_ELEMENT('Z', "<< e.getMinimum(2) << "," << e.getMaximum(2) << "," << tolerance << ")";
+ }
+ oss << ")," << s_srid.str() << ")";
+
+ run(oss);
+ oss.str("");
+
+}
+
bool Writer::BlockTableExists()
{
@@ -576,7 +648,8 @@
for ( boost::uint32_t i = 0; i < m_chipper.GetBlockCount(); ++i )
{
const chipper::Block& b = m_chipper.GetBlock(i);
- m_bounds.grow(b.GetBounds());
+ if (m_bounds.empty()) // If the user already set the bounds for this writer, we're using that
+ m_bounds.grow(b.GetBounds());
}
// Set up debugging info
diff -r e236d82d7d90 -r ca3ff449d03a src/drivers/oci/writer.hpp
--- a/src/drivers/oci/writer.hpp Wed Mar 09 13:24:26 2011 -0600
+++ b/src/drivers/oci/writer.hpp Wed Mar 09 14:04:43 2011 -0600
@@ -75,6 +75,7 @@
Options();
bool IsDebug() const;
+ bool Is3d() const;
boost::property_tree::ptree GetPTree() const {return m_tree; }
};
@@ -115,6 +116,7 @@
void WipeBlockTable();
void CreateBlockIndex();
void CreateBlockTable();
+ void CreateSDOEntry();
long CreatePCEntry(std::vector<boost::uint8_t> const* header_data);
long GetGType();
std::string CreatePCElemInfo();
More information about the Liblas-commits
mailing list