Add hierarchical altitude marks (untested).

debian-sid
Tom Payne 15 years ago
parent 41b1363dbc
commit ee6efb2a6f

@ -1,6 +1,9 @@
HIGH
Check indexes in thermal folder
Check indexes in colored tracklogs
Check why balloons don't point at point
Clean up heirarchical altitude marks
Clean up global styles
MEDIUM
Allow override of photo time

@ -372,10 +372,11 @@ class Flight(object):
folder = kml.Folder(name='Altitude marks',
styleUrl=style_url,
visibility=0)
for index in util.salient([c.ele for c in self.track.coords], 100):
for index, j in util.salient2([c.ele for c in self.track.coords],
[100, 50, 10]):
coord = self.track.coords[index]
i = globals.scales.altitude.discretize(coord.ele)
style_url = globals.altitude_styles[i].url()
style_url = globals.altitude_styles[j][i].url()
folder.add(self.make_placemark(globals,
coord,
altitudeMode='absolute',
@ -764,16 +765,19 @@ def flights2kmz(flights, roots=[], tz_offset=0, task=None):
title='altitude',
gradient=color.default_gradient)
globals.altitude_styles = []
for c in globals.scales.altitude.colors():
balloon_style = kml.BalloonStyle(text='$[description]')
icon_style = kml.IconStyle(globals.stock.icons[0],
color=c,
scale=globals.stock.icon_scales[0])
label_style = kml.LabelStyle(color=c,
scale=globals.stock.label_scales[0])
style = kml.Style(balloon_style, icon_style, label_style)
globals.altitude_styles.append(style)
stock.kmz.add_roots(*globals.altitude_styles)
for i in xrange(0, 3):
altitude_styles = []
for c in globals.scales.altitude.colors():
balloon_style = kml.BalloonStyle(text='$[description]')
icon_style = kml.IconStyle(globals.stock.icons[i],
color=c,
scale=globals.stock.icon_scales[i])
label_style = kml.LabelStyle(color=c,
scale=globals.stock.label_scales[i])
style = kml.Style(balloon_style, icon_style, label_style)
altitude_styles.append(style)
stock.kmz.add_roots(*altitude_styles)
globals.altitude_styles.append(altitude_styles)
gradient = color.bilinear_gradient
globals.scales.climb = scale.ZeroCenteredScale(globals.bounds.climb.tuple(),
title='climb',

@ -258,6 +258,47 @@ def salient(seq, epsilon=0):
return sorted(result)
def salient2(seq, epsilons):
def helper(start, stop):
if stop - start < 2:
return
delta = 0
left, right = start, stop
if seq[start] <= seq[stop]:
max_index = start
for i in xrange(start + 1, stop + 1):
if seq[i] > seq[max_index]:
max_index = i
elif seq[max_index] - seq[i] > delta:
left, right = max_index, i
delta = seq[max_index] - seq[i]
if seq[start] >= seq[stop]:
min_index = start
for i in xrange(start + 1, stop + 1):
if seq[i] < seq[min_index]:
min_index = i
elif seq[i] - seq[min_index] > delta:
left, right = min_index, i
delta = seq[i] - seq[min_index]
if delta >= epsilons[-1] and (left != start or right != stop):
for i, epsilon in enumerate(epsilons):
if delta < epsilon:
continue
if not left in result or result[left] > i:
result[left] = i
if not right in result or result[right] > i:
result[right] = i
helper(start, left)
helper(left, right)
helper(right, stop)
result = {}
if len(seq):
result[0] = 0
result[len(seq) - 1] = 0
helper(0, len(seq) - 1)
return result.items()
def datetime_floor(dt, delta):
if delta.seconds >= 3600:
return dt.replace(minute=0, second=0) \

Loading…
Cancel
Save