pombreda / libkml

Automatically exported from code.google.com/p/libkml
Other
0 stars 0 forks source link

Handling absolute kmz file uri #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Passing "file:///D:/Data/Test.kmz" uri to KmlCache::FetchKmlAbsolute() 
leads to trim uri to "D:/Data/Test.kmz" and this value is passed to 
NetFetcher to fetch. I think that this trim isn't correct.

What is the expected output? What do you see instead?
"file:///D:/Data/Test.kmz" is expected instead of "D:/Data/Test.kmz".

What version of the product are you using? On what operating system?
libkml 0.5.0, Windows XP, VS 2005

Please provide any additional information below.

Example code to reproduce the problem:

class NetFetcher : public kmlbase::NetFetcher {
  virtual bool FetchUrl(const std::string& url, std::string* data) const {
    return false;
  }
};

int _tmain(int argc, _TCHAR* argv[])
{
  NetFetcher            netFetcher;
  kmlengine::KmlCache   kmlCache(&netFetcher, 10);
  kmlengine::KmlFilePtr kmlFile = kmlCache.FetchKmlAbsolute("file:///D:/
Data/Test.kmz");

  return 0;
}

Original issue reported on code.google.com by DavidxMi...@gmail.com on 9 Nov 2008 at 12:48

GoogleCodeExporter commented 9 years ago
The Problem is, that in the function 

bool GetFetchableUri(const std::string& uri, std::string* fetchable_uri) 

in kml_uri.cc the scheme returned by the uri_parser->getScheme is "C" or in 
your case
"D" for the HD.
Replacing the segment

  std::string path;
  uri_parser->GetPath(&path);
  if (!path.empty()) {
    fetchable_uri->append(path);
  }

with

  std::string path;
  uri_parser->GetPath(&path);
  if (!path.empty()) {
      if( !scheme.empty() ) fetchable_uri->append( scheme ).append(":///");
    fetchable_uri->append(path);
  }

in said function seems to fix the problem.

Original comment by promesbe...@gmail.com on 19 Nov 2009 at 11:51