forked from trey0/geocamShare
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added setLineStyles.py, somewhat hackish way to get track colors
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |