Changeset 1600:7aaceb18f32f


Ignore:
Timestamp:
03/02/10 08:43:55 (5 months ago)
Author:
Howard Butler <hobu.inc@…>
Branch:
default
Message:

clean up warnings, add function to test if srid is geographic, and commit on execution of pre-block-sql

Location:
apps
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/las2oci.cpp

    r1599 r1600  
    148148        return 0; 
    149149    }     
    150 } 
    151  
     150     
     151    return true; 
     152} 
     153bool 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} 
    152189OWStatement* Run(OWConnection* connection, ostringstream& command)  
    153190{ 
     
    252289"end;"; 
    253290    statement = Run(connection, oss); 
    254     if (statement != 0) delete statement; else return false; 
     291    if (statement != 0) delete statement;  
    255292    oss.str(""); 
    256293     
    257294    oss << "DROP TABLE "<< tableName ; 
    258295    statement = Run(connection, oss); 
    259     if (statement != 0) delete statement; else return false; 
     296    if (statement != 0) delete statement;  
    260297    oss.str(""); 
    261298 
     
    365402            // d 8-byte IEEE  big-endian doubles, where d is the PC_TOT_DIMENSIONS value 
    366403            bool gotdata = GetPointData(p, bTime, point_data); 
    367  
     404             
     405            if (!gotdata) { throw std::runtime_error("Unable to fetch Point Data"); exit(1);} 
    368406            std::vector<liblas::uint8_t>::const_iterator d; 
    369407            for (d = point_data.begin(); d!=point_data.end(); d++) { 
     
    429467 
    430468extent* GetExtent(  const SpatialIndex::Region* b, 
    431                     bool bUse3d, 
    432                     bool bGeographic 
     469                    bool bUse3d 
    433470                 ) 
    434471{ 
     
    440477    y0 = b->getLow(1);  
    441478    y1 = b->getHigh(1); 
    442  
     479    z0 = 0; 
     480    z1 = 20000; 
    443481    if (bUse3d) { 
    444482        try { 
     
    446484            z1 = b->getHigh(2); 
    447485        } 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    } 
    463489    extent* e = (extent*) malloc (sizeof(extent)); 
    464490    e->x0 = x0; e->x1 = x1; 
     
    483509    b->element_arrays = (OCIArray**) malloc ( size * sizeof(OCIArray*)); 
    484510    b->coordinate_arrays = (OCIArray**) malloc ( size * sizeof(OCIArray*)); 
    485     
     511    return b; 
    486512} 
    487513bool FillBlock( OWConnection* connection,  
     
    502528 
    503529    list<SpatialIndex::id_type> const& ids = result.GetIDs(); 
    504     const SpatialIndex::Region* bounds = result.GetBounds(); 
    505      
     530    
    506531    b->pc_ids[index] = pc_id; 
    507532    b->srids[index] = srid; 
     
    528553 
    529554 
    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); 
    544557    SetOrdinates(statement, sdo_ordinates, e); 
    545558 
     
    638651 
    639652    list<SpatialIndex::id_type> const& ids = result.GetIDs(); 
    640     const SpatialIndex::Region* b = result.GetBounds(); 
     653    // const SpatialIndex::Region* b = result.GetBounds(); 
    641654    liblas::uint32_t num_points = ids.size(); 
    642655 
    643656 
    644     bool bGeographic = false; 
    645      
    646657    // EnableTracing(connection); 
    647658     
    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 3d 
    655         // if (bUseSolidGeometry == true) 
    656         //     bUse3d = true; 
    657     } 
    658  
    659659    long gtype = GetGType(bUse3d, bUseSolidGeometry); 
    660660 
     
    676676 
    677677    long* p_result_id = (long*) malloc( 1 * sizeof(long)); 
    678     long n_results = result.GetID(); 
    679678    p_result_id[0] = (long)result.GetID(); 
    680679     
     
    727726    connection->CreateType(&sdo_ordinates, connection->GetOrdinateType()); 
    728727     
    729     extent* e = GetExtent(result.GetBounds(), bUse3d, bGeographic); 
     728    extent* e = GetExtent(result.GetBounds(), bUse3d); 
    730729 
    731730     
     
    735734     
    736735    if (statement->Execute() == false) { 
    737         blocks* b = CreateBlock(324); 
    738736        delete statement; 
    739737        return false; 
     
    783781           
    784782    OWStatement* statement = 0; 
    785     OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1000 ); 
     783    // OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1000 ); 
    786784 
    787785    statement = con->CreateStatement(oss.str().c_str()); 
    788786    long j = 0; 
    789  
     787    bool inserted = false; 
    790788    for (i=results.begin(); i!=results.end(); i++) 
    791789    { 
     
    806804        //                  ); 
    807805         
    808         bool inserted = InsertBlock(con,  
     806        inserted = InsertBlock(con,  
    809807                                    *i, 
    810808                                    b, 
     
    818816                                    bUse3d); 
    819817    } 
    820     return true; 
     818    return inserted; 
    821819} 
    822820 
     
    845843 
    846844    ostringstream s_srid; 
    847     bool bGeographic = false; 
    848      
    849     // if (bUseSolidGeometry == true) { 
    850     //     bUse3d = true; 
    851     // } 
    852845     
    853846 
     
    856849        // bUse3d = true; 
    857850    } 
    858     // else if (srid == 4326) { 
    859     //     s_srid << "NULL"; 
    860     //     // bUse3d = true; 
    861     //     bGeographic = true; 
    862     // }  
    863851    else { 
    864852        s_srid << srid; 
     
    886874                z1 = 20000; 
    887875            } 
    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; 
    896884        } else { 
    897885            z0 = 0.0; 
     
    10561044 
    10571045 
    1058     bool bGeographic = false; 
    1059      
     1046    bool is_geo = IsGeographic(connection, srid); 
     1047     
     1048    std::cout <<"Is Geographic? :" << is_geo << std::endl; 
    10601049    if (srid == 0) { 
    10611050        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        } 
    10711052    else { 
    10721053        s_srid << srid; 
    1073         // bUse3d = false; 
    1074         // // If the user set an srid and set it to solid, we're still 3d 
    1075         // if (bUseSolidGeometry == true) 
    1076         //     bUse3d = true; 
    10771054    } 
    10781055 
     
    11021079     
    11031080 
    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 
    11411083 
    11421084    s_geom << "           mdsys.sdo_geometry("<<s_gtype.str() <<", "<<s_srid.str()<<", null,\n" 
     
    16661608            return false; 
    16671609        } 
    1668         oss.str("");         
     1610        oss.str(""); 
     1611        con->Commit();      
    16691612    } 
    16701613     
  • apps/oci_wrapper.cpp

    r1592 r1600  
    16611661 
    16621662        CPLError( CE_Failure, CPLE_AppDefined, "%.*s", 
    1663             sizeof(szMsg), szMsg ); 
     1663           (int) sizeof(szMsg), szMsg ); 
    16641664        break; 
    16651665     
     
    16771677 
    16781678            CPLError( CE_Failure, CPLE_AppDefined, "%.*s", 
    1679                 sizeof(szMsg), szMsg ); 
     1679                (int) sizeof(szMsg), szMsg ); 
    16801680            break; 
    16811681 
  • apps/oci_wrapper.h

    r1592 r1600  
    252252    bool                Commit(); // OCITransCommit()  
    253253    bool                StartTransaction(); //  //OCITransStart() 
    254     bool                EndTransaction() {Commit(); }  
     254    bool                EndTransaction() {return Commit(); }  
    255255 
    256256}; 
Note: See TracChangeset for help on using the changeset viewer.