Skip to content

Commit

Permalink
feat: add skip missing tiles option
Browse files Browse the repository at this point in the history
  • Loading branch information
kfilippenok committed Dec 4, 2024
1 parent 6922a1b commit c0e3078
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

A detailed list of available options and their possible applications with examples of the use of both individual options and their combinations.

🇬🇧 [English](./docs/USAGE.md) | 🇷🇺 [Russian](./docs/USAGE_RU.md)
🇬🇧 [English](./docs/USAGE.md) | 🇷🇺 [Русский](./docs/USAGE_RU.md)

## Supported platforms

Expand All @@ -41,7 +41,7 @@ You can download the utility on the [releases tab](https://github.com/kfilippeno

There are some restrictions when downloading tiles from OpenStreetMap and its like.

🇬🇧 [English](./docs/RESTRICTIONS.md) | 🇷🇺 [Russian](./docs/RESTRICTIONS_RU.md)
🇬🇧 [English](./docs/RESTRICTIONS.md) | 🇷🇺 [Русский](./docs/RESTRICTIONS_RU.md)

## Kanban

Expand Down
6 changes: 6 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ If you need the file extension in the name, use this option. The parameter with

****

### skip-missing

Skip missing tiles when receiving from the server.

****

### full-map

Download full map. Coordinates are not used.
Expand Down
8 changes: 7 additions & 1 deletion docs/USAGE_RU.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Usage
# Использование

🇬🇧 [English](./USAGE.md) | 🇷🇺 Русский

Expand Down Expand Up @@ -171,6 +171,12 @@ Example:

****

### skip-missing

Пропуск отсутствующих плиток при получении с сервера.

****

### full-map

Скачивание всей карты. Указанные координаты не учитываются.
Expand Down
16 changes: 16 additions & 0 deletions src/TilesDownload/TilesDownload.Classes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ HTileHelper = record helper for RTile
defMinZoom = 6;
defMaxZoom = 7;
defShowFileType = False;
defSkipMissing = False;
defTileRes = 256;
defOtherTileRes = False;

Expand Down Expand Up @@ -101,6 +102,7 @@ CTilesDownloader = class(TFPCustomHTTPClient)
FMaxZoom: Integer;
FCoordinates: array[0..1] of RCoordinate;
FShowFileType: Boolean;
FSkipMissing: Boolean;
strict private
function GetOutPathAuto: String;
function GetOutPathCustom: String;
Expand Down Expand Up @@ -143,6 +145,7 @@ CTilesDownloader = class(TFPCustomHTTPClient)
property MinZoom : Integer read FMinZoom write FMinZoom default defMinZoom;
property MaxZoom : Integer read FMaxZoom write FMaxZoom default defMaxZoom;
property ShowFileType : Boolean read FShowFileType write FShowFileType default defShowFileType;
property SkipMissing : Boolean read FSkipMissing write FSkipMissing default defSkipMissing;
property Coordinates[Index: Integer]: RCoordinate read getCoordinate write setCoordinate;
property TotalTilesCount : Longword read GetTotalTilesCount;
property TotalTilesCountOnCoordinates: Longword read GetTotalTilesCountOnCoordinates;
Expand Down Expand Up @@ -394,6 +397,7 @@ constructor CTilesDownloader.Create(AOwner: TComponent);
FMinZoom := defMinZoom;
FMaxZoom := defMinZoom;
FShowFileType := defShowFileType;
FSkipMissing := defSkipMissing;
end;

destructor CTilesDownloader.Destroy;
Expand Down Expand Up @@ -624,6 +628,12 @@ procedure CTilesDownloader.Download;
except
on E: ETileDownload do
begin
if SkipMissing and (E is ETDReceive) then
begin
WriteLn('! Skip missing tile');
Continue;
end;

WriteLn;
WriteLn('Error: ', E.Message);
Exit;
Expand Down Expand Up @@ -678,6 +688,12 @@ procedure CTilesDownloader.DownloadFullMap;
except
on E: ETileDownload do
begin
if SkipMissing and (E is ETDReceive) then
begin
WriteLn('! Skip missing tile');
Continue;
end;

WriteLn;
WriteLn('Error: ', E.Message);
Exit;
Expand Down
4 changes: 3 additions & 1 deletion src/TilesDownload/TilesDownload.Types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ interface
okShowFileType,
okFullMap,
okTileRes,
okMerge);
okMerge,
okSkipMissing);

TOptions = Set of TOptionKind;

Expand All @@ -66,6 +67,7 @@ function getOptionName(Option: TOptionKind): String;
okFullMap : Exit('full-map');
okTileRes : Exit('tile-res');
okMerge : Exit('merge');
okSkipMissing : Exit('skip-missing');
else
Exit('unknown');
end;
Expand Down
4 changes: 2 additions & 2 deletions src/tilesdownloader.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ ATilesDownloader = class(TCustomApplication)
if not OptionParameter[okPattern].IsEmpty then
Pattern := OptionParameter[okPattern];

if okShowFileType in glOptions then
ShowFileType := True;
ShowFileType := okShowFileType in glOptions;
SkipMissing := okSkipMissing in glOptions;
end;
try
try
Expand Down

0 comments on commit c0e3078

Please sign in to comment.