Changeset 2279
- Timestamp:
- 03/05/10 14:16:21 (5 months ago)
- Location:
- FalconView/trunk/public/fvw_core/GeodataDataSources
- Files:
-
- 2 added
- 5 modified
-
GeodataDataSources.vcproj (modified) (2 diffs)
-
KMLImageDataResource.cpp (added)
-
KMLImageDataResource.h (added)
-
KMLResource.h (modified) (3 diffs)
-
LibkmlDataSource.cpp (modified) (3 diffs)
-
LibkmlDataSource.h (modified) (7 diffs)
-
UtilityMethods.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FalconView/trunk/public/fvw_core/GeodataDataSources/GeodataDataSources.vcproj
r2277 r2279 550 550 </File> 551 551 <File 552 RelativePath=".\KMLImageDataResource.cpp" 553 > 554 </File> 555 <File 552 556 RelativePath=".\KMLNetworkLinkResource.cpp" 553 557 > … … 744 748 </File> 745 749 <File 750 RelativePath=".\KMLImageDataResource.h" 751 > 752 </File> 753 <File 746 754 RelativePath=".\KMLNetworkLinkResource.h" 747 755 > -
FalconView/trunk/public/fvw_core/GeodataDataSources/KMLResource.h
r2277 r2279 15 15 16 16 IStream* m_pMarshalingStream; 17 IFvDataSourceCallbackPtr m_marshaledCallback;18 17 19 18 public: … … 36 35 { 37 36 // create IStream used for marshalling 38 m_ marshaledCallback= NULL;37 m_pMarshalingStream = NULL; 39 38 THROW_IF_NOT_OK(::CoMarshalInterThreadInterfaceInStream(IID_IFvDataSourceCallback, 40 39 pDataSourceCallback, &m_pMarshalingStream)); … … 51 50 try 52 51 { 53 // marshall the IDisplayChangeNotifyEvents interface to this thread 54 HRESULT hr = ::CoGetInterfaceAndReleaseStream(m_pMarshalingStream, 55 IID_IFvDataSourceCallback, reinterpret_cast<void **>(&m_marshaledCallback)); 52 if (m_pMarshalingStream != NULL) 53 { 54 // marshall the IDisplayChangeNotifyEvents interface to this thread 55 IFvDataSourceCallbackPtr marshaledCallback; 56 56 57 if (m_marshaledCallback != NULL) 58 m_marshaledCallback->DataSourceChanged(); 57 HRESULT hr = ::CoGetInterfaceAndReleaseStream(m_pMarshalingStream, 58 IID_IFvDataSourceCallback, reinterpret_cast<void **>(&marshaledCallback)); 59 60 if (marshaledCallback != NULL) 61 marshaledCallback->DataSourceChanged(); 62 } 59 63 } 60 64 catch(_com_error &) -
FalconView/trunk/public/fvw_core/GeodataDataSources/LibkmlDataSource.cpp
r2277 r2279 38 38 #include "kml/base/file.h" 39 39 #include "kml/base/uri_parser.h" 40 #include "KMLImageDataResource.h" 41 #include "KMLDataLoader.h" 40 42 41 43 // CLibkmlDataSource 42 43 /* static */ ULONG CLibkmlDataSource::s_nextMemFile = 0;44 44 45 45 STDMETHODIMP CLibkmlDataSource::raw_Open(BSTR file) … … 441 441 442 442 // return a cached image, if there is one 443 STRING_TO_VARIANT_MAP::iterator iter = m_imageCache.begin(); //find(identifierAsChar); 444 if (iter != m_imageCache.end()) 445 { 446 // return the cached image 447 *imageData = _variant_t(iter->second).Detach(); // copies buffer to imageData 443 CKMLImageDataResource* pCachedImage = m_imageCache.Find(identifierAsChar); 444 if (pCachedImage != NULL) 445 { 446 pCachedImage->GetImageData(imageData); 448 447 return S_OK; 449 448 } 450 449 451 // no image cached 452 453 // fetch the image data 454 std::string file_contents; 455 FetchDataRelativeToDataSource(identifierAsChar, file_contents); 456 char mem_file_name[MEM_FILE_NAME_MAX_LENGTH]; 457 sprintf_s(mem_file_name, MEM_FILE_NAME_MAX_LENGTH, "/vsimem/LibkmlDSMemFile%u", s_nextMemFile++); 458 VSIFCloseL(VSIFileFromMemBuffer(mem_file_name, (GByte*)file_contents.c_str(), file_contents.length(), FALSE)); 459 460 // use GDAL to interpret the raw data 461 IFvGDALDataSetPtr GDALDataset(CLSID_FvGDALDataSet); 462 GDALDataset->Open(_bstr_t(mem_file_name)); 463 IRasterDataSetPtr raster = GDALDataset; 464 *imageData = raster->InterpretAsImage().Detach(); 465 VSIUnlink(mem_file_name); 466 467 // cache the image 468 m_imageCache[identifierAsChar] = _variant_t(imageData); // copies imageData to buffer 469 } 470 CATCH_BLOCK_RET 471 450 // no image cached. we'll create a resource for the image and 451 // load it in a background thread 452 CKMLImageDataResource* imageDataResource = new CKMLImageDataResource(this, identifierAsChar); 453 m_imageCache.Insert(identifierAsChar, imageDataResource); 454 CKMLDataLoader::GetInstance()->AddLoadRequest(this, imageDataResource); 455 456 imageDataResource->GetImageData(imageData); 457 } 458 CATCH_BLOCK_RET 459 460 return S_OK; 461 } 462 463 STDMETHODIMP CLibkmlDataSource::raw_DataSourceChanged() 464 { 465 FireDataSourceChanged(m_handle); 472 466 return S_OK; 473 467 } … … 956 950 return S_OK; 957 951 } 952 953 954 void CKmlImageCache::Insert(const std::string& imageId, CKMLImageDataResource *pResource) 955 { 956 // add smarts here to manage resource quotas in the cache 957 // 958 959 m_imageCache[imageId] = pResource; 960 } 961 962 CKMLImageDataResource* CKmlImageCache::Find(const std::string& imageId) 963 { 964 std::map<std::string, CKMLImageDataResource*>::iterator it = m_imageCache.find(imageId); 965 if (it == m_imageCache.end()) 966 return NULL; 967 968 return it->second; 969 } 970 971 void CKmlImageCache::Clear() 972 { 973 std::map<std::string, CKMLImageDataResource*>::iterator it = m_imageCache.begin(); 974 for(; it != m_imageCache.end(); ++it) 975 delete it->second; 976 } -
FalconView/trunk/public/fvw_core/GeodataDataSources/LibkmlDataSource.h
r2277 r2279 31 31 #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms." 32 32 #endif 33 34 class CKMLImageDataResource; 35 36 class CKmlImageCache 37 { 38 std::map<std::string, CKMLImageDataResource*> m_imageCache; 39 40 public: 41 void Insert(const std::string& imageId, CKMLImageDataResource *pResource); 42 CKMLImageDataResource* Find(const std::string& imageId); 43 void Clear(); 44 }; 33 45 34 46 // CLibkmlDataSource … … 44 56 public IDispatchImpl<IFvDataSourceEdit, &__uuidof(IFvDataSourceEdit), &LIBID_FvDataSourcesLib, /* wMajor = */ 1, /* wMinor = */ 0>, 45 57 public IDispatchImpl<IUIState, &__uuidof(IUIState), &LIBID_FvDataSourcesLib, /* wMajor = */ 1, /* wMinor = */ 0>, 58 public IDispatchImpl<IFvDataSourceCallback, &__uuidof(IUIState), &LIBID_FvDataSourcesLib, /* wMajor = */ 1, /* wMinor = */ 0>, 46 59 public CComErrorHandler 47 60 { … … 71 84 COM_INTERFACE_ENTRY(IRegionatedKMLContainer) 72 85 COM_INTERFACE_ENTRY(IUIState) 86 COM_INTERFACE_ENTRY(IFvDataSourceCallback) 73 87 END_COM_MAP() 74 88 … … 88 102 CInternalObjectRegistry::UnregisterObject(m_handle); 89 103 m_b_objectFinalReleased = true; 104 105 m_imageCache.Clear(); 90 106 } 91 107 … … 157 173 STDMETHOD(raw_GetImageByIdentifier)(BSTR identifier, VARIANT* imageData); 158 174 175 // IFvDataSourceCallback Methods 176 public: 177 STDMETHOD(raw_DataSourceChanged)(); 178 159 179 // IFvDataSourceEdit Methods 160 180 public: … … 185 205 kmlengine::KmzFilePtr m_kmz_file; // populate this if KMZ 186 206 ULONG m_internalRefs; 187 STRING_TO_VARIANT_MAPm_imageCache;207 CKmlImageCache m_imageCache; 188 208 DATA_SOURCE_CALLBACK_VECTOR m_callbacks; 189 209 bool m_b_objectFinalReleased; … … 200 220 static std::string s_dumpFile; 201 221 static void MaybeDumpKML(std::string& kml); 202 203 static ULONG s_nextMemFile;204 222 }; 205 223 -
FalconView/trunk/public/fvw_core/GeodataDataSources/UtilityMethods.h
r2242 r2279 146 146 STDMETHOD(raw_GetLeakData)(VARIANT* leakData); 147 147 148 static ULONG s_nextMemFile;149 150 148 static OGRPoint* Copy2OGR(IPoint* point); 151 149 static OGRLineString* Copy2OGR(ILineString* lineString);
