[Liblas-commits] hg: 5 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Sun May 23 08:20:58 EDT 2010
changeset 7fccc46e43cb in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7fccc46e43cb
summary: Update OCI blob array insert
changeset a90568c1a0b6 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=a90568c1a0b6
summary: Implement BLOB insert Array
changeset 18d6e0b9068f in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=18d6e0b9068f
summary: Implement BLOB insert Array
changeset 2b6c48a77b63 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=2b6c48a77b63
summary: Implement BLOB insert Array
changeset 44d6ba098ff9 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=44d6ba098ff9
summary: Implement BLOB insert array
diffstat:
apps/las2oci.cpp | 736 +++++++++++++++++++-----------------------
apps/oci_wrapper.cpp | 863 +++++++++++++++++++++++++++-----------------------
apps/oci_wrapper.h | 196 +++++++---
3 files changed, 926 insertions(+), 869 deletions(-)
diffs (truncated from 2541 to 300 lines):
diff -r a7e50a69311b -r 44d6ba098ff9 apps/las2oci.cpp
--- a/apps/las2oci.cpp Wed Mar 17 15:42:56 2010 -0500
+++ b/apps/las2oci.cpp Sun May 23 07:46:07 2010 +0300
@@ -1,3 +1,6 @@
+
+#include <stdlib.h>
+
// god-awful hack because of GDAL/GeoTIFF's shitty include structure
#define CPL_SERV_H_INCLUDED
@@ -39,6 +42,8 @@
#define compare_no_case(a,b,n) strncasecmp( (a), (b), (n) )
#endif
+#define MAX_POINTS_PER_ROW 1000
+
typedef struct
{
long* pc_ids;
@@ -86,7 +91,6 @@
return output;
}
-
std::istream* OpenInput(std::string filename, bool bEnd)
{
std::ios::openmode mode = std::ios::in | std::ios::binary;
@@ -155,6 +159,7 @@
return true;
}
+
bool IsGeographic(OWConnection* connection, long srid) {
ostringstream oss;
@@ -187,10 +192,11 @@
return true;
}
-
free(kind);
+
return false;
}
+
OWStatement* Run(OWConnection* connection, ostringstream& command)
{
OWStatement* statement = 0;
@@ -227,25 +233,24 @@
if (statement != 0) delete statement;
oss.str("");
- return true;
+ connection->Commit();
-
+ return true;
}
-
bool CreateBlockTable(OWConnection* connection, const char* tableName)
{
ostringstream oss;
OWStatement* statement = 0;
- oss << "CREATE TABLE "<< tableName <<" (OBJ_ID NUMBER, BLK_ID NUMBER, "
- " BLK_EXTENT MDSYS.SDO_GEOMETRY, BLK_DOMAIN MDSYS.SDO_ORGSCL_TYPE,"
- " PCBLK_MIN_RES NUMBER, PCBLK_MAX_RES NUMBER, NUM_POINTS NUMBER, "
- " NUM_UNSORTED_POINTS NUMBER, PT_SORT_DIM NUMBER, POINTS BLOB)";
+ oss << "CREATE TABLE " << tableName << " AS SELECT * FROM MDSYS.SDO_PC_BLK_TABLE";
+
statement = Run(connection, oss);
if (statement != 0) delete statement; else return false;
oss.str("");
+ connection->Commit();
+
return true;
}
@@ -312,66 +317,15 @@
if (statement != 0) delete statement; else return false;
oss.str("");
+ connection->Commit();
return true;
}
-bool GetPointData( liblas::Point const& p,
- bool bTime,
- std::vector<liblas::uint8_t>& point_data)
-{
- // This function returns an array of bytes describing the
- // x,y,z and optionally time values for the point.
- point_data.clear();
-
- double x = p.GetX();
- double y = p.GetY();
- double z = p.GetZ();
- double t = p.GetTime();
-
- liblas::uint8_t* x_b = reinterpret_cast<liblas::uint8_t*>(&x);
- liblas::uint8_t* y_b = reinterpret_cast<liblas::uint8_t*>(&y);
- liblas::uint8_t* z_b = reinterpret_cast<liblas::uint8_t*>(&z);
-
- liblas::uint8_t* t_b = reinterpret_cast<liblas::uint8_t*>(&t);
-
- // doubles are 8 bytes long. For each double, push back the
- // byte. We do this for all four values (x,y,z,t)
-
- // // little-endian
- // for (int i=0; i<sizeof(double); i++) {
- // point_data.push_back(y_b[i]);
- // }
- //
-
- // big-endian
- for (int i = sizeof(double) - 1; i >= 0; i--) {
- point_data.push_back(x_b[i]);
- }
-
- for (int i = sizeof(double) - 1; i >= 0; i--) {
- point_data.push_back(y_b[i]);
- }
-
- for (int i = sizeof(double) - 1; i >= 0; i--) {
- point_data.push_back(z_b[i]);
- }
-
-
- if (bTime)
- {
- for (int i = sizeof(double) - 1; i >= 0; i--) {
- point_data.push_back(t_b[i]);
- }
-
- }
-
- return true;
-}
bool GetResultData( const LASQueryResult& result,
liblas::Reader* reader,
- std::vector<liblas::uint8_t>& data,
+ std::vector<double>& data,
int nDimension)
{
list<SpatialIndex::id_type> const& ids = result.GetIDs();
@@ -390,9 +344,9 @@
data.clear();
list<SpatialIndex::id_type>::const_iterator i;
- vector<liblas::uint8_t>::iterator pi;
+// vector<liblas::uint8_t>::iterator pi;
- liblas::uint32_t block_id = result.GetID();
+// liblas::uint32_t block_id = result.GetID();
std::vector<liblas::uint8_t> point_data;
@@ -401,32 +355,15 @@
SpatialIndex::id_type id = *i;
bool doRead = reader->ReadPointAt(id);
+
if (doRead) {
+
liblas::Point const& p = reader->GetPoint();
- // d 8-byte IEEE big-endian doubles, where d is the PC_TOT_DIMENSIONS value
- bool gotdata = GetPointData(p, bTime, point_data);
-
- if (!gotdata) { throw std::runtime_error("Unable to fetch Point Data"); exit(1);}
- std::vector<liblas::uint8_t>::const_iterator d;
- for (d = point_data.begin(); d!=point_data.end(); ++d) {
- data.push_back(*d);
- }
-
- liblas::uint8_t* id_b = reinterpret_cast<liblas::uint8_t*>(&id);
- liblas::uint8_t* block_b = reinterpret_cast<liblas::uint8_t*>(&block_id);
-
- // 4-byte big-endian integer for the BLK_ID value
- for (int i = sizeof(liblas::uint32_t) - 1; i >= 0; i--) {
- data.push_back(block_b[i]);
- }
-
- // 4-byte big-endian integer for the PT_ID value
- for (int i = sizeof(liblas::uint32_t) - 1; i >= 0; i--) {
- data.push_back(id_b[i]);
- }
-
-
+ data.push_back( p.GetX() );
+ data.push_back( p.GetY() );
+ data.push_back( p.GetZ() );
+ data.push_back( p.GetIntensity() );
}
}
@@ -522,60 +459,6 @@
return b;
}
-bool FillBlocks( OWConnection* connection,
- OWStatement* statement,
- const LASQueryResult& result,
- liblas::Reader* reader,
- blocks* b,
- long index,
- int srid,
- long pc_id,
- long gtype,
- bool bUseSolidGeometry,
- bool bUse3d,
- long nDimensions
- )
-{
-
-
- list<SpatialIndex::id_type> const& ids = result.GetIDs();
-
-
- b->pc_ids[index] = pc_id;
- b->srids[index] = (long)srid;
- b->block_ids[index] = result.GetID();
- b->num_points[index] = (long)ids.size();
-
- std::vector<liblas::uint8_t>* blob = new std::vector<liblas::uint8_t>;
-
- bool gotdata = GetResultData(result, reader, *blob, nDimensions);
- if (! gotdata) throw std::runtime_error("unable to fetch point data byte array");
-
- b->blobs[index] = blob;
- // // FIXME: null srids not supported
- b->srids[index] = srid;
- b->gtypes[index] = gtype;
- //
- OCIArray* sdo_elem_info=0;
- connection->CreateType(&sdo_elem_info, connection->GetElemInfoType());
- SetElements(statement, sdo_elem_info, bUseSolidGeometry);
- //
- b->element_arrays[index] = sdo_elem_info;
-
- OCIArray* sdo_ordinates=0;
- connection->CreateType(&sdo_ordinates, connection->GetOrdinateType());
- //
- //
- //
- extent* e = GetExtent(result.GetBounds(), bUse3d);
- SetOrdinates(statement, sdo_ordinates, e);
-
- b->coordinate_arrays[index] = sdo_ordinates;
-
-
- return true;
-}
-
long GetGType( bool bUse3d,
bool bUseSolidGeometry)
{
@@ -598,270 +481,308 @@
return gtype;
}
-bool BindBlock(OWStatement* statement, blocks* b, long index)
+bool ArrayInsert( OWConnection* connection,
+ const char* insertStatement,
+ int* panObjId,
+ int* panBlockId,
+ int* panNumPoints,
+ double* padfBuffer,
+ int nArrayCols,
+ int nRowsToInsert)
{
- // oss << "INSERT INTO "<< table_name <<
- // "(OBJ_ID, BLK_ID, NUM_POINTS, POINTS, "
- // "PCBLK_MIN_RES, BLK_EXTENT, PCBLK_MAX_RES, NUM_UNSORTED_POINTS, PT_SORT_DIM) "
- // "VALUES ( :1, :2, :3, :4, 1, mdsys.sdo_geometry(:5, :6, null,:7, :8)"
- // ", 1, 0, 1)";
-
- // :1
- statement->Bind( b->pc_ids );
-
- // :2
- statement->Bind( b->block_ids );
+ OWStatement* statement = connection->CreateStatement( insertStatement );
- // :3
- statement->Bind( b->num_points);
-
- // :4
- statement->Define( b->locators, (int)b->size );
-
- long max_size = 0;
- for (int i = 0; i < b->size; i++) {
- max_size = std::max(max_size, (long)b->blobs[i]->size());
+ statement->Bind( panObjId );
+ statement->Bind( panBlockId );
+ statement->Bind( panNumPoints );
More information about the Liblas-commits
mailing list