Changeset 2277
- Timestamp:
- 03/05/10 11:44:10 (5 months ago)
- Location:
- FalconView/trunk/public/fvw_core/GeodataDataSources
- Files:
-
- 5 added
- 6 modified
-
GeodataDataSources.vcproj (modified) (2 diffs)
-
KMLDataLoader.cpp (added)
-
KMLDataLoader.h (added)
-
KMLNetworkLinkResource.cpp (added)
-
KMLNetworkLinkResource.h (added)
-
KMLResource.h (added)
-
LibkmlDataSource.cpp (modified) (7 diffs)
-
LibkmlDataSource.h (modified) (4 diffs)
-
LibkmlNetworkLink.cpp (modified) (18 diffs)
-
LibkmlNetworkLink.h (modified) (3 diffs)
-
stdafx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FalconView/trunk/public/fvw_core/GeodataDataSources/GeodataDataSources.vcproj
r2214 r2277 546 546 </File> 547 547 <File 548 RelativePath=".\KMLDataLoader.cpp" 549 > 550 </File> 551 <File 552 RelativePath=".\KMLNetworkLinkResource.cpp" 553 > 554 </File> 555 <File 548 556 RelativePath=".\LibkmlContainerBase.cpp" 549 557 > … … 732 740 </File> 733 741 <File 742 RelativePath=".\KMLDataLoader.h" 743 > 744 </File> 745 <File 746 RelativePath=".\KMLNetworkLinkResource.h" 747 > 748 </File> 749 <File 750 RelativePath=".\KMLResource.h" 751 > 752 </File> 753 <File 734 754 RelativePath=".\LibkmlContainerBase.h" 735 755 > -
FalconView/trunk/public/fvw_core/GeodataDataSources/LibkmlDataSource.cpp
r2267 r2277 387 387 std::string resolved_path(path); 388 388 389 if (m_kml_file_path )389 if (m_kml_file_path.size()) 390 390 { 391 391 // path is possibly relative to the path / URL of the file from which this was loaded 392 resolved_path = CUtilityMethods::ResolveURI(m_kml_file_path , path);392 resolved_path = CUtilityMethods::ResolveURI(m_kml_file_path.c_str(), path); 393 393 } 394 394 … … 441 441 442 442 // return a cached image, if there is one 443 STRING_TO_VARIANT_MAP::iterator iter = m_imageCache. find(identifierAsChar);443 STRING_TO_VARIANT_MAP::iterator iter = m_imageCache.begin(); //find(identifierAsChar); 444 444 if (iter != m_imageCache.end()) 445 445 { … … 528 528 529 529 // load the KML into this object 530 LoadKML(file_data, url_cstr);530 WrapKMLFile(LoadKML(file_data, url_cstr)); 531 531 } 532 532 CATCH_BLOCK_RET … … 563 563 __ensure_not_released(); 564 564 565 if (m_kml_file_path) 566 { 567 _bstr_t u(m_kml_file_path); 568 *url = u.Detach(); 565 if (m_kml_file_path.size()) 566 { 567 *url = _bstr_t(m_kml_file_path.c_str()).Detach(); 569 568 } 570 569 else … … 607 606 } 608 607 609 voidCLibkmlDataSource::LoadKML(std::string &kml, const char* path) // path may be a URL, if this was opened from a URL608 kmlengine::KmlFilePtr CLibkmlDataSource::LoadKML(std::string &kml, const char* path) // path may be a URL, if this was opened from a URL 610 609 { 611 610 // CreateFromParse creates some pseudo-memory leaks. These "leaks" do not grow and are not a problem. … … 652 651 // save the path to the file 653 652 654 if (m_kml_file_path)655 delete[] m_kml_file_path;656 657 653 if (path) 658 { 659 size_t s = strlen(path) + 1; 660 m_kml_file_path = new char[s]; 661 memcpy(m_kml_file_path, path, s); 662 } 663 654 m_kml_file_path = path; 655 656 return kml_file; 657 } 658 659 void CLibkmlDataSource::WrapKMLFile(const kmlengine::KmlFilePtr& kml_file) 660 { 664 661 // wrap the root element (must be a data source type) 665 662 kmldom::ElementPtr root = kml_file->get_root(); … … 923 920 (*iter)->DataSourceChanged(); 924 921 } 925 catch ( ...)922 catch (_com_error& ) 926 923 { 927 924 std::string msg("an exception was caught in making a callback on IFvDataSourceCallback"); -
FalconView/trunk/public/fvw_core/GeodataDataSources/LibkmlDataSource.h
r2267 r2277 47 47 { 48 48 public: 49 CLibkmlDataSource() : m_root_element(NULL), m_ kml_file_path(NULL), m_internalRefs(0), m_factory(NULL), m_b_objectFinalReleased(false),49 CLibkmlDataSource() : m_root_element(NULL), m_internalRefs(0), m_factory(NULL), m_b_objectFinalReleased(false), 50 50 m_visible(VARIANT_TRUE), m_expanded(VARIANT_TRUE) {} 51 51 … … 87 87 __ensure_not_released(); 88 88 CInternalObjectRegistry::UnregisterObject(m_handle); 89 if (m_kml_file_path)90 delete[] m_kml_file_path;91 89 m_b_objectFinalReleased = true; 92 90 } … … 120 118 121 119 void FetchDataRelativeToDataSource(const char* path, std::string& out_string); 122 void LoadKML(std::string &kml, const char* path); 120 kmlengine::KmlFilePtr LoadKML(std::string &kml, const char* path); 121 void WrapKMLFile(const kmlengine::KmlFilePtr& kml_file); 122 123 void SetKmlFilePath(const std::string& path) { m_kml_file_path = path; } 123 124 124 125 // ILibkmlDataSource Methods … … 181 182 LONG m_handle; 182 183 IFvDataSourcePtr m_root_element; 183 char *m_kml_file_path; // this may be a file path our a URL, may be NULL if KMZ184 std::string m_kml_file_path; // this may be a file path our a URL, may be NULL if KMZ 184 185 kmlengine::KmzFilePtr m_kmz_file; // populate this if KMZ 185 186 ULONG m_internalRefs; -
FalconView/trunk/public/fvw_core/GeodataDataSources/LibkmlNetworkLink.cpp
r2270 r2277 24 24 #include "LibkmlDataSource.h" 25 25 #include "ComErrorObject.h" 26 #include "KMLDataLoader.h" 26 27 27 28 // CLibkmlNetworkLink … … 32 33 { 33 34 PopulateWrappedDataSourceAsNecessary(); 34 if (m_wrappedDataSource) 35 return m_wrappedDataSource->get_DataSetCount(count); 35 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 36 if (wrappedDataSource) 37 return wrappedDataSource->get_DataSetCount(count); 36 38 } 37 39 catch (...) … … 54 56 { 55 57 PopulateWrappedDataSourceAsNecessary(); 56 if (m_wrappedDataSource) 57 return m_wrappedDataSource->raw_GetDataSet(index, dataSet); 58 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 59 if (wrappedDataSource) 60 return wrappedDataSource->raw_GetDataSet(index, dataSet); 58 61 return E_FAIL; 59 62 } … … 72 75 { 73 76 PopulateWrappedDataSourceAsNecessary(); 74 if (m_wrappedDataSource) 75 return m_wrappedDataSource->get_Name(name); 77 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 78 if (wrappedDataSource) 79 return wrappedDataSource->get_Name(name); 76 80 *name = _bstr_t("<NetworkLink>").Detach(); 77 81 } … … 87 91 { 88 92 PopulateWrappedDataSourceAsNecessary(); 89 if (m_wrappedDataSource) 90 return m_wrappedDataSource->raw_GetDataSetByName(name, dataSet); 93 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 94 if (wrappedDataSource) 95 return wrappedDataSource->raw_GetDataSetByName(name, dataSet); 91 96 return E_FAIL; 92 97 } … … 99 104 { 100 105 PopulateWrappedDataSourceAsNecessary(); 101 if (m_wrappedDataSource) 102 return m_wrappedDataSource->get_DataSourceCount(count); 106 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 107 if (wrappedDataSource) 108 return wrappedDataSource->get_DataSourceCount(count); 103 109 } 104 110 catch (...) … … 121 127 { 122 128 PopulateWrappedDataSourceAsNecessary(); 123 if (m_wrappedDataSource) 124 return m_wrappedDataSource->raw_GetDataSource(index, dataSource); 129 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 130 if (wrappedDataSource) 131 return wrappedDataSource->raw_GetDataSource(index, dataSource); 125 132 return E_FAIL; 126 133 } … … 133 140 { 134 141 PopulateWrappedDataSourceAsNecessary(); 135 if (m_wrappedDataSource) 136 return m_wrappedDataSource->raw_GetDataSourceByName(name, dataSource); 142 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 143 if (wrappedDataSource) 144 return wrappedDataSource->raw_GetDataSourceByName(name, dataSource); 137 145 return E_FAIL; 138 146 } … … 152 160 PopulateWrappedDataSourceAsNecessary(); 153 161 154 if (m_wrappedDataSource) 155 { 156 ISymbolFactoryPtr symbolFactory = m_wrappedDataSource; 162 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 163 if (wrappedDataSource) 164 { 165 ISymbolFactoryPtr symbolFactory = wrappedDataSource; 157 166 if (symbolFactory) 158 167 return symbolFactory->raw_GetImageByIdentifier(identifier, imageData); … … 181 190 try 182 191 { 183 if ( !m_wrappedDataSource&& m_networkLink->has_link())192 if (m_networkLinkResource.State() == Resource_Not_Loaded && m_networkLink->has_link()) 184 193 { 185 194 // If the regionation parameters have been set and the feature is active, … … 205 214 { 206 215 // get the base URL 207 IFvDataSourcePtr dataSource(CLSID_LibkmlDataSource);208 ILibkmlDataSourcePtr libkmlDataSource = dataSource;209 216 kmldom::LinkPtr link = m_networkLink->get_link(); 210 217 std::string url = CUtilityMethods::ResolveURI((char*)m_rootDS->URL, (char*)link->get_href().c_str()); … … 262 269 } 263 270 264 // populate the data source from the URL 265 long handle = libkmlDataSource->GetHandle(); 266 CLibkmlDataSource* ds = (CLibkmlDataSource*)CInternalObjectRegistry::GetObject(handle); 267 std::string kml_data; 268 ds->FetchDataRelativeToDataSource(url.c_str(), kml_data); 269 ds->LoadKML(kml_data, url.c_str()); 270 271 m_wrappedDataSource = dataSource.Detach(); 272 273 // register for callbacks on the wrapped data source so that changes notices get fired to anything registered 274 // for callbacks on the root data source 275 dataSource = libkmlDataSource; // reassociate the smart pointer after Detach() 276 dataSource->RegisterForCallbacks(this); 277 278 // indicate to the root data source that something has changed 279 if (!m_bFirstAttemptToLoad) 280 CLibkmlDataSource::FireDataSourceChanged(m_rootDS->Handle); 271 // Load the networklink in a background thread 272 m_networkLinkResource.SetResolvedUri(url); 273 CKMLDataLoader::GetInstance()->AddLoadRequest(this, &m_networkLinkResource); 281 274 } 282 275 } … … 284 277 catch (...) 285 278 { 286 m_wrappedDataSource = NULL;287 279 THROW_ERROR_MSG2(E_FAIL, "exception in CLibkmlNetworkLink::PopulateWrappedDataSourceAsNecessary()"); 288 280 } … … 296 288 { 297 289 PopulateWrappedDataSourceAsNecessary(); 298 if (m_wrappedDataSource) 299 return m_wrappedDataSource->raw_Extent2D(minX, minY, maxX, maxY); 290 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 291 if (wrappedDataSource) 292 return wrappedDataSource->raw_Extent2D(minX, minY, maxX, maxY); 300 293 return E_FAIL; 301 294 } … … 314 307 { 315 308 PopulateWrappedDataSourceAsNecessary(); 316 if (m_wrappedDataSource) 317 return m_wrappedDataSource->get_Description(description); 309 const IFvDataSourcePtr& wrappedDataSource = m_networkLinkResource.GetWrappedDataSource(); 310 if (wrappedDataSource) 311 return wrappedDataSource->get_Description(description); 318 312 *description = _bstr_t("A KML <NetworkLink>.").Detach(); 319 313 } … … 329 323 { 330 324 IFvDataSourcePtr rootDS = m_rootDS; 331 return rootDS->RegisterForCallbacks(fvDataSourceCallback); ;325 return rootDS->RegisterForCallbacks(fvDataSourceCallback); 332 326 } 333 327 CATCH_BLOCK_RET … … 339 333 { 340 334 IFvDataSourcePtr rootDS = m_rootDS; 341 return rootDS->UnregisterForCallbacks(fvDataSourceCallback); ;335 return rootDS->UnregisterForCallbacks(fvDataSourceCallback); 342 336 } 343 337 CATCH_BLOCK_RET … … 362 356 363 357 // pass the parameters on to any wrapped data source 364 IRegionatedKMLContainerPtr regionatedKMLContainer = m_ wrappedDataSource;358 IRegionatedKMLContainerPtr regionatedKMLContainer = m_networkLinkResource.GetWrappedDataSource(); 365 359 if (regionatedKMLContainer) 366 360 regionatedKMLContainer->SetRegionationParameters(leftLon, bottomLat, rightLon, topLat, degreesPerPixelX, degreesPerPixelY); -
FalconView/trunk/public/fvw_core/GeodataDataSources/LibkmlNetworkLink.h
r2270 r2277 25 25 #include "InternalObjectRegistry.h" 26 26 #include "ComErrorHandler.h" 27 #include "KMLNetworkLinkResource.h" 27 28 28 29 #include "kml/dom.h" … … 47 48 { 48 49 public: 49 CLibkmlNetworkLink() : m_ wrappedDataSource(NULL), m_bFirstAttemptToLoad(TRUE),50 CLibkmlNetworkLink() : m_bFirstAttemptToLoad(TRUE), 50 51 m_leftLon(-180.0), m_bottomLat(-90.0), m_rightLon(180.0), m_topLat(90.0), 51 m_degreesPerPixelX(-1.0), m_degreesPerPixelY(-1.0) {}52 m_degreesPerPixelX(-1.0), m_degreesPerPixelY(-1.0), m_networkLinkResource(this) {} 52 53 53 54 DECLARE_REGISTRY_RESOURCEID(IDR_LIBKMLNETWORKLINK) … … 126 127 void PopulateWrappedDataSourceAsNecessary(); 127 128 129 CKMLNetworkLinkResource m_networkLinkResource; 130 128 131 LONG m_handle; 129 132 ILibkmlDataSourcePtr m_rootDS; 130 133 kmldom::NetworkLinkPtr m_networkLink; 131 IFvDataSourcePtr m_wrappedDataSource;134 132 135 BOOL m_bFirstAttemptToLoad; // used to prevent firing data source changed notice the first time it's loaded 133 136 -
FalconView/trunk/public/fvw_core/GeodataDataSources/stdafx.h
r2268 r2277 82 82 typedef std::vector<ILinearRingPtr> LINEAR_RING_VECTOR; 83 83 84 #include <queue> 85 84 86 #define MEM_FILE_NAME_MAX_LENGTH 40 85 87
