コード例 #1
0
ファイル: System.cpp プロジェクト: nixz/covise
System::System()
{
    // setup GDAL
    GDALAllRegister();

    _trimOldestTiles = true;
    _numUnusedDatasetsToTrimFromCache = 10;
    _maxNumDatasets = (unsigned int)(double(vpb::getdtablesize()) * 0.8);

    _logDirectory = "logs";
    _taskDirectory = "tasks";

    _maxNumberOfFilesPerDirectory = 1000;

    readEnvironmentVariables();

    // preload the .osg plugin so its available in case we need to output source files containing core osg nodes
    osgDB::Registry::instance()->loadLibrary(osgDB::Registry::instance()->createLibraryNameForExtension("osg"));

    GDALDriverManager *driverManager = GetGDALDriverManager();
    if (driverManager)
    {
        for (int i = 0; i < driverManager->GetDriverCount(); ++i)
        {
            GDALDriver *driver = driverManager->GetDriver(i);
            if (driver)
            {
                const char *ext = driver->GetMetadataItem("DMD_EXTENSION");
                if (ext && strlen(ext) != 0)
                {
                    addSupportedExtension(ext,
                                          Source::IMAGE | Source::HEIGHT_FIELD,
                                          driver->GetMetadataItem(GDAL_DMD_LONGNAME));
                }
            }
        }
    }

    // add entries that GDAL doesn't list via it's DMD_EXTENSIONS but is known to support
    addSupportedExtension("jpeg", Source::IMAGE | Source::HEIGHT_FIELD, "JPEG");
    addSupportedExtension("tiff", Source::IMAGE | Source::HEIGHT_FIELD, "GeoTiff");
    addSupportedExtension("pgm", Source::IMAGE | Source::HEIGHT_FIELD, "Netpbm");
    addSupportedExtension("ppm", Source::IMAGE | Source::HEIGHT_FIELD, "Netpbm");

    addSupportedExtension("shp", Source::SHAPEFILE, "Shape file loader");

    addSupportedExtension("osgb", Source::MODEL, "OpenSceneGraph binary format");
    addSupportedExtension("osgx", Source::MODEL, "OpenSceneGraph xml format");
    addSupportedExtension("osgt", Source::MODEL, "OpenSceneGraph text/ascii format");

    addSupportedExtension("osg", Source::MODEL, "OpenSceneGraph .osg ascii format");
    addSupportedExtension("ive", Source::MODEL, "OpenSceneGraph .ive binary format");
}
コード例 #2
0
int OGRSFDriverRegistrar::GetDriverCount()

{
    /* We must be careful only to return drivers that are actual OGRSFDriver* */
    GDALDriverManager* poDriverManager = GetGDALDriverManager();
    int nTotal = poDriverManager->GetDriverCount();
    int nOGRDriverCount = 0;
    for(int i=0;i<nTotal;i++)
    {
        GDALDriver* poDriver = poDriverManager->GetDriver(i);
        if( poDriver->GetMetadataItem(GDAL_DCAP_VECTOR) != NULL )
            nOGRDriverCount ++;
    }
    return nOGRDriverCount;
}
コード例 #3
0
ファイル: gdal_rasterize_bin.cpp プロジェクト: jef-n/gdal
MAIN_START(argc, argv)
{
    /* Check strict compilation and runtime library version as we use C++ API */
    if (! GDAL_CHECK_VERSION(argv[0]))
        exit(1);

    EarlySetConfigOptions(argc, argv);

/* -------------------------------------------------------------------- */
/*      Generic arg processing.                                         */
/* -------------------------------------------------------------------- */
    GDALAllRegister();
    argc = GDALGeneralCmdLineProcessor(argc, &argv, 0);
    if( argc < 1 )
        exit( -argc );

    for( int i = 0; i < argc; i++ )
    {
        if( EQUAL(argv[i], "--utility_version") )
        {
            printf("%s was compiled against GDAL %s and "
                   "is running against GDAL %s\n",
                   argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));
            CSLDestroy(argv);
            return 0;
        }
        else if( EQUAL(argv[i], "--help") )
        {
            Usage();
        }
    }

    GDALRasterizeOptionsForBinary* psOptionsForBinary =
        GDALRasterizeOptionsForBinaryNew();
    // coverity[tainted_data]
    GDALRasterizeOptions *psOptions =
        GDALRasterizeOptionsNew(argv + 1, psOptionsForBinary);
    CSLDestroy(argv);

    if( psOptions == nullptr )
    {
        Usage();
    }

    if( !(psOptionsForBinary->bQuiet) )
    {
        GDALRasterizeOptionsSetProgress(psOptions, GDALTermProgress, nullptr);
    }

    if( psOptionsForBinary->pszSource == nullptr )
        Usage("No input file specified.");

    if( psOptionsForBinary->pszDest == nullptr )
        Usage("No output file specified.");

