Skip to content

Commit

Permalink
feat: show file type settings and add default path for save tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
kfilippenok committed Jan 20, 2025
1 parent e31dffb commit 004fa79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/TilesManipulations/TilesManipulations.Base.pas
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,13 @@ ETMDownload = class(ETilesManipulator);

TTilesManipulator = class
const
defPath = 'tiles/{p}/{z}/{x}/{y}';
defSkipMissing = False;
defShowFileType = False;
strict private
FLayers: TLayers;
FPath: String;
FShowFileType: Boolean;
FSkipMissing: Boolean;
strict private
function ProcessPath(const AProviderName: String; const AZoom: Integer; const AX, AY: Integer): String;
Expand All @@ -179,9 +182,10 @@ TTilesManipulator = class
procedure Download(const AMinZoom, AMaxZoom: Integer); virtual;
procedure Download(const AMinZoom, AMaxZoom: Integer; const AMinLatitude, AMaxLatitude, AMinLongitude, AMaxLongitude: Float); virtual; overload;
public
property Layers : TLayers read FLayers write FLayers;
property Path : String read FPath write FPath;
property SkipMissing: Boolean read FSkipMissing write FSkipMissing default defSkipMissing;
property Layers : TLayers read FLayers write FLayers;
property Path : String read FPath write FPath;
property ShowFileType: Boolean read FShowFileType write FShowFileType default defShowFileType;
property SkipMissing : Boolean read FSkipMissing write FSkipMissing default defSkipMissing;
end;

implementation
Expand Down Expand Up @@ -430,6 +434,7 @@ function TTilesManipulator.ProcessPath(const AProviderName: String;
Result := StringReplace(Result, '{z}', AZoom.ToString, [rfReplaceAll]);
Result := StringReplace(Result, '{x}', AX.ToString, [rfReplaceAll]);
Result := StringReplace(Result, '{y}', AY.ToString, [rfReplaceAll]);
Result := Result + IfThen(ShowFileType, '.png');
end;

procedure TTilesManipulator.SaveTile(const ATileImg: TBGRABitmap;
Expand Down Expand Up @@ -491,6 +496,8 @@ constructor TTilesManipulator.Create;
inherited Create;

FLayers := TLayers.Create(True);
FPath := defPath;
FShowFileType := defShowFileType;
FSkipMissing := defSkipMissing;
end;

Expand Down
1 change: 0 additions & 1 deletion src/tilesdownloader.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ ATilesDownloader = class(TCustomApplication)
TilesManipulator := TTilesManipulator.Create;
TilesManipulator.Layers.Add(Providers['osm-standard']);
TilesManipulator.Layers.Add(Providers['railway-standard']);
TilesManipulator.Path := 'tiles/{p}/{z}/{x}_{y}';
TilesManipulator.Download(0, 1);
TilesManipulator.Free;

Expand Down

0 comments on commit 004fa79

Please sign in to comment.