这篇教程C++ CPLFree函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLFree函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLFree函数的具体用法?C++ CPLFree怎么用?C++ CPLFree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLFree函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CPLFreeGRASSDataset::~GRASSDataset(){ CPLFree( pszProjection );}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:5,
示例2: OGRSQLiteExecuteSQLOGRLayer * OGRSQLiteExecuteSQL( OGRDataSource* poDS, const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect ){ char* pszTmpDBName = (char*) CPLMalloc(256); sprintf(pszTmpDBName, "/vsimem/ogr2sqlite/temp_%p.db", pszTmpDBName); OGRSQLiteDataSource* poSQLiteDS = NULL; int nRet; int bSpatialiteDB = FALSE; CPLString osOldVal; const char* pszOldVal = CPLGetConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", NULL); if( pszOldVal != NULL ) { osOldVal = pszOldVal; pszOldVal = osOldVal.c_str(); }/* -------------------------------------------------------------------- *//* Create in-memory sqlite/spatialite DB *//* -------------------------------------------------------------------- */#ifdef HAVE_SPATIALITE/* -------------------------------------------------------------------- *//* Creating an empty spatialite DB (with spatial_ref_sys populated *//* has a non-neglectable cost. So at the first attempt, let's make *//* one and cache it for later use. *//* -------------------------------------------------------------------- */#if 1 static vsi_l_offset nEmptyDBSize = 0; static GByte* pabyEmptyDB = NULL; { static void* hMutex = NULL; CPLMutexHolder oMutexHolder(&hMutex); static int bTried = FALSE; if( !bTried && CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_DIALECT_USE_SPATIALITE", "YES")) ) { bTried = TRUE; char* pszCachedFilename = (char*) CPLMalloc(256); sprintf(pszCachedFilename, "/vsimem/ogr2sqlite/reference_%p.db",pszCachedFilename); char** papszOptions = CSLAddString(NULL, "SPATIALITE=YES"); OGRSQLiteDataSource* poCachedDS = new OGRSQLiteDataSource(); nRet = poCachedDS->Create( pszCachedFilename, papszOptions ); CSLDestroy(papszOptions); papszOptions = NULL; delete poCachedDS; if( nRet ) /* Note: the reference file keeps the ownership of the data, so that */ /* it gets released with VSICleanupFileManager() */ pabyEmptyDB = VSIGetMemFileBuffer( pszCachedFilename, &nEmptyDBSize, FALSE ); CPLFree( pszCachedFilename ); } } /* The following configuration option is usefull mostly for debugging/testing */ if( pabyEmptyDB != NULL && CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_DIALECT_USE_SPATIALITE", "YES")) ) { GByte* pabyEmptyDBClone = (GByte*)VSIMalloc(nEmptyDBSize); if( pabyEmptyDBClone == NULL ) { CPLFree(pszTmpDBName); return NULL; } memcpy(pabyEmptyDBClone, pabyEmptyDB, nEmptyDBSize); VSIFCloseL(VSIFileFromMemBuffer( pszTmpDBName, pabyEmptyDBClone, nEmptyDBSize, TRUE )); poSQLiteDS = new OGRSQLiteDataSource(); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", "NO"); nRet = poSQLiteDS->Open( pszTmpDBName, TRUE ); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", pszOldVal); if( !nRet ) { /* should not happen really ! */ delete poSQLiteDS; VSIUnlink(pszTmpDBName); CPLFree(pszTmpDBName); return NULL; } bSpatialiteDB = TRUE; }#else /* No caching version */ poSQLiteDS = new OGRSQLiteDataSource(); char** papszOptions = CSLAddString(NULL, "SPATIALITE=YES"); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", "NO"); nRet = poSQLiteDS->Create( pszTmpDBName, papszOptions ); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", pszOldVal); CSLDestroy(papszOptions); papszOptions = NULL; if( nRet ) { bSpatialiteDB = TRUE; }#endif else//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
示例3: GDALAllRegisterint QgsNineCellFilter::processRaster( QProgressDialog* p ){ GDALAllRegister(); //open input file int xSize, ySize; GDALDatasetH inputDataset = openInputFile( xSize, ySize ); if ( inputDataset == NULL ) { return 1; //opening of input file failed } //output driver GDALDriverH outputDriver = openOutputDriver(); if ( outputDriver == 0 ) { return 2; } GDALDatasetH outputDataset = openOutputFile( inputDataset, outputDriver ); if ( outputDataset == NULL ) { return 3; //create operation on output file failed } //open first raster band for reading (operation is only for single band raster) GDALRasterBandH rasterBand = GDALGetRasterBand( inputDataset, 1 ); if ( rasterBand == NULL ) { GDALClose( inputDataset ); GDALClose( outputDataset ); return 4; } mInputNodataValue = GDALGetRasterNoDataValue( rasterBand, NULL ); GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset, 1 ); if ( outputRasterBand == NULL ) { GDALClose( inputDataset ); GDALClose( outputDataset ); return 5; } //try to set -9999 as nodata value GDALSetRasterNoDataValue( outputRasterBand, -9999 ); mOutputNodataValue = GDALGetRasterNoDataValue( outputRasterBand, NULL ); if ( ySize < 3 ) //we require at least three rows (should be true for most datasets) { GDALClose( inputDataset ); GDALClose( outputDataset ); return 6; } //keep only three scanlines in memory at a time float* scanLine1 = ( float * ) CPLMalloc( sizeof( float ) * xSize ); float* scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize ); float* scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize ); float* resultLine = ( float * ) CPLMalloc( sizeof( float ) * xSize ); if ( p ) { p->setMaximum( ySize ); } //values outside the layer extent (if the 3x3 window is on the border) are sent to the processing method as (input) nodata values for ( int i = 0; i < ySize; ++i ) { if ( p ) { p->setValue( i ); } if ( p && p->wasCanceled() ) { break; } if ( i == 0 ) { //fill scanline 1 with (input) nodata for the values above the first row and feed scanline2 with the first row for ( int a = 0; a < xSize; ++a ) { scanLine1[a] = mInputNodataValue; } GDALRasterIO( rasterBand, GF_Read, 0, 0, xSize, 1, scanLine2, xSize, 1, GDT_Float32, 0, 0 ); } else { //normally fetch only scanLine3 and release scanline 1 if we move forward one row CPLFree( scanLine1 ); scanLine1 = scanLine2; scanLine2 = scanLine3; scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize ); } if ( i == ySize - 1 ) //fill the row below the bottom with nodata values { for ( int a = 0; a < xSize; ++a ) {//.........这里部分代码省略.........
开发者ID:ACorradini,项目名称:QGIS,代码行数:101,
示例4: SetDescriptionCPLErr OGRPGeoTableLayer::Initialize( const char *pszTableName, const char *pszGeomCol, int nShapeType, double dfExtentLeft, double dfExtentRight, double dfExtentBottom, double dfExtentTop, int nSRID, int bHasZ ){ CPLODBCSession *poSession = poDS->GetSession(); SetDescription( pszTableName ); CPLFree( pszGeomColumn ); if( pszGeomCol == NULL ) pszGeomColumn = NULL; else pszGeomColumn = CPLStrdup( pszGeomCol ); CPLFree( pszFIDColumn ); pszFIDColumn = NULL; sExtent.MinX = dfExtentLeft; sExtent.MaxX = dfExtentRight; sExtent.MinY = dfExtentBottom; sExtent.MaxY = dfExtentTop; LookupSRID( nSRID ); /* -------------------------------------------------------------------- */ /* Setup geometry type. */ /* -------------------------------------------------------------------- */ OGRwkbGeometryType eOGRType; switch( nShapeType ) { case ESRI_LAYERGEOMTYPE_NULL: eOGRType = wkbNone; break; case ESRI_LAYERGEOMTYPE_POINT: eOGRType = wkbPoint; break; case ESRI_LAYERGEOMTYPE_MULTIPOINT: eOGRType = wkbMultiPoint; break; case ESRI_LAYERGEOMTYPE_POLYLINE: eOGRType = wkbLineString; break; case ESRI_LAYERGEOMTYPE_POLYGON: case ESRI_LAYERGEOMTYPE_MULTIPATCH: eOGRType = wkbPolygon; break; default: CPLDebug("PGeo", "Unexpected value for shape type : %d", nShapeType); eOGRType = wkbUnknown; break; } if( eOGRType != wkbUnknown && eOGRType != wkbNone && bHasZ ) eOGRType = wkbSetZ(eOGRType); CPL_IGNORE_RET_VAL(eOGRType); /* -------------------------------------------------------------------- */ /* Do we have a simple primary key? */ /* -------------------------------------------------------------------- */ CPLODBCStatement oGetKey( poSession ); if( oGetKey.GetPrimaryKeys( pszTableName ) && oGetKey.Fetch() ) { pszFIDColumn = CPLStrdup(oGetKey.GetColData( 3 )); if( oGetKey.Fetch() ) // more than one field in key! { CPLFree( pszFIDColumn ); pszFIDColumn = NULL; CPLDebug( "PGeo", "%s: Compound primary key, ignoring.", pszTableName ); } else CPLDebug( "PGeo", "%s: Got primary key %s.", pszTableName, pszFIDColumn ); } else CPLDebug( "PGeo", "%s: no primary key", pszTableName ); /* -------------------------------------------------------------------- */ /* Get the column definitions for this table. */ /* -------------------------------------------------------------------- */ CPLODBCStatement oGetCol( poSession ); CPLErr eErr; if( !oGetCol.GetColumns( pszTableName ) )//.........这里部分代码省略.........
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:101,
示例5: VSIFOpenLGDALDataset *VRTDataset::Open( GDALOpenInfo * poOpenInfo ){ char *pszVRTPath = NULL;/* -------------------------------------------------------------------- *//* Does this appear to be a virtual dataset definition XML *//* file? *//* -------------------------------------------------------------------- */ if( !Identify( poOpenInfo ) ) return NULL;/* -------------------------------------------------------------------- *//* Try to read the whole file into memory. *//* -------------------------------------------------------------------- */ char *pszXML; VSILFILE *fp = VSIFOpenL(poOpenInfo->pszFilename, "rb"); if( fp != NULL ) { unsigned int nLength; VSIFSeekL( fp, 0, SEEK_END ); nLength = (int) VSIFTellL( fp ); VSIFSeekL( fp, 0, SEEK_SET ); nLength = MAX(0,nLength); pszXML = (char *) VSIMalloc(nLength+1); if( pszXML == NULL ) { VSIFCloseL(fp); CPLError( CE_Failure, CPLE_OutOfMemory, "Failed to allocate %d byte buffer to hold VRT xml file.", nLength ); return NULL; } if( VSIFReadL( pszXML, 1, nLength, fp ) != nLength ) { VSIFCloseL(fp); CPLFree( pszXML ); CPLError( CE_Failure, CPLE_FileIO, "Failed to read %d bytes from VRT xml file.", nLength ); return NULL; } pszXML[nLength] = '/0'; pszVRTPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename)); VSIFCloseL(fp); }/* -------------------------------------------------------------------- *//* Or use the filename as the XML input. *//* -------------------------------------------------------------------- */ else { pszXML = CPLStrdup( poOpenInfo->pszFilename ); }/* -------------------------------------------------------------------- *//* Turn the XML representation into a VRTDataset. *//* -------------------------------------------------------------------- */ VRTDataset *poDS = (VRTDataset *) OpenXML( pszXML, pszVRTPath, poOpenInfo->eAccess ); if( poDS != NULL ) poDS->bNeedsFlush = FALSE; CPLFree( pszXML ); CPLFree( pszVRTPath );/* -------------------------------------------------------------------- *//* Open overviews. *//* -------------------------------------------------------------------- */ if( fp != NULL && poDS != NULL ) poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); return poDS;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:80,
示例6: Close//.........这里部分代码省略......... _sizeFieldLength = DDFScanInt(achLeader+20,1); _sizeFieldPos = DDFScanInt(achLeader+21,1); _sizeFieldTag = DDFScanInt(achLeader+23,1); if( _recLength < 12 || _fieldControlLength == 0 || _fieldAreaStart < 24 || _sizeFieldLength == 0 || _sizeFieldPos == 0 || _sizeFieldTag == 0 ) { bValid = FALSE; } }/* -------------------------------------------------------------------- *//* If the header is invalid, then clean up, report the error *//* and return. *//* -------------------------------------------------------------------- */ if( !bValid ) { VSIFCloseL( fpDDF ); fpDDF = NULL; if( !bFailQuietly ) CPLError( CE_Failure, CPLE_AppDefined, "File `%s' does not appear to have/n" "a valid ISO 8211 header./n", pszFilename ); return FALSE; }/* -------------------------------------------------------------------- *//* Read the whole record info memory. *//* -------------------------------------------------------------------- */ char *pachRecord; pachRecord = (char *) CPLMalloc(_recLength); memcpy( pachRecord, achLeader, nLeaderSize ); if( VSIFReadL( pachRecord+nLeaderSize, 1, _recLength-nLeaderSize, fpDDF ) != _recLength - nLeaderSize ) { if( !bFailQuietly ) CPLError( CE_Failure, CPLE_FileIO, "Header record is short on DDF file `%s'.", pszFilename ); return FALSE; }/* -------------------------------------------------------------------- *//* First make a pass counting the directory entries. *//* -------------------------------------------------------------------- */ int nFieldEntryWidth, nFDCount = 0; nFieldEntryWidth = _sizeFieldLength + _sizeFieldPos + _sizeFieldTag; for( i = nLeaderSize; i < _recLength; i += nFieldEntryWidth ) { if( pachRecord[i] == DDF_FIELD_TERMINATOR ) break; nFDCount++; }/* -------------------------------------------------------------------- *//* Allocate, and read field definitions. *//* -------------------------------------------------------------------- */ for( i = 0; i < nFDCount; i++ ) { char szTag[128]; int nEntryOffset = nLeaderSize + i*nFieldEntryWidth; int nFieldLength, nFieldPos; DDFFieldDefn *poFDefn; strncpy( szTag, pachRecord+nEntryOffset, _sizeFieldTag ); szTag[_sizeFieldTag] = '/0'; nEntryOffset += _sizeFieldTag; nFieldLength = DDFScanInt( pachRecord+nEntryOffset, _sizeFieldLength ); nEntryOffset += _sizeFieldLength; nFieldPos = DDFScanInt( pachRecord+nEntryOffset, _sizeFieldPos ); poFDefn = new DDFFieldDefn(); if( poFDefn->Initialize( this, szTag, nFieldLength, pachRecord+_fieldAreaStart+nFieldPos ) ) AddField( poFDefn ); else delete poFDefn; } CPLFree( pachRecord ); /* -------------------------------------------------------------------- *//* Record the current file offset, the beginning of the first *//* data record. *//* -------------------------------------------------------------------- */ nFirstRecordOffset = (long)VSIFTellL( fpDDF ); return TRUE;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例7: CPLCallocOGRErr OGRGeometryCollection::exportToWktInternal( char ** ppszDstText, OGRwkbVariant eWkbVariant, const char* pszSkipPrefix ) const{ char **papszGeoms; int iGeom; size_t nCumulativeLength = 0; OGRErr eErr; bool bMustWriteComma = false;/* -------------------------------------------------------------------- *//* Build a list of strings containing the stuff for each Geom. *//* -------------------------------------------------------------------- */ papszGeoms = (nGeomCount) ? (char **) CPLCalloc(sizeof(char *),nGeomCount) : NULL; for( iGeom = 0; iGeom < nGeomCount; iGeom++ ) { eErr = papoGeoms[iGeom]->exportToWkt( &(papszGeoms[iGeom]), eWkbVariant ); if( eErr != OGRERR_NONE ) goto error; size_t nSkip = 0; if( pszSkipPrefix != NULL && EQUALN(papszGeoms[iGeom], pszSkipPrefix, strlen(pszSkipPrefix)) && papszGeoms[iGeom][strlen(pszSkipPrefix)] == ' ' ) { nSkip = strlen(pszSkipPrefix) + 1; if( STARTS_WITH_CI(papszGeoms[iGeom] + nSkip, "ZM ") ) nSkip += 3; else if( STARTS_WITH_CI(papszGeoms[iGeom] + nSkip, "M ") ) nSkip += 2; if( STARTS_WITH_CI(papszGeoms[iGeom] + nSkip, "Z ") ) nSkip += 2; /* skip empty subgeoms */ if( papszGeoms[iGeom][nSkip] != '(' ) { CPLDebug( "OGR", "OGRGeometryCollection::exportToWkt() - skipping %s.", papszGeoms[iGeom] ); CPLFree( papszGeoms[iGeom] ); papszGeoms[iGeom] = NULL; continue; } } else if( eWkbVariant != wkbVariantIso ) { char *substr; if( (substr = strstr(papszGeoms[iGeom], " Z")) != NULL ) memmove(substr, substr+strlen(" Z"), 1+strlen(substr+strlen(" Z"))); } nCumulativeLength += strlen(papszGeoms[iGeom] + nSkip); }/* -------------------------------------------------------------------- *//* Return XXXXXXXXXXXXXXX EMPTY if we get no valid line string. *//* -------------------------------------------------------------------- */ if( nCumulativeLength == 0 ) { CPLFree( papszGeoms ); CPLString osEmpty; if( eWkbVariant == wkbVariantIso ) { if( Is3D() && IsMeasured() ) osEmpty.Printf("%s ZM EMPTY",getGeometryName()); else if( IsMeasured() ) osEmpty.Printf("%s M EMPTY",getGeometryName()); else if( Is3D() ) osEmpty.Printf("%s Z EMPTY",getGeometryName()); else osEmpty.Printf("%s EMPTY",getGeometryName()); } else osEmpty.Printf("%s EMPTY",getGeometryName()); *ppszDstText = CPLStrdup(osEmpty); return OGRERR_NONE; }/* -------------------------------------------------------------------- *//* Allocate the right amount of space for the aggregated string *//* -------------------------------------------------------------------- */ *ppszDstText = (char *) VSI_MALLOC_VERBOSE(nCumulativeLength + nGeomCount + 26); if( *ppszDstText == NULL ) { eErr = OGRERR_NOT_ENOUGH_MEMORY; goto error; }/* -------------------------------------------------------------------- *//* Build up the string, freeing temporary strings as we go. *//* -------------------------------------------------------------------- */ strcpy( *ppszDstText, getGeometryName() ); if( eWkbVariant == wkbVariantIso ) { if( (flags & OGR_G_3D) && (flags & OGR_G_MEASURED) ) strcat( *ppszDstText, " ZM" ); else if( flags & OGR_G_3D ) strcat( *ppszDstText, " Z" );//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例8: CPLError/********************************************************************** * TABCreateMAPBlockFromFile() * * Load data from the specified file location and create and initialize * a TABMAP*Block of the right type to handle it. * * Returns the new object if succesful or NULL if an error happened, in * which case CPLError() will have been called. **********************************************************************/TABRawBinBlock *TABCreateMAPBlockFromFile(FILE *fpSrc, int nOffset, int nSize /*= 512*/, GBool bHardBlockSize /*= TRUE */, TABAccess eAccessMode /*= TABRead*/){ TABRawBinBlock *poBlock = NULL; GByte *pabyBuf; if (fpSrc == NULL || nSize == 0) { CPLError(CE_Failure, CPLE_AssertionFailed, "TABCreateMAPBlockFromFile(): Assertion Failed!"); return NULL; } /*---------------------------------------------------------------- * Alloc a buffer to contain the data *---------------------------------------------------------------*/ pabyBuf = (GByte*)CPLMalloc(nSize*sizeof(GByte)); /*---------------------------------------------------------------- * Read from the file *---------------------------------------------------------------*/ if (VSIFSeek(fpSrc, nOffset, SEEK_SET) != 0 || VSIFRead(pabyBuf, sizeof(GByte), nSize, fpSrc)!=(unsigned int)nSize ) { CPLError(CE_Failure, CPLE_FileIO, "TABCreateMAPBlockFromFile() failed reading %d bytes at offset %d.", nSize, nOffset); CPLFree(pabyBuf); return NULL; } /*---------------------------------------------------------------- * Create an object of the right type * Header block is different: it does not start with the object * type byte but it is always the first block in a file *---------------------------------------------------------------*/ if (nOffset == 0) { poBlock = new TABMAPHeaderBlock; } else { switch(pabyBuf[0]) { case TABMAP_INDEX_BLOCK: poBlock = new TABMAPIndexBlock(eAccessMode); break; case TABMAP_OBJECT_BLOCK: poBlock = new TABMAPObjectBlock(eAccessMode); break; case TABMAP_COORD_BLOCK: poBlock = new TABMAPCoordBlock(eAccessMode); break; case TABMAP_TOOL_BLOCK: poBlock = new TABMAPToolBlock(eAccessMode); break; case TABMAP_GARB_BLOCK: default: poBlock = new TABRawBinBlock(eAccessMode, bHardBlockSize); break; } } /*---------------------------------------------------------------- * Init new object with the data we just read *---------------------------------------------------------------*/ if (poBlock->InitBlockFromData(pabyBuf, nSize, nSize, FALSE, fpSrc, nOffset) != 0) { // Some error happened... and CPLError() has been called delete poBlock; poBlock = NULL; } return poBlock;}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:87,
示例9: CPLFree/********************************************************************** * TABRawBinBlock::~TABRawBinBlock() * * Destructor. **********************************************************************/TABRawBinBlock::~TABRawBinBlock(){ if (m_pabyBuf) CPLFree(m_pabyBuf);}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:10,
示例10: GetLayerDefnOGRFeature *OGRSVGLayer::GetNextFeature(){ GetLayerDefn(); if (fpSVG == NULL) return NULL; if (bStopParsing) return NULL;#ifdef HAVE_EXPAT if (nFeatureTabIndex < nFeatureTabLength) { return ppoFeatureTab[nFeatureTabIndex++]; } if (VSIFEofL(fpSVG)) return NULL; char aBuf[BUFSIZ]; CPLFree(ppoFeatureTab); ppoFeatureTab = NULL; nFeatureTabLength = 0; nFeatureTabIndex = 0; nWithoutEventCounter = 0; iCurrentField = -1; int nDone; do { nDataHandlerCounter = 0; unsigned int nLen = (unsigned int) VSIFReadL( aBuf, 1, sizeof(aBuf), fpSVG ); nDone = VSIFEofL(fpSVG); if (XML_Parse(oParser, aBuf, nLen, nDone) == XML_STATUS_ERROR) { CPLError(CE_Failure, CPLE_AppDefined, "XML parsing of SVG file failed : %s at line %d, column %d", XML_ErrorString(XML_GetErrorCode(oParser)), (int)XML_GetCurrentLineNumber(oParser), (int)XML_GetCurrentColumnNumber(oParser)); bStopParsing = TRUE; break; } nWithoutEventCounter ++; } while (!nDone && nFeatureTabLength == 0 && !bStopParsing && nWithoutEventCounter < 1000); if (nWithoutEventCounter == 1000) { CPLError(CE_Failure, CPLE_AppDefined, "Too much data inside one element. File probably corrupted"); bStopParsing = TRUE; } return (nFeatureTabLength) ? ppoFeatureTab[nFeatureTabIndex++] : NULL;#else return NULL;#endif}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:61,
示例11: GXFOpenGXFHandle GXFOpen( const char * pszFilename ){ FILE *fp; GXFInfo_t *psGXF; char szTitle[71]; char **papszList; int nHeaderCount = 0;/* -------------------------------------------------------------------- *//* We open in binary to ensure that we can efficiently seek() *//* to any location when reading scanlines randomly. If we *//* opened as text we might still be able to seek(), but I *//* believe that on Windows, the C library has to read through *//* all the data to find the right spot taking into account DOS *//* CRs. *//* -------------------------------------------------------------------- */ fp = VSIFOpen( pszFilename, "rb" ); if( fp == NULL ) { /* how to effectively communicate this error out? */ CPLError( CE_Failure, CPLE_OpenFailed, "Unable to open file: %s/n", pszFilename ); return NULL; }/* -------------------------------------------------------------------- *//* Create the GXF Information object. *//* -------------------------------------------------------------------- */ psGXF = (GXFInfo_t *) VSICalloc( sizeof(GXFInfo_t), 1 ); psGXF->fp = fp; psGXF->dfTransformScale = 1.0; psGXF->nSense = GXFS_LL_RIGHT; psGXF->dfXPixelSize = 1.0; psGXF->dfYPixelSize = 1.0; psGXF->dfSetDummyTo = -1e12; psGXF->dfUnitToMeter = 1.0; psGXF->pszTitle = VSIStrdup("");/* -------------------------------------------------------------------- *//* Read the header, one line at a time. *//* -------------------------------------------------------------------- */ while( (papszList = GXFReadHeaderValue( fp, szTitle)) != NULL && nHeaderCount < MAX_HEADER_COUNT ) { if( STARTS_WITH_CI(szTitle, "#TITL") ) { CPLFree( psGXF->pszTitle ); psGXF->pszTitle = CPLStrdup( papszList[0] ); } else if( STARTS_WITH_CI(szTitle, "#POIN") ) { psGXF->nRawXSize = atoi(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#ROWS") ) { psGXF->nRawYSize = atoi(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#PTSE") ) { psGXF->dfXPixelSize = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#RWSE") ) { psGXF->dfYPixelSize = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#DUMM") ) { memset( psGXF->szDummy, 0, sizeof(psGXF->szDummy)); strncpy( psGXF->szDummy, papszList[0], sizeof(psGXF->szDummy) - 1); psGXF->dfSetDummyTo = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#XORI") ) { psGXF->dfXOrigin = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#YORI") ) { psGXF->dfYOrigin = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#ZMIN") ) { psGXF->dfZMinimum = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#ZMAX") ) { psGXF->dfZMaximum = CPLAtof(papszList[0]); } else if( STARTS_WITH_CI(szTitle, "#SENS") ) { psGXF->nSense = atoi(papszList[0]); } else if( STARTS_WITH_CI(szTitle,"#MAP_PROJECTION") ) { psGXF->papszMapProjection = papszList; papszList = NULL; } else if( STARTS_WITH_CI(szTitle,"#MAP_D") ) {//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例12: LaunderNameOGRLayer *OGRIngresDataSource::CreateLayer( const char * pszLayerNameIn, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ const char *pszGeometryType = NULL; const char *pszGeomColumnName; const char *pszExpectedFIDName; char *pszLayerName; int nDimension = 3; // Ingres only supports 2d currently if( CSLFetchBoolean(papszOptions,"LAUNDER",TRUE) ) pszLayerName = LaunderName( pszLayerNameIn ); else pszLayerName = CPLStrdup( pszLayerNameIn ); if( wkbFlatten(eType) == eType ) nDimension = 2; CPLDebug("INGRES","Creating layer %s.", pszLayerName);/* -------------------------------------------------------------------- *//* Do we already have this layer? If so, should we blow it *//* away? *//* -------------------------------------------------------------------- */ int iLayer; for( iLayer = 0; iLayer < nLayers; iLayer++ ) { if( EQUAL(pszLayerName,papoLayers[iLayer]->GetLayerDefn()->GetName()) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { DeleteLayer( iLayer ); } else { CPLFree( pszLayerName ); CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed./n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszLayerName ); return NULL; } } }/* -------------------------------------------------------------------- *//* What do we want to use for geometry and FID columns? *//* -------------------------------------------------------------------- */ pszGeomColumnName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME" ); if (!pszGeomColumnName) pszGeomColumnName="SHAPE"; pszExpectedFIDName = CSLFetchNameValue( papszOptions, "INGRES_FID" ); if (!pszExpectedFIDName) pszExpectedFIDName="OGR_FID"; CPLDebug("INGRES","Geometry Column Name %s.", pszGeomColumnName); CPLDebug("INGRES","FID Column Name %s.", pszExpectedFIDName);/* -------------------------------------------------------------------- *//* What sort of geometry column do we want to create? *//* -------------------------------------------------------------------- */ pszGeometryType = CSLFetchNameValue( papszOptions, "GEOMETRY_TYPE" ); if( pszGeometryType != NULL ) /* user selected type */; else if( wkbFlatten(eType) == wkbPoint ) pszGeometryType = "POINT"; else if( wkbFlatten(eType) == wkbLineString) { if( IsNewIngres() ) { pszGeometryType = "LINESTRING"; } else { pszGeometryType = "LONG LINE"; } } else if( wkbFlatten(eType) == wkbPolygon ) { if( IsNewIngres() ) { pszGeometryType = "POLYGON"; } else { pszGeometryType = "LONG POLYGON";//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例13: RasterliteInsertSRIDstatic int RasterliteInsertSRID(OGRDataSourceH hDS, const char* pszWKT){ CPLString osSQL; int nAuthorityCode = 0; CPLString osAuthorityName, osProjCS, osProj4; if (pszWKT != NULL && strlen(pszWKT) != 0) { OGRSpatialReferenceH hSRS = OSRNewSpatialReference(pszWKT); if (hSRS) { const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL); if (pszAuthorityName) osAuthorityName = pszAuthorityName; const char* pszProjCS = OSRGetAttrValue(hSRS, "PROJCS", 0); if (pszProjCS) osProjCS = pszProjCS; const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL); if (pszAuthorityCode) nAuthorityCode = atoi(pszAuthorityCode); char *pszProj4 = NULL; if( OSRExportToProj4( hSRS, &pszProj4 ) != OGRERR_NONE ) pszProj4 = CPLStrdup(""); osProj4 = pszProj4; CPLFree(pszProj4); } OSRDestroySpatialReference(hSRS); } int nSRSId = -1; if (nAuthorityCode != 0 && osAuthorityName.size() != 0) { osSQL.Printf ("SELECT srid FROM spatial_ref_sys WHERE auth_srid = %d", nAuthorityCode); OGRLayerH hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL); if (hLyr == NULL) { nSRSId = nAuthorityCode; if ( osProjCS.size() != 0 ) osSQL.Printf( "INSERT INTO spatial_ref_sys " "(srid, auth_name, auth_srid, ref_sys_name, proj4text) " "VALUES (%d, '%s', '%d', '%s', '%s')", nSRSId, osAuthorityName.c_str(), nAuthorityCode, osProjCS.c_str(), osProj4.c_str() ); else osSQL.Printf( "INSERT INTO spatial_ref_sys " "(srid, auth_name, auth_srid, proj4text) " "VALUES (%d, '%s', '%d', '%s')", nSRSId, osAuthorityName.c_str(), nAuthorityCode, osProj4.c_str() ); OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL); } else { OGRFeatureH hFeat = OGR_L_GetNextFeature(hLyr); if (hFeat) { nSRSId = OGR_F_GetFieldAsInteger(hFeat, 0); OGR_F_Destroy(hFeat); } OGR_DS_ReleaseResultSet(hDS, hLyr); } } return nSRSId;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:70,
示例14: ResetReading//.........这里部分代码省略......... if( poGeom == NULL ) { delete poNASFeature; return NULL; } if( m_poFilterGeom != NULL && !FilterGeometry( poGeom ) ) continue; }/* -------------------------------------------------------------------- *//* Convert the whole feature into an OGRFeature. *//* -------------------------------------------------------------------- */ int iField; OGRFeature *poOGRFeature = new OGRFeature( GetLayerDefn() ); poOGRFeature->SetFID( iNextNASId ); for( iField = 0; iField < poFClass->GetPropertyCount(); iField++ ) { const GMLProperty *psGMLProperty = poNASFeature->GetProperty( iField ); if( psGMLProperty == NULL || psGMLProperty->nSubProperties == 0 ) continue; switch( poFClass->GetProperty(iField)->GetType() ) { case GMLPT_Real: { poOGRFeature->SetField( iField, CPLAtof(psGMLProperty->papszSubProperties[0]) ); } break; case GMLPT_IntegerList: { int nCount = psGMLProperty->nSubProperties; int *panIntList = (int *) CPLMalloc(sizeof(int) * nCount ); int i; for( i = 0; i < nCount; i++ ) panIntList[i] = atoi(psGMLProperty->papszSubProperties[i]); poOGRFeature->SetField( iField, nCount, panIntList ); CPLFree( panIntList ); } break; case GMLPT_RealList: { int nCount = psGMLProperty->nSubProperties; double *padfList = (double *)CPLMalloc(sizeof(double)*nCount); int i; for( i = 0; i < nCount; i++ ) padfList[i] = CPLAtof(psGMLProperty->papszSubProperties[i]); poOGRFeature->SetField( iField, nCount, padfList ); CPLFree( padfList ); } break; case GMLPT_StringList: { poOGRFeature->SetField( iField, psGMLProperty->papszSubProperties ); } break; default: poOGRFeature->SetField( iField, psGMLProperty->papszSubProperties[0] ); break; } }/* -------------------------------------------------------------------- *//* Test against the attribute query. *//* -------------------------------------------------------------------- */ if( m_poAttrQuery != NULL && !m_poAttrQuery->Evaluate( poOGRFeature ) ) { delete poOGRFeature; continue; }/* -------------------------------------------------------------------- *//* Wow, we got our desired feature. Return it. *//* -------------------------------------------------------------------- */ if( poGeom && poOGRFeature->SetGeometryDirectly( poGeom ) != OGRERR_NONE ) { int iId = poNASFeature->GetClass()->GetPropertyIndex( "gml_id" ); const GMLProperty *poIdProp = poNASFeature->GetProperty(iId); CPLError( CE_Warning, CPLE_AppDefined, "NAS: could not set geometry (gml_id:%s)", poIdProp && poIdProp->nSubProperties>0 && poIdProp->papszSubProperties[0] ? poIdProp->papszSubProperties[0] : "(null)" ); } delete poNASFeature; return poOGRFeature; } return NULL;}
开发者ID:0004c,项目名称:node-gdal,代码行数:101,
示例15: CPLAssertint DDFModule::Create( const char *pszFilename ){ CPLAssert( fpDDF == NULL ); /* -------------------------------------------------------------------- *//* Create the file on disk. *//* -------------------------------------------------------------------- */ fpDDF = VSIFOpenL( pszFilename, "wb+" ); if( fpDDF == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to create file %s, check path and permissions.", pszFilename ); return FALSE; } bReadOnly = FALSE;/* -------------------------------------------------------------------- *//* Prepare all the field definition information. *//* -------------------------------------------------------------------- */ int iField; _fieldControlLength = 9; _recLength = 24 + nFieldDefnCount * (_sizeFieldLength+_sizeFieldPos+_sizeFieldTag) + 1; _fieldAreaStart = _recLength; for( iField=0; iField < nFieldDefnCount; iField++ ) { int nLength; papoFieldDefns[iField]->GenerateDDREntry( NULL, &nLength ); _recLength += nLength; }/* -------------------------------------------------------------------- *//* Setup 24 byte leader. *//* -------------------------------------------------------------------- */ char achLeader[25]; sprintf( achLeader+0, "%05d", (int) _recLength ); achLeader[5] = _interchangeLevel; achLeader[6] = _leaderIden; achLeader[7] = _inlineCodeExtensionIndicator; achLeader[8] = _versionNumber; achLeader[9] = _appIndicator; sprintf( achLeader+10, "%02d", (int) _fieldControlLength ); sprintf( achLeader+12, "%05d", (int) _fieldAreaStart ); strncpy( achLeader+17, _extendedCharSet, 3 ); sprintf( achLeader+20, "%1d", (int) _sizeFieldLength ); sprintf( achLeader+21, "%1d", (int) _sizeFieldPos ); achLeader[22] = '0'; sprintf( achLeader+23, "%1d", (int) _sizeFieldTag ); VSIFWriteL( achLeader, 24, 1, fpDDF );/* -------------------------------------------------------------------- *//* Write out directory entries. *//* -------------------------------------------------------------------- */ int nOffset = 0; for( iField=0; iField < nFieldDefnCount; iField++ ) { char achDirEntry[12]; int nLength; papoFieldDefns[iField]->GenerateDDREntry( NULL, &nLength ); strcpy( achDirEntry, papoFieldDefns[iField]->GetName() ); sprintf( achDirEntry + _sizeFieldTag, "%03d", nLength ); sprintf( achDirEntry + _sizeFieldTag + _sizeFieldLength, "%04d", nOffset ); nOffset += nLength; VSIFWriteL( achDirEntry, 11, 1, fpDDF ); } char chUT = DDF_FIELD_TERMINATOR; VSIFWriteL( &chUT, 1, 1, fpDDF );/* -------------------------------------------------------------------- *//* Write out the field descriptions themselves. *//* -------------------------------------------------------------------- */ for( iField=0; iField < nFieldDefnCount; iField++ ) { char *pachData; int nLength; papoFieldDefns[iField]->GenerateDDREntry( &pachData, &nLength ); VSIFWriteL( pachData, nLength, 1, fpDDF ); CPLFree( pachData ); } return TRUE;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:97,
示例16: CPLFreeVSIStdinFilesystemHandler::~VSIStdinFilesystemHandler(){ CPLFree(pabyBuffer); pabyBuffer = NULL;}
开发者ID:ViacheslavN,项目名称:GIS,代码行数:5,
示例17: CPLFreeOGRPGeoTableLayer::~OGRPGeoTableLayer(){ CPLFree( pszQuery ); ClearStatement();}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:6,
示例18: GDALMultiFilter//.........这里部分代码省略......... eErr = GDALRasterIO( hFiltMaskBand, GF_Read, 0, nNewLine, nXSize, 1, pabyFMaskBuf + nXSize * iBufOffset, nXSize, 1, GDT_Byte, 0, 0 ); if( eErr != CE_None ) break; eErr = GDALRasterIO( hTargetBand, GF_Read, 0, nNewLine, nXSize, 1, pafThisPass + nXSize * iBufOffset, nXSize, 1, GDT_Float32, 0, 0 ); if( eErr != CE_None ) break; }/* -------------------------------------------------------------------- *//* Loop over the loaded data, applying the filter to all loaded *//* lines with neighbours. *//* -------------------------------------------------------------------- */ int iFLine; for( iFLine = nNewLine-1; eErr == CE_None && iFLine >= nNewLine-nIterations; iFLine-- ) { int iLastOffset, iThisOffset, iNextOffset; iLastOffset = (iFLine-1) % nBufLines; iThisOffset = (iFLine ) % nBufLines; iNextOffset = (iFLine+1) % nBufLines; // default to preserving the old value. if( iFLine >= 0 ) memcpy( pafThisPass + iThisOffset * nXSize, pafLastPass + iThisOffset * nXSize, sizeof(float) * nXSize ); // currently this skips the first and last line. Eventually // we will enable these too. TODO if( iFLine < 1 || iFLine >= nYSize-1 ) { continue; } GDALFilterLine( pafSLastPass + iLastOffset * nXSize, pafLastPass + iThisOffset * nXSize, pafThisPass + iNextOffset * nXSize, pafThisPass + iThisOffset * nXSize, pabyTMaskBuf + iLastOffset * nXSize, pabyTMaskBuf + iThisOffset * nXSize, pabyTMaskBuf + iNextOffset * nXSize, pabyFMaskBuf + iThisOffset * nXSize, nXSize ); }/* -------------------------------------------------------------------- *//* Write out the top data line that will be rolling out of our *//* buffer. *//* -------------------------------------------------------------------- */ int iLineToSave = nNewLine - nIterations; if( iLineToSave >= 0 && eErr == CE_None ) { iBufOffset = iLineToSave % nBufLines; eErr = GDALRasterIO( hTargetBand, GF_Write, 0, iLineToSave, nXSize, 1, pafThisPass + nXSize * iBufOffset, nXSize, 1, GDT_Float32, 0, 0 ); }/* -------------------------------------------------------------------- *//* Report progress. *//* -------------------------------------------------------------------- */ if( eErr == CE_None && !pfnProgress( (nNewLine+1) / (double) (nYSize+nIterations), "Smoothing Filter...", pProgressArg ) ) { CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); eErr = CE_Failure; } }/* -------------------------------------------------------------------- *//* Cleanup *//* -------------------------------------------------------------------- */end: CPLFree( pabyTMaskBuf ); CPLFree( pabyFMaskBuf ); CPLFree( paf3PassLineBuf ); return eErr;}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例19: CPLStrdupCPLErr VRTDataset::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath ){ if( pszVRTPath != NULL ) this->pszVRTPath = CPLStrdup(pszVRTPath);/* -------------------------------------------------------------------- *//* Check for an SRS node. *//* -------------------------------------------------------------------- */ if( strlen(CPLGetXMLValue(psTree, "SRS", "")) > 0 ) { OGRSpatialReference oSRS; CPLFree( pszProjection ); pszProjection = NULL; if( oSRS.SetFromUserInput( CPLGetXMLValue(psTree, "SRS", "") ) == OGRERR_NONE ) oSRS.exportToWkt( &pszProjection ); }/* -------------------------------------------------------------------- *//* Check for a GeoTransform node. *//* -------------------------------------------------------------------- */ if( strlen(CPLGetXMLValue(psTree, "GeoTransform", "")) > 0 ) { const char *pszGT = CPLGetXMLValue(psTree, "GeoTransform", ""); char **papszTokens; papszTokens = CSLTokenizeStringComplex( pszGT, ",", FALSE, FALSE ); if( CSLCount(papszTokens) != 6 ) { CPLError( CE_Warning, CPLE_AppDefined, "GeoTransform node does not have expected six values."); } else { for( int iTA = 0; iTA < 6; iTA++ ) adfGeoTransform[iTA] = atof(papszTokens[iTA]); bGeoTransformSet = TRUE; } CSLDestroy( papszTokens ); }/* -------------------------------------------------------------------- *//* Check for GCPs. *//* -------------------------------------------------------------------- */ CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); if( psGCPList != NULL ) { CPLXMLNode *psXMLGCP; OGRSpatialReference oSRS; const char *pszRawProj = CPLGetXMLValue(psGCPList, "Projection", ""); CPLFree( pszGCPProjection ); if( strlen(pszRawProj) > 0 && oSRS.SetFromUserInput( pszRawProj ) == OGRERR_NONE ) oSRS.exportToWkt( &pszGCPProjection ); else pszGCPProjection = CPLStrdup(""); // Count GCPs. int nGCPMax = 0; for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; psXMLGCP = psXMLGCP->psNext ) nGCPMax++; pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),nGCPMax); for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; psXMLGCP = psXMLGCP->psNext ) { GDAL_GCP *psGCP = pasGCPList + nGCPCount; if( !EQUAL(psXMLGCP->pszValue,"GCP") || psXMLGCP->eType != CXT_Element ) continue; GDALInitGCPs( 1, psGCP ); CPLFree( psGCP->pszId ); psGCP->pszId = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Id","")); CPLFree( psGCP->pszInfo ); psGCP->pszInfo = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Info","")); psGCP->dfGCPPixel = atof(CPLGetXMLValue(psXMLGCP,"Pixel","0.0")); psGCP->dfGCPLine = atof(CPLGetXMLValue(psXMLGCP,"Line","0.0")); psGCP->dfGCPX = atof(CPLGetXMLValue(psXMLGCP,"X","0.0")); psGCP->dfGCPY = atof(CPLGetXMLValue(psXMLGCP,"Y","0.0")); psGCP->dfGCPZ = atof(CPLGetXMLValue(psXMLGCP,"Z","0.0")); nGCPCount++; } }//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例20: GDALFillNodata//.........这里部分代码省略......... } if( dfWeightSum > 0.0 ) { pabyMask[iX] = 255; pabyFiltMask[iX] = 255; pafScanline[iX] = (float) (dfValueSum / dfWeightSum); } }/* -------------------------------------------------------------------- *//* Write out the updated data and mask information. *//* -------------------------------------------------------------------- */ eErr = GDALRasterIO( hTargetBand, GF_Write, 0, iY, nXSize, 1, pafScanline, nXSize, 1, GDT_Float32, 0, 0 ); if( eErr != CE_None ) break; eErr = GDALRasterIO( hFiltMaskBand, GF_Write, 0, iY, nXSize, 1, pabyFiltMask, nXSize, 1, GDT_Byte, 0, 0 ); if( eErr != CE_None ) break;/* -------------------------------------------------------------------- *//* Flip this/last buffers. *//* -------------------------------------------------------------------- */ { float *pafTmp = pafThisValue; pafThisValue = pafLastValue; pafLastValue = pafTmp; GUInt32 *panTmp = panThisY; panThisY = panLastY; panLastY = panTmp; }/* -------------------------------------------------------------------- *//* report progress. *//* -------------------------------------------------------------------- */ if( eErr == CE_None && !pfnProgress( dfProgressRatio*(0.5+0.5*(nYSize-iY) / (double)nYSize), "Filling...", pProgressArg ) ) { CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); eErr = CE_Failure; } }/* ==================================================================== *//* Now we will do iterative average filters over the *//* interpolated values to smooth things out and make linear *//* artifacts less obvious. *//* ==================================================================== */ if( eErr == CE_None && nSmoothingIterations > 0 ) { // force masks to be to flushed and recomputed. GDALFlushRasterCache( hMaskBand ); void *pScaledProgress; pScaledProgress = GDALCreateScaledProgress( dfProgressRatio, 1.0, pfnProgress, NULL ); eErr = GDALMultiFilter( hTargetBand, hMaskBand, hFiltMaskBand, nSmoothingIterations, GDALScaledProgress, pScaledProgress ); GDALDestroyScaledProgress( pScaledProgress ); }/* -------------------------------------------------------------------- *//* Close and clean up temporary files. Free working buffers *//* -------------------------------------------------------------------- */end: CPLFree(panLastY); CPLFree(panThisY); CPLFree(panTopDownY); CPLFree(pafLastValue); CPLFree(pafThisValue); CPLFree(pafTopDownValue); CPLFree(pafScanline); CPLFree(pabyMask); CPLFree(pabyFiltMask); GDALClose( hYDS ); GDALClose( hValDS ); GDALClose( hFiltMaskDS ); CSLDestroy(papszWorkFileOptions); GDALDeleteDataset( hDriver, osYTmpFile ); GDALDeleteDataset( hDriver, osValTmpFile ); GDALDeleteDataset( hDriver, osFiltMaskTmpFile ); return eErr;}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例21: main//.........这里部分代码省略......... Usage("No index filename specified."); if( i_arg == argc ) Usage("No file to index specified.");/* -------------------------------------------------------------------- *//* Create and validate target SRS if given. *//* -------------------------------------------------------------------- */ if( bSetTargetSRS ) { if ( skip_different_projection ) { fprintf( stderr, "Warning : -skip_different_projection does not apply " "when -t_srs is requested./n" ); } hTargetSRS = OSRNewSpatialReference(""); if( OSRSetFromUserInput( hTargetSRS, pszTargetSRS ) != CE_None ) { OSRDestroySpatialReference( hTargetSRS ); fprintf( stderr, "Invalid target SRS `%s'./n", pszTargetSRS ); exit(1); } }/* -------------------------------------------------------------------- *//* Open or create the target shapefile and DBF file. *//* -------------------------------------------------------------------- */ index_filename_mod = CPLStrdup(CPLResetExtension(index_filename, "shp")); bExists = (VSIStat(index_filename_mod, &sStatBuf) == 0); if (!bExists) { CPLFree(index_filename_mod); index_filename_mod = CPLStrdup(CPLResetExtension(index_filename, "SHP")); bExists = (VSIStat(index_filename_mod, &sStatBuf) == 0); } CPLFree(index_filename_mod); if (bExists) { hTileIndexDS = OGROpen( index_filename, TRUE, NULL ); if (hTileIndexDS != NULL) { hLayer = OGR_DS_GetLayer(hTileIndexDS, 0); } } else { OGRSFDriverH hDriver; const char* pszDriverName = "ESRI Shapefile"; printf( "Creating new index file.../n" ); hDriver = OGRGetDriverByName( pszDriverName ); if( hDriver == NULL ) { printf( "%s driver not available./n", pszDriverName ); exit( 1 ); } hTileIndexDS = OGR_Dr_CreateDataSource( hDriver, index_filename, NULL ); if (hTileIndexDS) { char* pszLayerName = CPLStrdup(CPLGetBasename(index_filename)); /* get spatial reference for output file from target SRS (if set) */
开发者ID:TUW-GEO,项目名称:OGRSpatialRef3D,代码行数:67,
示例22: CPLFreeOGRFieldDefn::~OGRFieldDefn(){ CPLFree( pszName );}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:5,
示例23: GH5_FetchAttributebool GH5_FetchAttribute( hid_t loc_id, const char *pszAttrName, double &dfResult, bool bReportError ){ hid_t hAttr = H5Aopen_name( loc_id, pszAttrName ); dfResult = 0.0; if( hAttr < 0 ) { if( bReportError ) CPLError( CE_Failure, CPLE_AppDefined, "Attempt to read attribute %s failed, not found.", pszAttrName ); return false; } hid_t hAttrTypeID = H5Aget_type( hAttr ); hid_t hAttrNativeType = H5Tget_native_type( hAttrTypeID, H5T_DIR_DEFAULT );/* -------------------------------------------------------------------- *//* Confirm that we have a single element value. *//* -------------------------------------------------------------------- */ hid_t hAttrSpace = H5Aget_space( hAttr ); hsize_t anSize[64]; int nAttrDims = H5Sget_simple_extent_dims( hAttrSpace, anSize, NULL ); int i, nAttrElements = 1; for( i=0; i < nAttrDims; i++ ) { nAttrElements *= (int) anSize[i]; } if( nAttrElements != 1 ) { if( bReportError ) CPLError( CE_Failure, CPLE_AppDefined, "Attempt to read attribute %s failed, count=%d, not 1.", pszAttrName, nAttrElements ); H5Sclose( hAttrSpace ); H5Tclose( hAttrNativeType ); H5Tclose( hAttrTypeID ); H5Aclose( hAttr ); return false; } /* -------------------------------------------------------------------- *//* Read the value. *//* -------------------------------------------------------------------- */ void *buf = (void *)CPLMalloc( H5Tget_size( hAttrNativeType )); H5Aread( hAttr, hAttrNativeType, buf );/* -------------------------------------------------------------------- *//* Translate to double. *//* -------------------------------------------------------------------- */ if( H5Tequal( H5T_NATIVE_INT, hAttrNativeType ) ) dfResult = *((int *) buf); else if( H5Tequal( H5T_NATIVE_FLOAT, hAttrNativeType ) ) dfResult = *((float *) buf); else if( H5Tequal( H5T_NATIVE_DOUBLE, hAttrNativeType ) ) dfResult = *((double *) buf); else { if( bReportError ) CPLError( CE_Failure, CPLE_AppDefined, "Attribute %s of unsupported type for conversion to double.", pszAttrName ); CPLFree( buf ); H5Sclose( hAttrSpace ); H5Tclose( hAttrNativeType ); H5Tclose( hAttrTypeID ); H5Aclose( hAttr ); return false; } CPLFree( buf ); H5Sclose( hAttrSpace ); H5Tclose( hAttrNativeType ); H5Tclose( hAttrTypeID ); H5Aclose( hAttr ); return true;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:86,
示例24: switchOGRFeature *OGRAVCLayer::TranslateFeature( void *pAVCFeature ){ m_nFeaturesRead++; switch( eSectionType ) {/* ==================================================================== *//* ARC *//* ==================================================================== */ case AVCFileARC: { AVCArc *psArc = static_cast<AVCArc *>( pAVCFeature );/* -------------------------------------------------------------------- *//* Create feature. *//* -------------------------------------------------------------------- */ OGRFeature *poOGRFeature = new OGRFeature( GetLayerDefn() ); poOGRFeature->SetFID( psArc->nArcId );/* -------------------------------------------------------------------- *//* Apply the line geometry. *//* -------------------------------------------------------------------- */ OGRLineString *poLine = new OGRLineString(); poLine->setNumPoints( psArc->numVertices ); for( int iVert = 0; iVert < psArc->numVertices; iVert++ ) poLine->setPoint( iVert, psArc->pasVertices[iVert].x, psArc->pasVertices[iVert].y ); poOGRFeature->SetGeometryDirectly( poLine );/* -------------------------------------------------------------------- *//* Apply attributes. *//* -------------------------------------------------------------------- */ poOGRFeature->SetField( 0, psArc->nUserId ); poOGRFeature->SetField( 1, psArc->nFNode ); poOGRFeature->SetField( 2, psArc->nTNode ); poOGRFeature->SetField( 3, psArc->nLPoly ); poOGRFeature->SetField( 4, psArc->nRPoly ); return poOGRFeature; }/* ==================================================================== *//* PAL (Polygon) *//* RPL (Region) *//* ==================================================================== */ case AVCFilePAL: case AVCFileRPL: { AVCPal *psPAL = static_cast<AVCPal *>( pAVCFeature );/* -------------------------------------------------------------------- *//* Create feature. *//* -------------------------------------------------------------------- */ OGRFeature *poOGRFeature = new OGRFeature( GetLayerDefn() ); poOGRFeature->SetFID( psPAL->nPolyId );/* -------------------------------------------------------------------- *//* Apply attributes. *//* -------------------------------------------------------------------- */ // Setup ArcId list. int *panArcs = static_cast<int *>( CPLMalloc(sizeof(int) * psPAL->numArcs ) ); for( int i = 0; i < psPAL->numArcs; i++ ) panArcs[i] = psPAL->pasArcs[i].nArcId; poOGRFeature->SetField( 0, psPAL->numArcs, panArcs ); CPLFree( panArcs ); return poOGRFeature; }/* ==================================================================== *//* CNT (Centroid) *//* ==================================================================== */ case AVCFileCNT: { AVCCnt *psCNT = (AVCCnt *) pAVCFeature;/* -------------------------------------------------------------------- *//* Create feature. *//* -------------------------------------------------------------------- */ OGRFeature *poOGRFeature = new OGRFeature( GetLayerDefn() ); poOGRFeature->SetFID( psCNT->nPolyId );/* -------------------------------------------------------------------- *//* Apply Geometry *//* -------------------------------------------------------------------- */ poOGRFeature->SetGeometryDirectly( new OGRPoint( psCNT->sCoord.x, psCNT->sCoord.y ) );/* -------------------------------------------------------------------- *//* Apply attributes. *//* -------------------------------------------------------------------- */ poOGRFeature->SetField( 0, psCNT->numLabels, psCNT->panLabelIds ); return poOGRFeature; }//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例25: CPLCallocOGRErr OGRGeometryCollection::exportToWkt( char ** ppszDstText ) const{ char **papszGeoms; int iGeom, nCumulativeLength = 0; OGRErr eErr; if( getNumGeometries() == 0 ) { *ppszDstText = CPLStrdup("GEOMETRYCOLLECTION EMPTY"); return OGRERR_NONE; }/* -------------------------------------------------------------------- *//* Build a list of strings containing the stuff for each Geom. *//* -------------------------------------------------------------------- */ papszGeoms = (char **) CPLCalloc(sizeof(char *),nGeomCount); for( iGeom = 0; iGeom < nGeomCount; iGeom++ ) { eErr = papoGeoms[iGeom]->exportToWkt( &(papszGeoms[iGeom]) ); if( eErr != OGRERR_NONE ) goto error; nCumulativeLength += strlen(papszGeoms[iGeom]); } /* -------------------------------------------------------------------- *//* Allocate the right amount of space for the aggregated string *//* -------------------------------------------------------------------- */ *ppszDstText = (char *) VSIMalloc(nCumulativeLength + nGeomCount + 23); if( *ppszDstText == NULL ) { eErr = OGRERR_NOT_ENOUGH_MEMORY; goto error; }/* -------------------------------------------------------------------- *//* Build up the string, freeing temporary strings as we go. *//* -------------------------------------------------------------------- */ strcpy( *ppszDstText, getGeometryName() ); strcat( *ppszDstText, " (" ); nCumulativeLength = strlen(*ppszDstText); for( iGeom = 0; iGeom < nGeomCount; iGeom++ ) { if( iGeom > 0 ) (*ppszDstText)[nCumulativeLength++] = ','; int nGeomLength = strlen(papszGeoms[iGeom]); memcpy( *ppszDstText + nCumulativeLength, papszGeoms[iGeom], nGeomLength ); nCumulativeLength += nGeomLength; VSIFree( papszGeoms[iGeom] ); } (*ppszDstText)[nCumulativeLength++] = ')'; (*ppszDstText)[nCumulativeLength] = '/0'; CPLFree( papszGeoms ); return OGRERR_NONE;error: for( iGeom = 0; iGeom < nGeomCount; iGeom++ ) CPLFree( papszGeoms[iGeom] ); CPLFree( papszGeoms ); return eErr;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:69,
注:本文中的CPLFree函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLGetBasename函数代码示例 C++ CPLFormFilename函数代码示例 |