这篇教程C++ CPLGetFilename函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLGetFilename函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetFilename函数的具体用法?C++ CPLGetFilename怎么用?C++ CPLGetFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLGetFilename函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetDatasetFastbool wxGxOpenFileGDB::Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel){ wxGISDataset* pDSet = GetDatasetFast(); if (NULL != pDSet) { pDSet->Close(); wsDELETE(pDSet); } if (pTrackCancel) pTrackCancel->PutMessage(wxString::Format(_("%s %s %s"), _("Move"), GetCategory().c_str(), m_sName.c_str()), wxNOT_FOUND, enumGISMessageInfo); //CPLString szFullDestPath = CPLFormFilename(szDestPath, CPLGetFilename(m_sPath), NULL); CPLString szFullDestPath = CheckUniqPath(szDestPath, CPLGetFilename(m_sPath), true, " "); bool bRet = MoveDir(m_sPath, szFullDestPath, 777, pTrackCancel); if (!bRet) { const char* err = CPLGetLastErrorMsg(); wxString sErr = wxString::Format(_("Operation '%s' failed! GDAL error: %s, %s '%s'"), _("Move"), GetCategory().c_str(), wxString(err, wxConvUTF8).c_str(), wxString(m_sPath, wxConvUTF8).c_str()); wxLogError(sErr); if (pTrackCancel) pTrackCancel->PutMessage(sErr, wxNOT_FOUND, enumGISMessageErr); return false; } return true;}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:29,
示例2: CPLFormCIFilenameint TSXDataset::Identify( GDALOpenInfo *poOpenInfo ){ if (poOpenInfo->fpL == NULL || poOpenInfo->nHeaderBytes < 260) { if( poOpenInfo->bIsDirectory ) { const CPLString osFilename = CPLFormCIFilename( poOpenInfo->pszFilename, CPLGetFilename( poOpenInfo->pszFilename ), "xml" ); /* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */ if (!(STARTS_WITH_CI(CPLGetBasename( osFilename ), "TSX1_SAR") || STARTS_WITH_CI(CPLGetBasename( osFilename ), "TDX1_SAR"))) return 0; VSIStatBufL sStat; if( VSIStatL( osFilename, &sStat ) == 0 ) return 1; } return 0; } /* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */ if (!(STARTS_WITH_CI(CPLGetBasename( poOpenInfo->pszFilename ), "TSX1_SAR") || STARTS_WITH_CI(CPLGetBasename( poOpenInfo->pszFilename ), "TDX1_SAR"))) return 0; /* finally look for the <level1Product tag */ if (!STARTS_WITH_CI(reinterpret_cast<char *>( poOpenInfo->pabyHeader ), "<level1Product") ) return 0; return 1;}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:34,
示例3: osFilenameint CTGDataset::Identify( GDALOpenInfo * poOpenInfo ){ CPLString osFilename(poOpenInfo->pszFilename); GDALOpenInfo* poOpenInfoToDelete = NULL; /* GZipped grid_cell.gz files are common, so automagically open them */ /* if the /vsigzip/ has not been explicitely passed */ const char* pszFilename = CPLGetFilename(poOpenInfo->pszFilename); if ((EQUAL(pszFilename, "grid_cell.gz") || EQUAL(pszFilename, "grid_cell1.gz") || EQUAL(pszFilename, "grid_cell2.gz")) && !EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9)) { osFilename = "/vsigzip/"; osFilename += poOpenInfo->pszFilename; poOpenInfo = poOpenInfoToDelete = new GDALOpenInfo(osFilename.c_str(), GA_ReadOnly, poOpenInfo->papszSiblingFiles); } if (poOpenInfo->nHeaderBytes < HEADER_LINE_COUNT * 80) { delete poOpenInfoToDelete; return FALSE; }/* -------------------------------------------------------------------- *//* Chech that it looks roughly as a CTG dataset *//* -------------------------------------------------------------------- */ const char* pszData = (const char*)poOpenInfo->pabyHeader; int i; for(i=0;i<4 * 80;i++) { if (!((pszData[i] >= '0' && pszData[i] <= '9') || pszData[i] == ' ' || pszData[i] == '-')) { delete poOpenInfoToDelete; return FALSE; } } char szField[11]; int nRows = atoi(ExtractField(szField, pszData, 0, 10)); int nCols = atoi(ExtractField(szField, pszData, 20, 10)); int nMinColIndex = atoi(ExtractField(szField, pszData+80, 0, 5)); int nMinRowIndex = atoi(ExtractField(szField, pszData+80, 5, 5)); int nMaxColIndex = atoi(ExtractField(szField, pszData+80, 10, 5)); int nMaxRowIndex = atoi(ExtractField(szField, pszData+80, 15, 5)); if (nRows <= 0 || nCols <= 0 || nMinColIndex != 1 || nMinRowIndex != 1 || nMaxRowIndex != nRows || nMaxColIndex != nCols) { delete poOpenInfoToDelete; return FALSE; } delete poOpenInfoToDelete; return TRUE;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:60,
示例4: CPLStrdupvoid OGRCSVDataSource::CreateForSingleFile( const char* pszDirname, const char *pszFilename ){ pszName = CPLStrdup( pszDirname ); bUpdate = true; osDefaultCSVName = CPLGetFilename(pszFilename);}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:7,
示例5: CPLFormCIFilenameint TSXDataset::Identify( GDALOpenInfo *poOpenInfo ){ if (poOpenInfo->fpL == NULL || poOpenInfo->nHeaderBytes < 260) { if( poOpenInfo->bIsDirectory ) { CPLString osFilename = CPLFormCIFilename( poOpenInfo->pszFilename, CPLGetFilename( poOpenInfo->pszFilename ), "xml" ); /* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */ if (!(EQUALN(CPLGetBasename( osFilename ), "TSX1_SAR", 8) || EQUALN(CPLGetBasename( osFilename ), "TDX1_SAR", 8))) return 0; VSIStatBufL sStat; if( VSIStatL( osFilename, &sStat ) == 0 ) return 1; } return 0; } /* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */ if (!(EQUALN(CPLGetBasename( poOpenInfo->pszFilename ), "TSX1_SAR", 8) || EQUALN(CPLGetBasename( poOpenInfo->pszFilename ), "TDX1_SAR", 8))) return 0; /* finally look for the <level1Product tag */ if (!EQUALN((char *)poOpenInfo->pabyHeader, "<level1Product", 14)) return 0; return 1;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:33,
示例6: CPLGetFilenameint SRTMHGTDataset::Identify( GDALOpenInfo * poOpenInfo ){ const char* fileName = CPLGetFilename(poOpenInfo->pszFilename); if( strlen(fileName) < 11 || fileName[7] != '.' ) return FALSE; CPLString osLCFilename(CPLString(fileName).tolower()); if( (osLCFilename[0] != 'n' && osLCFilename[0] != 's') || (osLCFilename[3] != 'e' && osLCFilename[3] != 'w') ) return FALSE; if( !STARTS_WITH(fileName, "/vsizip/") && osLCFilename.endsWith(".hgt.zip") ) { CPLString osNewName("/vsizip/"); osNewName += poOpenInfo->pszFilename; osNewName += "/"; osNewName += CPLString(fileName).substr(0, 7); osNewName += ".hgt"; GDALOpenInfo oOpenInfo(osNewName, GA_ReadOnly); return Identify(&oOpenInfo); } if( !STARTS_WITH(fileName, "/vsizip/") && osLCFilename.endsWith(".srtmswbd.raw.zip") ) { CPLString osNewName("/vsizip/"); osNewName += poOpenInfo->pszFilename; osNewName += "/"; osNewName += CPLString(fileName).substr(0, 7); osNewName += ".raw"; GDALOpenInfo oOpenInfo(osNewName, GA_ReadOnly); return Identify(&oOpenInfo); } if( !osLCFilename.endsWith(".hgt") && !osLCFilename.endsWith(".raw") && !osLCFilename.endsWith(".hgt.gz") ) return FALSE;/* -------------------------------------------------------------------- *//* We check the file size to see if it is *//* SRTM1 (below or above lat 50) or SRTM 3 *//* -------------------------------------------------------------------- */ VSIStatBufL fileStat; if(VSIStatL(poOpenInfo->pszFilename, &fileStat) != 0) return FALSE; if(fileStat.st_size != 3601 * 3601 && fileStat.st_size != 3601 * 3601 * 2 && fileStat.st_size != 1801 * 3601 * 2 && fileStat.st_size != 1201 * 1201 * 2 ) return FALSE; return TRUE;}
开发者ID:hdfeos,项目名称:gdal,代码行数:56,
示例7: CSLFindStringint OGROpenFileGDBDataSource::FileExists(const char* pszFilename){ if( m_papszFiles ) return CSLFindString(m_papszFiles, CPLGetFilename(pszFilename)) >= 0; else { VSIStatBufL sStat; return VSIStatExL(pszFilename, &sStat, VSI_STAT_EXISTS_FLAG) == 0; }}
开发者ID:garnertb,项目名称:gdal,代码行数:10,
示例8: GDALMDReaderPleiades/** * GDALMDReaderSpot() */GDALMDReaderSpot::GDALMDReaderSpot(const char *pszPath, char **papszSiblingFiles) : GDALMDReaderPleiades(pszPath, papszSiblingFiles){ const char* pszIMDSourceFilename; const char* pszDirName = CPLGetDirname(pszPath); if(m_osIMDSourceFilename.empty()) { pszIMDSourceFilename = CPLFormFilename( pszDirName, "METADATA.DIM", NULL ); if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles)) { m_osIMDSourceFilename = pszIMDSourceFilename; } else { pszIMDSourceFilename = CPLFormFilename( pszDirName, "metadata.dim", NULL ); if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles)) { m_osIMDSourceFilename = pszIMDSourceFilename; } } } // if the file name ended on METADATA.DIM // Linux specific // example: R2_CAT_091028105025131_1/METADATA.DIM if(m_osIMDSourceFilename.empty()) { if(EQUAL(CPLGetFilename(pszPath), "IMAGERY.TIF")) { pszIMDSourceFilename = CPLSPrintf( "%s//METADATA.DIM", CPLGetPath(pszPath)); if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles)) { m_osIMDSourceFilename = pszIMDSourceFilename; } else { pszIMDSourceFilename = CPLSPrintf( "%s//metadata.dim", CPLGetPath(pszPath)); if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles)) { m_osIMDSourceFilename = pszIMDSourceFilename; } } } } if(m_osIMDSourceFilename.size()) CPLDebug( "MDReaderSpot", "IMD Filename: %s", m_osIMDSourceFilename.c_str() );}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:57,
示例9: Resetint OGRXPlaneDataSource::Open( const char * pszFilename, int bReadWholeFile ){ Reset(); this->bReadWholeFile = bReadWholeFile; const char* pszShortFilename = CPLGetFilename(pszFilename); if (EQUAL(pszShortFilename, "nav.dat") || EQUAL(pszShortFilename, "earth_nav.dat")) { poReader = OGRXPlaneCreateNavFileReader(this); } else if (EQUAL(pszShortFilename, "apt.dat")) { poReader = OGRXPlaneCreateAptFileReader(this); } else if (EQUAL(pszShortFilename, "fix.dat") || EQUAL(pszShortFilename, "earth_fix.dat")) { poReader = OGRXPlaneCreateFixFileReader(this); } else if (EQUAL(pszShortFilename, "awy.dat") || EQUAL(pszShortFilename, "earth_awy.dat")) { poReader = OGRXPlaneCreateAwyFileReader(this); } int bRet; if (poReader && poReader->StartParsing(pszFilename) == FALSE) { delete poReader; poReader = NULL; } if (poReader) { pszName = CPLStrdup(pszFilename); if ( !bReadWholeFile ) { for( int i = 0; i < nLayers; i++ ) papoLayers[i]->SetReader(poReader->CloneForLayer(papoLayers[i])); } bRet = TRUE; } else bRet = FALSE; return bRet;}
开发者ID:0004c,项目名称:node-gdal,代码行数:50,
示例10: CPLGetFilenameCPLErrGDALDefaultOverviews::BuildOverviewsSubDataset( const char * pszPhysicalFile, const char * pszResampling, int nOverviews, int * panOverviewList, int nBands, int * panBandList, GDALProgressFunc pfnProgress, void * pProgressData){ if( osOvrFilename.length() == 0 && nOverviews > 0 ) { VSIStatBufL sStatBuf; int iSequence = 0; // Used after for. for( iSequence = 0; iSequence < 100; iSequence++ ) { osOvrFilename.Printf( "%s_%d.ovr", pszPhysicalFile, iSequence ); if( VSIStatExL( osOvrFilename, &sStatBuf, VSI_STAT_EXISTS_FLAG ) != 0 ) { CPLString osAdjustedOvrFilename; if( poDS->GetMOFlags() & GMO_PAM_CLASS ) { osAdjustedOvrFilename.Printf( ":::BASE:::%s_%d.ovr", CPLGetFilename(pszPhysicalFile), iSequence ); } else { osAdjustedOvrFilename = osOvrFilename; } poDS->SetMetadataItem( "OVERVIEW_FILE", osAdjustedOvrFilename, "OVERVIEWS" ); break; } } if( iSequence == 100 ) osOvrFilename = ""; } return BuildOverviews( NULL, pszResampling, nOverviews, panOverviewList, nBands, panBandList, pfnProgress, pProgressData );}
开发者ID:ryandavid,项目名称:rotobox,代码行数:48,
示例11: CPLFormCIFilenameint SAFEDataset::Identify( GDALOpenInfo *poOpenInfo ){ /* Check for the case where we're trying to read the calibrated data: */ if (STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL1_CALIB:")) { return TRUE; } /* Check for the case where we're trying to read the subdatasets: */ if (STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL1_DS:")) { return TRUE; } /* Check for directory access when there is a manifest.safe file in the directory. */ if( poOpenInfo->bIsDirectory ) { VSIStatBufL sStat; CPLString osMDFilename = CPLFormCIFilename( poOpenInfo->pszFilename, "manifest.safe", nullptr ); if( VSIStatL( osMDFilename, &sStat ) == 0 && VSI_ISREG(sStat.st_mode) ) { GDALOpenInfo oOpenInfo( osMDFilename, GA_ReadOnly, nullptr ); return Identify(&oOpenInfo); } return FALSE; } /* otherwise, do our normal stuff */ if( !EQUAL(CPLGetFilename(poOpenInfo->pszFilename), "manifest.safe") ) return FALSE; if( poOpenInfo->nHeaderBytes < 100 ) return FALSE; if( strstr((const char *) poOpenInfo->pabyHeader, "<xfdu:XFDU" ) == nullptr) return FALSE; // This driver doesn't handle Sentinel-2 data if( strstr((const char *) poOpenInfo->pabyHeader, "sentinel-2" ) != nullptr) return FALSE; return TRUE;}
开发者ID:tbonfort,项目名称:gdal,代码行数:46,
示例12: lockerbool wxGISDataset::Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel){ wxCriticalSectionLocker locker(m_CritSect); Close(); char** papszFileList = GetFileList(); papszFileList = CSLAddString( papszFileList, m_sPath ); if(!papszFileList) { if(pTrackCancel) pTrackCancel->PutMessage(_("No files to move"), wxNOT_FOUND, enumGISMessageErr); return false; } CPLString szFileName = CPLGetBasename(GetUniqPath(m_sPath, szDestPath, CPLGetBasename(m_sPath))); char** papszMovedFileList = NULL; for(int i = 0; papszFileList[i] != NULL; ++i ) { CPLString szNewDestFileName(CPLFormFilename(szDestPath, szFileName, GetExtension(papszFileList[i], szFileName))); papszMovedFileList = CSLAddString(papszMovedFileList, szNewDestFileName); if(!MoveFile(szNewDestFileName, papszFileList[i], pTrackCancel)) { // Try to put the ones we moved back. pTrackCancel->Reset(); for( --i; i >= 0; i-- ) MoveFile( papszFileList[i], papszMovedFileList[i]); CSLDestroy( papszFileList ); CSLDestroy( papszMovedFileList ); return false; } } m_sPath = CPLFormFilename(szDestPath, CPLGetFilename(m_sPath), NULL); CSLDestroy( papszFileList ); CSLDestroy( papszMovedFileList ); return true;}
开发者ID:Mileslee,项目名称:wxgis,代码行数:42,
示例13: CPLGetFilenameint SRTMHGTDataset::Identify( GDALOpenInfo * poOpenInfo ){ const char* fileName = CPLGetFilename(poOpenInfo->pszFilename); if( strlen(fileName) < 11 || !EQUALN(&fileName[7], ".hgt", 4) ) return FALSE;/* -------------------------------------------------------------------- *//* We check the file size to see if it is 25,934,402 bytes *//* (SRTM 1) or 2,884,802 bytes (SRTM 3) */ /* -------------------------------------------------------------------- */ VSIStatBufL fileStat; if(VSIStatL(poOpenInfo->pszFilename, &fileStat) != 0) return FALSE; if(fileStat.st_size != 25934402 && fileStat.st_size != 2884802) return FALSE; return TRUE;}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:20,
示例14: EQUALstatic GDALDataset *OGRTABDriverOpen( GDALOpenInfo* poOpenInfo ){ OGRTABDataSource *poDS; if( OGRTABDriverIdentify(poOpenInfo) == FALSE ) { return NULL; } if (EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "MIF") || EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "MID") ) { if( poOpenInfo->eAccess == GA_Update ) return NULL; }#ifdef DEBUG /* For AFL, so that .cur_input is detected as the archive filename */ if( poOpenInfo->fpL != NULL && !STARTS_WITH(poOpenInfo->pszFilename, "/vsitar/") && EQUAL(CPLGetFilename(poOpenInfo->pszFilename), ".cur_input") ) { GDALOpenInfo oOpenInfo( (CPLString("/vsitar/") + poOpenInfo->pszFilename).c_str(), poOpenInfo->nOpenFlags ); oOpenInfo.papszOpenOptions = poOpenInfo->papszOpenOptions; return OGRTABDriverOpen(&oOpenInfo); }#endif poDS = new OGRTABDataSource(); if( poDS->Open( poOpenInfo, TRUE ) ) return poDS; else { delete poDS; return NULL; }}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:39,
示例15: GetGxCatalogbool wxGxLocalDBFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds){ wxGxCatalogBase* pCatalog = GetGxCatalog(); bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT; for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- ) { VSIStatBufL BufL; int ret = VSIStatL(pFileNames[i], &BufL); if(ret == 0) { if (VSI_ISDIR(BufL.st_mode) && wxGISEQUAL(CPLGetExtension(pFileNames[i]), "gdb")) { wxGxObject* pObj = GetGxObject(pParent, wxString(CPLGetFilename(pFileNames[i]), wxConvUTF8), pFileNames[i], enumContGDBFolder, bCheckNames); if(pObj) pChildrenIds.Add(pObj->GetId()); pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL ); } //TODO: mdb, sqlite, db extensions } } return true;}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:22,
示例16: OGRTABDriverIdentifystatic int OGRTABDriverIdentify( GDALOpenInfo* poOpenInfo ){ /* Files not ending with .tab, .mif or .mid are not handled by this driver */ if( !poOpenInfo->bStatOK ) return FALSE; if( poOpenInfo->bIsDirectory ) return -1; /* unsure */ if( poOpenInfo->fpL == NULL ) return FALSE; if (EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "MIF") || EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "MID") ) { return TRUE; } if (EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "TAB") ) { for( int i = 0; i < poOpenInfo->nHeaderBytes; i++) { const char* pszLine = (const char*)poOpenInfo->pabyHeader + i; if (STARTS_WITH_CI(pszLine, "Fields")) return TRUE; else if (STARTS_WITH_CI(pszLine, "create view")) return TRUE; else if (STARTS_WITH_CI(pszLine, "/"//IsSeamless/" = /"TRUE/"")) return TRUE; } }#ifdef DEBUG /* For AFL, so that .cur_input is detected as the archive filename */ if( !STARTS_WITH(poOpenInfo->pszFilename, "/vsitar/") && EQUAL(CPLGetFilename(poOpenInfo->pszFilename), ".cur_input") ) { return -1; }#endif return FALSE;}
开发者ID:ryandavid,项目名称:rotobox,代码行数:38,
示例17: getRscFilenamestatic CPLString getRscFilename( GDALOpenInfo *poOpenInfo ){ CPLString osRscFilename; char **papszSiblingFiles = poOpenInfo->GetSiblingFiles(); if ( papszSiblingFiles == NULL ) { osRscFilename = CPLFormFilename( NULL, poOpenInfo->pszFilename, "rsc" ); VSIStatBufL psRscStatBuf; if ( VSIStatL( osRscFilename, &psRscStatBuf ) != 0 ) { osRscFilename = ""; } } else { /* ------------------------------------------------------------ */ /* We need to tear apart the filename to form a .rsc */ /* filename. */ /* ------------------------------------------------------------ */ CPLString osPath = CPLGetPath( poOpenInfo->pszFilename ); CPLString osName = CPLGetFilename( poOpenInfo->pszFilename ); int iFile = CSLFindString( papszSiblingFiles, CPLFormFilename( NULL, osName, "rsc" ) ); if( iFile >= 0 ) { osRscFilename = CPLFormFilename( osPath, papszSiblingFiles[iFile], NULL ); } } return osRscFilename;}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:36,
示例18: CPLStrdupint OGRCSVDataSource::Open( const char * pszFilename, int bUpdateIn, int bForceOpen, char** papszOpenOptions ){ pszName = CPLStrdup( pszFilename ); bUpdate = bUpdateIn; if (bUpdateIn && bForceOpen && EQUAL(pszFilename, "/vsistdout/")) return TRUE; /* For writable /vsizip/, do nothing more */ if (bUpdateIn && bForceOpen && strncmp(pszFilename, "/vsizip/", 8) == 0) return TRUE; CPLString osFilename(pszFilename); CPLString osBaseFilename = CPLGetFilename(pszFilename); CPLString osExt = GetRealExtension(osFilename); pszFilename = NULL; int bIgnoreExtension = EQUALN(osFilename, "CSV:", 4); int bUSGeonamesFile = FALSE; /* int bGeonamesOrgFile = FALSE; */ if (bIgnoreExtension) { osFilename = osFilename + 4; } /* Those are *not* real .XLS files, but text file with tab as column separator */ if (EQUAL(osBaseFilename, "NfdcFacilities.xls") || EQUAL(osBaseFilename, "NfdcRunways.xls") || EQUAL(osBaseFilename, "NfdcRemarks.xls") || EQUAL(osBaseFilename, "NfdcSchedules.xls")) { if (bUpdateIn) return FALSE; bIgnoreExtension = TRUE; } else if ((EQUALN(osBaseFilename, "NationalFile_", 13) || EQUALN(osBaseFilename, "POP_PLACES_", 11) || EQUALN(osBaseFilename, "HIST_FEATURES_", 14) || EQUALN(osBaseFilename, "US_CONCISE_", 11) || EQUALN(osBaseFilename, "AllNames_", 9) || EQUALN(osBaseFilename, "Feature_Description_History_", 28) || EQUALN(osBaseFilename, "ANTARCTICA_", 11) || EQUALN(osBaseFilename, "GOVT_UNITS_", 11) || EQUALN(osBaseFilename, "NationalFedCodes_", 17) || EQUALN(osBaseFilename, "AllStates_", 10) || EQUALN(osBaseFilename, "AllStatesFedCodes_", 18) || (strlen(osBaseFilename) > 2 && EQUALN(osBaseFilename+2, "_Features_", 10)) || (strlen(osBaseFilename) > 2 && EQUALN(osBaseFilename+2, "_FedCodes_", 10))) && (EQUAL(osExt, "txt") || EQUAL(osExt, "zip")) ) { if (bUpdateIn) return FALSE; bIgnoreExtension = TRUE; bUSGeonamesFile = TRUE; if (EQUAL(osExt, "zip") && strstr(osFilename, "/vsizip/") == NULL ) { osFilename = "/vsizip/" + osFilename; } } else if (EQUAL(osBaseFilename, "allCountries.txt") || EQUAL(osBaseFilename, "allCountries.zip")) { if (bUpdateIn) return FALSE; bIgnoreExtension = TRUE; /* bGeonamesOrgFile = TRUE; */ if (EQUAL(osExt, "zip") && strstr(osFilename, "/vsizip/") == NULL ) { osFilename = "/vsizip/" + osFilename; } }/* -------------------------------------------------------------------- *//* Determine what sort of object this is. *//* -------------------------------------------------------------------- */ VSIStatBufL sStatBuf; if( VSIStatExL( osFilename, &sStatBuf, VSI_STAT_NATURE_FLAG ) != 0 ) return FALSE;/* -------------------------------------------------------------------- *//* Is this a single CSV file? *//* -------------------------------------------------------------------- */ if( VSI_ISREG(sStatBuf.st_mode) && (bIgnoreExtension || EQUAL(osExt,"csv") || EQUAL(osExt,"tsv")) ) { if (EQUAL(CPLGetFilename(osFilename), "NfdcFacilities.xls")) { return OpenTable( osFilename, papszOpenOptions, "ARP"); } else if (EQUAL(CPLGetFilename(osFilename), "NfdcRunways.xls")) { OpenTable( osFilename, papszOpenOptions, "BaseEndPhysical"); OpenTable( osFilename, papszOpenOptions, "BaseEndDisplaced");//.........这里部分代码省略.........
开发者ID:MattLatt,项目名称:GDAL_2.0.x_VC,代码行数:101,
示例19: STARTS_WITH_CIGDALDataset *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,
示例20: whileint OGRSelafinDataSource::Open(const char * pszFilename, int bUpdateIn, int bCreate) { // Check if a range is set and extract it and the filename const char *pszc=pszFilename; if (*pszFilename==0) return FALSE; while (*pszc) ++pszc; if (*(pszc-1)==']') { --pszc; while (pszc!=pszFilename && *pszc!='[') pszc--; if (pszc==pszFilename) return FALSE; poRange.setRange(pszc); } pszName = CPLStrdup( pszFilename ); pszName[pszc-pszFilename]=0; bUpdate = bUpdateIn; if (bCreate && EQUAL(pszName, "/vsistdout/")) return TRUE; /* For writable /vsizip/, do nothing more */ if (bCreate && STARTS_WITH(pszName, "/vsizip/")) return TRUE; CPLString osFilename(pszName); CPLString osBaseFilename = CPLGetFilename(pszName); // Determine what sort of object this is. VSIStatBufL sStatBuf; if (VSIStatExL( osFilename, &sStatBuf, VSI_STAT_NATURE_FLAG ) != 0) return FALSE; // Is this a single Selafin file? if (VSI_ISREG(sStatBuf.st_mode)) return OpenTable( pszName ); // Is this a single a ZIP file with only a Selafin file inside ? if( STARTS_WITH(osFilename, "/vsizip/") && VSI_ISREG(sStatBuf.st_mode) ) { char** papszFiles = VSIReadDir(osFilename); if (CSLCount(papszFiles) != 1) { CSLDestroy(papszFiles); return FALSE; } osFilename = CPLFormFilename(osFilename, papszFiles[0], NULL); CSLDestroy(papszFiles); return OpenTable( osFilename ); }#ifdef notdef // Otherwise it has to be a directory. if( !VSI_ISDIR(sStatBuf.st_mode) ) return FALSE; // Scan through for entries which look like Selafin files int nNotSelafinCount = 0, i; char **papszNames = VSIReadDir( osFilename ); for( i = 0; papszNames != NULL && papszNames[i] != NULL; i++ ) { CPLString oSubFilename = CPLFormFilename( osFilename, papszNames[i], NULL ); if( EQUAL(papszNames[i],".") || EQUAL(papszNames[i],"..") ) continue; if( VSIStatL( oSubFilename, &sStatBuf ) != 0 || !VSI_ISREG(sStatBuf.st_mode) ) { nNotSelafinCount++; continue; } if( !OpenTable( oSubFilename ) ) { CPLDebug("Selafin", "Cannot open %s", oSubFilename.c_str()); nNotSelafinCount++; continue; } } CSLDestroy( papszNames ); // We presume that this is indeed intended to be a Selafin datasource if over half the files were Selafin files. return nNotSelafinCount < nLayers;#else return FALSE;#endif}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:66,
示例21: 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,
示例22: HFAAuxBuildOverviewsCPLErr HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS, GDALDataset **ppoODS, int nBands, int *panBandList, int nNewOverviews, int *panNewOverviewList, const char *pszResampling, GDALProgressFunc pfnProgress, void *pProgressData ){/* ==================================================================== *//* If the .aux file doesn't exist yet then create it now. *//* ==================================================================== */ if( *ppoODS == NULL ) { GDALDataType eDT = GDT_Unknown;/* -------------------------------------------------------------------- *//* Determine the band datatype, and verify that all bands are *//* the same. *//* -------------------------------------------------------------------- */ int iBand; for( iBand = 0; iBand < nBands; iBand++ ) { GDALRasterBand *poBand = poParentDS->GetRasterBand( panBandList[iBand] ); if( iBand == 0 ) eDT = poBand->GetRasterDataType(); else { if( eDT != poBand->GetRasterDataType() ) { CPLError( CE_Failure, CPLE_NotSupported, "HFAAuxBuildOverviews() doesn't support a mixture of band" " data types." ); return CE_Failure; } } }/* -------------------------------------------------------------------- *//* Create the HFA (.aux) file. We create it with *//* COMPRESSED=YES so that no space will be allocated for the *//* base band. *//* -------------------------------------------------------------------- */ GDALDriver *poHFADriver = (GDALDriver *) GDALGetDriverByName("HFA"); if (poHFADriver == NULL) { CPLError( CE_Failure, CPLE_AppDefined, "HFA driver is unavailable." ); return CE_Failure; } const char *apszOptions[4] = { "COMPRESSED=YES", "AUX=YES", NULL, NULL }; CPLString osDepFileOpt = "DEPENDENT_FILE="; osDepFileOpt += CPLGetFilename(poParentDS->GetDescription()); apszOptions[2] = osDepFileOpt.c_str(); *ppoODS = poHFADriver->Create( pszOvrFilename, poParentDS->GetRasterXSize(), poParentDS->GetRasterYSize(), poParentDS->GetRasterCount(), eDT, (char **)apszOptions ); if( *ppoODS == NULL ) return CE_Failure; }/* ==================================================================== *//* Create the layers. We depend on the normal buildoverviews *//* support for HFA to do this. But we disable the internal *//* computation of the imagery for these layers. *//* *//* We avoid regenerating the new layers here, because if we did *//* it would use the base layer from the .aux file as the source *//* data, and that is fake (all invalid tiles). *//* ==================================================================== */ CPLString oAdjustedResampling = "NO_REGEN:"; oAdjustedResampling += pszResampling; CPLErr eErr = (*ppoODS)->BuildOverviews( oAdjustedResampling, nNewOverviews, panNewOverviewList, nBands, panBandList, pfnProgress, pProgressData ); return eErr;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:91,
示例23: CPLFormFilenamevoid GDALPamProxyDB::SaveDB(){/* -------------------------------------------------------------------- *//* Open the database relating original names to proxy .aux.xml *//* file names. *//* -------------------------------------------------------------------- */ CPLString osDBName = CPLFormFilename( osProxyDBDir, "gdal_pam_proxy", "dat" ); void *hLock = CPLLockFile( osDBName, 1.0 ); // proceed even if lock fails - we need CPLBreakLockFile()! if( hLock == NULL ) { CPLError( CE_Warning, CPLE_AppDefined, "GDALPamProxyDB::SaveDB() - Failed to lock %s file, proceeding anyways.", osDBName.c_str() ); } FILE *fpDB = VSIFOpenL( osDBName, "w" ); if( fpDB == NULL ) { if( hLock ) CPLUnlockFile( hLock ); CPLError( CE_Failure, CPLE_AppDefined, "Failed to save %s Pam Proxy DB./n%s", osDBName.c_str(), VSIStrerror( errno ) ); return; }/* -------------------------------------------------------------------- *//* Write header. *//* -------------------------------------------------------------------- */ GByte abyHeader[100]; memset( abyHeader, ' ', sizeof(abyHeader) ); strncpy( (char *) abyHeader, "GDAL_PROXY", 10 ); sprintf( (char *) abyHeader + 10, "%9d", nUpdateCounter ); VSIFWriteL( abyHeader, 1, 100, fpDB );/* -------------------------------------------------------------------- *//* Write names. *//* -------------------------------------------------------------------- */ unsigned int i; for( i = 0; i < aosOriginalFiles.size(); i++ ) { size_t nBytesWritten; const char *pszProxyFile; VSIFWriteL( aosOriginalFiles[i].c_str(), 1, strlen(aosOriginalFiles[i].c_str())+1, fpDB ); pszProxyFile = CPLGetFilename(aosProxyFiles[i]); nBytesWritten = VSIFWriteL( pszProxyFile, 1, strlen(pszProxyFile)+1, fpDB ); if( nBytesWritten != strlen(pszProxyFile)+1 ) { CPLError( CE_Failure, CPLE_AppDefined, "Failed to write complete %s Pam Proxy DB./n%s", osDBName.c_str(), VSIStrerror( errno ) ); VSIFCloseL( fpDB ); VSIUnlink( osDBName ); return; } } VSIFCloseL( fpDB ); if( hLock ) CPLUnlockFile( hLock );}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:77,
示例24: CPLErrorGDALDataset *TSXDataset::Open( GDALOpenInfo *poOpenInfo ) {/* -------------------------------------------------------------------- *//* Is this a TerraSAR-X product file? *//* -------------------------------------------------------------------- */ if (!TSXDataset::Identify( poOpenInfo )) { return NULL; /* nope */ }/* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CPLError( CE_Failure, CPLE_NotSupported, "The TSX driver does not support update access to existing" " datasets./n" ); return NULL; } CPLString osFilename; if( poOpenInfo->bIsDirectory ) { osFilename = CPLFormCIFilename( poOpenInfo->pszFilename, CPLGetFilename( poOpenInfo->pszFilename ), "xml" ); } else osFilename = poOpenInfo->pszFilename; /* Ingest the XML */ CPLXMLNode *psData = CPLParseXMLFile( osFilename ); if (psData == NULL) return NULL; /* find the product components */ CPLXMLNode *psComponents = CPLGetXMLNode( psData, "=level1Product.productComponents" ); if (psComponents == NULL) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to find <productComponents> tag in file./n" ); CPLDestroyXMLNode(psData); return NULL; } /* find the product info tag */ CPLXMLNode *psProductInfo = CPLGetXMLNode( psData, "=level1Product.productInfo" ); if (psProductInfo == NULL) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to find <productInfo> tag in file./n" ); CPLDestroyXMLNode(psData); return NULL; }/* -------------------------------------------------------------------- *//* Create the dataset. *//* -------------------------------------------------------------------- */ TSXDataset *poDS = new TSXDataset();/* -------------------------------------------------------------------- *//* Read in product info. *//* -------------------------------------------------------------------- */ poDS->SetMetadataItem( "SCENE_CENTRE_TIME", CPLGetXMLValue( psProductInfo, "sceneInfo.sceneCenterCoord.azimuthTimeUTC", "unknown" ) ); poDS->SetMetadataItem( "OPERATIONAL_MODE", CPLGetXMLValue( psProductInfo, "generationInfo.groundOperationsType", "unknown" ) ); poDS->SetMetadataItem( "ORBIT_CYCLE", CPLGetXMLValue( psProductInfo, "missionInfo.orbitCycle", "unknown" ) ); poDS->SetMetadataItem( "ABSOLUTE_ORBIT", CPLGetXMLValue( psProductInfo, "missionInfo.absOrbit", "unknown" ) ); poDS->SetMetadataItem( "ORBIT_DIRECTION", CPLGetXMLValue( psProductInfo, "missionInfo.orbitDirection", "unknown" ) ); poDS->SetMetadataItem( "IMAGING_MODE", CPLGetXMLValue( psProductInfo, "acquisitionInfo.imagingMode", "unknown" ) ); poDS->SetMetadataItem( "PRODUCT_VARIANT", CPLGetXMLValue( psProductInfo, "productVariantInfo.productVariant", "unknown" ) ); char *pszDataType = CPLStrdup( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageDataType", "unknown" ) ); poDS->SetMetadataItem( "IMAGE_TYPE", pszDataType ); /* Get raster information */ int nRows = atoi( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.numberOfRows", "" ) ); int nCols = atoi( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.numberOfColumns", "" ) ); poDS->nRasterXSize = nCols; poDS->nRasterYSize = nRows; poDS->SetMetadataItem( "ROW_SPACING", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.rowSpacing", "unknown" ) ); poDS->SetMetadataItem( "COL_SPACING", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.columnSpacing", "unknown" ) ); poDS->SetMetadataItem( "COL_SPACING_UNITS", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.columnSpacing.units", "unknown" ) );//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例25: EQUALN//.........这里部分代码省略......... eType = GDT_Int32; else if( EQUAL(osCellType,"IEEE4ByteReal") ) eType = GDT_Float32; else if( EQUAL(osCellType,"IEEE8ByteReal") ) eType = GDT_Float64; else { CPLDebug( "ERS", "Unknown CellType '%s'", osCellType.c_str() ); eType = GDT_Byte; }/* -------------------------------------------------------------------- *//* Pick up the word order. *//* -------------------------------------------------------------------- */ int bNative;#ifdef CPL_LSB bNative = EQUAL(poHeader->Find( "ByteOrder", "LSBFirst" ), "LSBFirst");#else bNative = EQUAL(poHeader->Find( "ByteOrder", "MSBFirst" ), "MSBFirst");#endif/* -------------------------------------------------------------------- *//* Figure out the name of the target file. *//* -------------------------------------------------------------------- */ CPLString osPath = CPLGetPath( poOpenInfo->pszFilename ); CPLString osDataFile = poHeader->Find( "DataFile", "" ); CPLString osDataFilePath; if( osDataFile.length() == 0 ) // just strip off extension. { osDataFile = CPLGetFilename( poOpenInfo->pszFilename ); osDataFile = osDataFile.substr( 0, osDataFile.find_last_of('.') ); } osDataFilePath = CPLFormFilename( osPath, osDataFile, NULL );/* -------------------------------------------------------------------- *//* DataSetType = Translated files are links to things like ecw *//* files. *//* -------------------------------------------------------------------- */ if( EQUAL(poHeader->Find("DataSetType",""),"Translated") ) { poDS->poDepFile = (GDALDataset *) GDALOpenShared( osDataFilePath, poOpenInfo->eAccess ); if( poDS->poDepFile != NULL && poDS->poDepFile->GetRasterCount() >= nBands ) { int iBand; for( iBand = 0; iBand < nBands; iBand++ ) { // Assume pixel interleaved. poDS->SetBand( iBand+1, poDS->poDepFile->GetRasterBand( iBand+1 ) ); } } }/* ==================================================================== *//* While ERStorage indicates a raw file. *//* ==================================================================== */ else if( EQUAL(poHeader->Find("DataSetType",""),"ERStorage") )
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:67,
示例26: CPLDebugvoid GDALDefaultOverviews::OverviewScan(){ if( bCheckedForOverviews || poDS == NULL ) return; bCheckedForOverviews = true; CPLDebug( "GDAL", "GDALDefaultOverviews::OverviewScan()" );/* -------------------------------------------------------------------- *//* Open overview dataset if it exists. *//* -------------------------------------------------------------------- */ if( pszInitName == NULL ) pszInitName = CPLStrdup(poDS->GetDescription()); if( !EQUAL(pszInitName,":::VIRTUAL:::") && GDALCanFileAcceptSidecarFile(pszInitName) ) { if( bInitNameIsOVR ) osOvrFilename = pszInitName; else osOvrFilename.Printf( "%s.ovr", pszInitName ); std::vector<char> achOvrFilename; achOvrFilename.resize(osOvrFilename.size() + 1); memcpy(&(achOvrFilename[0]), osOvrFilename.c_str(), osOvrFilename.size() + 1); bool bExists = CPL_TO_BOOL( CPLCheckForFile( &achOvrFilename[0], papszInitSiblingFiles ) ); osOvrFilename = &achOvrFilename[0];#if !defined(WIN32) if( !bInitNameIsOVR && !bExists && !papszInitSiblingFiles ) { osOvrFilename.Printf( "%s.OVR", pszInitName ); memcpy(&(achOvrFilename[0]), osOvrFilename.c_str(), osOvrFilename.size() + 1); bExists = CPL_TO_BOOL( CPLCheckForFile( &achOvrFilename[0], papszInitSiblingFiles ) ); osOvrFilename = &achOvrFilename[0]; if( !bExists ) osOvrFilename.Printf( "%s.ovr", pszInitName ); }#endif if( bExists ) { poODS = static_cast<GDALDataset *>( GDALOpenEx( osOvrFilename, GDAL_OF_RASTER | (poDS->GetAccess() == GA_Update ? GDAL_OF_UPDATE : 0), NULL, NULL, papszInitSiblingFiles ) ); } }/* -------------------------------------------------------------------- *//* We didn't find that, so try and find a corresponding aux *//* file. Check that we are the dependent file of the aux *//* file. *//* *//* We only use the .aux file for overviews if they already have *//* overviews existing, or if USE_RRD is set true. *//* -------------------------------------------------------------------- */ if( !poODS && !EQUAL(pszInitName,":::VIRTUAL:::") && GDALCanFileAcceptSidecarFile(pszInitName) ) { bool bTryFindAssociatedAuxFile = true; if( papszInitSiblingFiles ) { CPLString osAuxFilename = CPLResetExtension( pszInitName, "aux"); int iSibling = CSLFindString( papszInitSiblingFiles, CPLGetFilename(osAuxFilename) ); if( iSibling < 0 ) { osAuxFilename = pszInitName; osAuxFilename += ".aux"; iSibling = CSLFindString( papszInitSiblingFiles, CPLGetFilename(osAuxFilename) ); if( iSibling < 0 ) bTryFindAssociatedAuxFile = false; } } if( bTryFindAssociatedAuxFile ) { poODS = GDALFindAssociatedAuxFile( pszInitName, poDS->GetAccess(), poDS ); } if( poODS ) { const bool bUseRRD = CPLTestBool(CPLGetConfigOption("USE_RRD","NO")); bOvrIsAux = true; if( GetOverviewCount(1) == 0 && !bUseRRD ) { bOvrIsAux = false;//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,
示例27: CPLDebugint ISIS2Dataset::WriteLabel( CPLString osFilename, CPLString osRasterFile, CPLString sObjectTag, unsigned int nXSize, unsigned int nYSize, unsigned int nBands, GDALDataType eType, GUIntBig iRecords, const char * pszInterleaving, GUIntBig &iLabelRecords, bool bRelaunch){ CPLDebug("ISIS2", "Write Label filename = %s, rasterfile = %s",osFilename.c_str(),osRasterFile.c_str()); bool bAttachedLabel = EQUAL(osRasterFile, ""); VSILFILE *fpLabel = VSIFOpenL( osFilename, "w" ); if( fpLabel == NULL ) { CPLError( CE_Failure, CPLE_FileIO, "Failed to create %s:/n%s", osFilename.c_str(), VSIStrerror( errno ) ); return FALSE; } unsigned int iLevel(0); unsigned int nWritingBytes(0); /* write common header */ nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "PDS_VERSION_ID", "PDS3" ); nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, ""); nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "/* File identification and structure */"); nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "RECORD_TYPE", "FIXED_LENGTH" ); nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "RECORD_BYTES", CPLString().Printf("%d",RECORD_SIZE)); nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "FILE_RECORDS", CPLString().Printf(CPL_FRMT_GUIB,iRecords)); nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "LABEL_RECORDS", CPLString().Printf(CPL_FRMT_GUIB,iLabelRecords)); if(!bAttachedLabel) { nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "FILE_NAME", CPLGetFilename(osRasterFile)); } nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, ""); nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "/* Pointers to Data Objects */"); if(bAttachedLabel) { nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, CPLString().Printf("^%s",sObjectTag.c_str()), CPLString().Printf(CPL_FRMT_GUIB,iLabelRecords+1)); } else { nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, CPLString().Printf("^%s",sObjectTag.c_str()), CPLString().Printf("(/"%s/",1)",CPLGetFilename(osRasterFile))); } if(EQUAL(sObjectTag, "QUBE")) { ISIS2Dataset::WriteQUBE_Information(fpLabel, iLevel, nWritingBytes, nXSize, nYSize, nBands, eType, pszInterleaving); } nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "END"); // check if file record is correct unsigned int q = nWritingBytes/RECORD_SIZE; if( q <= iLabelRecords) { // correct we add space after the label end for complete from iLabelRecords unsigned int nSpaceBytesToWrite = (unsigned int) (iLabelRecords * RECORD_SIZE - nWritingBytes); VSIFPrintfL(fpLabel,"%*c", nSpaceBytesToWrite, ' '); } else { iLabelRecords = q+1; ISIS2Dataset::WriteLabel(osFilename, osRasterFile, sObjectTag, nXSize, nYSize, nBands, eType, iRecords, pszInterleaving, iLabelRecords); } VSIFCloseL( fpLabel ); return TRUE;}
开发者ID:codedis213,项目名称:elastic_search_practice,代码行数:64,
示例28: CPLErrorGDALDataset * SRTMHGTDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, int bStrict, char ** /* papszOptions*/, GDALProgressFunc pfnProgress, void * pProgressData ){/* -------------------------------------------------------------------- *//* Some some rudimentary checks *//* -------------------------------------------------------------------- */ const int nBands = poSrcDS->GetRasterCount(); if (nBands == 0) { CPLError( CE_Failure, CPLE_NotSupported, "SRTMHGT driver does not support source dataset with zero band./n"); return nullptr; } else if (nBands != 1) { CPLError( (bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported, "SRTMHGT driver only uses the first band of the dataset./n"); if (bStrict) return nullptr; }/* -------------------------------------------------------------------- *//* Checks the input SRS *//* -------------------------------------------------------------------- */ OGRSpatialReference ogrsr_input; ogrsr_input.importFromWkt(poSrcDS->GetProjectionRef()); OGRSpatialReference ogrsr_wgs84; ogrsr_wgs84.SetWellKnownGeogCS( "WGS84" ); if ( ogrsr_input.IsSameGeogCS(&ogrsr_wgs84) == FALSE) { CPLError( CE_Warning, CPLE_AppDefined, "The source projection coordinate system is %s. Only WGS 84 " "is supported./nThe SRTMHGT driver will generate a file as " "if the source was WGS 84 projection coordinate system.", poSrcDS->GetProjectionRef() ); }/* -------------------------------------------------------------------- *//* Work out the LL origin. *//* -------------------------------------------------------------------- */ double adfGeoTransform[6]; if (poSrcDS->GetGeoTransform( adfGeoTransform ) != CE_None) { CPLError( CE_Failure, CPLE_AppDefined, "Source image must have a geo transform matrix."); return nullptr; } const int nLLOriginLat = static_cast<int>( std::floor(adfGeoTransform[3] + poSrcDS->GetRasterYSize() * adfGeoTransform[5] + 0.5) ); int nLLOriginLong = static_cast<int>( std::floor(adfGeoTransform[0] + 0.5) ); if (std::abs(nLLOriginLat - ( adfGeoTransform[3] + (poSrcDS->GetRasterYSize() - 0.5 ) * adfGeoTransform[5] ) ) > 1e-10 || std::abs(nLLOriginLong - ( adfGeoTransform[0] + 0.5 * adfGeoTransform[1])) > 1e-10 ) { CPLError( CE_Warning, CPLE_AppDefined, "The corner coordinates of the source are not properly " "aligned on plain latitude/longitude boundaries."); }/* -------------------------------------------------------------------- *//* Check image dimensions. *//* -------------------------------------------------------------------- */ const int nXSize = poSrcDS->GetRasterXSize(); const int nYSize = poSrcDS->GetRasterYSize(); if (!((nXSize == 1201 && nYSize == 1201) || (nXSize == 3601 && nYSize == 3601) || (nXSize == 1801 && nYSize == 3601))) { CPLError( CE_Failure, CPLE_AppDefined, "Image dimensions should be 1201x1201, 3601x3601 or 1801x3601."); return nullptr; }/* -------------------------------------------------------------------- *//* Check filename. *//* -------------------------------------------------------------------- */ char expectedFileName[12]; CPLsnprintf(expectedFileName, sizeof(expectedFileName), "%c%02d%c%03d.HGT", (nLLOriginLat >= 0) ? 'N' : 'S', (nLLOriginLat >= 0) ? nLLOriginLat : -nLLOriginLat, (nLLOriginLong >= 0) ? 'E' : 'W', (nLLOriginLong >= 0) ? nLLOriginLong : -nLLOriginLong); if (!EQUAL(expectedFileName, CPLGetFilename(pszFilename))) {//.........这里部分代码省略.........
开发者ID:hdfeos,项目名称:gdal,代码行数:101,
注:本文中的CPLGetFilename函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLGetLastErrorMsg函数代码示例 C++ CPLGetExtension函数代码示例 |