- Timestamp:
- 03/05/10 11:44:10 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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);
