diff --git a/components/lazmapviewer/source/mvdownloadengine.pas b/components/lazmapviewer/source/mvdownloadengine.pas index 33829a89e..91513d800 100644 --- a/components/lazmapviewer/source/mvdownloadengine.pas +++ b/components/lazmapviewer/source/mvdownloadengine.pas @@ -24,7 +24,6 @@ type TMvCustomDownloadEngine = class(TComponent) protected - function GetLocalFileName(const Url: String): String; procedure InternalDownloadFile(const Url: String; AStream: TStream); virtual; abstract; procedure LoadFromLocalFile(const AFileName: String; AStream: TStream); public @@ -35,28 +34,20 @@ type implementation uses - StrUtils; - -const - FILE_SCHEME = 'file://'; + URIParser; { TMvCustomDownloadEngine } procedure TMvCustomDownloadEngine.DownloadFile(const Url: string; AStream: TStream); +var + fn: String; begin - if AnsiStartsText(FILE_SCHEME, Url) then - LoadFromLocalFile(GetLocalFileName(Url), AStream) + if URIToFileName(Url, fn) then + LoadFromLocalFile(fn, AStream) else InternalDownloadFile(Url, AStream); end; -// Chops the "file://" off of a local file name. -// Note: Does not check whether the Url really begins with "file://". -function TMvCustomDownloadEngine.GetLocalFileName(const Url: String): String; -begin - Result := Copy(Url, Length(FILE_SCHEME) + 1, MaxInt); -end; - procedure TMvCustomDownloadEngine.LoadFromLocalFile(const AFileName: String; AStream: TStream); var diff --git a/components/lazmapviewer/source/mvengine.pas b/components/lazmapviewer/source/mvengine.pas index a740baf82..8720f84c3 100644 --- a/components/lazmapviewer/source/mvengine.pas +++ b/components/lazmapviewer/source/mvengine.pas @@ -487,7 +487,7 @@ begin Env := TEnvTile(Data); Id := Env.Tile; MapO := Env.Win.MapProvider; - if Assigned(MapO) then + if Assigned(MapO) and Assigned(Cache) then begin if not Cache.InCache(MapO, Id) then begin @@ -500,7 +500,7 @@ begin try try FDownloadEngine.DownloadFile(Url, lStream); - Cache.Add(MapO, Id, lStream); + if Assigned(Cache) then Cache.Add(MapO, Id, lStream); except end; finally diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index aaaa34e48..680f4ce67 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -61,7 +61,7 @@ Type function GetCachePath: String; function GetCenter: TRealPoint; function GetDownloadEngine: TMvCustomDownloadEngine; - function GetDrawingEngine: TMvCustoMDrawingEngine; + function GetDrawingEngine: TMvCustomDrawingEngine; function GetMapProvider: String; function GetOnCenterMove: TNotifyEvent; function GetOnChange: TNotifyEvent;