Created
February 2, 2018 22:33
-
-
Save kmcallister/771fc394e3f4f381abfecfb3b328686f to your computer and use it in GitHub Desktop.
Mysterious garbage code for generating bike map PDFs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
pfx='gray/15' | |
#xs = sorted(map(int, os.listdir(pfx))) | |
#ys = sorted(int(n.split('.')[0]) for n in os.listdir('%s/%d' % (pfx,xs[0]))) | |
xs = range(9910,9919) | |
ys = range(12115,12127) | |
for n in ['%s/%d/%d.png' % (pfx,x,y) for y in ys for x in xs]: | |
print n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
wget -c -x -nH -i urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
for x in $(seq 303 310); do | |
for y in $(seq 370 379); do | |
echo http://tile.openstreetmap.org/10/$x/$y.png | |
done | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
montage -mode Concatenate -tile 7x8 $( | |
for y in $(seq 371 378); do | |
for x in $(seq 304 310); do | |
echo road/10/$x/$y.png | |
done | |
done) key.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
for l in A B C D E F G H I J K L M N O P Q R S; do | |
convert -adjoin -density 300 pages/$l*.png pdfs/$l.pdf | |
done | |
pdftk pdfs/* cat output pages.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
pagemap = '''\ | |
XXXXXXXXXX | |
XXXXXXXXXXXX | |
XXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXX | |
XXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXX | |
XXXXXXXXXX | |
XXXXXXXXXXX | |
XXXXXXXXXXXXX | |
XXXXXXXXXXXXX | |
XXXXXXXXXXX | |
XXXXXXXXXXX | |
XXXXXXXXXXX | |
XXXXXXXXX | |
XXXXXXXXX | |
XXXXXXXXX ''' | |
pagerows = pagemap.split('\n') | |
wp = 22 | |
hp = 19 | |
n = 0 | |
for y in xrange(hp): | |
for x in xrange(wp): | |
if pagerows[y][x] == ' ': | |
continue | |
tiles = ["gray/15/%d/%d.png" % (9748 + 9*x + i, 11916 + 12*y + j) | |
for j in xrange(12) for i in xrange(9) ] | |
name = "pages/%s%02d.png" % (chr(ord('A')+x), y) | |
with file('jobs/%03d' % (n,), 'w') as f: | |
print >>f, "montage -mode Concatenate -tile 9x12 %s %s" % (" ".join(tiles), name) | |
n += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
pagemap = '''\ | |
XXXXXXXX | |
XXXXXXXX | |
XXXXXXXX | |
XXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXX | |
XXXX | |
XXXX | |
XXXX | |
XXXXX | |
XXXXX | |
XXXX | |
XXX | |
XXX | |
XXX | |
XXX ''' | |
pagerows = pagemap.split('\n') | |
wp = 21 | |
hp = 17 | |
n = 0 | |
for y in xrange(hp): | |
for x in xrange(wp): | |
if pagerows[y][x] != ' ': | |
print '%s%02d.png' % (chr(ord('A')+x), y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
for f in cycle/15/*/*.png; do | |
t=$(echo $f | sed s/cycle/gray/g) | |
mkdir -p $(dirname $t) | |
convert -type Grayscale $f $t | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment