您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CPLResetExtension函数代码示例

51自学网 2021-06-01 20:04:49
  C++
这篇教程C++ CPLResetExtension函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CPLResetExtension函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLResetExtension函数的具体用法?C++ CPLResetExtension怎么用?C++ CPLResetExtension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CPLResetExtension函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PAuxDelete

static CPLErr PAuxDelete( const char * pszBasename ){    VSILFILE *fp = VSIFOpenL( CPLResetExtension( pszBasename, "aux" ), "r" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "%s does not appear to be a PAux dataset, there is no .aux file.",                  pszBasename );        return CE_Failure;    }    const char *pszLine = CPLReadLineL( fp );    CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));    if( pszLine == NULL || !STARTS_WITH_CI(pszLine, "AuxilaryTarget") )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "%s does not appear to be a PAux dataset,/n"                  "the .aux file does not start with AuxilaryTarget",                  pszBasename );        return CE_Failure;    }    if( VSIUnlink( pszBasename ) != 0 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "OS unlinking file %s.", pszBasename );        return CE_Failure;    }    VSIUnlink( CPLResetExtension( pszBasename, "aux" ) );    return CE_None;}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:35,


示例2: CPLResetExtension

OGRSpatialReference *OGRShapeLayer::GetSpatialRef(){    if (bSRSSet)        return poSRS;    bSRSSet = TRUE;/* -------------------------------------------------------------------- *//*      Is there an associated .prj file we can read?                   *//* -------------------------------------------------------------------- */    const char  *pszPrjFile = CPLResetExtension( pszFullName, "prj" );    char    **papszLines;    char* apszOptions[] = { (char*)"EMIT_ERROR_IF_CANNOT_OPEN_FILE=FALSE", NULL };    papszLines = CSLLoad2( pszPrjFile, -1, -1, apszOptions );    if (papszLines == NULL)    {        pszPrjFile = CPLResetExtension( pszFullName, "PRJ" );        papszLines = CSLLoad2( pszPrjFile, -1, -1, apszOptions );    }    if( papszLines != NULL )    {        poSRS = new OGRSpatialReference();        if( poSRS->importFromESRI( papszLines ) != OGRERR_NONE )        {            delete poSRS;            poSRS = NULL;        }        CSLDestroy( papszLines );    }    return poSRS;}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:35,


示例3: GetWorldFilePath

