Use a rendered terrain image instead of the scanned map

This commit is contained in:
Olly Betts 2015-07-21 16:59:14 +01:00
parent 18e7126dd9
commit 6be112763a
2 changed files with 16 additions and 16 deletions

View File

@ -187,14 +187,14 @@ def get_img_name(maparea):
maps = { maps = {
# id left top right bottom zoom description # id left top right bottom zoom description
# G&K G&K G&K G&K factor # UTM33 UTM33 UTM33 UTM33 factor
# DO NOT just change the coordinates of "all" - they MUST match the borders of the scanned map. # DO NOT just change the coordinates of "all" - they MUST match the borders of the background image.
"all": [ 409276.28, 5283481.05, 412201.56, 5279805.56, 1.0, "All"], "all": [ 409276., 5285237., 413197., 5279805., 1.0, "All"],
"40": [ 411110.51, 5281325.74, 411602.22, 5280722.74, 3.0, "Eishöhle"], "40": [ 411110., 5281326., 411603., 5280722., 3.0, "Eishöhle"],
"76": [ 410293.14, 5282170.72, 410930.97, 5281607.07, 3.0, "Eislufthöhle"], "76": [ 410293., 5282171., 410931., 5281607., 3.0, "Eislufthöhle"],
"204": [ 411226.79, 5283085.08, 411903.50, 5282315.82, 3.0, "Steinbrückenhöhle"], "204": [ 411226., 5283086., 411904., 5282315., 3.0, "Steinbrückenhöhle"],
"tc": [ 410071.88, 5281645.52, 410938.73, 5281036.96, 3.0, "Near Top Camp"], "tc": [ 410071., 5281646., 410939., 5281036., 3.0, "Near Top Camp"],
"gk": [ 410918.96, 5285236.99, 413196.87, 5283288.24, 4.0, "Grießkogel Area"], "gk": [ 410918., 5285237., 413197., 5283288., 4.0, "Grießkogel Area"],
} }
# Keys in the order in which we want the maps output # Keys in the order in which we want the maps output
mapcodes = ["all", "gk", "40", "76", "204", "tc"] mapcodes = ["all", "gk", "40", "76", "204", "tc"]
@ -217,7 +217,7 @@ SIZE = 8
myFont = ImageFont.truetype(FONT, SIZE) myFont = ImageFont.truetype(FONT, SIZE)
showbg = not(len(sys.argv) > 1 and sys.argv[1] == '--white') showbg = not(len(sys.argv) > 1 and sys.argv[1] == '--white')
mainImage = Image.open("pguidemap.jpg") mainImage = Image.open("pguidemap.png")
if not showbg: if not showbg:
mainImage = Image.new("RGB", mainImage.size, '#ffffff') mainImage = Image.new("RGB", mainImage.size, '#ffffff')
@ -232,13 +232,13 @@ for maparea in maps.keys():
else: else:
M = maps['all'] M = maps['all']
W, H = mainImage.size W, H = mainImage.size
l = int((m[L] - M[L]) / (M[R] - M[L]) * W) l = int(float(m[L] - M[L]) / (M[R] - M[L]) * W)
t = int((m[T] - M[T]) / (M[B] - M[T]) * H) t = int(float(m[T] - M[T]) / (M[B] - M[T]) * H)
r = int((m[R] - M[L]) / (M[R] - M[L]) * W) r = int(float(m[R] - M[L]) / (M[R] - M[L]) * W)
b = int((m[B] - M[T]) / (M[B] - M[T]) * H) b = int(float(m[B] - M[T]) / (M[B] - M[T]) * H)
img = mainImage.crop((l, t, r, b)) img = mainImage.crop((l, t, r, b))
w = int(round(m[ZOOM] * (m[R] - m[L]) / (M[R] - M[L]) * W)) w = int(round(m[ZOOM] * float(m[R] - m[L]) / (M[R] - M[L]) * W))
h = int(round(m[ZOOM] * (m[B] - m[T]) / (M[B] - M[T]) * H)) h = int(round(m[ZOOM] * float(m[B] - m[T]) / (M[B] - M[T]) * H))
print "%s: H %d W %d" % (maparea, h, w) print "%s: H %d W %d" % (maparea, h, w)
img = img.resize((w, h), Image.BICUBIC) img = img.resize((w, h), Image.BICUBIC)
imgs[maparea] = img imgs[maparea] = img
@ -247,7 +247,7 @@ for maparea in maps.keys():
draws[maparea] = draw draws[maparea] = draw
imgmaps[maparea] = [] imgmaps[maparea] = []
# Draw scale bar # Draw scale bar
m100 = int(100 / (m[R] - m[L]) * img.size[0]) m100 = int(100.0 / (m[R] - m[L]) * img.size[0])
draw.line([10, SIZE*3, 10, SIZE*2], fill='#000000') draw.line([10, SIZE*3, 10, SIZE*2], fill='#000000')
draw.line([10, SIZE*2, 10+m100, SIZE*2], fill='#000000') draw.line([10, SIZE*2, 10+m100, SIZE*2], fill='#000000')
draw.line([10+m100, SIZE * 3, 10+m100, SIZE*2], fill='#000000') draw.line([10+m100, SIZE * 3, 10+m100, SIZE*2], fill='#000000')

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 KiB