/* -------------------------------------------------------------------- */
/*      Open input file.                                                */
/* -------------------------------------------------------------------- */
    GDALDatasetH hInDS = GDALOpenEx(
        psOptionsForBinary->pszSource, GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR,
        nullptr, nullptr, nullptr);

    if( hInDS == nullptr )
        exit(1);

/* -------------------------------------------------------------------- */
/*      Open output file if it exists.                                  */
/* -------------------------------------------------------------------- */
    GDALDatasetH hDstDS = nullptr;
    if( !(psOptionsForBinary->bCreateOutput) )
    {
        CPLPushErrorHandler(CPLQuietErrorHandler);
        hDstDS = GDALOpenEx(
            psOptionsForBinary->pszDest,
            GDAL_OF_RASTER | GDAL_OF_VERBOSE_ERROR | GDAL_OF_UPDATE,
            nullptr, nullptr, nullptr );
        CPLPopErrorHandler();
    }

    if( psOptionsForBinary->pszFormat != nullptr &&
        (psOptionsForBinary->bCreateOutput || hDstDS == nullptr) )
    {
        GDALDriverManager *poDM = GetGDALDriverManager();
        GDALDriver *poDriver =
            poDM->GetDriverByName(psOptionsForBinary->pszFormat);
        char** papszDriverMD = (poDriver) ? poDriver->GetMetadata(): nullptr;
        if( poDriver == nullptr ||
            !CPLTestBool(CSLFetchNameValueDef(papszDriverMD, GDAL_DCAP_RASTER,
                                              "FALSE")) ||
            !CPLTestBool(CSLFetchNameValueDef(papszDriverMD, GDAL_DCAP_CREATE,
                                              "FALSE")) )
        {
            fprintf(stderr,
                    "Output driver `%s' not recognised or does not support "
                    "direct output file creation.\n",
                    psOptionsForBinary->pszFormat);
            fprintf(stderr,
                    "The following format drivers are configured and "
                    "support direct output:\n" );

            for( int iDriver = 0; iDriver < poDM->GetDriverCount(); iDriver++ )
            {
                GDALDriver* poIter = poDM->GetDriver(iDriver);
                papszDriverMD = poIter->GetMetadata();
                if( CPLTestBool(
                        CSLFetchNameValueDef(papszDriverMD, GDAL_DCAP_RASTER,
                                             "FALSE")) &&
                    CPLTestBool(
                        CSLFetchNameValueDef(papszDriverMD, GDAL_DCAP_CREATE,
                                             "FALSE")) )
                {
                    fprintf(stderr,  "  -> `%s'\n", poIter->GetDescription());
                }
            }
            exit(1);
        }
    }

    int bUsageError = FALSE;
    GDALDatasetH hRetDS = GDALRasterize(psOptionsForBinary->pszDest,
                                        hDstDS,
                                        hInDS,
                                        psOptions, &bUsageError);
    if(bUsageError == TRUE)
        Usage();
    const int nRetCode = hRetDS ? 0 : 1;

    GDALClose(hInDS);
    GDALClose(hRetDS);
    GDALRasterizeOptionsFree(psOptions);
    GDALRasterizeOptionsForBinaryFree(psOptionsForBinary);

    GDALDestroyDriverManager();

    return nRetCode;
}