CPLString GetWorldFilePath(const CPLString &soPath){    //1. thirst and last char from ext and third char set w (e.g. jpw)    CPLString sExt = CPLGetExtension(soPath);    CPLString sNewExt;    sNewExt += sExt[0];    sNewExt += sExt[sExt.size() - 1];    sNewExt += 'w';    CPLString szPath = (char*)CPLResetExtension(soPath, sNewExt);	if(CPLCheckForFile((char*)szPath.c_str(), NULL))		return szPath;    //4. add wx to ext    sNewExt += 'x';    szPath = (char*)CPLResetExtension(soPath, sNewExt);	if(CPLCheckForFile((char*)szPath.c_str(), NULL))		return szPath;    //2. wld    szPath = (char*)CPLResetExtension(soPath, "wld");    if(CPLCheckForFile((char*)szPath.c_str(), NULL))		return szPath;    //3. add w to ext    szPath = soPath + CPLString("w");    if(CPLCheckForFile((char*)szPath.c_str(), NULL))		return szPath;    return CPLString();}
开发者ID:Mileslee,项目名称:wxgis,代码行数:26,


示例4: CPLError

OGRErr OGRShapeLayer::DropSpatialIndex(){    if( !CheckForQIX() )    {        CPLError( CE_Warning, CPLE_AppDefined,                   "Layer %s has no spatial index, DROP SPATIAL INDEX failed.",                  poFeatureDefn->GetName() );        return OGRERR_FAILURE;    }    VSIFClose( fpQIX );    fpQIX = NULL;    bCheckedForQIX = FALSE;        const char *pszQIXFilename;    pszQIXFilename = CPLResetExtension( pszFullName, "qix" );    CPLDebug( "SHAPE", "Unlinking index file %s", pszQIXFilename );    if( VSIUnlink( pszQIXFilename ) != 0 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Failed to delete file %s./n%s",                   pszQIXFilename, VSIStrerror( errno ) );        return OGRERR_FAILURE;    }    if( !bSbnSbxDeleted )    {        const char *pszIndexFilename;        const char papszExt[2][4] = { "sbn", "sbx" };        int i;        for( i = 0; i < 2; i++ )        {            pszIndexFilename = CPLResetExtension( pszFullName, papszExt[i] );            CPLDebug( "SHAPE", "Trying to unlink index file %s", pszIndexFilename );            if( VSIUnlink( pszIndexFilename ) != 0 )            {                CPLDebug( "SHAPE",                          "Failed to delete file %s./n%s",                           pszIndexFilename, VSIStrerror( errno ) );            }        }    }    bSbnSbxDeleted = TRUE;    return OGRERR_NONE;}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:50,


示例5: CPLError

OGRErr OGRShapeDataSource::DeleteLayer( int iLayer ){    char *pszFilename;/* -------------------------------------------------------------------- *//*      Verify we are in update mode.                                   *//* -------------------------------------------------------------------- */    if( !bDSUpdate )    {        CPLError( CE_Failure, CPLE_NoWriteAccess,                  "Data source %s opened read-only./n"                  "Layer %d cannot be deleted./n",                  pszName, iLayer );        return OGRERR_FAILURE;    }    if( iLayer < 0 || iLayer >= nLayers )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "Layer %d not in legal range of 0 to %d.",                   iLayer, nLayers-1 );        return OGRERR_FAILURE;    }    OGRShapeLayer* poLayerToDelete = (OGRShapeLayer*) papoLayers[iLayer];    pszFilename = CPLStrdup(poLayerToDelete->GetFullName());    delete poLayerToDelete;    while( iLayer < nLayers - 1 )    {        papoLayers[iLayer] = papoLayers[iLayer+1];        iLayer++;    }    nLayers--;    VSIUnlink( CPLResetExtension(pszFilename, "shp") );    VSIUnlink( CPLResetExtension(pszFilename, "shx") );    VSIUnlink( CPLResetExtension(pszFilename, "dbf") );    VSIUnlink( CPLResetExtension(pszFilename, "prj") );    VSIUnlink( CPLResetExtension(pszFilename, "qix") );    CPLFree( pszFilename );    return OGRERR_NONE;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:50,


示例6: GDALClose

CPLErr GDALDefaultOverviews::CleanOverviews(){    // Anything to do?    if( poODS == NULL )        return CE_None;    // Delete the overview file(s).    GDALDriver *poOvrDriver = poODS->GetDriver();    GDALClose( poODS );    poODS = NULL;    const CPLErr eErr = poOvrDriver != NULL ?        poOvrDriver->Delete( osOvrFilename ) : CE_None;    // Reset the saved overview filename.    if( !EQUAL(poDS->GetDescription(),":::VIRTUAL:::") )    {        const bool bUseRRD = CPLTestBool(CPLGetConfigOption("USE_RRD","NO"));        if( bUseRRD )            osOvrFilename = CPLResetExtension( poDS->GetDescription(), "aux" );        else            osOvrFilename.Printf( "%s.ovr", poDS->GetDescription() );    }    else    {        osOvrFilename = "";    }    return eErr;}
开发者ID:ryandavid,项目名称:rotobox,代码行数:32,


示例7: CPLError

OGRErr OGRSXFDriver::DeleteDataSource(const char* pszName){    int iExt;    //TODO: add more extensions if aplicable    static const char *apszExtensions[] = { "szf", "rsc", "SZF", "RSC", NULL };    VSIStatBufL sStatBuf;    if (VSIStatL(pszName, &sStatBuf) != 0)    {        CPLError(CE_Failure, CPLE_AppDefined,            "%s does not appear to be a valid sxf file.",            pszName);        return OGRERR_FAILURE;    }    for (iExt = 0; apszExtensions[iExt] != NULL; iExt++)    {        const char *pszFile = CPLResetExtension(pszName,            apszExtensions[iExt]);        if (VSIStatL(pszFile, &sStatBuf) == 0)            VSIUnlink(pszFile);    }    return OGRERR_NONE;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:26,


示例8: CPLError

OGRErr OGRShapeLayer::DropSpatialIndex(){    if( !CheckForQIX() )    {        CPLError( CE_Warning, CPLE_AppDefined,                   "Layer %s has no spatial index, DROP SPATIAL INDEX failed.",                  poFeatureDefn->GetName() );        return OGRERR_FAILURE;    }    VSIFClose( fpQIX );    fpQIX = NULL;    bCheckedForQIX = FALSE;        const char *pszQIXFilename;    pszQIXFilename = CPLResetExtension( pszFullName, "qix" );    CPLDebug( "SHAPE", "Unlinking index file %s", pszQIXFilename );    if( VSIUnlink( pszQIXFilename ) != 0 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Failed to delete file %s./n%s",                   pszQIXFilename, VSIStrerror( errno ) );        return OGRERR_FAILURE;    }    else        return OGRERR_NONE;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:30,


示例9: CPLError

OGRErr OGRGeoconceptDriver::DeleteDataSource( const char *pszDataSource ){    int iExt;    VSIStatBuf sStatBuf;    static const char *apszExtensions[] =         { "gxt", "txt", "gct", "gcm", "gcr", NULL };    if( VSIStat( pszDataSource, &sStatBuf ) != 0 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "%s does not appear to be a file or directory.",                  pszDataSource );        return OGRERR_FAILURE;    }    if( VSI_ISREG(sStatBuf.st_mode)         && (            EQUAL(CPLGetExtension(pszDataSource),"gxt") ||            EQUAL(CPLGetExtension(pszDataSource),"txt")           ) )    {        for( iExt=0; apszExtensions[iExt] != NULL; iExt++ )        {            const char *pszFile = CPLResetExtension(pszDataSource,                                                    apszExtensions[iExt] );            if( VSIStat( pszFile, &sStatBuf ) == 0 )                VSIUnlink( pszFile );        }    }    else if( VSI_ISDIR(sStatBuf.st_mode) )    {        char **papszDirEntries = CPLReadDir( pszDataSource );        int  iFile;        for( iFile = 0;              papszDirEntries != NULL && papszDirEntries[iFile] != NULL;             iFile++ )        {            if( CSLFindString( (char **) apszExtensions,                                CPLGetExtension(papszDirEntries[iFile])) != -1)            {                VSIUnlink( CPLFormFilename( pszDataSource,                                             papszDirEntries[iFile],                                             NULL ) );            }        }        CSLDestroy( papszDirEntries );        VSIRmdir( pszDataSource );    }    return OGRERR_NONE;}
开发者ID:samalone,项目名称:gdal-ios,代码行数:56,


示例10: DropSpatialIndex

OGRErr OGRShapeLayer::CreateSpatialIndex( int nMaxDepth ){/* -------------------------------------------------------------------- *//*      If we have an existing spatial index, blow it away first.       *//* -------------------------------------------------------------------- */    if( CheckForQIX() )        DropSpatialIndex();    bCheckedForQIX = FALSE;/* -------------------------------------------------------------------- *//*      Build a quadtree structure for this file.                       *//* -------------------------------------------------------------------- */    SHPTree	*psTree;    SyncToDisk();    psTree = SHPCreateTree( hSHP, 2, nMaxDepth, NULL, NULL );    if( NULL == psTree )    {        // TODO - mloskot: Is it better to return OGRERR_NOT_ENOUGH_MEMORY?        CPLDebug( "SHAPE",                  "Index creation failure. Likely, memory allocation error." );        return OGRERR_FAILURE;    }/* -------------------------------------------------------------------- *//*      Trim unused nodes from the tree.                                *//* -------------------------------------------------------------------- */    SHPTreeTrimExtraNodes( psTree );/* -------------------------------------------------------------------- *//*      Dump tree to .qix file.                                         *//* -------------------------------------------------------------------- */    char *pszQIXFilename;    pszQIXFilename = CPLStrdup(CPLResetExtension( pszFullName, "qix" ));    CPLDebug( "SHAPE", "Creating index file %s", pszQIXFilename );    SHPWriteTree( psTree, pszQIXFilename );    CPLFree( pszQIXFilename );/* -------------------------------------------------------------------- *//*      cleanup                                                         *//* -------------------------------------------------------------------- */    SHPDestroyTree( psTree );    CheckForQIX();    return OGRERR_NONE;}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:56,


示例11: CPLFormFilename

void OGROpenFileGDBDataSource::AddLayer( const CPLString& osName,                                         int nInterestTable,                                         int& nCandidateLayers,                                         int& nLayersSDC,                                         const CPLString& osDefinition,                                         const CPLString& osDocumentation,                                         const char* pszGeomName,                                         OGRwkbGeometryType eGeomType ){    std::map<std::string, int>::const_iterator oIter =                                    m_osMapNameToIdx.find(osName);    int idx = 0;    if( oIter != m_osMapNameToIdx.end() )        idx = oIter->second;    if( idx > 0 && (nInterestTable < 0 || nInterestTable == idx) )    {        const char* pszFilename = CPLFormFilename(            m_osDirName, CPLSPrintf("a%08x", idx), "gdbtable");        if( FileExists(pszFilename) )        {            nCandidateLayers ++;            if( m_papszFiles != NULL )            {                const char* pszSDC = CPLResetExtension(pszFilename, "gdbtable.sdc");                if( FileExists(pszSDC) )                {                    nLayersSDC ++;                    CPLError(CE_Warning, CPLE_AppDefined,                            "%s layer has a %s file whose format is unhandled",                            osName.c_str(), pszSDC);                    return;                }            }            m_apoLayers.push_back(                new OGROpenFileGDBLayer(pszFilename,                                        osName,                                        osDefinition,                                        osDocumentation,                                        pszGeomName, eGeomType));        }    }}
开发者ID:garnertb,项目名称:gdal,代码行数:44,


示例12: CPLFree

CPLErr SAGADataset::SetProjection( const char *pszSRS ){/* -------------------------------------------------------------------- *//*      Reset coordinate system on the dataset.                         *//* -------------------------------------------------------------------- */    CPLFree( pszProjection );    pszProjection = CPLStrdup( pszSRS );    if( strlen(pszSRS) == 0 )        return CE_None;/* -------------------------------------------------------------------- *//*      Convert to ESRI WKT.                                            *//* -------------------------------------------------------------------- */    OGRSpatialReference oSRS( pszSRS );    char *pszESRI_SRS = NULL;    oSRS.morphToESRI();    oSRS.exportToWkt( &pszESRI_SRS );/* -------------------------------------------------------------------- *//*      Write to .prj file.                                             *//* -------------------------------------------------------------------- */    CPLString osPrjFilename = CPLResetExtension( GetDescription(), "prj" );    VSILFILE *fp;    fp = VSIFOpenL( osPrjFilename.c_str(), "wt" );    if( fp != NULL )    {        VSIFWriteL( pszESRI_SRS, 1, strlen(pszESRI_SRS), fp );        VSIFWriteL( (void *) "/n", 1, 1, fp );        VSIFCloseL( fp );    }    CPLFree( pszESRI_SRS );    return CE_None;}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:39,


示例13: STARTS_WITH_CI

GDALDataset *PAuxDataset::Open( GDALOpenInfo * poOpenInfo ){    if( poOpenInfo->nHeaderBytes < 1 )        return NULL;/* -------------------------------------------------------------------- *//*      If this is an .aux file, fetch out and form the name of the     *//*      file it references.                                             *//* -------------------------------------------------------------------- */    CPLString osTarget = poOpenInfo->pszFilename;    if( EQUAL(CPLGetExtension( poOpenInfo->pszFilename ),"aux")        && STARTS_WITH_CI((const char *) poOpenInfo->pabyHeader, "AuxilaryTarget: "))    {        char szAuxTarget[1024];        const char *pszSrc = reinterpret_cast<const char *>(            poOpenInfo->pabyHeader+16 );        int i = 0;        for( ;             pszSrc[i] != 10 && pszSrc[i] != 13 && pszSrc[i] != '/0'                 && i < static_cast<int>( sizeof(szAuxTarget) ) - 1;             i++ )        {            szAuxTarget[i] = pszSrc[i];        }        szAuxTarget[i] = '/0';        char *pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));        osTarget = CPLFormFilename(pszPath, szAuxTarget, NULL);        CPLFree(pszPath);    }/* -------------------------------------------------------------------- *//*      Now we need to tear apart the filename to form a .aux           *//*      filename.                                                       *//* -------------------------------------------------------------------- */    CPLString osAuxFilename = CPLResetExtension(osTarget,"aux");/* -------------------------------------------------------------------- *//*      Do we have a .aux file?                                         *//* -------------------------------------------------------------------- */    char** papszSiblingFiles = poOpenInfo->GetSiblingFiles();    if( papszSiblingFiles != NULL        && CSLFindString( papszSiblingFiles,                          CPLGetFilename(osAuxFilename) ) == -1 )    {        return NULL;    }    VSILFILE *fp = VSIFOpenL( osAuxFilename, "r" );    if( fp == NULL )    {        osAuxFilename = CPLResetExtension(osTarget,"AUX");        fp = VSIFOpenL( osAuxFilename, "r" );    }    if( fp == NULL )        return NULL;/* -------------------------------------------------------------------- *//*      Is this file a PCI .aux file?  Check the first line for the     *//*      telltale AuxilaryTarget keyword.                                *//*                                                                      *//*      At this point we should be verifying that it refers to our      *//*      binary file, but that is a pretty involved test.                *//* -------------------------------------------------------------------- */    const char *pszLine = CPLReadLineL( fp );    CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));    if( pszLine == NULL        || (!STARTS_WITH_CI(pszLine, "AuxilaryTarget")            && !STARTS_WITH_CI(pszLine, "AuxiliaryTarget")) )    {        return NULL;    }/* -------------------------------------------------------------------- *//*      Create a corresponding GDALDataset.                             *//* -------------------------------------------------------------------- */    PAuxDataset *poDS = new PAuxDataset();/* -------------------------------------------------------------------- *//*      Load the .aux file into a string list suitable to be            *//*      searched with CSLFetchNameValue().                              *//* -------------------------------------------------------------------- */    poDS->papszAuxLines = CSLLoad( osAuxFilename );    poDS->pszAuxFilename = CPLStrdup(osAuxFilename);/* -------------------------------------------------------------------- *//*      Find the RawDefinition line to establish overall parameters.    *//* -------------------------------------------------------------------- */    pszLine = CSLFetchNameValue(poDS->papszAuxLines, "RawDefinition");    // It seems PCI now writes out .aux files without RawDefinition in    // some cases.  See bug 947.    if( pszLine == NULL )//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,


示例14: CSLCount

bool wxGxPrjFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds){    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )    {        CPLString szExt = CPLGetExtension(pFileNames[i]);        wxGxObject* pGxObj = NULL;         if(wxGISEQUAL(szExt, "prj"))        {            bool bAdd = true;            for(int j = 0; prj_notadd_exts[j] != NULL; ++j )            {                if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))                {                    bAdd = false;                    break;                }            }            if(bAdd)            {                pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumESRIPrjFile, bCheckNames);            }            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );        }        else if(wxGISEQUAL(szExt, "qpj"))        {            bool bAdd = true;            for(int j = 0; prj_notadd_exts[j] != NULL; ++j )            {                if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))                {                    bAdd = false;                    break;                }            }            if(bAdd)            {                pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumQPJfile, bCheckNames);            }            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );        }        else if(wxGISEQUAL(szExt, "spr"))        {            pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumSPRfile, bCheckNames);            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );        }        if(pGxObj)        {            pChildrenIds.Add(pGxObj->GetId());            pGxObj = NULL;        }    }	return true;}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:62,


