bool OGRGeomediaDriver::InstallMdbDriver() { if ( !FindDriverLib() ) { return false; } else { CPLAssert( !osDriverFile.empty() ); CPLDebug( "Geomedia", "MDB Tools driver: %s", osDriverFile.c_str() ); CPLString driverName("Microsoft Access Driver (*.mdb)"); CPLString driver(driverName); driver += '\0'; driver += "Driver="; driver += osDriverFile; // Found by FindDriverLib() driver += '\0'; driver += "FileUsage=1"; driver += '\0'; driver += '\0'; // Create installer and register driver CPLODBCDriverInstaller dri; if ( !dri.InstallDriver(driver.c_str(), 0, ODBC_INSTALL_COMPLETE) ) { // Report ODBC error CPLError( CE_Failure, CPLE_AppDefined, "ODBC: %s", dri.GetLastError() ); return false; } } return true; }
BPath BPrinter::_DriverPath() const { BString driverName(_ReadAttribute(PSRV_PRINTER_ATTR_DRIVER_NAME)); if (driverName.Length() <= 0) return BPath(); directory_which directories[] = { B_USER_NONPACKAGED_ADDONS_DIRECTORY, B_USER_ADDONS_DIRECTORY, B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, B_SYSTEM_ADDONS_DIRECTORY }; BPath path; driverName.Prepend("Print/"); for (int32 i = 0; i < sizeof(directories) / sizeof(directories[0]); ++i) { if (find_directory(directories[i], &path) == B_OK) { path.Append(driverName.String()); BEntry driver(path.Path()); if (driver.InitCheck() == B_OK && driver.Exists() && driver.IsFile()) return path; } } return BPath(); }
void ConnDlg::on_okButton_clicked() { if (ui.comboDriver->currentText().isEmpty()) { ui.status_label->setText(tr("请选择一个数据库驱动!")); ui.comboDriver->setFocus(); } else if(ui.comboDriver->currentText() =="QSQLITE") { addSqliteConnection(); //创建数据库表,如已存在则无须执行 creatDB(); accept(); } else { QSqlError err = addConnection(driverName(), databaseName(), hostName(),userName(), password(), port()); if (err.type() != QSqlError::NoError) ui.status_label->setText(err.text()); else ui.status_label->setText(tr("连接数据库成功!")); //创建数据库表,如已存在则无须执行 accept(); } }
void CorePlugin::launchSqlTool() { qfLogFuncFrame(); QString program = QCoreApplication::applicationDirPath() + "/qsqlmon"; #ifdef Q_OS_WIN program += ".exe"; #endif qfDebug() << "launchnig" << program; QStringList otcs; { auto conn = qf::core::sql::Connection::forName(); otcs << "description=QuickEvent"; otcs << "driver=" + conn.driverName(); otcs << "host=" + conn.hostName(); otcs << "port=" + QString::number(conn.port()); otcs << "user="******"password="******"database=" + conn.databaseName(); } QStringList arguments; arguments << "--one-time-connection-settings" << otcs.join('&'); QProcess *process = new QProcess(this); process->start(program, arguments); }
QScriptValue Sql::drivers(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(context) QStringList driverNames = QSqlDatabase::drivers(); QSet<Driver> driverList; for(int index = 0; index < driverNames.size(); ++index) { const QString &driverNameToInclude = driverNames.at(index); for(int driverIndex = 0; driverIndex < DriverCount; ++driverIndex) { if(driverName(static_cast<Driver>(driverIndex)) == driverNameToInclude) driverList.insert(static_cast<Driver>(driverIndex)); } } QScriptValue back = engine->newArray(driverList.size()); int index = 0; for(const Driver &driver: driverList) { back.setProperty(index, driver); ++index; } return back; }
ItemSequence_t RegisterFunction::evaluate( const ExternalFunction::Arguments_t &args, const zorba::StaticContext *aStaticContext, const zorba::DynamicContext *aDynamincContext) const { JdbcModule::initGlobals(aStaticContext); Item result; JDBC_MODULE_TRY; jstring driverName(NULL); Item item = JdbcModule::getItemArg(args, 0); bool hasUsername = false; if (item.isJSONItem()) { Iterator_t lKeys = item.getObjectKeys(); lKeys->open(); Item lKey; while (lKeys->next(lKey)) { zorba::String keystring = lKey.getStringValue(); zorba::String value = item.getObjectValue(keystring).getStringValue(); if (keystring == "driver") { driverName = env->NewStringUTF(value.c_str()); CHECK_EXCEPTION; } } lKeys->close(); } jobject oRegister; if (driverName) { oRegister = env->CallStaticObjectMethod( jClass.classID, jClass.forName, driverName); CHECK_EXCEPTION; } JDBC_MODULE_CATCH; return ItemSequence_t(new EmptySequence()); }
Sql::Sql(Driver driver) : CodeClass(), mDatabase(new QSqlDatabase) { mDriverName = driverName(driver); }
ossimProjection* ossimGdalProjectionFactory::createProjection(const ossimFilename& filename, ossim_uint32 entryIdx)const { ossimKeywordlist kwl; if(ossimString(filename).trim().empty()) return 0; // ossimRefPtr<ossimImageHandler> h = new ossimGdalTileSource; GDALDatasetH h = GDALOpen(filename.c_str(), GA_ReadOnly); GDALDriverH driverH = 0; ossimProjection* proj = 0; if(h) { driverH = GDALGetDatasetDriver( h ); ossimString driverName( driverH ? GDALGetDriverShortName( driverH ) : "" ); // use OSSIM's projection loader for NITF // if(driverName == "NITF") { GDALClose(h); return 0; } if(entryIdx != 0) { char** papszMetadata = GDALGetMetadata( h, "SUBDATASETS" ); //--- // ??? (drb) Should this be: // if ( entryIdx >= CSLCount(papszMetadata) ) close... //--- if( papszMetadata&&(CSLCount(papszMetadata) < static_cast<ossim_int32>(entryIdx)) ) { ossimNotify(ossimNotifyLevel_WARN) << "ossimGdalProjectionFactory::createProjection: We don't support multi entry handlers through the factory yet, only through the handler!"; GDALClose(h); return 0; } else { GDALClose(h); return 0; } } ossimString wkt(GDALGetProjectionRef( h )); double geoTransform[6]; bool transOk = GDALGetGeoTransform( h, geoTransform ) == CE_None; bool wktTranslatorOk = wkt.empty()?false:wktTranslator.toOssimKwl(wkt, kwl); if(!wktTranslatorOk) { ossim_uint32 gcpCount = GDALGetGCPCount(h); if(gcpCount > 3) { ossim_uint32 idx = 0; const GDAL_GCP* gcpList = GDALGetGCPs(h); ossimTieGptSet tieSet; if(gcpList) { for(idx = 0; idx < gcpCount; ++idx) { ossimDpt dpt(gcpList[idx].dfGCPPixel, gcpList[idx].dfGCPLine); ossimGpt gpt(gcpList[idx].dfGCPY, gcpList[idx].dfGCPX, gcpList[idx].dfGCPZ); tieSet.addTiePoint(new ossimTieGpt(gpt, dpt, .5)); } //ossimPolynomProjection* tempProj = new ossimPolynomProjection; ossimBilinearProjection* tempProj = new ossimBilinearProjection; //tempProj->setupOptimizer("1 x y x2 xy y2 x3 y3 xy2 x2y z xz yz"); tempProj->optimizeFit(tieSet); proj = tempProj; } } } if ( transOk && proj==0 ) { ossimString proj_type(kwl.find(ossimKeywordNames::TYPE_KW)); ossimString datum_type(kwl.find(ossimKeywordNames::DATUM_KW)); ossimString units(kwl.find(ossimKeywordNames::UNITS_KW)); if ( proj_type.trim().empty() && (driverName == "MrSID" || driverName == "JP2MrSID") ) { bool bClose = true; // ESH 04/2008, #54: if no rotation factors use geographic system if( geoTransform[2] == 0.0 && geoTransform[4] == 0.0 ) { ossimString projTag( GDALGetMetadataItem( h, "IMG__PROJECTION_NAME", "" ) ); if ( projTag.contains("Geographic") ) { bClose = false; kwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection", true); proj_type = kwl.find( ossimKeywordNames::TYPE_KW ); // Assign units if set in Metadata ossimString unitTag( GDALGetMetadataItem( h, "IMG__HORIZONTAL_UNITS", "" ) ); if ( unitTag.contains("dd") ) // decimal degrees { units = "degrees"; } else if ( unitTag.contains("dm") ) // decimal minutes { units = "minutes"; } else if ( unitTag.contains("ds") ) // decimal seconds { units = "seconds"; } } } if ( bClose == true ) { GDALClose(h); return 0; } } // Pixel-is-point of pixel-is area affects the location of the tiepoint since OSSIM is // always pixel-is-point so 1/2 pixel shift may be necessary: if((driverName == "MrSID") || (driverName == "JP2MrSID") || (driverName == "AIG")) { const char* rasterTypeStr = GDALGetMetadataItem( h, "GEOTIFF_CHAR__GTRasterTypeGeoKey", "" ); ossimString rasterTypeTag( rasterTypeStr ); // If the raster type is pixel_is_area, shift the tie point by // half a pixel to locate it at the pixel center. if ((driverName == "AIG") || (rasterTypeTag.contains("RasterPixelIsArea"))) { geoTransform[0] += fabs(geoTransform[1]) / 2.0; geoTransform[3] -= fabs(geoTransform[5]) / 2.0; } } else { // Conventionally, HFA stores the pixel alignment type for each band. Here assume all // bands are the same. Consider only the first band: GDALRasterBandH bBand = GDALGetRasterBand( h, 1 ); char** papszMetadata = GDALGetMetadata( bBand, NULL ); if (CSLCount(papszMetadata) > 0) { for(int i = 0; papszMetadata[i] != NULL; i++ ) { ossimString metaStr = papszMetadata[i]; metaStr.upcase(); if (metaStr.contains("AREA_OR_POINT")) { ossimString pixel_is_point_or_area = metaStr.split("=")[1]; pixel_is_point_or_area.upcase(); if (pixel_is_point_or_area.contains("AREA")) { // Need to shift the tie point so that pixel is point: geoTransform[0] += fabs(geoTransform[1]) / 2.0; geoTransform[3] -= fabs(geoTransform[5]) / 2.0; } break; } } } } kwl.remove(ossimKeywordNames::UNITS_KW); ossimDpt gsd(fabs(geoTransform[1]), fabs(geoTransform[5])); ossimDpt tie(geoTransform[0], geoTransform[3]); ossimUnitType savedUnitType = static_cast<ossimUnitType>(ossimUnitTypeLut::instance()->getEntryNumber(units)); ossimUnitType unitType = savedUnitType; if(unitType == OSSIM_UNIT_UNKNOWN) unitType = OSSIM_METERS; if((proj_type == "ossimLlxyProjection") || (proj_type == "ossimEquDistCylProjection")) { // ESH 09/2008 -- Add the orig_lat and central_lon if the image // is using geographic coordsys. This is used to convert the // gsd to linear units. // Half the number of pixels in lon/lat directions int nPixelsLon = GDALGetRasterXSize(h)/2.0; int nPixelsLat = GDALGetRasterYSize(h)/2.0; // Shift from image corner to center in lon/lat double shiftLon = nPixelsLon * fabs(gsd.x); double shiftLat = -nPixelsLat * fabs(gsd.y); // lon/lat of center pixel of the image double centerLon = tie.x + shiftLon; double centerLat = tie.y + shiftLat; kwl.add(ossimKeywordNames::ORIGIN_LATITUDE_KW, centerLat, true); kwl.add(ossimKeywordNames::CENTRAL_MERIDIAN_KW, centerLon, true); kwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, tie.y, true); kwl.add(ossimKeywordNames::TIE_POINT_LON_KW, tie.x, true); kwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT, gsd.y, true); kwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON, gsd.x, true); if(savedUnitType == OSSIM_UNIT_UNKNOWN) { unitType = OSSIM_DEGREES; } } kwl.add(ossimKeywordNames::PIXEL_SCALE_XY_KW, gsd.toString(), true); kwl.add(ossimKeywordNames::PIXEL_SCALE_UNITS_KW, units, true); kwl.add(ossimKeywordNames::TIE_POINT_XY_KW, tie.toString(), true); kwl.add(ossimKeywordNames::TIE_POINT_UNITS_KW, units, true); std::stringstream mString; // store as a 4x4 matrix mString << ossimString::toString(geoTransform[1], 20) << " " << ossimString::toString(geoTransform[2], 20) << " " << 0 << " " << ossimString::toString(geoTransform[0], 20) << " " << ossimString::toString(geoTransform[4], 20) << " " << ossimString::toString(geoTransform[5], 20) << " " << 0 << " " << ossimString::toString(geoTransform[3], 20) << " " << 0 << " " << 0 << " " << 1 << " " << 0 << " " << 0 << " " << 0 << " " << 0 << " " << 1; kwl.add(ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW, mString.str().c_str(), true); //--- // SPECIAL CASE: ArcGrid in British National Grid //--- if(driverName == "AIG" && datum_type == "OSGB_1936") { ossimFilename prj_file = filename.path() + "/prj.adf"; if(prj_file.exists()) { ossimKeywordlist prj_kwl(' '); prj_kwl.addFile(prj_file); ossimString proj = prj_kwl.find("Projection"); // Reset projection and Datum correctly for BNG. if(proj.upcase().contains("GREATBRITAIN")) { kwl.add(ossimKeywordNames::TYPE_KW, "ossimBngProjection", true); ossimString datum = prj_kwl.find("Datum"); if(datum != "") { if(datum == "OGB_A") datum = "OGB-A"; else if(datum == "OGB_B") datum = "OGB-B"; else if(datum == "OGB_C") datum = "OGB-C"; else if(datum == "OGB_D") datum = "OGB-D"; else if(datum == "OGB_M") datum = "OGB-M"; else if(datum == "OGB_7") datum = "OGB-7"; kwl.add(ossimKeywordNames::DATUM_KW, datum, true); } } } } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalProjectionFactory: createProjection KWL = \n " << kwl << std::endl; } GDALClose(h); proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl); } return proj; }