[Liblas-commits] r1303 - in trunk: apps include/liblas/index
src/index
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat Jul 4 01:21:17 EDT 2009
Author: hobu
Date: Sat Jul 4 01:21:16 2009
New Revision: 1303
URL: http://liblas.org/changeset/1303
Log:
blk_extent index creation
Modified:
trunk/apps/las2oci.cpp
trunk/include/liblas/index/query.hpp
trunk/src/index/query.cpp
Modified: trunk/apps/las2oci.cpp
==============================================================================
--- trunk/apps/las2oci.cpp (original)
+++ trunk/apps/las2oci.cpp Sat Jul 4 01:21:16 2009
@@ -34,6 +34,8 @@
#endif
+
+
std::istream* OpenInput(std::string filename)
{
std::ios::openmode const mode = std::ios::in | std::ios::binary;
@@ -331,6 +333,52 @@
return true;
}
+
+bool CreateSDOEntry(OWConnection* connection, const char* tableName, LASQuery* query, int srid)
+{
+ ostringstream oss;
+ OWStatement* statement = 0;
+ // SpatialIndex::Region* b = query->bounds;
+ ostringstream oss_geom;
+
+ oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ oss.precision(2);
+
+// code = """
+// INSERT INTO user_sdo_geom_metadata VALUES (
+// 'foo',
+// 'blk_extent',
+// MDSYS.SDO_DIM_ARRAY(
+// MDSYS.SDO_DIM_ELEMENT('X', 630250.000000, 630500.000000, 0.05),
+// MDSYS.SDO_DIM_ELEMENT('Y', 4834500, 4834750, 0.05)),
+// 8307)
+// """
+ oss << "INSERT INTO user_sdo_geom_metadata VALUES ('" << tableName <<
+ "','blk_extent', MDSYS.SDO_DIM_ARRAY("
+ "MDSYS.SDO_DIM_ELEMENT('X', "<< query->bounds.getLow(0) <<","<< query->bounds.getHigh(0)<<",0.05),"
+ "MDSYS.SDO_DIM_ELEMENT('Y', "<< query->bounds.getLow(1) <<","<< query->bounds.getHigh(1)<<",0.05)),"
+ << srid << ")";
+ statement = Run(connection, oss);
+ if (statement != 0) delete statement; else return false;
+ oss.str("");
+
+ return true;
+
+}
+
+bool CreateBlockIndex(OWConnection* connection, const char* tableName)
+{
+ ostringstream oss;
+ OWStatement* statement = 0;
+
+ oss << "CREATE INDEX "<< tableName <<"_cloud_idx on "<<tableName<<"(blk_extent) INDEXTYPE IS MDSYS.SPATIAL_INDEX" ;
+ statement = Run(connection, oss);
+ if (statement != 0) delete statement; else return false;
+ oss.str("");
+
+ return true;
+
+}
void usage() {}
int main(int argc, char* argv[])
@@ -458,6 +506,9 @@
bool inserted = InsertBlock(con, *i, srid, reader2, table_name.c_str());
}
+
+ CreateSDOEntry(con, table_name.c_str(), query, srid );
+ CreateBlockIndex(con, table_name.c_str());
// Cleanup(con, "base");
// int iCol = 0;
Modified: trunk/include/liblas/index/query.hpp
==============================================================================
--- trunk/include/liblas/index/query.hpp (original)
+++ trunk/include/liblas/index/query.hpp Sat Jul 4 01:21:16 2009
@@ -89,6 +89,8 @@
std::queue<SpatialIndex::id_type> m_ids;
uint32_t m_count;
std::list<LASQueryResult> m_results;
+ bool m_first;
+
public:
LASQuery();
@@ -98,6 +100,7 @@
void getNextEntry(const SpatialIndex::IEntry& entry, SpatialIndex::id_type& nextEntry, bool& hasNext);
std::list<LASQueryResult>& GetResults() {return m_results;}
+ SpatialIndex::Region bounds;
};
Modified: trunk/src/index/query.cpp
==============================================================================
--- trunk/src/index/query.cpp (original)
+++ trunk/src/index/query.cpp Sat Jul 4 01:21:16 2009
@@ -53,10 +53,21 @@
namespace liblas
{
- LASQuery::LASQuery() :m_count(0){}
+ LASQuery::LASQuery() :m_count(0),m_first(true){}
void LASQuery::getNextEntry(const SpatialIndex::IEntry& entry, SpatialIndex::id_type& nextEntry, bool& hasNext) {
// the first time we are called, entry points to the root.
+
+ if (m_first) {
+ SpatialIndex::IShape* ps;
+ entry.getShape(&ps);
+ ps->getMBR(bounds);
+ delete ps;
+
+ // any other time through we're no longer at the root so
+ // we wouldn't get the entire index's bounding box
+ m_first = false;
+ }
const SpatialIndex::INode* n = dynamic_cast<const SpatialIndex::INode*>(&entry);
// if (n !=0 ) {
More information about the Liblas-commits
mailing list