Changeset 1590:ad4b53ae2aeb
- Timestamp:
- 02/22/10 14:36:37 (5 months ago)
- Branch:
- default
- File:
-
- 1 edited
-
apps/las2oci.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/las2oci.cpp
r1589 r1590 39 39 40 40 typedef struct 41 { 42 long* srid; 41 { 42 long* pc_ids; 43 long* block_ids; 44 long* num_points; 45 std::vector<liblas::uint8_t>** blobs; 46 47 long* srids; 48 long* gtypes; 49 OCIArray** element_arrays; 50 OCIArray** coordinate_arrays; 43 51 44 } block; 52 } blocks; 53 54 typedef struct 55 { 56 double x0; 57 double x1; 58 double y0; 59 double y1; 60 double z0; 61 double z1; 62 bool bUse3d; 63 64 } extent; 65 45 66 46 67 bool KDTreeIndexExists(std::string& filename) … … 363 384 void SetOrdinates( OWStatement* statement, 364 385 OCIArray* sdo_ordinates, 365 double x0, double x1, 366 double y0, double y1, 367 double z0, double z1, 368 bool bUse3d) 369 { 370 371 statement->AddElement(sdo_ordinates, x0); 372 statement->AddElement(sdo_ordinates, y0); 373 if (bUse3d) 374 statement->AddElement(sdo_ordinates, z0); 375 376 statement->AddElement(sdo_ordinates, x1); 377 statement->AddElement(sdo_ordinates, y1); 378 if (bUse3d) 379 statement->AddElement(sdo_ordinates, z1); 386 extent* extent) 387 { 388 389 statement->AddElement(sdo_ordinates, extent->x0); 390 statement->AddElement(sdo_ordinates, extent->y0); 391 if (extent->bUse3d) 392 statement->AddElement(sdo_ordinates, extent->z0); 393 394 statement->AddElement(sdo_ordinates, extent->x1); 395 statement->AddElement(sdo_ordinates, extent->y1); 396 if (extent->bUse3d) 397 statement->AddElement(sdo_ordinates, extent->z1); 380 398 381 399 382 400 } 383 bool InsertBlock(OWConnection* connection, 384 const LASQueryResult& result, 385 int srid, 386 LASReader* reader, 387 const char* tableName, 388 long precision, 389 long pc_id, 390 bool bUseSolidGeometry, 391 bool bUse3d) 392 { 393 ostringstream oss; 394 395 list<SpatialIndex::id_type> const& ids = result.GetIDs(); 401 402 extent* GetExtent( const LASQueryResult& result, 403 bool bUse3d, 404 bool bGeographic 405 ) 406 { 407 double x0, x1, y0, y1, z0, z1; 396 408 const SpatialIndex::Region* b = result.GetBounds(); 397 liblas::uint32_t num_points =ids.size();398 ostringstream oss_geom;399 400 ostringstream s_srid;401 long gtype;402 ostringstream s_eleminfo;403 bool bGeographic = false;404 405 EnableTracing(connection);406 407 if (srid == 4326) {408 bGeographic = true;409 }410 else {411 s_srid << srid;412 // bUse3d = false;413 // If the user set an srid and set it to solid, we're still 3d414 // if (bUseSolidGeometry == true)415 // bUse3d = true;416 }417 418 if (bUse3d) {419 if (bUseSolidGeometry == true) {420 gtype = 3008;421 422 } else {423 gtype = 3003;424 }425 } else {426 if (bUseSolidGeometry == true) {427 gtype = 2008;428 } else {429 gtype = 2003;430 }431 }432 433 double x0, x1, y0, y1, z0, z1;434 435 436 x0 = b->getLow(0);437 x1 = b->getHigh(0);438 y0 = b->getLow(1);439 y1 = b->getHigh(1);440 441 409 if (bUse3d) { 442 410 try { … … 457 425 z0 = 0.0; 458 426 z1 = 20000.0; 427 } 428 429 extent* e = (extent*) malloc (sizeof(extent)); 430 e->x0 = x0; e->x1 = x1; 431 e->y0 = y0; e->y1 = y1; 432 e->z0 = z0; e->z1 = z1; 433 e->bUse3d = bUse3d; 434 435 return e; 436 } 437 bool FillBlock( OWConnection* connection, 438 OWStatement* statement, 439 const LASQueryResult& result, 440 LASReader* reader, 441 blocks* b, 442 long index, 443 444 int srid, 445 long pc_id, 446 long block_id, 447 long num_points, 448 long gtype, 449 bool bUseSolidGeometry, 450 bool bUse3d, 451 long nDimensions 452 453 ) 454 { 455 456 457 list<SpatialIndex::id_type> const& ids = result.GetIDs(); 458 const SpatialIndex::Region* bounds = result.GetBounds(); 459 460 b->pc_ids[index] = pc_id; 461 b->srids[index] = srid; 462 b->block_ids[index] = result.GetID(); 463 b->num_points[index] = (long)ids.size(); 464 465 std::vector<liblas::uint8_t>* blob = new std::vector<liblas::uint8_t>; 466 467 bool gotdata = GetResultData(result, reader, *blob, nDimensions); 468 if (! gotdata) throw std::runtime_error("unable to fetch point data byte array"); 469 b->blobs[index] = blob; 470 b->srids[index] = srid; 471 b->gtypes[index] = gtype; 472 473 OCIArray* sdo_elem_info=0; 474 connection->CreateType(&sdo_elem_info, connection->GetElemInfoType()); 475 SetElements(statement, sdo_elem_info, bUseSolidGeometry); 476 477 b->element_arrays[index] = sdo_elem_info; 478 479 OCIArray* sdo_ordinates=0; 480 connection->CreateType(&sdo_ordinates, connection->GetOrdinateType()); 481 482 extent* e = (extent*) malloc(sizeof(extent)); 483 SetOrdinates(statement, sdo_ordinates, e); 484 485 b->coordinate_arrays[index] = sdo_ordinates; 486 487 return true; 488 } 489 490 long GetGType( bool bUse3d, 491 bool bUseSolidGeometry) 492 { 493 long gtype = 0; 494 if (bUse3d) { 495 if (bUseSolidGeometry == true) { 496 gtype = 3008; 497 498 } else { 499 gtype = 3003; 500 } 501 } else { 502 if (bUseSolidGeometry == true) { 503 gtype = 2008; 504 } else { 505 gtype = 2003; 506 } 507 } 508 509 return gtype; 510 } 511 512 bool InsertBlock(OWConnection* connection, 513 const LASQueryResult& result, 514 int srid, 515 LASReader* reader, 516 const char* tableName, 517 long precision, 518 long pc_id, 519 bool bUseSolidGeometry, 520 bool bUse3d) 521 { 522 ostringstream oss; 523 524 list<SpatialIndex::id_type> const& ids = result.GetIDs(); 525 const SpatialIndex::Region* b = result.GetBounds(); 526 liblas::uint32_t num_points =ids.size(); 527 528 529 long gtype = GetGType(bUse3d, bUseSolidGeometry); 530 531 532 bool bGeographic = false; 533 534 EnableTracing(connection); 535 536 if (srid == 4326) { 537 bGeographic = true; 538 } 539 else { 540 // s_srid << srid; 541 // bUse3d = false; 542 // If the user set an srid and set it to solid, we're still 3d 543 // if (bUseSolidGeometry == true) 544 // bUse3d = true; 545 } 546 547 548 double x0, x1, y0, y1, z0, z1; 549 550 551 x0 = b->getLow(0); 552 x1 = b->getHigh(0); 553 y0 = b->getLow(1); 554 y1 = b->getHigh(1); 555 556 if (bUse3d) { 557 try { 558 z0 = b->getLow(2); 559 z1 = b->getHigh(2); 560 } catch (Tools::IndexOutOfBoundsException& e) { 561 z0 = 0; 562 z1 = 20000; 563 } 564 } else if (bGeographic) { 565 x0 = -180.0; 566 x1 = 180.0; 567 y0 = -90.0; 568 y1 = 90.0; 569 z0 = 0.0; 570 z1 = 20000.0; 571 } else { 572 z0 = 0.0; 573 z1 = 20000.0; 459 574 } 460 575 461 576 462 oss_geom.setf(std::ios_base::fixed, std::ios_base::floatfield);463 oss_geom.precision(precision);577 // oss_geom.setf(std::ios_base::fixed, std::ios_base::floatfield); 578 // oss_geom.precision(precision); 464 579 465 580 oss << "INSERT INTO "<< tableName << … … 530 645 connection->CreateType(&sdo_ordinates, connection->GetOrdinateType()); 531 646 532 SetOrdinates(statement, sdo_ordinates, x0, x1, y0, y1, z0, z1, bUse3d); 647 extent* e = GetExtent(result, bUse3d, bGeographic); 648 649 650 // x0, x1, y0, y1, z0, z1, bUse3d 651 SetOrdinates(statement, sdo_ordinates, e); 533 652 statement->Bind(&sdo_ordinates, connection->GetOrdinateType()); 534 653 … … 582 701 bUse3d); 583 702 } 584 703 return true; 585 704 } 586 705
Note: See TracChangeset
for help on using the changeset viewer.
