Changeset 1600:7aaceb18f32f
- Timestamp:
- 03/02/10 08:43:55 (5 months ago)
- Branch:
- default
- Location:
- apps
- Files:
-
- 3 edited
-
las2oci.cpp (modified) (22 diffs)
-
oci_wrapper.cpp (modified) (2 diffs)
-
oci_wrapper.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
apps/las2oci.cpp
r1599 r1600 148 148 return 0; 149 149 } 150 } 151 150 151 return true; 152 } 153 bool IsGeographic(OWConnection* connection, long srid) { 154 155 ostringstream oss; 156 char* kind = (char* ) malloc (OWNAME * sizeof(char)); 157 oss << "SELECT COORD_REF_SYS_KIND from MDSYS.SDO_COORD_REF_SYSTEM WHERE SRID = :1"; 158 159 OWStatement* statement = 0; 160 161 statement = connection->CreateStatement(oss.str().c_str()); 162 long* p_srid = (long*) malloc( 1 * sizeof(long)); 163 p_srid[0] = srid; 164 165 statement->Bind(p_srid); 166 statement->Define(kind); 167 if (statement->Execute() == false) { 168 169 std::cout << "statement execution failed " << CPLGetLastErrorMsg() << std::endl; 170 delete statement; 171 return false; 172 } 173 174 if (compare_no_case(kind, "GEOGRAPHIC2D",12) == 0) { 175 delete statement; 176 free(kind); 177 return true; 178 } 179 if (compare_no_case(kind, "GEOGRAPHIC3D",12) == 0) { 180 delete statement; 181 free(kind); 182 return true; 183 } 184 185 186 free(kind); 187 return false; 188 } 152 189 OWStatement* Run(OWConnection* connection, ostringstream& command) 153 190 { … … 252 289 "end;"; 253 290 statement = Run(connection, oss); 254 if (statement != 0) delete statement; else return false;291 if (statement != 0) delete statement; 255 292 oss.str(""); 256 293 257 294 oss << "DROP TABLE "<< tableName ; 258 295 statement = Run(connection, oss); 259 if (statement != 0) delete statement; else return false;296 if (statement != 0) delete statement; 260 297 oss.str(""); 261 298 … … 365 402 // d 8-byte IEEE big-endian doubles, where d is the PC_TOT_DIMENSIONS value 366 403 bool gotdata = GetPointData(p, bTime, point_data); 367 404 405 if (!gotdata) { throw std::runtime_error("Unable to fetch Point Data"); exit(1);} 368 406 std::vector<liblas::uint8_t>::const_iterator d; 369 407 for (d = point_data.begin(); d!=point_data.end(); d++) { … … 429 467 430 468 extent* GetExtent( const SpatialIndex::Region* b, 431 bool bUse3d, 432 bool bGeographic 469 bool bUse3d 433 470 ) 434 471 { … … 440 477 y0 = b->getLow(1); 441 478 y1 = b->getHigh(1); 442 479 z0 = 0; 480 z1 = 20000; 443 481 if (bUse3d) { 444 482 try { … … 446 484 z1 = b->getHigh(2); 447 485 } catch (Tools::IndexOutOfBoundsException& e) { 448 z0 = 0; 449 z1 = 20000; 450 } 451 } else if (bGeographic) { 452 x0 = -180.0; 453 x1 = 180.0; 454 y0 = -90.0; 455 y1 = 90.0; 456 z0 = 0.0; 457 z1 = 20000.0; 458 } else { 459 z0 = 0.0; 460 z1 = 20000.0; 461 } 462 486 487 } 488 } 463 489 extent* e = (extent*) malloc (sizeof(extent)); 464 490 e->x0 = x0; e->x1 = x1; … … 483 509 b->element_arrays = (OCIArray**) malloc ( size * sizeof(OCIArray*)); 484 510 b->coordinate_arrays = (OCIArray**) malloc ( size * sizeof(OCIArray*)); 485 511 return b; 486 512 } 487 513 bool FillBlock( OWConnection* connection, … … 502 528 503 529 list<SpatialIndex::id_type> const& ids = result.GetIDs(); 504 const SpatialIndex::Region* bounds = result.GetBounds(); 505 530 506 531 b->pc_ids[index] = pc_id; 507 532 b->srids[index] = srid; … … 528 553 529 554 530 bool bGeographic = false; 531 532 if (srid == 4326) { 533 bGeographic = true; 534 } 535 else { 536 // s_srid << srid; 537 // bUse3d = false; 538 // If the user set an srid and set it to solid, we're still 3d 539 // if (bUseSolidGeometry == true) 540 // bUse3d = true; 541 } 542 543 extent* e = GetExtent(result.GetBounds(), bUse3d, bGeographic); 555 556 extent* e = GetExtent(result.GetBounds(), bUse3d); 544 557 SetOrdinates(statement, sdo_ordinates, e); 545 558 … … 638 651 639 652 list<SpatialIndex::id_type> const& ids = result.GetIDs(); 640 const SpatialIndex::Region* b = result.GetBounds();653 // const SpatialIndex::Region* b = result.GetBounds(); 641 654 liblas::uint32_t num_points = ids.size(); 642 655 643 656 644 bool bGeographic = false;645 646 657 // EnableTracing(connection); 647 658 648 if (srid == 4326) {649 bGeographic = true;650 }651 else {652 // s_srid << srid;653 // bUse3d = false;654 // If the user set an srid and set it to solid, we're still 3d655 // if (bUseSolidGeometry == true)656 // bUse3d = true;657 }658 659 659 long gtype = GetGType(bUse3d, bUseSolidGeometry); 660 660 … … 676 676 677 677 long* p_result_id = (long*) malloc( 1 * sizeof(long)); 678 long n_results = result.GetID();679 678 p_result_id[0] = (long)result.GetID(); 680 679 … … 727 726 connection->CreateType(&sdo_ordinates, connection->GetOrdinateType()); 728 727 729 extent* e = GetExtent(result.GetBounds(), bUse3d , bGeographic);728 extent* e = GetExtent(result.GetBounds(), bUse3d); 730 729 731 730 … … 735 734 736 735 if (statement->Execute() == false) { 737 blocks* b = CreateBlock(324);738 736 delete statement; 739 737 return false; … … 783 781 784 782 OWStatement* statement = 0; 785 OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1000 );783 // OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1000 ); 786 784 787 785 statement = con->CreateStatement(oss.str().c_str()); 788 786 long j = 0; 789 787 bool inserted = false; 790 788 for (i=results.begin(); i!=results.end(); i++) 791 789 { … … 806 804 // ); 807 805 808 boolinserted = InsertBlock(con,806 inserted = InsertBlock(con, 809 807 *i, 810 808 b, … … 818 816 bUse3d); 819 817 } 820 return true;818 return inserted; 821 819 } 822 820 … … 845 843 846 844 ostringstream s_srid; 847 bool bGeographic = false;848 849 // if (bUseSolidGeometry == true) {850 // bUse3d = true;851 // }852 845 853 846 … … 856 849 // bUse3d = true; 857 850 } 858 // else if (srid == 4326) {859 // s_srid << "NULL";860 // // bUse3d = true;861 // bGeographic = true;862 // }863 851 else { 864 852 s_srid << srid; … … 886 874 z1 = 20000; 887 875 } 888 } else if (bGeographic) {889 x0 = -180.0;890 x1 = 180.0;891 y0 = -90.0;892 y1 = 90.0;893 z0 = 0.0;894 z1 = 20000.0;895 tolerance = 0.000000005;876 // } else if (bGeographic) { 877 // x0 = -180.0; 878 // x1 = 180.0; 879 // y0 = -90.0; 880 // y1 = 90.0; 881 // z0 = 0.0; 882 // z1 = 20000.0; 883 // tolerance = 0.000000005; 896 884 } else { 897 885 z0 = 0.0; … … 1056 1044 1057 1045 1058 bool bGeographic = false; 1059 1046 bool is_geo = IsGeographic(connection, srid); 1047 1048 std::cout <<"Is Geographic? :" << is_geo << std::endl; 1060 1049 if (srid == 0) { 1061 1050 s_srid << "NULL"; 1062 // bUse3d = true; 1063 // bUseSolidGeometry = true; 1064 } 1065 // else if (srid == 4326) { 1066 // // bUse3d = true; 1067 // // bUseSolidGeometry = false; 1068 // bGeographic = true; 1069 // s_srid << "NULL"; 1070 // } 1051 } 1071 1052 else { 1072 1053 s_srid << srid; 1073 // bUse3d = false;1074 // // If the user set an srid and set it to solid, we're still 3d1075 // if (bUseSolidGeometry == true)1076 // bUse3d = true;1077 1054 } 1078 1055 … … 1102 1079 1103 1080 1104 extent* e = GetExtent( &(query->bounds), bUse3d, bGeographic ); 1105 1106 // double x0, x1, y0, y1, z0, z1; 1107 double tolerance = 0.05; 1108 1109 // Nuke our extents of we're overridding them 1110 if (bSetExtents){ 1111 e->x0 = xmin; e->x1 = xmax; 1112 e->y0 = ymin; e->y1 = ymax; 1113 e->z0 = zmin; e->z1 = zmax; 1114 } 1115 // x0 = query->bounds.getLow(0); 1116 // x1 = query->bounds.getHigh(0); 1117 // y0 = query->bounds.getLow(1); 1118 // y1 = query->bounds.getHigh(1); 1119 // 1120 // if (bUse3d) { 1121 // try { 1122 // z0 = query->bounds.getLow(2); 1123 // z1 = query->bounds.getHigh(2); 1124 // } catch (Tools::IndexOutOfBoundsException& e) { 1125 // z0 = 0; 1126 // z1 = 20000; 1127 // } 1128 // } else if (bGeographic) { 1129 // x0 = -180.0; 1130 // y0 = 180.0; 1131 // y0 = -90.0; 1132 // y1 = 90.0; 1133 // z0 = 0.0; 1134 // z1 = 20000.0; 1135 // tolerance = 0.000000005; 1136 // } else { 1137 // z0 = 0.0; 1138 // z1 = 20000.0; 1139 // } 1140 // } 1081 extent* e = GetExtent( &(query->bounds), bUse3d ); 1082 1141 1083 1142 1084 s_geom << " mdsys.sdo_geometry("<<s_gtype.str() <<", "<<s_srid.str()<<", null,\n" … … 1666 1608 return false; 1667 1609 } 1668 oss.str(""); 1610 oss.str(""); 1611 con->Commit(); 1669 1612 } 1670 1613 -
apps/oci_wrapper.cpp
r1592 r1600 1661 1661 1662 1662 CPLError( CE_Failure, CPLE_AppDefined, "%.*s", 1663 sizeof(szMsg), szMsg );1663 (int) sizeof(szMsg), szMsg ); 1664 1664 break; 1665 1665 … … 1677 1677 1678 1678 CPLError( CE_Failure, CPLE_AppDefined, "%.*s", 1679 sizeof(szMsg), szMsg );1679 (int) sizeof(szMsg), szMsg ); 1680 1680 break; 1681 1681 -
apps/oci_wrapper.h
r1592 r1600 252 252 bool Commit(); // OCITransCommit() 253 253 bool StartTransaction(); // //OCITransStart() 254 bool EndTransaction() { Commit(); }254 bool EndTransaction() {return Commit(); } 255 255 256 256 };
Note: See TracChangeset
for help on using the changeset viewer.
