[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Jul 30 12:52:53 EDT 2010
changeset e0d2d9052f56 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=e0d2d9052f56
summary: update to latest svn
changeset d4cea42a18e2 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d4cea42a18e2
summary: pull forward Ivan's array binding code, not yet working
diffstat:
apps/las2oci.cpp | 836 +++++++++++++++++++++-------------------------
apps/oci_wrapper.cpp | 897 +++++++++++++++++++++++++++-----------------------
apps/oci_wrapper.h | 195 +++++++---
3 files changed, 997 insertions(+), 931 deletions(-)
diffs (truncated from 2776 to 300 lines):
diff -r 6c316ce9fb1c -r d4cea42a18e2 apps/las2oci.cpp
--- a/apps/las2oci.cpp Fri Jul 30 17:05:09 2010 +0100
+++ b/apps/las2oci.cpp Fri Jul 30 11:52:25 2010 -0500
@@ -1,3 +1,6 @@
+
+#include <stdlib.h>
+
// god-awful hack because of GDAL/GeoTIFF's shitty include structure
#define CPL_SERV_H_INCLUDED
@@ -10,7 +13,6 @@
#include <liblas/laspoint.hpp>
#include <liblas/lasreader.hpp>
#include <liblas/lasheader.hpp>
-#include <liblas/lasbounds.hpp>
#include <string>
#include <sstream>
@@ -24,6 +26,8 @@
#include <sys/stat.h>
+#include <liblas/lasbounds.hpp>
+
#include <oci.h>
using namespace std;
@@ -35,12 +39,46 @@
#define compare_no_case(a,b,n) strncasecmp( (a), (b), (n) )
#endif
+// #define MAX_POINTS_PER_ROW 1000
+
+
#include <boost/array.hpp>
#include <boost/shared_ptr.hpp>
typedef std::vector<liblas::uint32_t> IDVector;
typedef boost::shared_ptr< IDVector > IDVectorPtr;
+typedef struct
+{
+ long* pc_ids;
+ long* block_ids;
+ long* num_points;
+ OCILobLocator** locators; // =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
+
+ std::vector<liblas::uint8_t>** blobs;
+
+ long* srids;
+ long* gtypes;
+ OCIArray** element_arrays;
+ OCIArray** coordinate_arrays;
+
+ long size;
+
+} blocks;
+
+typedef struct
+{
+ double x0;
+ double x1;
+ double y0;
+ double y1;
+ double z0;
+ double z1;
+ bool bUse3d;
+
+} extent;
+
+
class IndexResult
{
public:
@@ -126,41 +164,9 @@
m_results.push_back(result);
}
- liblas::Bounds b2(mins[0], mins[1], maxs[0], maxs[1]);
- (*bounds) = b2;
+ bounds = boost::shared_ptr<liblas::Bounds>(new liblas::Bounds(mins[0], mins[1], maxs[0], maxs[1]));
}
-typedef struct
-{
- long* pc_ids;
- long* block_ids;
- long* num_points;
- OCILobLocator** locators; // =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
-
- std::vector<liblas::uint8_t>** blobs;
-
- long* srids;
- long* gtypes;
- OCIArray** element_arrays;
- OCIArray** coordinate_arrays;
-
- long size;
-
-} blocks;
-
-typedef struct
-{
- double x0;
- double x1;
- double y0;
- double y1;
- double z0;
- double z1;
- bool bUse3d;
-
-} extent;
-
-
bool KDTreeIndexExists(std::string& filename)
{
struct stat stats;
@@ -177,7 +183,6 @@
return output;
}
-
std::istream* OpenInput(std::string filename, bool bEnd)
{
std::ios::openmode mode = std::ios::in | std::ios::binary;
@@ -246,6 +251,7 @@
return true;
}
+
bool IsGeographic(OWConnection* connection, long srid) {
ostringstream oss;
@@ -278,10 +284,11 @@
return true;
}
-
free(kind);
+
return false;
}
+
OWStatement* Run(OWConnection* connection, ostringstream& command)
{
OWStatement* statement = 0;
@@ -318,25 +325,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;
}
@@ -403,69 +409,19 @@
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 IndexResult& result,
liblas::Reader* reader,
- std::vector<liblas::uint8_t>& data,
+ std::vector<double>& data,
int nDimension)
{
IDVector const& ids = result.GetIDs();
+ // list<SpatialIndex::id_type> const& ids = result.GetIDs();
// d 8-byte IEEE big-endian doubles, where d is the PC_TOT_DIMENSIONS value
@@ -473,51 +429,38 @@
// 4-byte big-endian integer for the PT_ID value
bool bTime = false;
- if (nDimension == 4)
- {
- bTime = true;
- }
+ // if (nDimension == 4)
+ // {
+ // bTime = true;
+ // }
data.clear();
+
+ IDVector::const_iterator i;
+ vector<liblas::uint8_t>::iterator pi;
- IDVector::const_iterator i;
- vector<liblas::uint8_t>::iterator pi;
+ // list<SpatialIndex::id_type>::const_iterator i;
+// 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;
for (i=ids.begin(); i!=ids.end(); ++i)
{
liblas::uint32_t id = *i;
+ // 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);
More information about the Liblas-commits
mailing list