这篇教程C++ CSLTokenizeString函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CSLTokenizeString函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLTokenizeString函数的具体用法?C++ CSLTokenizeString怎么用?C++ CSLTokenizeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CSLTokenizeString函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: whileconst char * E00GRIDRasterBand::GetUnitType(){ E00GRIDDataset *poGDS = (E00GRIDDataset *) poDS; poGDS->ReadMetadata(); if (poGDS->papszPrj == NULL) return GDALPamRasterBand::GetUnitType(); char** papszIter = poGDS->papszPrj; const char* pszRet = ""; while(*papszIter) { if (STARTS_WITH_CI(*papszIter, "Zunits")) { char** papszTokens = CSLTokenizeString(*papszIter); if (CSLCount(papszTokens) == 2) { if (EQUAL(papszTokens[1], "FEET")) pszRet = "ft"; else if (EQUAL(papszTokens[1], "METERS")) pszRet = "m"; } CSLDestroy(papszTokens); break; } papszIter ++; } return pszRet;}
开发者ID:ryandavid,项目名称:rotobox,代码行数:31,
示例2: CSLTokenizeStringGBool MIDDATAFile::IsValidFeature(const char *pszString){ char **papszToken ; papszToken = CSLTokenizeString(pszString); // printf("%s/n",pszString); if (CSLCount(papszToken) == 0) { CSLDestroy(papszToken); return FALSE; } if (EQUAL(papszToken[0],"NONE") || EQUAL(papszToken[0],"POINT") || EQUAL(papszToken[0],"LINE") || EQUAL(papszToken[0],"PLINE") || EQUAL(papszToken[0],"REGION") || EQUAL(papszToken[0],"ARC") || EQUAL(papszToken[0],"TEXT") || EQUAL(papszToken[0],"RECT") || EQUAL(papszToken[0],"ROUNDRECT") || EQUAL(papszToken[0],"ELLIPSE") || EQUAL(papszToken[0],"MULTIPOINT")|| EQUAL(papszToken[0],"COLLECTION") ) { CSLDestroy(papszToken); return TRUE; } CSLDestroy(papszToken); return FALSE;}
开发者ID:drownedout,项目名称:datamap,代码行数:29,
示例3: OSR_GDSstatic CPLString OSR_GDS( char **papszNV, const char *pszField, const char *pszDefaultValue ){ if( papszNV == nullptr || papszNV[0] == nullptr ) return pszDefaultValue; int iLine = 0; // Used after for. for( ; papszNV[iLine] != nullptr && !EQUALN(papszNV[iLine],pszField,strlen(pszField)); iLine++ ) {} if( papszNV[iLine] == nullptr ) return pszDefaultValue; else { char **papszTokens = CSLTokenizeString(papszNV[iLine]); CPLString osResult; if( CSLCount(papszTokens) > 1 ) osResult = papszTokens[1]; else osResult = pszDefaultValue; CSLDestroy(papszTokens); return osResult; }}
开发者ID:hdfeos,项目名称:gdal,代码行数:29,
示例4: CheckExtensionConsistencyvoid CheckExtensionConsistency(const char* pszDestFilename, const char* pszDriverName){ char* pszDestExtension = CPLStrdup(CPLGetExtension(pszDestFilename)); if (pszDestExtension[0] != '/0') { int nDriverCount = GDALGetDriverCount(); CPLString osConflictingDriverList; for(int i=0;i<nDriverCount;i++) { GDALDriverH hDriver = GDALGetDriver(i); const char* pszDriverExtensions = GDALGetMetadataItem( hDriver, GDAL_DMD_EXTENSIONS, NULL ); if( pszDriverExtensions ) { char** papszTokens = CSLTokenizeString( pszDriverExtensions ); for(int j=0; papszTokens[j]; j++) { const char* pszDriverExtension = papszTokens[j]; if (EQUAL(pszDestExtension, pszDriverExtension)) { if (GDALGetDriverByName(pszDriverName) != hDriver) { if (osConflictingDriverList.size()) osConflictingDriverList += ", "; osConflictingDriverList += GDALGetDriverShortName(hDriver); } else { /* If the request driver allows the used extension, then */ /* just stop iterating now */ osConflictingDriverList = ""; break; } } } CSLDestroy(papszTokens); } } if (osConflictingDriverList.size()) { fprintf(stderr, "Warning: The target file has a '%s' extension, which is normally used by the %s driver%s,/n" "but the requested output driver is %s. Is it really what you want ?/n", pszDestExtension, osConflictingDriverList.c_str(), strchr(osConflictingDriverList.c_str(), ',') ? "s" : "", pszDriverName); } } CPLFree(pszDestExtension);}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:54,
示例5: atoiCPLErr VRTKernelFilteredSource::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath, void* pUniqueHandle, std::map<CPLString, GDALDataset*>& oMapSharedSources ){ { const CPLErr eErr = VRTFilteredSource::XMLInit( psTree, pszVRTPath, pUniqueHandle, oMapSharedSources ); if( eErr != CE_None ) return eErr; } const int nNewKernelSize = atoi(CPLGetXMLValue(psTree,"Kernel.Size","0")); if( nNewKernelSize == 0 ) return CE_None; char **papszCoefItems = CSLTokenizeString( CPLGetXMLValue(psTree,"Kernel.Coefs","") ); const int nCoefs = CSLCount(papszCoefItems); const bool bSquare = nCoefs == nNewKernelSize * nNewKernelSize; const bool bSeparable = nCoefs == nNewKernelSize && nCoefs != 1; if( !bSquare && !bSeparable ) { CSLDestroy( papszCoefItems ); CPLError( CE_Failure, CPLE_AppDefined, "Got wrong number of filter kernel coefficients (%s). " "Expected %d or %d, got %d.", CPLGetXMLValue(psTree,"Kernel.Coefs",""), nNewKernelSize * nNewKernelSize, nNewKernelSize, nCoefs ); return CE_Failure; } double *padfNewCoefs = static_cast<double *>( CPLMalloc( sizeof(double) * nCoefs ) ); for( int i = 0; i < nCoefs; i++ ) padfNewCoefs[i] = CPLAtof(papszCoefItems[i]); const CPLErr eErr = SetKernel( nNewKernelSize, bSeparable, padfNewCoefs ); CPLFree( padfNewCoefs ); CSLDestroy( papszCoefItems ); SetNormalized( atoi(CPLGetXMLValue(psTree,"Kernel.normalized","0")) ); return eErr;}
开发者ID:OSGeo,项目名称:gdal,代码行数:53,
示例6: CSLTokenizeStringstd::vector<double>OGRDXFWriterLayer::PrepareLineTypeDefinition( OGRStylePen *poPen ){/* -------------------------------------------------------------------- *//* Fetch pattern. *//* -------------------------------------------------------------------- */ GBool bDefault; const char *pszPattern = poPen->Pattern( bDefault ); if( bDefault || strlen(pszPattern) == 0 ) return std::vector<double>();/* -------------------------------------------------------------------- *//* Split into pen up / pen down bits. *//* -------------------------------------------------------------------- */ char **papszTokens = CSLTokenizeString(pszPattern); std::vector<double> adfWeightTokens; for( int i = 0; papszTokens != nullptr && papszTokens[i] != nullptr; i++ ) { const char *pszToken = papszTokens[i]; CPLString osAmount; CPLString osDXFEntry; // Split amount and unit. const char *pszUnit = pszToken; // Used after for. for( ; strchr( "0123456789.", *pszUnit) != nullptr; pszUnit++ ) {} osAmount.assign(pszToken,(int) (pszUnit-pszToken)); // If the unit is other than 'g' we really should be trying to // do some type of transformation - but what to do? Pretty hard. // Even entries are "pen down" represented as positive in DXF. // "Pen up" entries (gaps) are represented as negative. if( i%2 == 0 ) adfWeightTokens.push_back( CPLAtof( osAmount ) ); else adfWeightTokens.push_back( -CPLAtof( osAmount ) ); } CSLDestroy( papszTokens ); return adfWeightTokens;}
开发者ID:OSGeo,项目名称:gdal,代码行数:48,
示例7: whilevoid OGRXPlaneNavReader::Read(){ const char* pszLine = NULL; while( (pszLine = CPLReadLineL(fp)) != NULL ) { papszTokens = CSLTokenizeString(pszLine); nTokens = CSLCount(papszTokens); nLineNumber++; if (nTokens == 1 && strcmp(papszTokens[0], "99") == 0) { CSLDestroy(papszTokens); papszTokens = NULL; bEOF = true; return; } else if( nTokens == 0 || !assertMinCol(9) ) { CSLDestroy(papszTokens); papszTokens = NULL; continue; } const int nType = atoi(papszTokens[0]); if (!((nType >= NAVAID_NDB && nType <= NAVAID_IM) || nType == NAVAID_DME_COLOC || nType == NAVAID_DME_STANDALONE)) { CPLDebug("XPlane", "Line %d : bad feature code '%s'", nLineNumber, papszTokens[0]); CSLDestroy(papszTokens); papszTokens = NULL; continue; } ParseRecord(nType); CSLDestroy(papszTokens); papszTokens = NULL; if( poInterestLayer && !poInterestLayer->IsEmpty() ) return; } papszTokens = NULL; bEOF = true;}
开发者ID:ryandavid,项目名称:rotobox,代码行数:47,
示例8: atoiCPLErr VRTKernelFilteredSource::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath ){ CPLErr eErr = VRTFilteredSource::XMLInit( psTree, pszVRTPath ); int nNewKernelSize, i, nCoefs; double *padfNewCoefs; if( eErr != CE_None ) return eErr; nNewKernelSize = atoi(CPLGetXMLValue(psTree,"Kernel.Size","0")); if( nNewKernelSize == 0 ) return CE_None; char **papszCoefItems = CSLTokenizeString( CPLGetXMLValue(psTree,"Kernel.Coefs","") ); nCoefs = CSLCount(papszCoefItems); if( nCoefs != nNewKernelSize * nNewKernelSize ) { CSLDestroy( papszCoefItems ); CPLError( CE_Failure, CPLE_AppDefined, "Got wrong number of filter kernel coefficients (%s)./n" "Expected %d, got %d.", CPLGetXMLValue(psTree,"Kernel.Coefs",""), nNewKernelSize * nNewKernelSize, nCoefs ); return CE_Failure; } padfNewCoefs = (double *) CPLMalloc(sizeof(double) * nCoefs); for( i = 0; i < nCoefs; i++ ) padfNewCoefs[i] = CPLAtof(papszCoefItems[i]); eErr = SetKernel( nNewKernelSize, padfNewCoefs ); CPLFree( padfNewCoefs ); CSLDestroy( papszCoefItems ); SetNormalized( atoi(CPLGetXMLValue(psTree,"Kernel.normalized","0")) ); return eErr;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:46,
示例9: whilechar *PAuxDataset::PCI2WKT( const char *pszGeosys, const char *pszProjParms ){ OGRSpatialReference oSRS; while( *pszGeosys == ' ' ) pszGeosys++;/* -------------------------------------------------------------------- *//* Parse projection parameters array. *//* -------------------------------------------------------------------- */ double adfProjParms[16]; memset( adfProjParms, 0, sizeof(adfProjParms) ); if( pszProjParms != NULL ) { char **papszTokens; int i; papszTokens = CSLTokenizeString( pszProjParms ); for( i=0; papszTokens != NULL && papszTokens[i] != NULL && i < 16; i++) adfProjParms[i] = atof(papszTokens[i]); CSLDestroy( papszTokens ); } /* -------------------------------------------------------------------- *//* Convert to SRS. *//* -------------------------------------------------------------------- */ if( oSRS.importFromPCI( pszGeosys, NULL, adfProjParms ) == OGRERR_NONE ) { char *pszResult = NULL; oSRS.exportToWkt( &pszResult ); return pszResult; } else return NULL;}
开发者ID:samalone,项目名称:gdal-ios,代码行数:43,
示例10: DoesDriverHandleExtensionstatic bool DoesDriverHandleExtension( GDALDriverH hDriver, const char* pszExt ){ bool bRet = false; const char* pszDriverExtensions = GDALGetMetadataItem( hDriver, GDAL_DMD_EXTENSIONS, NULL ); if( pszDriverExtensions ) { char** papszTokens = CSLTokenizeString( pszDriverExtensions ); for(int j=0; papszTokens[j]; j++) { if( EQUAL(pszExt, papszTokens[j]) ) { bRet = true; break; } } CSLDestroy(papszTokens); } return bRet;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:20,
示例11: whilechar *PAuxDataset::PCI2WKT( const char *pszGeosys, const char *pszProjParms ){ while( *pszGeosys == ' ' ) pszGeosys++;/* -------------------------------------------------------------------- *//* Parse projection parameters array. *//* -------------------------------------------------------------------- */ double adfProjParms[16] = { 0.0 }; if( pszProjParms != nullptr ) { char **papszTokens = CSLTokenizeString( pszProjParms ); for( int i = 0; i < 16 && papszTokens != nullptr && papszTokens[i] != nullptr; i++ ) adfProjParms[i] = CPLAtof(papszTokens[i]); CSLDestroy( papszTokens ); }/* -------------------------------------------------------------------- *//* Convert to SRS. *//* -------------------------------------------------------------------- */ OGRSpatialReference oSRS; if( oSRS.importFromPCI( pszGeosys, nullptr, adfProjParms ) == OGRERR_NONE ) { char *pszResult = nullptr; oSRS.exportToWkt( &pszResult ); return pszResult; } return nullptr;}
开发者ID:hdfeos,项目名称:gdal,代码行数:39,
示例12: CSLTokenizeStringOGRLayer* OGRTABDataSource::ExecuteSQL( const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect ){ char **papszTokens = CSLTokenizeString(pszStatement); if( CSLCount(papszTokens) == 6 && EQUAL(papszTokens[0], "CREATE") && EQUAL(papszTokens[1], "INDEX") && EQUAL(papszTokens[2], "ON") && EQUAL(papszTokens[4], "USING") ) { IMapInfoFile* poLayer = dynamic_cast<IMapInfoFile*>( GetLayerByName(papszTokens[3])); if( poLayer == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "`%s' failed failed, no such layer as `%s'.", pszStatement, papszTokens[3]); CSLDestroy(papszTokens); return nullptr; } int nFieldIdx = poLayer->GetLayerDefn()->GetFieldIndex(papszTokens[5]); CSLDestroy(papszTokens); if( nFieldIdx < 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "`%s' failed, field not found.", pszStatement); return nullptr; } poLayer->SetFieldIndexed(nFieldIdx); return nullptr; } CSLDestroy(papszTokens); return GDALDataset::ExecuteSQL(pszStatement, poSpatialFilter, pszDialect);}
开发者ID:ksshannon,项目名称:gdal,代码行数:37,
示例13: whilevoid OGRXPlaneFixReader::Read(){ const char* pszLine; while((pszLine = CPLReadLine(fp)) != NULL) { papszTokens = CSLTokenizeString(pszLine); nTokens = CSLCount(papszTokens); nLineNumber ++; if (nTokens == 1 && strcmp(papszTokens[0], "99") == 0) { CSLDestroy(papszTokens); papszTokens = NULL; bEOF = TRUE; return; } else if (nTokens == 0 || assertMinCol(3) == FALSE) { CSLDestroy(papszTokens); papszTokens = NULL; continue; } ParseRecord(); CSLDestroy(papszTokens); papszTokens = NULL; if (poInterestLayer && poInterestLayer->IsEmpty() == FALSE) return; } papszTokens = NULL; bEOF = TRUE;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:36,
示例14: CPLAssertint OGRGPSBabelDataSource::Open( const char * pszDatasourceName, const char* pszGPSBabelDriverNameIn, char** papszOpenOptionsIn ){ if (!STARTS_WITH_CI(pszDatasourceName, "GPSBABEL:")) { CPLAssert(pszGPSBabelDriverNameIn); pszGPSBabelDriverName = CPLStrdup(pszGPSBabelDriverNameIn); pszFilename = CPLStrdup(pszDatasourceName); } else { if( CSLFetchNameValue(papszOpenOptionsIn, "FILENAME") ) pszFilename = CPLStrdup(CSLFetchNameValue(papszOpenOptionsIn, "FILENAME")); if( CSLFetchNameValue(papszOpenOptionsIn, "GPSBABEL_DRIVER") ) { if( pszFilename == NULL ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing FILENAME"); return FALSE; } pszGPSBabelDriverName = CPLStrdup(CSLFetchNameValue(papszOpenOptionsIn, "DRIVER")); /* A bit of validation to avoid command line injection */ if (!IsValidDriverName(pszGPSBabelDriverName)) return FALSE; } } pszName = CPLStrdup( pszDatasourceName ); bool bExplicitFeatures = false; bool bWaypoints = true; bool bTracks = true; bool bRoutes = true; if (pszGPSBabelDriverName == NULL) { const char* pszSep = strchr(pszDatasourceName + 9, ':'); if (pszSep == NULL) { CPLError( CE_Failure, CPLE_AppDefined, "Wrong syntax. Expected GPSBabel:driver_name:file_name"); return FALSE; } pszGPSBabelDriverName = CPLStrdup(pszDatasourceName + 9); *(strchr(pszGPSBabelDriverName, ':')) = '/0'; /* A bit of validation to avoid command line injection */ if (!IsValidDriverName(pszGPSBabelDriverName)) return FALSE; /* Parse optional features= option */ if (STARTS_WITH_CI(pszSep+1, "features=")) { const char* pszNextSep = strchr(pszSep+1, ':'); if (pszNextSep == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Wrong syntax. Expected " "GPSBabel:driver_name[,options]*:[" "features=waypoints,tracks,routes:]file_name"); return FALSE; } char* pszFeatures = CPLStrdup(pszSep+1+9); *strchr(pszFeatures, ':') = 0; char** papszTokens = CSLTokenizeString(pszFeatures); char** papszIter = papszTokens; bool bErr = false; bExplicitFeatures = true; bWaypoints = false; bTracks = false; bRoutes = false; while(papszIter && *papszIter) { if (EQUAL(*papszIter, "waypoints")) bWaypoints = true; else if (EQUAL(*papszIter, "tracks")) bTracks = true; else if (EQUAL(*papszIter, "routes")) bRoutes = true; else { CPLError( CE_Failure, CPLE_AppDefined, "Wrong value for 'features' options"); bErr = true; } papszIter++; } CSLDestroy(papszTokens); CPLFree(pszFeatures); if (bErr)//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例15: GetLayerByNameOGRLayer * OGRShapeDataSource::ExecuteSQL( const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect ){ /* ==================================================================== */ /* Handle command to drop a spatial index. */ /* ==================================================================== */ if( EQUALN(pszStatement, "REPACK ", 7) ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName( pszStatement + 7 ); if( poLayer != NULL ) poLayer->Repack(); else { CPLError( CE_Failure, CPLE_AppDefined, "No such layer as '%s' in REPACK.", pszStatement + 7 ); } return NULL; } /* ==================================================================== */ /* Handle command to drop a spatial index. */ /* ==================================================================== */ if( EQUALN(pszStatement, "DROP SPATIAL INDEX ON ", 22) ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName( pszStatement + 22 ); if( poLayer != NULL ) poLayer->DropSpatialIndex(); else { CPLError( CE_Failure, CPLE_AppDefined, "No such layer as '%s' in DROP SPATIAL INDEX.", pszStatement + 19 ); } return NULL; } /* ==================================================================== */ /* Handle all comands except spatial index creation generically. */ /* ==================================================================== */ if( !EQUALN(pszStatement,"CREATE SPATIAL INDEX ON ",24) ) return OGRDataSource::ExecuteSQL( pszStatement, poSpatialFilter, pszDialect ); /* -------------------------------------------------------------------- */ /* Parse into keywords. */ /* -------------------------------------------------------------------- */ char **papszTokens = CSLTokenizeString( pszStatement ); if( CSLCount(papszTokens) < 5 || !EQUAL(papszTokens[0],"CREATE") || !EQUAL(papszTokens[1],"SPATIAL") || !EQUAL(papszTokens[2],"INDEX") || !EQUAL(papszTokens[3],"ON") || CSLCount(papszTokens) > 7 || (CSLCount(papszTokens) == 7 && !EQUAL(papszTokens[5],"DEPTH")) ) { CSLDestroy( papszTokens ); CPLError( CE_Failure, CPLE_AppDefined, "Syntax error in CREATE SPATIAL INDEX command./n" "Was '%s'/n" "Should be of form 'CREATE SPATIAL INDEX ON <table> [DEPTH <n>]'", pszStatement ); return NULL; } /* -------------------------------------------------------------------- */ /* Get depth if provided. */ /* -------------------------------------------------------------------- */ int nDepth = 0; if( CSLCount(papszTokens) == 7 ) nDepth = atoi(papszTokens[6]); /* -------------------------------------------------------------------- */ /* What layer are we operating on. */ /* -------------------------------------------------------------------- */ OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName(papszTokens[4]); CSLDestroy( papszTokens ); if( poLayer == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s not recognised.", papszTokens[4] ); return NULL; } poLayer->CreateSpatialIndex( nDepth ); return NULL;}
开发者ID:RyanHun,项目名称:World-Wind-Java,代码行数:96,
示例16: main//.........这里部分代码省略........./* Create a transformation object from the source to *//* destination coordinate system. *//* -------------------------------------------------------------------- */ if( nGCPCount != 0 && nOrder == -1 ) { pfnTransformer = GDALTPSTransform; hTransformArg = GDALCreateTPSTransformer( nGCPCount, pasGCPs, FALSE ); } else if( nGCPCount != 0 ) { pfnTransformer = GDALGCPTransform; hTransformArg = GDALCreateGCPTransformer( nGCPCount, pasGCPs, nOrder, FALSE ); } else { pfnTransformer = GDALGenImgProjTransform; hTransformArg = GDALCreateGenImgProjTransformer2( hSrcDS, hDstDS, papszTO ); } CSLDestroy( papszTO ); if( hTransformArg == NULL ) { exit( 1 ); }/* -------------------------------------------------------------------- *//* Read points from stdin, transform and write to stdout. *//* -------------------------------------------------------------------- */ while( !feof(stdin) ) { char szLine[1024]; if( fgets( szLine, sizeof(szLine)-1, stdin ) == NULL ) break; char **papszTokens = CSLTokenizeString(szLine); double dfX, dfY, dfZ = 0.0; int bSuccess = TRUE; if( CSLCount(papszTokens) < 2 ) { CSLDestroy(papszTokens); continue; } dfX = atof(papszTokens[0]); dfY = atof(papszTokens[1]); if( CSLCount(papszTokens) >= 3 ) dfZ = atof(papszTokens[2]); if( pfnTransformer( hTransformArg, bInverse, 1, &dfX, &dfY, &dfZ, &bSuccess ) && bSuccess ) { printf( "%.15g %.15g %.15g/n", dfX, dfY, dfZ ); } else { printf( "transformation failed./n" ); } CSLDestroy(papszTokens); } if( nGCPCount != 0 && nOrder == -1 ) { GDALDestroyTPSTransformer(hTransformArg); } else if( nGCPCount != 0 ) { GDALDestroyGCPTransformer(hTransformArg); } else { GDALDestroyGenImgProjTransformer(hTransformArg); } if (nGCPCount) { GDALDeinitGCPs( nGCPCount, pasGCPs ); CPLFree( pasGCPs ); } if (hSrcDS) GDALClose(hSrcDS); if (hDstDS) GDALClose(hDstDS); GDALDumpOpenDatasets( stderr ); GDALDestroyDriverManager(); CSLDestroy( argv ); return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例17: GetLayerByNameOGRLayer * OGRShapeDataSource::ExecuteSQL( const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect ){/* ==================================================================== *//* Handle command to drop a spatial index. *//* ==================================================================== */ if( EQUALN(pszStatement, "REPACK ", 7) ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName( pszStatement + 7 ); if( poLayer != NULL ) { if( poLayer->Repack() != OGRERR_NONE ) { CPLError( CE_Failure, CPLE_AppDefined, "REPACK of layer '%s' failed.", pszStatement + 7 ); } } else { CPLError( CE_Failure, CPLE_AppDefined, "No such layer as '%s' in REPACK.", pszStatement + 7 ); } return NULL; }/* ==================================================================== *//* Handle command to shrink columns to their minimum size. *//* ==================================================================== */ if( EQUALN(pszStatement, "RESIZE ", 7) ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName( pszStatement + 7 ); if( poLayer != NULL ) poLayer->ResizeDBF(); else { CPLError( CE_Failure, CPLE_AppDefined, "No such layer as '%s' in RESIZE.", pszStatement + 7 ); } return NULL; }/* ==================================================================== *//* Handle command to recompute extent *//* ==================================================================== */ if( EQUALN(pszStatement, "RECOMPUTE EXTENT ON ", 20) ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName( pszStatement + 20 ); if( poLayer != NULL ) poLayer->RecomputeExtent(); else { CPLError( CE_Failure, CPLE_AppDefined, "No such layer as '%s' in RECOMPUTE EXTENT.", pszStatement + 20 ); } return NULL; } /* ==================================================================== *//* Handle command to drop a spatial index. *//* ==================================================================== */ if( EQUALN(pszStatement, "DROP SPATIAL INDEX ON ", 22) ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName( pszStatement + 22 ); if( poLayer != NULL ) poLayer->DropSpatialIndex(); else { CPLError( CE_Failure, CPLE_AppDefined, "No such layer as '%s' in DROP SPATIAL INDEX.", pszStatement + 22 ); } return NULL; } /* ==================================================================== *//* Handle all comands except spatial index creation generically. *//* ==================================================================== */ if( !EQUALN(pszStatement,"CREATE SPATIAL INDEX ON ",24) ) { char **papszTokens = CSLTokenizeString( pszStatement ); if( CSLCount(papszTokens) >=4 && (EQUAL(papszTokens[0],"CREATE") || EQUAL(papszTokens[0],"DROP")) && EQUAL(papszTokens[1],"INDEX") && EQUAL(papszTokens[2],"ON") ) { OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName(papszTokens[3]);//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例18: GDALSimpleWarpRemappingstatic voidGDALSimpleWarpRemapping( int nBandCount, GByte **papabySrcData, int nSrcXSize, int nSrcYSize, char **papszWarpOptions ){/* ==================================================================== *//* Process any and all single value REMAP commands. *//* ==================================================================== */ char **papszRemaps = CSLFetchNameValueMultiple( papszWarpOptions, "REMAP" ); for( int iRemap = 0; iRemap < CSLCount(papszRemaps); iRemap++ ) {/* -------------------------------------------------------------------- *//* What are the pixel values to map from and to? *//* -------------------------------------------------------------------- */ char **papszTokens = CSLTokenizeString( papszRemaps[iRemap] ); if( CSLCount(papszTokens) != 2 ) { CPLError( CE_Warning, CPLE_AppDefined, "Ill formed REMAP `%s' ignored in GDALSimpleWarpRemapping()", papszRemaps[iRemap] ); CSLDestroy( papszTokens ); continue; } const int nFromValue = atoi(papszTokens[0]); const int nToValue = atoi(papszTokens[1]); CSLDestroy( papszTokens );/* -------------------------------------------------------------------- *//* Pass over each band searching for matches. *//* -------------------------------------------------------------------- */ for( int iBand = 0; iBand < nBandCount; iBand++ ) { GByte *pabyData = papabySrcData[iBand]; int nPixelCount = nSrcXSize * nSrcYSize; while( nPixelCount != 0 ) { if( *pabyData == nFromValue ) *pabyData = static_cast<GByte>( nToValue ); pabyData++; nPixelCount--; } } } CSLDestroy( papszRemaps );/* ==================================================================== *//* Process any and all REMAP_MULTI commands. *//* ==================================================================== */ papszRemaps = CSLFetchNameValueMultiple( papszWarpOptions, "REMAP_MULTI" ); for( int iRemap = 0; iRemap < CSLCount(papszRemaps); iRemap++ ) {/* -------------------------------------------------------------------- *//* What are the pixel values to map from and to? *//* -------------------------------------------------------------------- */ char **papszTokens = CSLTokenizeString( papszRemaps[iRemap] ); if( CSLCount(papszTokens) % 2 == 1 || CSLCount(papszTokens) == 0 || CSLCount(papszTokens) > nBandCount * 2 ) { CPLError( CE_Warning, CPLE_AppDefined, "Ill formed REMAP_MULTI `%s' ignored in GDALSimpleWarpRemapping()", papszRemaps[iRemap] ); CSLDestroy( papszTokens ); continue; } const int nMapBandCount = CSLCount(papszTokens) / 2; int *panFromValue = static_cast<int *>( CPLMalloc(sizeof(int) * nMapBandCount ) ); int *panToValue = static_cast<int *>( CPLMalloc(sizeof(int) * nMapBandCount ) ); for( int iBand = 0; iBand < nMapBandCount; iBand++ ) { panFromValue[iBand] = atoi(papszTokens[iBand]); panToValue[iBand] = atoi(papszTokens[iBand+nMapBandCount]); } CSLDestroy( papszTokens );/* -------------------------------------------------------------------- *//* Search for matching values to replace. *//* -------------------------------------------------------------------- */ const int nPixelCount = nSrcXSize * nSrcYSize;//.........这里部分代码省略.........
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例19: main//.........这里部分代码省略........./* -------------------------------------------------------------------- *//* If histogram equalization is requested, do it now. *//* -------------------------------------------------------------------- */ if( EQUAL(pszMethod,"equalize") ) { ComputeEqualizationLUTs( hDataset, nLUTBins, &padfScaleMin, &padfScaleMax, &papanLUTs, pfnProgress ); }/* -------------------------------------------------------------------- *//* If we have a config file, assume it is for input and read *//* it. *//* -------------------------------------------------------------------- */ else if( pszConfigFile != NULL ) { char **papszLines = CSLLoad( pszConfigFile ); if( CSLCount(papszLines) == 0 ) exit( 1 ); if( CSLCount(papszLines) != nBandCount ) { fprintf( stderr, "Did not get %d lines in config file as expected./n", nBandCount ); exit( 1 ); } padfScaleMin = (double *) CPLCalloc(nBandCount,sizeof(double)); padfScaleMax = (double *) CPLCalloc(nBandCount,sizeof(double)); for( iBand = 0; iBand < nBandCount; iBand++ ) { int iLUT; char **papszTokens = CSLTokenizeString( papszLines[iBand] ); if( CSLCount(papszTokens) < 3 || atoi(papszTokens[0]) != iBand+1 ) { fprintf( stderr, "Line %d seems to be corrupt./n", iBand+1 ); exit( 1 ); } // Process scale min/max padfScaleMin[iBand] = atof(papszTokens[1]); padfScaleMax[iBand] = atof(papszTokens[2]); if( CSLCount(papszTokens) == 3 ) continue; // process lut if( iBand == 0 ) { nLUTBins = CSLCount(papszTokens) - 3; papanLUTs = (int **) CPLCalloc(sizeof(int*),nBandCount); } papanLUTs[iBand] = (int *) CPLCalloc(nLUTBins,sizeof(int)); for( iLUT = 0; iLUT < nLUTBins; iLUT++ ) papanLUTs[iBand][iLUT] = atoi(papszTokens[iLUT+3]); CSLDestroy( papszTokens ); } }
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:66,
示例20: VSIFOpenLGDALDataset *DOQ2Dataset::Open( GDALOpenInfo * poOpenInfo ){ int nWidth=0, nHeight=0, nBandStorage=0, nBandTypes=0; /* -------------------------------------------------------------------- *//* We assume the user is pointing to the binary (ie. .bil) file. *//* -------------------------------------------------------------------- */ if( poOpenInfo->nHeaderBytes < 212 ) return NULL; int nLineCount = 0; const char *pszLine; int nBytesPerPixel=0; const char *pszDatumLong=NULL, *pszDatumShort=NULL; const char *pszUnits=NULL; char *pszQuadname = NULL; char *pszQuadquad = NULL; char *pszState = NULL; int nZone=0, nProjType=0; int nSkipBytes=0, nBytesPerLine, i, nBandCount = 0; double dfULXMap=0.0, dfULYMap = 0.0; double dfXDim=0.0, dfYDim=0.0; char **papszMetadata = NULL; if(! EQUALN((const char *) poOpenInfo->pabyHeader, "BEGIN_USGS_DOQ_HEADER", 21) ) return NULL; VSILFILE* fp = VSIFOpenL(poOpenInfo->pszFilename, "rb"); if (fp == NULL) return NULL; /* read and discard the first line */ pszLine = CPLReadLineL( fp ); while( (pszLine = CPLReadLineL( fp )) != NULL ) { char **papszTokens; nLineCount++; if( EQUAL(pszLine,"END_USGS_DOQ_HEADER") ) break; papszTokens = CSLTokenizeString( pszLine ); if( CSLCount( papszTokens ) < 2 ) { CSLDestroy( papszTokens ); break; } if( EQUAL(papszTokens[0],"SAMPLES_AND_LINES") && CSLCount(papszTokens) >= 3 ) { nWidth = atoi(papszTokens[1]); nHeight = atoi(papszTokens[2]); } else if( EQUAL(papszTokens[0],"BYTE_COUNT") ) { nSkipBytes = atoi(papszTokens[1]); } else if( EQUAL(papszTokens[0],"XY_ORIGIN") && CSLCount(papszTokens) >= 3 ) { dfULXMap = atof(papszTokens[1]); dfULYMap = atof(papszTokens[2]); } else if( EQUAL(papszTokens[0],"HORIZONTAL_RESOLUTION") ) { dfXDim = dfYDim = atof(papszTokens[1]); } else if( EQUAL(papszTokens[0],"BAND_ORGANIZATION") ) { if( EQUAL(papszTokens[1],"SINGLE FILE") ) nBandStorage = 1; if( EQUAL(papszTokens[1],"BSQ") ) nBandStorage = 1; if( EQUAL(papszTokens[1],"BIL") ) nBandStorage = 1; if( EQUAL(papszTokens[1],"BIP") ) nBandStorage = 4; } else if( EQUAL(papszTokens[0],"BAND_CONTENT") ) { if( EQUAL(papszTokens[1],"BLACK&WHITE") ) nBandTypes = 1; else if( EQUAL(papszTokens[1],"COLOR") ) nBandTypes = 5; else if( EQUAL(papszTokens[1],"RGB") ) nBandTypes = 5; else if( EQUAL(papszTokens[1],"RED") ) nBandTypes = 5; else if( EQUAL(papszTokens[1],"GREEN") ) nBandTypes = 5; else if( EQUAL(papszTokens[1],"BLUE") ) nBandTypes = 5; nBandCount++; } else if( EQUAL(papszTokens[0],"BITS_PER_PIXEL") ) {//.........这里部分代码省略.........
开发者ID:samalone,项目名称:gdal-ios,代码行数:101,
示例21: atoiCPLErr VRTWarpedDataset::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath ){ CPLErr eErr;/* -------------------------------------------------------------------- *//* Initialize blocksize before calling sub-init so that the *//* band initializers can get it from the dataset object when *//* they are created. *//* -------------------------------------------------------------------- */ nBlockXSize = atoi(CPLGetXMLValue(psTree,"BlockXSize","512")); nBlockYSize = atoi(CPLGetXMLValue(psTree,"BlockYSize","128"));/* -------------------------------------------------------------------- *//* Initialize all the general VRT stuff. This will even *//* create the VRTWarpedRasterBands and initialize them. *//* -------------------------------------------------------------------- */ eErr = VRTDataset::XMLInit( psTree, pszVRTPath ); if( eErr != CE_None ) return eErr;/* -------------------------------------------------------------------- *//* Find the GDALWarpOptions XML tree. *//* -------------------------------------------------------------------- */ CPLXMLNode *psOptionsTree; psOptionsTree = CPLGetXMLNode( psTree, "GDALWarpOptions" ); if( psOptionsTree == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Count not find required GDALWarpOptions in XML." ); return CE_Failure; }/* -------------------------------------------------------------------- *//* Adjust the SourceDataset in the warp options to take into *//* account that it is relative to the VRT if appropriate. *//* -------------------------------------------------------------------- */ int bRelativeToVRT = atoi(CPLGetXMLValue(psOptionsTree, "SourceDataset.relativeToVRT", "0" )); const char *pszRelativePath = CPLGetXMLValue(psOptionsTree, "SourceDataset", "" ); char *pszAbsolutePath; if( bRelativeToVRT ) pszAbsolutePath = CPLStrdup(CPLProjectRelativeFilename( pszVRTPath, pszRelativePath ) ); else pszAbsolutePath = CPLStrdup(pszRelativePath); CPLSetXMLValue( psOptionsTree, "SourceDataset", pszAbsolutePath ); CPLFree( pszAbsolutePath );/* -------------------------------------------------------------------- *//* And instantiate the warp options, and corresponding warp *//* operation. *//* -------------------------------------------------------------------- */ GDALWarpOptions *psWO; psWO = GDALDeserializeWarpOptions( psOptionsTree ); if( psWO == NULL ) return CE_Failure; this->eAccess = GA_Update; psWO->hDstDS = this;/* -------------------------------------------------------------------- *//* Instantiate the warp operation. *//* -------------------------------------------------------------------- */ poWarper = new GDALWarpOperation(); eErr = poWarper->Initialize( psWO ); if( eErr != CE_None) {/* -------------------------------------------------------------------- *//* We are responsible for cleaning up the transformer outselves. *//* -------------------------------------------------------------------- */ if( psWO->pTransformerArg != NULL ) GDALDestroyTransformer( psWO->pTransformerArg ); } GDALDestroyWarpOptions( psWO ); if( eErr != CE_None ) { delete poWarper; poWarper = NULL; }/* -------------------------------------------------------------------- *//* Generate overviews, if appropriate. *//* -------------------------------------------------------------------- */ char **papszTokens = CSLTokenizeString( CPLGetXMLValue( psTree, "OverviewList", "" )); int iOverview; for( iOverview = 0; papszTokens != NULL && papszTokens[iOverview] != NULL;//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例22: whilevoid OGRUKOOAP190Layer::ParseHeaders(){ while(TRUE) { const char* pszLine = CPLReadLine2L(fp,81,NULL); if (pszLine == NULL || EQUALN(pszLine, "EOF", 3)) { break; } int nLineLen = strlen(pszLine); while(nLineLen > 0 && pszLine[nLineLen-1] == ' ') { ((char*)pszLine)[nLineLen-1] = '/0'; nLineLen --; } if (pszLine[0] != 'H') break; if (nLineLen < 33) continue; if (!bUseEastingNorthingAsGeometry && strncmp(pszLine, "H1500", 5) == 0 && poSRS == NULL) { if (strncmp(pszLine + 33 - 1, "WGS84", 5) == 0 || strncmp(pszLine + 33 - 1, "WGS-84", 6) == 0) { poSRS = new OGRSpatialReference(SRS_WKT_WGS84); } else if (strncmp(pszLine + 33 - 1, "WGS72", 5) == 0) { poSRS = new OGRSpatialReference(); poSRS->SetFromUserInput("WGS72"); } } else if (!bUseEastingNorthingAsGeometry && strncmp(pszLine, "H1501", 5) == 0 && poSRS != NULL && nLineLen >= 32 + 6 * 6 + 10) { char aszParams[6][6+1]; char szZ[10+1]; int i; for(i=0;i<6;i++) { ExtractField(aszParams[i], pszLine, 33 - 1 + i * 6, 6); } ExtractField(szZ, pszLine, 33 - 1 + 6 * 6, 10); poSRS->SetTOWGS84(CPLAtof(aszParams[0]), CPLAtof(aszParams[1]), CPLAtof(aszParams[2]), CPLAtof(aszParams[3]), CPLAtof(aszParams[4]), CPLAtof(aszParams[5]), CPLAtof(szZ)); } else if (strncmp(pszLine, "H0200", 5) == 0) { char** papszTokens = CSLTokenizeString(pszLine + 33 - 1); for(int i = 0; papszTokens[i] != NULL; i++) { if (strlen(papszTokens[i]) == 4) { int nVal = atoi(papszTokens[i]); if (nVal >= 1900) { if (nYear != 0 && nYear != nVal) { CPLDebug("SEGUKOOA", "Several years found in H0200. Ignoring them!"); nYear = 0; break; } nYear = nVal; } } } CSLDestroy(papszTokens); } } VSIFSeekL( fp, 0, SEEK_SET );}
开发者ID:drownedout,项目名称:datamap,代码行数:83,
示例23: whilevoid OGRUKOOAP190Layer::ParseHeaders(){ while( true ) { const char* pszLine = CPLReadLine2L(fp,81,nullptr); if (pszLine == nullptr || STARTS_WITH_CI(pszLine, "EOF")) { break; } int nLineLen = static_cast<int>(strlen(pszLine)); while(nLineLen > 0 && pszLine[nLineLen-1] == ' ') { ((char*)pszLine)[nLineLen-1] = '/0'; nLineLen --; } if (pszLine[0] != 'H') break; if (nLineLen < 33) continue; if (!bUseEastingNorthingAsGeometry && STARTS_WITH(pszLine, "H1500") && poSRS == nullptr) { if (STARTS_WITH(pszLine + 33 - 1, "WGS84") || STARTS_WITH(pszLine + 33 - 1, "WGS-84")) { poSRS = new OGRSpatialReference(SRS_WKT_WGS84_LAT_LONG); poSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); } else if (STARTS_WITH(pszLine + 33 - 1, "WGS72")) { poSRS = new OGRSpatialReference(); poSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); poSRS->SetFromUserInput("WGS72"); } } else if (!bUseEastingNorthingAsGeometry && STARTS_WITH(pszLine, "H1501") && poSRS != nullptr && nLineLen >= 32 + 6 * 6 + 10) { char aszParams[6][6+1]; char szZ[10+1]; for( int i = 0; i < 6; i++ ) { ExtractField(aszParams[i], pszLine, 33 - 1 + i * 6, 6); } ExtractField(szZ, pszLine, 33 - 1 + 6 * 6, 10); poSRS->SetTOWGS84(CPLAtof(aszParams[0]), CPLAtof(aszParams[1]), CPLAtof(aszParams[2]), CPLAtof(aszParams[3]), CPLAtof(aszParams[4]), CPLAtof(aszParams[5]), CPLAtof(szZ)); } else if (STARTS_WITH(pszLine, "H0200")) { char** papszTokens = CSLTokenizeString(pszLine + 33 - 1); for(int i = 0; papszTokens[i] != nullptr; i++) { if (strlen(papszTokens[i]) == 4) { int nVal = atoi(papszTokens[i]); if (nVal >= 1900) { if( nYear != 0 && nYear != nVal ) { CPLDebug("SEGUKOOA", "Several years found in H0200. Ignoring them!"); nYear = 0; break; } nYear = nVal; } } } CSLDestroy(papszTokens); } } VSIFSeekL( fp, 0, SEEK_SET );}
开发者ID:OSGeo,项目名称:gdal,代码行数:84,
示例24: STARTS_WITH_CI//.........这里部分代码省略......... 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 ) { delete poDS; return NULL; } char **papszTokens = CSLTokenizeString(pszLine); if( CSLCount(papszTokens) < 3 ) { CPLError( CE_Failure, CPLE_AppDefined, "RawDefinition missing or corrupt in %s.", poOpenInfo->pszFilename ); delete poDS; CSLDestroy( papszTokens ); return NULL; } poDS->nRasterXSize = atoi(papszTokens[0]); poDS->nRasterYSize = atoi(papszTokens[1]); poDS->nBands = atoi(papszTokens[2]); poDS->eAccess = poOpenInfo->eAccess; CSLDestroy( papszTokens ); if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize) || !GDALCheckBandCount(poDS->nBands, FALSE)) { delete poDS; return NULL; }/* -------------------------------------------------------------------- *//* Open the file. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { poDS->fpImage = VSIFOpenL( osTarget, "rb+" );
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:66,
示例25: OGRGeneralCmdLineProcessor//.........这里部分代码省略........./* -------------------------------------------------------------------- */ else if( EQUAL(papszArgv[iArg],"--optfile") ) { const char *pszLine; FILE *fpOptFile; if( iArg + 1 >= nArgc ) { CPLError( CE_Failure, CPLE_AppDefined, "--optfile option given without filename." ); CSLDestroy( papszReturn ); return -1; } fpOptFile = VSIFOpen( papszArgv[iArg+1], "rb" ); if( fpOptFile == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Unable to open optfile '%s'./n%s", papszArgv[iArg+1], VSIStrerror( errno ) ); CSLDestroy( papszReturn ); return -1; } while( (pszLine = CPLReadLine( fpOptFile )) != NULL ) { char **papszTokens; int i; if( pszLine[0] == '#' || strlen(pszLine) == 0 ) continue; papszTokens = CSLTokenizeString( pszLine ); for( i = 0; papszTokens != NULL && papszTokens[i] != NULL; i++) papszReturn = CSLAddString( papszReturn, papszTokens[i] ); CSLDestroy( papszTokens ); } VSIFClose( fpOptFile ); iArg += 1; }/* -------------------------------------------------------------------- *//* --formats *//* -------------------------------------------------------------------- */#ifdef OGR_ENABLED else if( EQUAL(papszArgv[iArg], "--formats") ) { int iDr; printf( "Supported Formats:/n" ); OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar(); for( iDr = 0; iDr < poR->GetDriverCount(); iDr++ ) { OGRSFDriver *poDriver = poR->GetDriver(iDr); if( poDriver->TestCapability( ODrCCreateDataSource ) ) printf( " -> /"%s/" (read/write)/n", poDriver->GetName() ); else printf( " -> /"%s/" (readonly)/n", poDriver->GetName() );
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:67,
示例26: OGRFeatureOGRFeature *OGRHTFPolygonLayer::GetNextRawFeature(){ OGRFeature* poFeature = new OGRFeature(poFeatureDefn); const char* pszLine; OGRLinearRing oLR; int bHastFirstCoord = FALSE; double dfFirstEasting = 0, dfFirstNorthing = 0; double dfIslandEasting = 0, dfIslandNorthing = 0; int bInIsland = FALSE; OGRPolygon* poPoly = new OGRPolygon(); while( (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL) { if (pszLine[0] == ';') { /* comment */ ; } else if (pszLine[0] == 0) { /* end of polygon is marked by a blank line */ break; } else if (strncmp(pszLine, "POLYGON DESCRIPTION: ", strlen("POLYGON DESCRIPTION: ")) == 0) { poFeature->SetField(0, pszLine + strlen("POLYGON DESCRIPTION: ")); } else if (strncmp(pszLine, "POLYGON IDENTIFIER: ", strlen("POLYGON IDENTIFIER: ")) == 0) { poFeature->SetField(1, pszLine + strlen("POLYGON IDENTIFIER: ")); } else if (strncmp(pszLine, "SEAFLOOR COVERAGE: ", strlen("SEAFLOOR COVERAGE:")) == 0) { const char* pszVal = pszLine + strlen("SEAFLOOR COVERAGE: "); if (*pszVal != '*') poFeature->SetField(2, pszVal); } else if (strncmp(pszLine, "POSITION ACCURACY: ", strlen("POSITION ACCURACY:")) == 0) { const char* pszVal = pszLine + strlen("POSITION ACCURACY: "); if (*pszVal != '*') poFeature->SetField(3, pszVal); } else if (strncmp(pszLine, "DEPTH ACCURACY: ", strlen("DEPTH ACCURACY:")) == 0) { const char* pszVal = pszLine + strlen("DEPTH ACCURACY: "); if (*pszVal != '*') poFeature->SetField(4, pszVal); } else if (strcmp(pszLine, "END OF POLYGON DATA") == 0) { bEOF = TRUE; break; } else { char** papszTokens = CSLTokenizeString(pszLine); if (CSLCount(papszTokens) == 4) { double dfEasting = atof(papszTokens[2]); double dfNorthing = atof(papszTokens[3]); if (!bHastFirstCoord) { bHastFirstCoord = TRUE; dfFirstEasting = dfEasting; dfFirstNorthing = dfNorthing; oLR.addPoint(dfEasting, dfNorthing); } else if (dfFirstEasting == dfEasting && dfFirstNorthing == dfNorthing) { if (!bInIsland) { oLR.addPoint(dfEasting, dfNorthing); poPoly->addRing(&oLR); oLR.empty(); bInIsland = TRUE; } } else if (bInIsland && oLR.getNumPoints() == 0) { dfIslandEasting = dfEasting; dfIslandNorthing = dfNorthing; oLR.addPoint(dfEasting, dfNorthing); } else if (bInIsland && dfIslandEasting == dfEasting && dfIslandNorthing == dfNorthing) { oLR.addPoint(dfEasting, dfNorthing); poPoly->addRing(&oLR); oLR.empty(); } else {//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例27: CPLStrdupGDALRasterizeOptions *GDALRasterizeOptionsNew(char** papszArgv, GDALRasterizeOptionsForBinary* psOptionsForBinary){ GDALRasterizeOptions *psOptions = new GDALRasterizeOptions; psOptions->pszFormat = CPLStrdup("GTiff"); psOptions->pfnProgress = GDALDummyProgress; psOptions->pProgressData = NULL; psOptions->bCreateOutput = FALSE; psOptions->b3D = FALSE; psOptions->bInverse = FALSE; memset(&(psOptions->sEnvelop), 0, sizeof(psOptions->sEnvelop)); psOptions->papszCreationOptions = NULL; psOptions->papszLayers = NULL; psOptions->pszSQL = NULL; psOptions->pszDialect = NULL; psOptions->pszBurnAttribute = NULL; psOptions->pszWHERE = NULL; psOptions->papszRasterizeOptions = NULL; psOptions->dfXRes = 0; psOptions->dfYRes = 0; psOptions->bCreateOutput = FALSE; psOptions->eOutputType = GDT_Float64; psOptions->bNoDataSet = FALSE; psOptions->dfNoData = 0; psOptions->bGotBounds = FALSE; psOptions->nXSize = 0; psOptions->nYSize = 0; psOptions->hSRS = NULL; psOptions->bTargetAlignedPixels = FALSE;/* -------------------------------------------------------------------- *//* Handle command line arguments. *//* -------------------------------------------------------------------- */ int argc = CSLCount(papszArgv); for( int i = 0; i < argc; i++ ) { if( EQUAL(papszArgv[i],"-of") && i < argc-1 ) { ++i; CPLFree(psOptions->pszFormat); psOptions->pszFormat = CPLStrdup(papszArgv[i]); psOptions->bCreateOutput = TRUE; if( psOptionsForBinary ) { psOptionsForBinary->bFormatExplicitlySet = TRUE; } } else if( EQUAL(papszArgv[i],"-q") || EQUAL(papszArgv[i],"-quiet") ) { if( psOptionsForBinary ) psOptionsForBinary->bQuiet = TRUE; } else if( EQUAL(papszArgv[i],"-a") && i < argc-1 ) { CPLFree(psOptions->pszBurnAttribute); psOptions->pszBurnAttribute = CPLStrdup(papszArgv[++i]); } else if( EQUAL(papszArgv[i],"-b") && i < argc-1 ) { if (strchr(papszArgv[i+1], ' ')) { char** papszTokens = CSLTokenizeString( papszArgv[i+1] ); char** papszIter = papszTokens; while(papszIter && *papszIter) { psOptions->anBandList.push_back(atoi(*papszIter)); papszIter ++; } CSLDestroy(papszTokens); i += 1; } else { while(i < argc-1 && ArgIsNumeric(papszArgv[i+1])) { psOptions->anBandList.push_back(atoi(papszArgv[i+1])); i += 1; } } } else if( EQUAL(papszArgv[i],"-3d") ) { psOptions->b3D = TRUE; psOptions->papszRasterizeOptions = CSLSetNameValue( psOptions->papszRasterizeOptions, "BURN_VALUE_FROM", "Z"); } else if( EQUAL(papszArgv[i],"-add") ) { psOptions->papszRasterizeOptions = CSLSetNameValue( psOptions->papszRasterizeOptions, "MERGE_ALG", "ADD"); } else if( EQUAL(papszArgv[i],"-chunkysize") && i < argc-1 ) { psOptions->papszRasterizeOptions = CSLSetNameValue( psOptions->papszRasterizeOptions, "CHUNKYSIZE", papszArgv[++i] ); }//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例28: VSIFSeekL//.........这里部分代码省略......... if (pabyBuffer[i] == '}') { bEOGFound = TRUE; break; } } } } } } if (bEOGFound) { VSIFSeekL(fp, VSIFTellL(fp) - nRead + i + 1, SEEK_SET); e00ReadPtr->iInBufPtr = 0; e00ReadPtr->szInBuf[0] = '/0'; break; } if (nEndPos == 0) break; if ((unsigned int)nRead == nToRead) { memmove(pabyBuffer + nToRead, pabyBuffer, NEEDLE_SIZE); if (nEndPos >= (vsi_l_offset)nToRead) nEndPos -= nToRead; else nEndPos = 0; VSIFSeekL(fp, nEndPos, SEEK_SET); } else break; } CPLFree(pabyBuffer); if (!bEOGFound) return; } const char* pszLine = NULL; bool bPRJFound = false; bool bStatsFound = false; while((pszLine = ReadLine()) != NULL) { if (STARTS_WITH_CI(pszLine, "PRJ 2")) { bPRJFound = true; while((pszLine = ReadLine()) != NULL) { if (EQUAL(pszLine, "EOP")) { break; } papszPrj = CSLAddString(papszPrj, pszLine); } OGRSpatialReference oSRS; if( oSRS.importFromESRI( papszPrj ) != OGRERR_NONE ) { CPLError( CE_Warning, CPLE_AppDefined, "Failed to parse PRJ section, ignoring." ); } else { char* pszWKT = NULL; if (oSRS.exportToWkt(&pszWKT) == OGRERR_NONE && pszWKT != NULL) osProjection = pszWKT; CPLFree(pszWKT); } if (bStatsFound) break; } else if (strcmp(pszLine, "STDV 8-1 254-1 15 3 60-1 -1 -1-1 4-") == 0) { bStatsFound = true; pszLine = ReadLine(); if (pszLine) { CPLString osStats = pszLine; pszLine = ReadLine(); if (pszLine) { osStats += pszLine; char** papszTokens = CSLTokenizeString(osStats); if (CSLCount(papszTokens) == 4) { dfMin = CPLAtof(papszTokens[0]); dfMax = CPLAtof(papszTokens[1]); dfMean = CPLAtof(papszTokens[2]); dfStddev = CPLAtof(papszTokens[3]); bHasStats = TRUE; } CSLDestroy(papszTokens); } } if (bPRJFound) break; } }}
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,
注:本文中的CSLTokenizeString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CSLTokenizeStringComplex函数代码示例 C++ CSLTestBoolean函数代码示例 |