Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 739bb6b

Browse files
author
U-eagle\spasche
committed
Add option to save generated image.
1 parent befb9df commit 739bb6b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tc-bench.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self):
5252
def fetch(self, options, bbox, layers):
5353
# TODO: generate TILES_URL with those parameters.
5454
params = {'WIDTH': ['256'], 'SERVICE': ['WMS'],
55-
'FORMAT': ['image/png'], 'REQUEST': ['GetMap'], 'HEIGHT': ['256'],
55+
'FORMAT': 'image/png', 'REQUEST': ['GetMap'], 'HEIGHT': ['256'],
5656
'SRS': ['EPSG:21781'], 'VERSION': ['1.1.1']}
5757
params["LAYERS"] = ','.join(layers)
5858
params["BBOX"] = bbox
@@ -61,6 +61,12 @@ def fetch(self, options, bbox, layers):
6161
duration = time.time() - start
6262
assert format == "image/png"
6363
self.check_image(image)
64+
if options.save_images:
65+
images_dir = os.path.join(os.path.dirname(__file__), "image_results")
66+
if not os.path.isdir(images_dir):
67+
os.mkdir(images_dir)
68+
n = len(os.listdir(images_dir))
69+
open(os.path.join(images_dir, "res_%003i.png" % (n + 1)), "wb").write(image)
6470
return duration
6571

6672
def main():
@@ -71,6 +77,7 @@ def main():
7177
parser.add_option("-v", "--verbose", action="store_true")
7278
parser.add_option("-d", "--dummy", action="store_true")
7379
parser.add_option("--profile", action="store_true")
80+
parser.add_option("-s", "--save-images", action="store_true")
7481
parser.add_option("", "--server")
7582

7683
parser.add_option("", "--fetcher", default="tc",

0 commit comments

Comments
 (0)