From 923d868c85fb71ed4b10dc5bda6a564dd9ef3c98 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Mon, 6 Nov 2023 18:53:12 -0700 Subject: [PATCH] minor changes --- README.md | 19 ++++++++++++++----- pkg/image.py | 4 +++- pkg/thread.py | 2 +- test.sh | 7 +++++++ 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 test.sh diff --git a/README.md b/README.md index 8625a8d..d591533 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,19 @@ _Scrape tiles from WMTS servers._ -You know what I hate? Those godforsaken WMTS servers, perched on their digital thrones, acting like they're the TILE TYRANTS of the universe. They think they can just LOCK UP their precious little tiles and keep me from doing my THING? HA! +You know what I hate? Those godforsaken WMTS servers, perched on their digital thrones, acting like they're the TILE +TYRANTS of the universe. They think they can just LOCK UP their precious little tiles and keep me from doing my THING? +HA! -No more will these WMTS servers shroud their CRAPPY-ASS tiles in mystery. I'm coming for your DATA, you binary BASTARDS, and there's not a SINGLE 1 or 0 you can throw at me that will stop my CHARGE. +No more will these WMTS servers shroud their CRAPPY-ASS tiles in mystery. I'm coming for your DATA, you binary BASTARDS, +and there's not a SINGLE 1 or 0 you can throw at me that will stop my CHARGE. -You think your firewalls and security mumbo-jumbo can keep me at bay? THINK AGAIN. I'll slice through your defenses like a HOT PIZZA through COLD BUTTER. I'll have your DATA, and there's absolutely NOTHING, I repeat, NOTHING you can do to STOP ME. +You think your firewalls and security mumbo-jumbo can keep me at bay? THINK AGAIN. I'll slice through your defenses like +a HOT PIZZA through COLD BUTTER. I'll have your DATA, and there's absolutely NOTHING, I repeat, NOTHING you can do to +STOP ME. -So, buckle up, WMTS servers. Your reign of TILE TERROR is about to CRASH AND BURN. I'm coming for your DATA, and I'm bringing a whole lot of CHAOS with me. +So, buckle up, WMTS servers. Your reign of TILE TERROR is about to CRASH AND BURN. I'm coming for your DATA, and I'm +bringing a whole lot of CHAOS with me. ### Install @@ -29,9 +35,12 @@ python3 exfiltrate.py \ --threads 30 ``` +Building the GeoTIFF will take dozens of gigs of memory for any significant extent! For example, a 21 mile extent +required about 400GB of memory. You can use swap for this, but don't expect it to be very quick if you go this route. + ### ArcGIS -??? +TODO ### Credits diff --git a/pkg/image.py b/pkg/image.py index ea778fc..4fac620 100644 --- a/pkg/image.py +++ b/pkg/image.py @@ -1,6 +1,7 @@ import random from pathlib import Path +import PIL from PIL import Image @@ -20,5 +21,6 @@ def is_png(file_path): try: img = Image.open(file_path) return img.format == 'PNG' - except: + except PIL.UnidentifiedImageError as e: + # tqdm.write(str(e)) return False diff --git a/pkg/thread.py b/pkg/thread.py index 611355d..23560c3 100644 --- a/pkg/thread.py +++ b/pkg/thread.py @@ -23,7 +23,7 @@ def download_tile(task): if not is_png(output_path): # Delete the file and try again. del_path(output_path) - tqdm.write(f'{output_path} is not a PNG, deleting and retrying...') + tqdm.write(f'cannot identify image file: "{output_path}", deleting and retrying...') else: return row, col, 'exist' tile_url = f"{base_url}/{row}/{col}".replace('//', '/').replace(':/', '://') diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..38c42cc --- /dev/null +++ b/test.sh @@ -0,0 +1,7 @@ +venv/bin/python3 exfiltrate.py \ + https://wmts.nlsc.gov.tw/wmts/nURBAN/default/EPSG:3857/ \ + --zoom 20 \ + --referer https://maps.nlsc.gov.tw/ \ + --bbox 25.076387 121.68951 25.068282 121.700175 \ + --threads 30 \ + --output ~/Downloads/wmts-output/