Skip to content

Commit

Permalink
added setLineStyles.py, somewhat hackish way to get track colors
Browse files Browse the repository at this point in the history
  • Loading branch information
trey0 committed Nov 10, 2011
1 parent 720c1cb commit 7e88e0b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions bin/setLineStyles.py
@@ -0,0 +1,46 @@
#!/usr/bin/env python

from geocamTrack.models import Track, LineStyle, IconStyle

# hex abgr
COLORS = ['ff0000ff', # red
'ffff00ff', # magenta
'ffffff00', # cyan
'ff00ffff', # yellow
'ff0088ff', # orange
'ffff0000', # blue
]

def setLineStyles():
defaultLineStyle = LineStyle.objects.get(id=1)
defaultIconStyle = IconStyle.objects.get(id=1)
for i, track in enumerate(Track.objects.all()):
color = COLORS[i % len(COLORS)]

lineStyle = LineStyle(name=track.name,
color=color,
width=defaultLineStyle.width)
lineStyle.save()

iconStyle = IconStyle(name=track.name,
url=defaultIconStyle.url,
width=defaultIconStyle.width,
height=defaultIconStyle.height,
scale=defaultIconStyle.scale,
color=color)
iconStyle.save()

track.lineStyle = lineStyle
track.iconStyle = iconStyle
track.save()

def main():
import optparse
parser = optparse.OptionParser('usage: %prog')
opts, args = parser.parse_args()
if args:
parser.error('expected no args')
setLineStyles()

if __name__ == '__main__':
main()

0 comments on commit 7e88e0b

Please sign in to comment.