示例15: CPLError

//.........这里部分代码省略.........                  pszCRLFFormat );#ifdef WIN32        bUseCRLF = true;#endif    }    poCSVLayer->SetCRLF( bUseCRLF );/* -------------------------------------------------------------------- *//*      Should we write the geometry ?                                  *//* -------------------------------------------------------------------- */    const char *pszGeometry = CSLFetchNameValue( papszOptions, "GEOMETRY");    if( bEnableGeometryFields )    {        poCSVLayer->SetWriteGeometry(eGType, OGR_CSV_GEOM_AS_WKT,            CSLFetchNameValueDef(papszOptions, "GEOMETRY_NAME", "WKT"));    }    else if (pszGeometry != NULL)    {        if (EQUAL(pszGeometry, "AS_WKT"))        {            poCSVLayer->SetWriteGeometry(eGType, OGR_CSV_GEOM_AS_WKT,                CSLFetchNameValueDef(papszOptions, "GEOMETRY_NAME", "WKT"));        }        else if (EQUAL(pszGeometry, "AS_XYZ") ||                 EQUAL(pszGeometry, "AS_XY") ||                 EQUAL(pszGeometry, "AS_YX"))        {            if (eGType == wkbUnknown || wkbFlatten(eGType) == wkbPoint)            {                poCSVLayer->SetWriteGeometry(                    eGType,                    EQUAL(pszGeometry, "AS_XYZ") ? OGR_CSV_GEOM_AS_XYZ :                    EQUAL(pszGeometry, "AS_XY") ?  OGR_CSV_GEOM_AS_XY :                    OGR_CSV_GEOM_AS_YX);            }            else            {                CPLError( CE_Warning, CPLE_AppDefined,                          "Geometry type %s is not compatible with "                          "GEOMETRY=AS_XYZ.",                          OGRGeometryTypeToName(eGType) );            }        }        else        {            CPLError( CE_Warning, CPLE_AppDefined,                      "Unsupported value %s for creation option GEOMETRY",                       pszGeometry );        }    }/* -------------------------------------------------------------------- *//*      Should we create a CSVT file ?                                  *//* -------------------------------------------------------------------- */    const char *pszCreateCSVT = CSLFetchNameValue( papszOptions, "CREATE_CSVT");    if (pszCreateCSVT && CPLTestBool(pszCreateCSVT))    {        poCSVLayer->SetCreateCSVT(true);/* -------------------------------------------------------------------- *//*      Create .prj file                                                *//* -------------------------------------------------------------------- */        if( poSpatialRef != NULL && osFilename != "/vsistdout/" )        {            char* pszWKT = NULL;            poSpatialRef->exportToWkt(&pszWKT);            if( pszWKT )            {                VSILFILE* fpPRJ                    = VSIFOpenL(CPLResetExtension(osFilename, "prj"), "wb");                if( fpPRJ )                {                    CPL_IGNORE_RET_VAL(VSIFPrintfL(fpPRJ, "%s/n", pszWKT));                    VSIFCloseL(fpPRJ);                }                CPLFree(pszWKT);            }        }    }/* -------------------------------------------------------------------- *//*      Should we write a UTF8 BOM ?                                    *//* -------------------------------------------------------------------- */    const char *pszWriteBOM = CSLFetchNameValue( papszOptions, "WRITE_BOM");    if( pszWriteBOM )        poCSVLayer->SetWriteBOM(CPLTestBool(pszWriteBOM));    nLayers++;    papoLayers = static_cast<OGRLayer **>(        CPLRealloc( papoLayers, sizeof(void*) * nLayers ) );    OGRLayer* poLayer = poCSVLayer;    if( osFilename != "/vsistdout/" )        poLayer = new OGRCSVEditableLayer(poCSVLayer, NULL);    papoLayers[nLayers-1] = poLayer;    return poLayer;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,


示例16: main

