GDALProxyPoolDataset::~GDALProxyPoolDataset() { if( !bShared ) { GDALDatasetPool::CloseDataset(GetDescription(), eAccess); } /* See comment in constructor */ /* It is not really a genuine shared dataset, so we don't */ /* want ~GDALDataset() to try to release it from its */ /* shared dataset hashset. This will save a */ /* "Should not happen. Cannot find %s, this=%p in phSharedDatasetSet" debug message */ bShared = FALSE; CPLFree(pszProjectionRef); CPLFree(pszGCPProjection); if (nGCPCount) { GDALDeinitGCPs( nGCPCount, pasGCPList ); CPLFree( pasGCPList ); } if (metadataSet) CPLHashSetDestroy(metadataSet); if (metadataItemSet) CPLHashSetDestroy(metadataItemSet); GDALDatasetPool::Unref(); }
GDALProxyPoolDataset::~GDALProxyPoolDataset() { CPLFree(pszProjectionRef); CPLFree(pszGCPProjection); if (nGCPCount) { GDALDeinitGCPs( nGCPCount, pasGCPList ); CPLFree( pasGCPList ); } if (metadataSet) CPLHashSetDestroy(metadataSet); if (metadataItemSet) CPLHashSetDestroy(metadataItemSet); GDALDatasetPool::Unref(); }
void object::test<4>() { #define HASH_SET_SIZE 1000 CPLHashSet* set = CPLHashSetNew(NULL, NULL, NULL); for(int i=0;i<HASH_SET_SIZE;i++) { ensure(CPLHashSetInsert(set, (void*)i) == TRUE); } ensure(CPLHashSetSize(set) == HASH_SET_SIZE); for(int i=0;i<HASH_SET_SIZE;i++) { ensure(CPLHashSetInsert(set, (void*)i) == FALSE); } ensure(CPLHashSetSize(set) == HASH_SET_SIZE); for(int i=0;i<HASH_SET_SIZE;i++) { ensure(CPLHashSetLookup(set, (const void*)i) == (const void*)i); } int sum = 0; CPLHashSetForeach(set, sumValues, &sum); ensure(sum == (HASH_SET_SIZE-1) * HASH_SET_SIZE / 2); for(int i=0;i<HASH_SET_SIZE;i++) { ensure(CPLHashSetRemove(set, (void*)i) == TRUE); } ensure(CPLHashSetSize(set) == 0); CPLHashSetDestroy(set); }
/* ******************************************************************** */ GDALProxyPoolRasterBand::~GDALProxyPoolRasterBand() { if (metadataSet) CPLHashSetDestroy(metadataSet); if (metadataItemSet) CPLHashSetDestroy(metadataItemSet); CPLFree(pszUnitType); CSLDestroy(papszCategoryNames); if (poColorTable) delete poColorTable; int i; for(i=0;i<nSizeProxyOverviewRasterBand;i++) { if (papoProxyOverviewRasterBand[i]) delete papoProxyOverviewRasterBand[i]; } CPLFree(papoProxyOverviewRasterBand); if (poProxyMaskBand) delete poProxyMaskBand; }
void OGRXPlaneAirwayIntersectionLayer::ResetReading() { if (poReader) { CPLHashSetDestroy(poSet); poSet = CPLHashSetNew(HashAirwayIntersectionFeatureFunc, EqualAirwayIntersectionFeatureFunc, FreeAirwayIntersectionFeatureFunc); } OGRXPlaneLayer::ResetReading(); }
void object::test<3>() { CPLHashSet* set = CPLHashSetNew(CPLHashSetHashStr, CPLHashSetEqualStr, CPLFree); ensure(CPLHashSetInsert(set, CPLStrdup("hello")) == TRUE); ensure(CPLHashSetInsert(set, CPLStrdup("good morning")) == TRUE); ensure(CPLHashSetInsert(set, CPLStrdup("bye bye")) == TRUE); ensure(CPLHashSetSize(set) == 3); ensure(CPLHashSetInsert(set, CPLStrdup("bye bye")) == FALSE); ensure(CPLHashSetSize(set) == 3); ensure(CPLHashSetRemove(set, "bye bye") == TRUE); ensure(CPLHashSetSize(set) == 2); ensure(CPLHashSetRemove(set, "good afternoon") == FALSE); ensure(CPLHashSetSize(set) == 2); CPLHashSetDestroy(set); }
static char* CPLLoadSchemaStr(const char* pszXSDFilename) { #ifdef HAS_VALIDATION_BUG CPLHasLibXMLBug(); #endif CPLHashSet* hSetSchemas = CPLHashSetNew(CPLHashSetHashStr, CPLHashSetEqualStr, CPLFree); CPLXMLNode* psSchema = CPLLoadSchemaStrInternal(hSetSchemas, pszXSDFilename); char* pszStr = NULL; if (psSchema) { CPLMoveImportAtBeginning(psSchema); pszStr = CPLSerializeXMLTree(psSchema); CPLDestroyXMLNode(psSchema); } CPLHashSetDestroy(hSetSchemas); return pszStr; }
const char *VRTSourcedRasterBand::GetMetadataItem( const char * pszName, const char * pszDomain ) { /* ==================================================================== */ /* LocationInfo handling. */ /* ==================================================================== */ if( pszDomain != NULL && EQUAL(pszDomain,"LocationInfo") && (EQUALN(pszName,"Pixel_",6) || EQUALN(pszName,"GeoPixel_",9)) ) { int iPixel, iLine; /* -------------------------------------------------------------------- */ /* What pixel are we aiming at? */ /* -------------------------------------------------------------------- */ if( EQUALN(pszName,"Pixel_",6) ) { if( sscanf( pszName+6, "%d_%d", &iPixel, &iLine ) != 2 ) return NULL; } else if( EQUALN(pszName,"GeoPixel_",9) ) { double adfGeoTransform[6]; double adfInvGeoTransform[6]; double dfGeoX, dfGeoY; if( sscanf( pszName+9, "%lf_%lf", &dfGeoX, &dfGeoY ) != 2 ) return NULL; if( GetDataset() == NULL ) return NULL; if( GetDataset()->GetGeoTransform( adfGeoTransform ) != CE_None ) return NULL; if( !GDALInvGeoTransform( adfGeoTransform, adfInvGeoTransform ) ) return NULL; iPixel = (int) floor( adfInvGeoTransform[0] + adfInvGeoTransform[1] * dfGeoX + adfInvGeoTransform[2] * dfGeoY ); iLine = (int) floor( adfInvGeoTransform[3] + adfInvGeoTransform[4] * dfGeoX + adfInvGeoTransform[5] * dfGeoY ); } else return NULL; if( iPixel < 0 || iLine < 0 || iPixel >= GetXSize() || iLine >= GetYSize() ) return NULL; /* -------------------------------------------------------------------- */ /* Find the file(s) at this location. */ /* -------------------------------------------------------------------- */ char **papszFileList = NULL; int nListMaxSize = 0, nListSize = 0; CPLHashSet* hSetFiles = CPLHashSetNew(CPLHashSetHashStr, CPLHashSetEqualStr, NULL); for( int iSource = 0; iSource < nSources; iSource++ ) { int nReqXOff, nReqYOff, nReqXSize, nReqYSize; int nOutXOff, nOutYOff, nOutXSize, nOutYSize; if (!papoSources[iSource]->IsSimpleSource()) continue; VRTSimpleSource *poSrc = (VRTSimpleSource *) papoSources[iSource]; if( !poSrc->GetSrcDstWindow( iPixel, iLine, 1, 1, 1, 1, &nReqXOff, &nReqYOff, &nReqXSize, &nReqYSize, &nOutXOff, &nOutYOff, &nOutXSize, &nOutYSize ) ) continue; poSrc->GetFileList( &papszFileList, &nListSize, &nListMaxSize, hSetFiles ); } /* -------------------------------------------------------------------- */ /* Format into XML. */ /* -------------------------------------------------------------------- */ int i; osLastLocationInfo = "<LocationInfo>"; for( i = 0; i < nListSize; i++ ) { osLastLocationInfo += "<File>"; char* pszXMLEscaped = CPLEscapeString(papszFileList[i], -1, CPLES_XML); osLastLocationInfo += pszXMLEscaped; CPLFree(pszXMLEscaped); osLastLocationInfo += "</File>"; } osLastLocationInfo += "</LocationInfo>"; CSLDestroy( papszFileList ); CPLHashSetDestroy( hSetFiles ); return osLastLocationInfo.c_str(); } /* ==================================================================== */ /* Other domains. */ /* ==================================================================== */ else return GDALRasterBand::GetMetadataItem( pszName, pszDomain ); }
OGRXPlaneAirwayIntersectionLayer::~OGRXPlaneAirwayIntersectionLayer() { CPLHashSetDestroy(poSet); }