Skip to content

Commit

Permalink
Fixed up some misplaced code
Browse files Browse the repository at this point in the history
  • Loading branch information
cluening committed Jan 7, 2015
1 parent 87f8cb2 commit c223d77
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions gpx2ps.py
Expand Up @@ -5,11 +5,13 @@
import argparse

# To do
# - fix projection
# - specify output file on command line (default to sys.stdout)
# - include presets (in a config file?)
# - if line length is over a limit, use moveto instead of lineto
# - put title on page
# - in lower right corner; with box around it; specify on command line
# - or maybe centered at the bottom
# - put a logo on the page (command line option for .eps file?)
# - add landscape postscript header
# - specify the page size?
Expand Down Expand Up @@ -100,12 +102,20 @@ def main():
maxlon = point[1]
if point[1] < minlon:
minlon = point[1]

# Below are approximately Los Alamos
# maxlat = 35.925005
# maxlon = -106.255603
# minlat = 35.860472
# minlon = -106.339116

# Fix the aspect ratio, expanding in one direction as needed
if (maxlon-minlon)/(maxlat-minlat) < float(papersize[1])/float(papersize[0]):
height = maxlat - minlat
newwidth = height * (float(papersize[1])/float(papersize[0]))
widthdiff = newwidth - (maxlon - minlon)
maxlon = maxlon + (widthdiff/2)
minlon = minlon - (widthdiff/2)
else:
width = maxlon - minlon
newheight = width / (float(papersize[1])/float(papersize[0]))
heightdiff = newheight - (maxlat - minlat)
maxlat = maxlat + (heightdiff/2)
minlat = minlat - (heightdiff/2)

print "90 rotate"
print "%d %d translate" % (0, papersize[0]*-1)
Expand All @@ -123,20 +133,6 @@ def main():

gpx = doelement(tree.getroot())

# Fix the aspect ratio, expanding in one direction as needed
if (maxlon-minlon)/(maxlat-minlat) < float(papersize[1])/float(papersize[0]):
height = maxlat - minlat
newwidth = height * (float(papersize[1])/float(papersize[0]))
widthdiff = newwidth - (maxlon - minlon)
maxlon = maxlon + (widthdiff/2)
minlon = minlon - (widthdiff/2)
else:
width = maxlon - minlon
newheight = width / (float(papersize[1])/float(papersize[0]))
heightdiff = newheight - (maxlat - minlat)
maxlat = maxlat + (heightdiff/2)
minlat = minlat - (heightdiff/2)

print "%% File: %s" % inputfile
for track in gpx:
for segment in track:
Expand Down

0 comments on commit c223d77

Please sign in to comment.