[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Nov 24 13:06:41 EST 2009
changeset 662246d734c4 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=662246d734c4
summary: rework srid/solid/3d interactions
changeset c58362f937df in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=c58362f937df
summary: merge
diffstat:
apps/las2oci.cpp | 464 +++++++++++++++++++++++++++++---------
include/liblas/index/datastream.hpp | 2 +-
src/index/datastream.cpp | 2 +-
3 files changed, 355 insertions(+), 113 deletions(-)
diffs (truncated from 668 to 300 lines):
diff -r 9380e733d922 -r c58362f937df apps/las2oci.cpp
--- a/apps/las2oci.cpp Thu Nov 12 09:03:02 2009 -0600
+++ b/apps/las2oci.cpp Tue Nov 24 12:03:11 2009 -0600
@@ -146,7 +146,22 @@
oss << "DELETE from " <<cloudTableName;
statement = Run(connection, oss);
- if (statement != 0) delete statement; else return false;
+ if (statement != 0) delete statement; else
+ {
+ // if we failed, try dropping the index
+ std::cout << "Dropping index ..." << std::endl;
+ oss.str("");
+ oss << "DROP INDEX "<<tableName<<"_cloud_idx" ;
+ statement = Run(connection, oss);
+ if (statement != 0) delete statement; else return false;
+ oss.str("");
+
+ // redelete from the table
+ oss << "DELETE from " <<cloudTableName;
+ statement = Run(connection, oss);
+ if (statement != 0) delete statement; else return false;
+ oss.str("");
+ }
oss.str("");
std::string cloudColumnName_l = std::string(cloudColumnName);
@@ -181,7 +196,9 @@
oss << "DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='"<<table<<"'" ;
statement = Run(connection, oss);
if (statement != 0) delete statement; else return false;
- oss.str("");
+ oss.str("");
+
+
return true;
}
@@ -308,7 +325,8 @@
const char* tableName,
long precision,
long pc_id,
- bool bUseSolidGeometry)
+ bool bUseSolidGeometry,
+ bool bUse3d)
{
ostringstream oss;
@@ -320,38 +338,81 @@
ostringstream s_srid;
ostringstream s_gtype;
ostringstream s_eleminfo;
- bool bUse3d = true;
- bool bGeographic = true;
+ bool bGeographic = false;
if (srid == 0) {
s_srid << "NULL";
- bUse3d = true;
- bUseSolidGeometry = true;
+ // bUse3d = true;
+ // bUseSolidGeometry = true;
}
else if (srid == 4326) {
- bUse3d = true;
- bUseSolidGeometry = true;
+ // bUse3d = true;
+ // bUseSolidGeometry = true;
bGeographic = true;
- s_srid << "NULL";
+ s_srid << srid;
+ // s_srid << "NULL";
}
else {
s_srid << srid;
- bUse3d = false;
+ // bUse3d = false;
// If the user set an srid and set it to solid, we're still 3d
- if (bUseSolidGeometry == true)
- bUse3d = true;
+ // if (bUseSolidGeometry == true)
+ // bUse3d = true;
}
- if (bUseSolidGeometry == true) {
- s_gtype << "3008";
- s_eleminfo << "(1,1007,3)";
+ if (bUse3d) {
+ if (bUseSolidGeometry == true) {
+ s_gtype << "3008";
+ s_eleminfo << "(1,1007,3)";
+ } else {
+ s_gtype << "3003";
+ s_eleminfo << "(1,1003,3)";
+
+ }
} else {
- s_gtype << "3003";
- s_eleminfo << "(1,1003,3)";
+ if (bUseSolidGeometry == true) {
+ s_gtype << "2008";
+ s_eleminfo << "(1,1007,3)";
+ } else {
+ s_gtype << "2003";
+ s_eleminfo << "(1,1003,3)";
+
+ }
+ }
+
+ double x0, x1, y0, y1, z0, z1;
+ double tolerance = 0.05;
+
+
+ x0 = b->getLow(0);
+ x1 = b->getHigh(0);
+ y0 = b->getLow(1);
+ y1 = b->getHigh(1);
+
+ if (bUse3d) {
+ try {
+ z0 = b->getLow(2);
+ z1 = b->getHigh(2);
+ } catch (Tools::IndexOutOfBoundsException& e) {
+ z0 = 0;
+ z1 = 20000;
+ }
+ } else if (bGeographic) {
+ x0 = -180.0;
+ x1 = 180.0;
+ y0 = -90.0;
+ y1 = 90.0;
+ z0 = 0.0;
+ z1 = 20000.0;
+ tolerance = 0.000000005;
+ } else {
+ z0 = 0.0;
+ z1 = 20000.0;
}
+
// std::cout << "use 3d?: " << bUse3d << " srid: " << s_srid.str() << std::endl;
oss_geom.setf(std::ios_base::fixed, std::ios_base::floatfield);
oss_geom.precision(precision);
@@ -360,27 +421,20 @@
" mdsys.sdo_elem_info_array"<< s_eleminfo.str() <<",\n"
" mdsys.sdo_ordinate_array(\n";
- oss_geom << b->getLow(0) <<","<<
- b->getLow(1) <<",";
+ oss_geom << x0 << ",\n" << y0 << ",\n";
if (bUse3d) {
- if (!bGeographic) {
- oss_geom << b->getLow(2) <<",";
- } else {
- oss_geom <<"0,";
- }
+ oss_geom << z0 << ",\n";
}
-
- oss_geom << b->getHigh(0) <<","<<
- b->getHigh(1);
+
+ oss_geom << x1 << ",\n" << y1 << "\n";
+
if (bUse3d) {
- if (!bGeographic) {
- oss_geom <<","<< b->getHigh(2);
- } else {
- oss_geom <<",20000";
- }
+ oss_geom << ",\n";
+ oss_geom << z1;
}
+
oss_geom << "))";
oss << "INSERT INTO "<< tableName <<
"(OBJ_ID, BLK_ID, NUM_POINTS, BLK_EXTENT, POINTS, PCBLK_MIN_RES, PCBLK_MAX_RES, NUM_UNSORTED_POINTS, PT_SORT_DIM) VALUES ( "
@@ -447,7 +501,15 @@
LASQuery* query,
long srid,
long precision,
- bool bUseSolidGeometry)
+ bool bUseSolidGeometry,
+ bool bUse3d,
+ bool bSetExtents,
+ double xmin,
+ double xmax,
+ double ymin,
+ double ymax,
+ double zmin,
+ double zmax)
{
ostringstream oss;
OWStatement* statement = 0;
@@ -456,48 +518,73 @@
oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
oss.precision(precision);
-
+
ostringstream s_srid;
- bool bUse3d = false;
bool bGeographic = false;
- if (bUseSolidGeometry == true) {
- bUse3d = true;
- }
+ // if (bUseSolidGeometry == true) {
+ // bUse3d = true;
+ // }
if (srid == 0) {
s_srid << "NULL";
- bUse3d = true;
+ // bUse3d = true;
}
- else if (srid == 4326) {
- s_srid << "NULL";
- bUse3d = true;
- bGeographic = true;
- } else {
+ // else if (srid == 4326) {
+ // s_srid << "NULL";
+ // // bUse3d = true;
+ // bGeographic = true;
+ // }
+ else {
s_srid << srid;
}
+
+ double x0, x1, y0, y1, z0, z1;
+ double tolerance = 0.05;
+
+ if (bSetExtents){
+ x0 = xmin; x1 = xmax;
+ y0 = ymin; y1 = ymax;
+ z0 = zmin; z1 = zmax;
+ } else {
+ x0 = query->bounds.getLow(0);
+ x1 = query->bounds.getHigh(0);
+ y0 = query->bounds.getLow(1);
+ y1 = query->bounds.getHigh(1);
+
+ if (bUse3d) {
+ try {
+ z0 = query->bounds.getLow(2);
+ z1 = query->bounds.getHigh(2);
+ } catch (Tools::IndexOutOfBoundsException& e) {
+ z0 = 0;
+ z1 = 20000;
+ }
+ } else if (bGeographic) {
+ x0 = -180.0;
+ x1 = 180.0;
+ y0 = -90.0;
+ y1 = 90.0;
+ z0 = 0.0;
+ z1 = 20000.0;
+ tolerance = 0.000000005;
+ } else {
+ z0 = 0.0;
+ z1 = 20000.0;
+ }
+ }
+
+
oss << "INSERT INTO user_sdo_geom_metadata VALUES ('" << tableName <<
"','blk_extent', MDSYS.SDO_DIM_ARRAY(";
- if (bGeographic == true) {
- oss << "MDSYS.SDO_DIM_ELEMENT('X', -180, 180, .000000005),"
- "MDSYS.SDO_DIM_ELEMENT('Y', -180, 180, .000000005)";
- } else {
- oss << "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)";
-
- }
-
- // "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)";
-
+ oss << "MDSYS.SDO_DIM_ELEMENT('X', " << x0 << "," << x1 <<"," << tolerance << "),"
+ "MDSYS.SDO_DIM_ELEMENT('Y', " << y0 << "," << y1 <<"," << tolerance << ")";
+
if (bUse3d) {
oss << ",";
- if (bGeographic)
- oss <<"MDSYS.SDO_DIM_ELEMENT('Z', "<< 0 <<","<< 200000<<",0.000000005)";
- else
- oss << "MDSYS.SDO_DIM_ELEMENT('Z', "<< query->bounds.getLow(2) <<","<< query->bounds.getHigh(2)<<",0.00000005)";
+ oss <<"MDSYS.SDO_DIM_ELEMENT('Z', "<< z0 << "," << z1 << "," << tolerance << ")";
}
oss << ")," << s_srid.str() << ")";
@@ -512,24 +599,24 @@
More information about the Liblas-commits
mailing list