//.........这里部分代码省略.........    // create warper    char **papszTO = NULL;    papszTO = CSLSetNameValue( papszTO, "METHOD", "GCP_TPS" );    papszTO = CSLSetNameValue( papszTO, "NUM_THREADS", "4" );    papszTO = CSLSetNameValue( papszTO, "DST_SRS", pszSpaRefDef );    papszTO = CSLSetNameValue( papszTO, "SRC_SRS", pszSpaRefDef );    papszTO = CSLSetNameValue( papszTO, "INSERT_CENTER_LONG", "FALSE" );    GDALDriver *poOutputDriver = (GDALDriver *) GDALGetDriverByName( "GTiff" );    CPLSetConfigOption( "CHECK_WITH_INVERT_PROJ", "TRUE" );    void* hTransformArg = GDALCreateGenImgProjTransformer2( poSrcDataset, NULL, papszTO );    GDALTransformerInfo* psInfo = (GDALTransformerInfo*)hTransformArg;    double adfThisGeoTransform[6];    double adfExtent[4];    int nThisPixels, nThisLines;    // suggest the raster output size    if( GDALSuggestedWarpOutput2( poSrcDataset, psInfo->pfnTransform, hTransformArg, adfThisGeoTransform, &nThisPixels, &nThisLines, adfExtent, 0 ) != CE_None )    {        Usage( "Suggest Output failed" );        return EXIT_FAILURE;    }    adfThisGeoTransform[0] = DstEnv.MinX;    adfThisGeoTransform[3] = DstEnv.MaxY;    int nPixels = (int) ((DstEnv.MaxX - DstEnv.MinX) / adfThisGeoTransform[1] + 0.5);    int nLines = (int) ((DstEnv.MaxY - DstEnv.MinY) / -adfThisGeoTransform[5] + 0.5);    GDALSetGenImgProjTransformerDstGeoTransform( hTransformArg, adfThisGeoTransform);    // create new raster    CPLString sOutputRasterPath = CPLResetExtension(sFileName, "tif");    GDALDataset  *poDstDataset = poOutputDriver->Create(sOutputRasterPath, nPixels, nLines, poSrcDataset->GetRasterCount(), GDT_Byte, NULL );    if( NULL == poDstDataset )    {        Usage( "Create Output failed" );        return EXIT_FAILURE;    }    poDstDataset->SetProjection( pszSpaRefDef );    poDstDataset->SetGeoTransform( adfThisGeoTransform );#ifdef APRROX_MAXERROR    hTransformArg = GDALCreateApproxTransformer( GDALGenImgProjTransform,  hTransformArg, APRROX_MAXERROR);    GDALTransformerFunc pfnTransformer = GDALApproxTransform;    GDALApproxTransformerOwnsSubtransformer(hTransformArg, TRUE);#else    GDALTransformerFunc pfnTransformer = GDALGenImgProjTransform;#endif // APRROX_MAXERROR    // warp    GDALWarpOptions *psWO = GDALCreateWarpOptions();    psWO->eWorkingDataType = GDT_Byte;    psWO->eResampleAlg = GRA_NearestNeighbour;    psWO->hSrcDS = poSrcDataset;    psWO->hDstDS = poDstDataset;    psWO->pfnTransformer = pfnTransformer;    psWO->pTransformerArg = hTransformArg;    psWO->pfnProgress = GDALTermProgress;    psWO->nBandCount = poSrcDataset->GetRasterCount();
开发者ID:BishopGIS,项目名称:gisconf2015,代码行数:66,


示例17: PrepareGCP

//.........这里部分代码省略.........    double dfDist1 = pt1->Distance(pt2);    double dfDist2 = pt2->Distance(pt3);    double dfDist3 = pt3->Distance(pt4);    double dfDist4 = pt4->Distance(pt1);    double dfHalfWidth = (dfDist2 + dfDist4) / 4;    double dfHalfHeight = (dfDist1 + dfDist3) / 4;    double dfAltitudeAtSide = (dfHalfWidth * dfFocusM) / dfFilmHalfHeightM;    double dfAltitudeAtSceneCenter = sqrt( dfAltitudeAtSide * dfAltitudeAtSide - dfHalfHeight * dfHalfHeight);    double dfAltitude = dfAltitudeAtSceneCenter * cos(dfMountAngleRad); // 145 - 220 km    double dfDistCenter = dfAltitudeAtSceneCenter * sin(dfMountAngleRad);    OGRLineString lnCenterLeft;    lnCenterLeft.addPoint(&ptShortSideBeg);    lnCenterLeft.addPoint(ptCenter);    OGRPoint ptSatCenter = GetTangetPoint(lnCenterLeft, dfDistCenter);    std::vector<OGRPoint> aPt1, aPt2;    int nTotalGCPCount = ((SEGMENT_STEPS + 1) * 2);    GDAL_GCP *paGSPs = (GDAL_GCP *) CPLMalloc (nTotalGCPCount * sizeof(GDAL_GCP));    GDALInitGCPs(nTotalGCPCount, paGSPs);    double dfImageStepLen = double(nRasterSizeX) / SEGMENT_STEPS;    double dfImageCenterX = 0;    OGRLineString lnCenter;    lnCenter.addPoint(&ptShortSideBeg);    lnCenter.addPoint(ptCenter);    lnCenter.addPoint(&ptShortSideEnd);    double dfCenterLineLen = lnCenter.get_Length();    double dfStepLen = dfCenterLineLen / SEGMENT_STEPS;    double dfCenterLineHalfLen = dfCenterLineLen / 2;    for(double i = 0; i <= dfCenterLineLen; i += dfStepLen)    {        OGRPoint ptTmp;        lnCenter.Value(i, &ptTmp);        double dfDist = fabs(dfCenterLineHalfLen - i);        double dfWidthTmp = GetWidthForHeight(dfAltitudeAtSceneCenter, dfDist, dfRatio);        OGRLineString lnTmpLine;        lnTmpLine.addPoint(ptCenter);        lnTmpLine.addPoint(&ptTmp);        int direction = 1;        if(dfCenterLineHalfLen < i)            direction = -1;        OGRPoint ptUp = GetTangetPoint(lnTmpLine, dfWidthTmp * direction);        OGRPoint ptDown = GetTangetPoint(lnTmpLine, -dfWidthTmp * direction);        //OGRPoint ptUp = GetValue(dfWidthTmp, lnTmpLine);        //OGRPoint ptDown = GetValue(-dfWidthTmp, lnTmpLine);        aPt1.push_back(ptUp);        aPt2.push_back(ptDown);        paGSPs[nGCPCount].dfGCPLine = 0;        paGSPs[nGCPCount].dfGCPPixel = dfImageCenterX;        paGSPs[nGCPCount].dfGCPX = ptDown.getX();        paGSPs[nGCPCount].dfGCPY = ptDown.getY();        paGSPs[nGCPCount].dfGCPZ = dfMeanHeight;        paGSPs[nGCPCount].pszId = CPLStrdup(CPLSPrintf("pt%d", nGCPCount));        nGCPCount++;        paGSPs[nGCPCount].dfGCPLine = nRasterSizeY;        paGSPs[nGCPCount].dfGCPPixel = dfImageCenterX;        paGSPs[nGCPCount].dfGCPX = ptUp.getX();        paGSPs[nGCPCount].dfGCPY = ptUp.getY();        paGSPs[nGCPCount].dfGCPZ = dfMeanHeight;        paGSPs[nGCPCount].pszId = CPLStrdup(CPLSPrintf("pt%d", nGCPCount));        nGCPCount++;        dfImageCenterX += dfImageStepLen;    }    // add points to polygon    OGRLinearRing Ring;    for(int i = 0; i < aPt1.size(); ++i)        Ring.addPoint(aPt1[i].getX(), aPt1[i].getY());    for(int i = aPt2.size() - 1; i >= 0; --i)        Ring.addPoint(aPt2[i].getX(), aPt2[i].getY());    Ring.closeRings();    OGRPolygon Rgn;    Rgn.addRingDirectly((OGRCurve*)Ring.clone());    Rgn.assignSpatialReference(oDstOGRSpatialReference.Clone());    Rgn.flattenTo2D();    Rgn.getEnvelope(&DstEnv);    SaveGeometry(CPLResetExtension(sFileName, "shp"), Rgn, oDstOGRSpatialReference);    return paGSPs;}
开发者ID:BishopGIS,项目名称:gisconf2015,代码行数:101,


示例18: CPLGetExtension

void BSBDataset::ScanForGCPsNos( const char *pszFilename ){    char **Tokens;    const char *geofile;    const char *extension;    int fileGCPCount=0;    extension = CPLGetExtension(pszFilename);    // pseudointelligently try and guess whether we want a .geo or a .GEO    if (extension[1] == 'O')    {        geofile = CPLResetExtension( pszFilename, "GEO");    } else {        geofile = CPLResetExtension( pszFilename, "geo");    }    FILE *gfp = VSIFOpen( geofile, "r" );  // Text files    if( gfp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Couldn't find a matching .GEO file: %s", geofile );        return;    }    char *thisLine = (char *) CPLMalloc( 80 ); // FIXME    // Count the GCPs (reference points) and seek the file pointer 'gfp' to the starting point    while (fgets(thisLine, 80, gfp))    {        if( EQUALN(thisLine, "Point", 5) )            fileGCPCount++;    }    VSIRewind( gfp );    // Memory has not been allocated to fileGCPCount yet    pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),fileGCPCount+1);    while (fgets(thisLine, 80, gfp))    {        if( EQUALN(thisLine, "Point", 5) )        {            // got a point line, turn it into a gcp            Tokens = CSLTokenizeStringComplex(thisLine, "= ", FALSE, FALSE);            if (CSLCount(Tokens) >= 5)            {                GDALInitGCPs( 1, pasGCPList + nGCPCount );                pasGCPList[nGCPCount].dfGCPX = atof(Tokens[1]);                pasGCPList[nGCPCount].dfGCPY = atof(Tokens[2]);                pasGCPList[nGCPCount].dfGCPPixel = atof(Tokens[4]);                pasGCPList[nGCPCount].dfGCPLine = atof(Tokens[3]);                CPLFree( pasGCPList[nGCPCount].pszId );                char	szName[50];                sprintf( szName, "GCP_%d", nGCPCount+1 );                pasGCPList[nGCPCount].pszId = CPLStrdup( szName );                nGCPCount++;            }            CSLDestroy(Tokens);        }    }    CPLFree(thisLine);    VSIFClose(gfp);}
开发者ID:samalone,项目名称:gdal-ios,代码行数:66,


示例19: CPLFree

CPLErr BTDataset::SetProjection( const char *pszNewProjection ){    CPLErr eErr = CE_None;    CPLFree( pszProjection );    pszProjection = CPLStrdup( pszNewProjection );    bHeaderModified = TRUE;/* -------------------------------------------------------------------- *//*      Parse projection.                                               *//* -------------------------------------------------------------------- */    OGRSpatialReference oSRS( pszProjection );    GInt16  nShortTemp = 0;/* -------------------------------------------------------------------- *//*      Linear units.                                                   *//* -------------------------------------------------------------------- */    if( oSRS.IsGeographic() )    {        // nShortTemp = 0;    }    else    {        const double dfLinear = oSRS.GetLinearUnits();        if( std::abs(dfLinear - 0.3048) < 0.0000001 )            nShortTemp = 2;        else if( std::abs(dfLinear - CPLAtof(SRS_UL_US_FOOT_CONV))                 < 0.00000001 )            nShortTemp = 3;        else            nShortTemp = 1;    }    nShortTemp = CPL_LSBWORD16( 1 );    memcpy( abyHeader + 22, &nShortTemp, 2 );/* -------------------------------------------------------------------- *//*      UTM Zone                                                        *//* -------------------------------------------------------------------- */    int bNorth = FALSE;    nShortTemp = (GInt16) oSRS.GetUTMZone( &bNorth );    if( bNorth )        nShortTemp = -nShortTemp;    nShortTemp = CPL_LSBWORD16( nShortTemp );    memcpy( abyHeader + 24, &nShortTemp, 2 );/* -------------------------------------------------------------------- *//*      Datum                                                           *//* -------------------------------------------------------------------- */    if( oSRS.GetAuthorityName( "GEOGCS|DATUM" ) != NULL        && EQUAL(oSRS.GetAuthorityName( "GEOGCS|DATUM" ),"EPSG") )        nShortTemp = static_cast<GInt16>(            atoi(oSRS.GetAuthorityCode( "GEOGCS|DATUM" )) + 2000);    else        nShortTemp = -2;    nShortTemp = CPL_LSBWORD16( nShortTemp ); /* datum unknown */    memcpy( abyHeader + 26, &nShortTemp, 2 );/* -------------------------------------------------------------------- *//*      Write out the projection to a .prj file.                        *//* -------------------------------------------------------------------- */    const char  *pszPrjFile = CPLResetExtension( GetDescription(), "prj" );    VSILFILE * fp = VSIFOpenL( pszPrjFile, "wt" );    if( fp != NULL )    {        CPL_IGNORE_RET_VAL(VSIFPrintfL( fp, "%s/n", pszProjection ));        CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));        abyHeader[60] = 1;    }    else    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Unable to write out .prj file." );        eErr = CE_Failure;    }    return eErr;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:83,


示例20: GDALWriteIMDFile

CPLErr GDALWriteIMDFile( const char *pszFilename, char **papszMD ){    CPLString osRPBFilename = CPLResetExtension( pszFilename, "IMD" );/* -------------------------------------------------------------------- *//*      Read file and parse.                                            *//* -------------------------------------------------------------------- */    VSILFILE *fp = VSIFOpenL( osRPBFilename, "w" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Unable to create %s for writing./n%s",                  osRPBFilename.c_str(), CPLGetLastErrorMsg() );        return CE_Failure;    }/* ==================================================================== *//* -------------------------------------------------------------------- *//*      Loop through all values writing.                                *//* -------------------------------------------------------------------- *//* ==================================================================== */    int iKey;    CPLString osCurSection;    for( iKey = 0; papszMD[iKey] != NULL; iKey++ )    {        char *pszRawKey = NULL;        const char *pszValue = CPLParseNameValue( papszMD[iKey], &pszRawKey );        CPLString osKeySection, osKeyItem;        char *pszDot = strchr(pszRawKey,'.');/* -------------------------------------------------------------------- *//*      Split stuff like BAND_P.ULLon into section and item.            *//* -------------------------------------------------------------------- */        if( pszDot == NULL )        {            osKeyItem = pszRawKey;        }        else        {            osKeyItem = pszDot+1;            *pszDot = '/0';            osKeySection = pszRawKey;        }        CPLFree( pszRawKey );/* -------------------------------------------------------------------- *//*      Close and/or start sections as needed.                          *//* -------------------------------------------------------------------- */        if( osCurSection.size() && !EQUAL(osCurSection,osKeySection) )            VSIFPrintfL( fp, "END_GROUP = %s/n", osCurSection.c_str() );        if( osKeySection.size() && !EQUAL(osCurSection,osKeySection) )            VSIFPrintfL( fp, "BEGIN_GROUP = %s/n", osKeySection.c_str() );        osCurSection = osKeySection;/* -------------------------------------------------------------------- *//*      Print out simple item.                                          *//* -------------------------------------------------------------------- */        if( osCurSection.size() )            VSIFPrintfL( fp, "/t%s = ", osKeyItem.c_str() );        else            VSIFPrintfL( fp, "%s = ", osKeyItem.c_str() );        if( pszValue[0] != '(' )            VSIFPrintfL( fp, "%s;/n", pszValue );        else            GDALWriteIMDMultiLine( fp, pszValue );    }/* -------------------------------------------------------------------- *//*      Close off.                                                      *//* -------------------------------------------------------------------- */    if( osCurSection.size() )        VSIFPrintfL( fp, "END_GROUP = %s/n", osCurSection.c_str() );    VSIFPrintfL( fp, "END;/n" );    VSIFCloseL( fp );    return CE_None;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:85,


示例21: VFKReader

/*!  /brief VFKReaderSQLite constructor*/VFKReaderSQLite::VFKReaderSQLite(const char *pszFilename) : VFKReader(pszFilename){    const char *pszDbNameConf;    CPLString   osDbName;    CPLString   osCommand;    VSIStatBufL sStatBufDb, sStatBufVfk;    /* open tmp SQLite DB (re-use DB file if already exists) */    pszDbNameConf = CPLGetConfigOption("OGR_VFK_DB_NAME", NULL);    if (pszDbNameConf) {	osDbName = pszDbNameConf;    }    else {	osDbName = CPLResetExtension(m_pszFilename, "db");    }    size_t nLen = osDbName.length();    if( nLen > 2048 )    {        nLen = 2048;        osDbName.resize(nLen);    }    m_pszDBname = new char [nLen+1];    std::strncpy(m_pszDBname, osDbName.c_str(), nLen);    m_pszDBname[nLen] = 0;    CPLDebug("OGR-VFK", "Using internal DB: %s",             m_pszDBname);    if (CPLTestBool(CPLGetConfigOption("OGR_VFK_DB_SPATIAL", "YES")))	m_bSpatial = TRUE;    /* build geometry from DB */    else	m_bSpatial = FALSE;   /* store also geometry in DB */    m_bNewDb = TRUE;    if (VSIStatL(osDbName, &sStatBufDb) == 0) {	if (CPLTestBool(CPLGetConfigOption("OGR_VFK_DB_OVERWRITE", "NO"))) {	    m_bNewDb = TRUE;     /* overwrite existing DB */            CPLDebug("OGR-VFK", "Internal DB (%s) already exists and will be overwritten",                     m_pszDBname);	    VSIUnlink(osDbName);        }        else {            if (VSIStatL(pszFilename, &sStatBufVfk) == 0 &&                sStatBufVfk.st_mtime > sStatBufDb.st_mtime) {                CPLDebug("OGR-VFK",                         "Found %s but ignoring because it appears/n"                         "be older than the associated VFK file.",                         osDbName.c_str());                m_bNewDb = TRUE;                VSIUnlink(osDbName);            }            else {                m_bNewDb = FALSE;    /* re-use existing DB */            }        }    }    /*    if (m_bNewDb) {      CPLError(CE_Warning, CPLE_AppDefined,               "INFO: No internal SQLite DB found. Reading VFK data may take some time...");    }    */    CPLDebug("OGR-VFK", "New DB: %s Spatial: %s",	     m_bNewDb ? "yes" : "no", m_bSpatial ? "yes" : "no");    if (SQLITE_OK != sqlite3_open(osDbName, &m_poDB)) {        CPLError(CE_Failure, CPLE_AppDefined,                 "Creating SQLite DB failed");    }    else {        char* pszErrMsg = NULL;        CPL_IGNORE_RET_VAL(sqlite3_exec(m_poDB, "PRAGMA synchronous = OFF", NULL, NULL, &pszErrMsg));        sqlite3_free(pszErrMsg);    }    if (m_bNewDb) {        /* new DB, create support metadata tables */        osCommand.Printf("CREATE TABLE %s (file_name text, table_name text, num_records integer, "                         "num_features integer, num_geometries integer, table_defn text)",                         VFK_DB_TABLE);        ExecuteSQL(osCommand.c_str());        /* header table */        osCommand.Printf("CREATE TABLE %s (key text, value text)", VFK_DB_HEADER);        ExecuteSQL(osCommand.c_str());    }}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:91,


示例22: CPLAssert

OGRErr OGRCSVEditableLayerSynchronizer::EditableSyncToDisk(OGRLayer* poEditableLayer,                                                           OGRLayer** ppoDecoratedLayer){    CPLAssert( m_poCSVLayer == *ppoDecoratedLayer );    CPLString osLayerName(m_poCSVLayer->GetName());    CPLString osFilename(m_poCSVLayer->GetFilename());    const bool bCreateCSVT = m_poCSVLayer->GetCreateCSVT();    CPLString osCSVTFilename(CPLResetExtension(osFilename, "csvt"));    VSIStatBufL sStatBuf;    const bool bHasCSVT = VSIStatL(osCSVTFilename, &sStatBuf) == 0;    CPLString osTmpFilename(osFilename);    CPLString osTmpCSVTFilename(osFilename);    if( VSIStatL(osFilename, &sStatBuf) == 0 )    {        osTmpFilename += "_ogr_tmp.csv";        osTmpCSVTFilename += "_ogr_tmp.csvt";    }    const char chDelimiter = m_poCSVLayer->GetDelimiter();    OGRCSVLayer* poCSVTmpLayer = new OGRCSVLayer( osLayerName, NULL,                                                  osTmpFilename,                                                  true, true, chDelimiter );    poCSVTmpLayer->BuildFeatureDefn(NULL, NULL, m_papszOpenOptions);    poCSVTmpLayer->SetCRLF( m_poCSVLayer->GetCRLF() );    poCSVTmpLayer->SetCreateCSVT( bCreateCSVT || bHasCSVT );    poCSVTmpLayer->SetWriteBOM( m_poCSVLayer->GetWriteBOM() );    if( m_poCSVLayer->GetGeometryFormat() == OGR_CSV_GEOM_AS_WKT )        poCSVTmpLayer->SetWriteGeometry( wkbNone, OGR_CSV_GEOM_AS_WKT, NULL );    OGRErr eErr = OGRERR_NONE;    OGRFeatureDefn* poEditableFDefn =  poEditableLayer->GetLayerDefn();    for( int i=0; eErr == OGRERR_NONE &&                  i < poEditableFDefn->GetFieldCount(); i++ )    {        OGRFieldDefn oFieldDefn(poEditableFDefn->GetFieldDefn(i));        int iGeomFieldIdx = 0;        if( (EQUAL(oFieldDefn.GetNameRef(), "WKT") &&             (iGeomFieldIdx = poEditableFDefn->GetGeomFieldIndex("")) >= 0) ||            (iGeomFieldIdx = poEditableFDefn->GetGeomFieldIndex(oFieldDefn.GetNameRef())) >= 0 )        {            OGRGeomFieldDefn oGeomFieldDefn(                poEditableFDefn->GetGeomFieldDefn(iGeomFieldIdx) );            eErr = poCSVTmpLayer->CreateGeomField( &oGeomFieldDefn );        }        else        {            eErr = poCSVTmpLayer->CreateField( &oFieldDefn );        }    }    const bool bHasXY = ( !m_poCSVLayer->GetXField().empty() &&                          !m_poCSVLayer->GetYField().empty() );    const bool bHasZ = ( !m_poCSVLayer->GetZField().empty() );    if( bHasXY && !CPLFetchBool(m_papszOpenOptions, "KEEP_GEOM_COLUMNS", true) )    {        if( poCSVTmpLayer->GetLayerDefn()->GetFieldIndex(m_poCSVLayer->GetXField()) < 0 )        {            OGRFieldDefn oFieldDefn(m_poCSVLayer->GetXField(), OFTReal);            if( eErr == OGRERR_NONE )                eErr = poCSVTmpLayer->CreateField( &oFieldDefn );        }        if( poCSVTmpLayer->GetLayerDefn()->GetFieldIndex(m_poCSVLayer->GetYField()) < 0 )        {            OGRFieldDefn oFieldDefn(m_poCSVLayer->GetYField(), OFTReal);            if( eErr == OGRERR_NONE )                eErr = poCSVTmpLayer->CreateField( &oFieldDefn );        }        if( bHasZ && poCSVTmpLayer->GetLayerDefn()->GetFieldIndex(m_poCSVLayer->GetZField()) < 0 )        {            OGRFieldDefn oFieldDefn(m_poCSVLayer->GetZField(), OFTReal);            if( eErr == OGRERR_NONE )                eErr = poCSVTmpLayer->CreateField( &oFieldDefn );        }    }    int nFirstGeomColIdx = 0;    if( m_poCSVLayer->HasHiddenWKTColumn() )    {        poCSVTmpLayer->SetWriteGeometry(            poEditableFDefn->GetGeomFieldDefn(0)->GetType(),            OGR_CSV_GEOM_AS_WKT,            poEditableFDefn->GetGeomFieldDefn(0)->GetNameRef());        nFirstGeomColIdx = 1;    }    if( !(poEditableFDefn->GetGeomFieldCount() == 1 && bHasXY) )    {        for( int i=nFirstGeomColIdx; eErr == OGRERR_NONE &&                i < poEditableFDefn->GetGeomFieldCount(); i++ )        {            OGRGeomFieldDefn oGeomFieldDefn( poEditableFDefn->GetGeomFieldDefn(i) );            if( poCSVTmpLayer->GetLayerDefn()->GetGeomFieldIndex(oGeomFieldDefn.GetNameRef()) >= 0 )                continue;            eErr = poCSVTmpLayer->CreateGeomField( &oGeomFieldDefn );        }    }    OGRFeature* poFeature = NULL;    poEditableLayer->ResetReading();//.........这里部分代码省略.........
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,


示例23: CPLResetExtension

int OGRIdrisiLayer::Detect_AVL_ADC(const char* pszFilename){// --------------------------------------------------------------------//      Look for .adc file// --------------------------------------------------------------------    const char* pszADCFilename = CPLResetExtension(pszFilename, "adc");    VSILFILE* fpADC = VSIFOpenL(pszADCFilename, "rb");    if (fpADC == NULL)    {        pszADCFilename = CPLResetExtension(pszFilename, "ADC");        fpADC = VSIFOpenL(pszADCFilename, "rb");    }    char** papszADC = NULL;    if (fpADC != NULL)    {        VSIFCloseL(fpADC);        fpADC = NULL;        CPLPushErrorHandler(CPLQuietErrorHandler);        papszADC = CSLLoad2(pszADCFilename, 1024, 256, NULL);        CPLPopErrorHandler();        CPLErrorReset();    }    if (papszADC == NULL)        return FALSE;    CSLSetNameValueSeparator( papszADC, ":" );    const char *pszVersion = CSLFetchNameValue( papszADC, "file format " );    if( pszVersion == NULL || !EQUAL( pszVersion, "IDRISI Values A.1" ) )    {        CSLDestroy( papszADC );        return FALSE;    }    const char *pszFileType = CSLFetchNameValue( papszADC, "file type   " );    if( pszFileType == NULL || !EQUAL( pszFileType, "ascii" ) )    {        CPLDebug("IDRISI", ".adc file found, but file type != ascii");        CSLDestroy( papszADC );        return FALSE;    }    const char* pszRecords = CSLFetchNameValue( papszADC, "records     " );    if( pszRecords == NULL || atoi(pszRecords) != (int)nTotalFeatures )    {        CPLDebug("IDRISI", ".adc file found, but 'records' not found or not "                 "consistent with feature number declared in .vdc");        CSLDestroy( papszADC );        return FALSE;    }    const char* pszFields = CSLFetchNameValue( papszADC, "fields      " );    if( pszFields == NULL || atoi(pszFields) <= 1 )    {        CPLDebug("IDRISI", ".adc file found, but 'fields' not found or invalid");        CSLDestroy( papszADC );        return FALSE;    }// --------------------------------------------------------------------//      Look for .avl file// --------------------------------------------------------------------    const char* pszAVLFilename = CPLResetExtension(pszFilename, "avl");    fpAVL = VSIFOpenL(pszAVLFilename, "rb");    if (fpAVL == NULL)    {        pszAVLFilename = CPLResetExtension(pszFilename, "AVL");        fpAVL = VSIFOpenL(pszAVLFilename, "rb");    }    if (fpAVL == NULL)    {        CSLDestroy( papszADC );        return FALSE;    }// --------------------------------------------------------------------//      Build layer definition// --------------------------------------------------------------------    int iCurField;    char szKey[32];    iCurField = 0;    sprintf(szKey, "field %d ", iCurField);    char** papszIter = papszADC;    const char* pszLine;    int bFieldFound = FALSE;    CPLString osFieldName;    while((pszLine = *papszIter) != NULL)    {        //CPLDebug("IDRISI", "%s", pszLine);        if (strncmp(pszLine, szKey, strlen(szKey)) == 0)        {            const char* pszColon = strchr(pszLine, ':');            if (pszColon)            {//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,


示例24: DTEDOpenEx

//.........这里部分代码省略.........    poDS->SetMetadataItem( "DTED_MaintenanceDate", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_MATCHMERGE_DATE );    poDS->SetMetadataItem( "DTED_MatchMergeDate", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_MAINT_DESCRIPTION );    poDS->SetMetadataItem( "DTED_MaintenanceDescription", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_PRODUCER );    poDS->SetMetadataItem( "DTED_Producer", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTDATUM );    poDS->SetMetadataItem( "DTED_VerticalDatum", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_HORIZDATUM );    poDS->SetMetadataItem( "DTED_HorizontalDatum", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_DIGITIZING_SYS );    poDS->SetMetadataItem( "DTED_DigitizingSystem", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_COMPILATION_DATE );    poDS->SetMetadataItem( "DTED_CompilationDate", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_HORIZACCURACY );    poDS->SetMetadataItem( "DTED_HorizontalAccuracy", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_REL_HORIZACCURACY );    poDS->SetMetadataItem( "DTED_RelHorizontalAccuracy", pszValue );    CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_REL_VERTACCURACY );    poDS->SetMetadataItem( "DTED_RelVerticalAccuracy", pszValue );    CPLFree( pszValue );        pszValue = DTEDGetMetadata( psDTED, DTEDMD_ORIGINLAT );    poDS->SetMetadataItem( "DTED_OriginLatitude", pszValue );    CPLFree( pszValue );        pszValue = DTEDGetMetadata( psDTED, DTEDMD_ORIGINLONG );    poDS->SetMetadataItem( "DTED_OriginLongitude", pszValue );    CPLFree( pszValue );        pszValue = DTEDGetMetadata( psDTED, DTEDMD_NIMA_DESIGNATOR );     poDS->SetMetadataItem( "DTED_NimaDesignator", pszValue );     CPLFree( pszValue );    pszValue = DTEDGetMetadata( psDTED, DTEDMD_PARTIALCELL_DSI );    poDS->SetMetadataItem( "DTED_PartialCellIndicator", pszValue );    CPLFree( pszValue );    poDS->SetMetadataItem( GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT );/* -------------------------------------------------------------------- *//*      Initialize any PAM information.                                 *//* -------------------------------------------------------------------- */    poDS->SetDescription( poOpenInfo->pszFilename );    poDS->TryLoadXML( poOpenInfo->GetSiblingFiles() );    // if no SR in xml, try aux    const char* pszPrj = poDS->GDALPamDataset::GetProjectionRef();    if( !pszPrj || strlen(pszPrj) == 0 )    {        int bTryAux = TRUE;        if( poOpenInfo->GetSiblingFiles() != NULL &&            CSLFindString(poOpenInfo->GetSiblingFiles(), CPLResetExtension(CPLGetFilename(poOpenInfo->pszFilename), "aux")) < 0 &&            CSLFindString(poOpenInfo->GetSiblingFiles(), CPLSPrintf("%s.aux", CPLGetFilename(poOpenInfo->pszFilename))) < 0 )            bTryAux = FALSE;        if( bTryAux )        {            GDALDataset* poAuxDS = GDALFindAssociatedAuxFile( poOpenInfo->pszFilename, GA_ReadOnly, poDS );            if( poAuxDS )            {                pszPrj = poAuxDS->GetProjectionRef();                if( pszPrj && strlen(pszPrj) > 0 )                {                    CPLFree( poDS->pszProjection );                    poDS->pszProjection = CPLStrdup(pszPrj);                }                GDALClose( poAuxDS );            }        }    }/* -------------------------------------------------------------------- *//*      Support overviews.                                              *//* -------------------------------------------------------------------- */    poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename,                                 poOpenInfo->GetSiblingFiles() );    return( poDS );}
开发者ID:drownedout,项目名称:datamap,代码行数:101,


示例25: BTDataset

GDALDataset *BTDataset::Open( GDALOpenInfo * poOpenInfo ){/* -------------------------------------------------------------------- *//*      Verify that this is some form of binterr file.                  *//* -------------------------------------------------------------------- */    if( poOpenInfo->nHeaderBytes < 256)        return NULL;    if( !STARTS_WITH((const char *) poOpenInfo->pabyHeader, "binterr") )        return NULL;/* -------------------------------------------------------------------- *//*      Create the dataset.                                             *//* -------------------------------------------------------------------- */    BTDataset *poDS = new BTDataset();    memcpy( poDS->abyHeader, poOpenInfo->pabyHeader, 256 );/* -------------------------------------------------------------------- *//*      Get the version.                                                *//* -------------------------------------------------------------------- */    char szVersion[4] = {};    strncpy( szVersion, (char *) (poDS->abyHeader + 7), 3 );    szVersion[3] = '/0';    poDS->nVersionCode = static_cast<int>(CPLAtof(szVersion) * 10);/* -------------------------------------------------------------------- *//*      Extract core header information, being careful about the        *//*      version.                                                        *//* -------------------------------------------------------------------- */    GInt32 nIntTemp = 0;    memcpy( &nIntTemp, poDS->abyHeader + 10, 4 );    poDS->nRasterXSize = CPL_LSBWORD32( nIntTemp );    memcpy( &nIntTemp, poDS->abyHeader + 14, 4 );    poDS->nRasterYSize = CPL_LSBWORD32( nIntTemp );    if( !GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize) )    {        delete poDS;        return NULL;    }    GInt16 nDataSize = 0;    memcpy( &nDataSize, poDS->abyHeader+18, 2 );    nDataSize = CPL_LSBWORD16( nDataSize );    GDALDataType eType = GDT_Unknown;    if( poDS->abyHeader[20] != 0 && nDataSize == 4 )        eType = GDT_Float32;    else if( poDS->abyHeader[20] == 0 && nDataSize == 4 )        eType = GDT_Int32;    else if( poDS->abyHeader[20] == 0 && nDataSize == 2 )        eType = GDT_Int16;    else    {        CPLError( CE_Failure, CPLE_AppDefined,                  ".bt file data type unknown, got datasize=%d.",                  nDataSize );        delete poDS;        return NULL;    }    /*        rcg, apr 7/06: read offset 62 for vert. units.        If zero, assume 1.0 as per spec.    */    memcpy( &poDS->m_fVscale, poDS->abyHeader + 62, 4 );    CPL_LSBPTR32(&poDS->m_fVscale);    if(poDS->m_fVscale == 0.0f)        poDS->m_fVscale = 1.0f;/* -------------------------------------------------------------------- *//*      Try to read a .prj file if it is indicated.                     *//* -------------------------------------------------------------------- */    OGRSpatialReference oSRS;    if( poDS->nVersionCode >= 12 && poDS->abyHeader[60] != 0 )    {        const char  *pszPrjFile = CPLResetExtension( poOpenInfo->pszFilename,                                                     "prj" );        VSILFILE *fp = VSIFOpenL( pszPrjFile, "rt" );        if( fp != NULL )        {            const int nBufMax = 10000;            char *pszBuffer = static_cast<char *>(CPLMalloc(nBufMax));            const int nBytes =                static_cast<int>(VSIFReadL( pszBuffer, 1, nBufMax-1, fp ));            CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));            pszBuffer[nBytes] = '/0';            char *pszBufPtr = pszBuffer;            if( oSRS.importFromWkt( &pszBufPtr ) != OGRERR_NONE )            {//.........这里部分代码省略.........
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,


示例26: GDALWriteRPBFile

CPLErr GDALWriteRPBFile( const char *pszFilename, char **papszMD ){    CPLString osRPBFilename = CPLResetExtension( pszFilename, "RPB" );/* -------------------------------------------------------------------- *//*      Read file and parse.                                            *//* -------------------------------------------------------------------- */    VSILFILE *fp = VSIFOpenL( osRPBFilename, "w" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Unable to create %s for writing./n%s",                  osRPBFilename.c_str(), CPLGetLastErrorMsg() );        return CE_Failure;    }/* -------------------------------------------------------------------- *//*      Write the prefix information.                                   *//* -------------------------------------------------------------------- */    VSIFPrintfL( fp, "%s", "satId = /"QB02/";/n" );    VSIFPrintfL( fp, "%s", "bandId = /"P/";/n" );    VSIFPrintfL( fp, "%s", "SpecId = /"RPC00B/";/n" );    VSIFPrintfL( fp, "%s", "BEGIN_GROUP = IMAGE/n" );    VSIFPrintfL( fp, "%s", "/terrBias = 0.0;/n" );    VSIFPrintfL( fp, "%s", "/terrRand = 0.0;/n" );/* -------------------------------------------------------------------- *//*      Write RPC values from our RPC metadata.                         *//* -------------------------------------------------------------------- */    int i;    for( i = 0; apszRPBMap[i] != NULL; i += 2 )    {        const char *pszRPBVal = CSLFetchNameValue( papszMD, apszRPBMap[i] );        const char *pszRPBTag;        if( pszRPBVal == NULL )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s field missing in metadata, %s file not written.",                      apszRPBMap[i], osRPBFilename.c_str() );            VSIFCloseL( fp );            VSIUnlink( osRPBFilename );            return CE_Failure;        }        pszRPBTag = apszRPBMap[i+1];        if( EQUALN(pszRPBTag,"IMAGE.",6) )            pszRPBTag += 6;        if( strstr(apszRPBMap[i], "COEF" ) == NULL )        {            VSIFPrintfL( fp, "/t%s = %s;/n", pszRPBTag, pszRPBVal );        }        else        {            // Reformat in brackets with commas over multiple lines.            VSIFPrintfL( fp, "/t%s = (/n", pszRPBTag );            char **papszItems = CSLTokenizeStringComplex( pszRPBVal, " ,",                                                          FALSE, FALSE );            if( CSLCount(papszItems) != 20 )            {                CPLError( CE_Failure, CPLE_AppDefined,                          "%s field is corrupt (not 20 values), %s file not written./n%s = %s",                          apszRPBMap[i], osRPBFilename.c_str(),                          apszRPBMap[i], pszRPBVal );                VSIFCloseL( fp );                VSIUnlink( osRPBFilename );                CSLDestroy( papszItems );                return CE_Failure;            }            int j;            for( j = 0; j < 20; j++ )            {                if( j < 19 )                    VSIFPrintfL( fp, "/t/t/t%s,/n", papszItems[j] );                else                    VSIFPrintfL( fp, "/t/t/t%s);/n", papszItems[j] );            }            CSLDestroy( papszItems );        }    }/* -------------------------------------------------------------------- *//*      Write end part                                                  *//* -------------------------------------------------------------------- */    VSIFPrintfL( fp, "%s", "END_GROUP = IMAGE/n" );    VSIFPrintfL( fp, "END;/n" );    VSIFCloseL( fp );    return CE_None;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:100,


示例27: CPLGetExtension

int OGRShapeDataSource::OpenFile( const char *pszNewName, int bUpdate,                                  int bTestOpen ){    SHPHandle   hSHP;    DBFHandle   hDBF;    const char *pszExtension = CPLGetExtension( pszNewName );    (void) bTestOpen;    if( !EQUAL(pszExtension,"shp") && !EQUAL(pszExtension,"shx")        && !EQUAL(pszExtension,"dbf") )        return FALSE;/* -------------------------------------------------------------------- *//*      SHPOpen() should include better (CPL based) error reporting,    *//*      and we should be trying to distinquish at this point whether    *//*      failure is a result of trying to open a non-shapefile, or       *//*      whether it was a shapefile and we want to report the error      *//*      up.                                                             *//*                                                                      *//*      Care is taken to suppress the error and only reissue it if      *//*      we think it is appropriate.                                     *//* -------------------------------------------------------------------- */    CPLPushErrorHandler( CPLQuietErrorHandler );    if( bUpdate )        hSHP = DS_SHPOpen( pszNewName, "r+" );    else        hSHP = DS_SHPOpen( pszNewName, "r" );    CPLPopErrorHandler();    if( hSHP == NULL         && (!EQUAL(CPLGetExtension(pszNewName),"dbf")             || strstr(CPLGetLastErrorMsg(),".shp") == NULL) )    {        CPLString osMsg = CPLGetLastErrorMsg();        CPLError( CE_Failure, CPLE_OpenFailed, "%s", osMsg.c_str() );        return FALSE;    }    CPLErrorReset();    /* -------------------------------------------------------------------- *//*      Open the .dbf file, if it exists.  To open a dbf file, the      *//*      filename has to either refer to a successfully opened shp       *//*      file or has to refer to the actual .dbf file.                   *//* -------------------------------------------------------------------- */    if( hSHP != NULL || EQUAL(CPLGetExtension(pszNewName),"dbf") )    {        if( bUpdate )        {            hDBF = DS_DBFOpen( pszNewName, "r+" );            if( hSHP != NULL && hDBF == NULL )            {                for(int i=0;i<2;i++)                {                    VSIStatBufL sStat;                    const char* pszDBFName = CPLResetExtension(pszNewName,                                                    (i == 0 ) ? "dbf" : "DBF");                    VSILFILE* fp = NULL;                    if( VSIStatExL( pszDBFName, &sStat, VSI_STAT_EXISTS_FLAG) == 0 )                    {                        fp = VSIFOpenL(pszDBFName, "r+");                        if (fp == NULL)                        {                            CPLError( CE_Failure, CPLE_OpenFailed,                                    "%s exists, but cannot be opened in update mode",                                    pszDBFName );                            SHPClose(hSHP);                            return FALSE;                        }                        VSIFCloseL(fp);                        break;                    }                }            }        }        else            hDBF = DS_DBFOpen( pszNewName, "r" );    }    else        hDBF = NULL;            if( hDBF == NULL && hSHP == NULL )        return FALSE;/* -------------------------------------------------------------------- *//*      Create the layer object.                                        *//* -------------------------------------------------------------------- */    OGRShapeLayer       *poLayer;    poLayer = new OGRShapeLayer( this, pszNewName, hSHP, hDBF, NULL, FALSE, bUpdate,                                 wkbNone );    poLayer->SetModificationDate(            CSLFetchNameValue( papszOpenOptions, "DBF_DATE_LAST_UPDATE" ) );/* -------------------------------------------------------------------- *//*      Add layer to data source layer list.                            *//* -------------------------------------------------------------------- *///.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,



注:本文中的CPLResetExtension函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CPLSetConfigOption函数代码示例
C++ CPLRealloc函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。