summaryrefslogtreecommitdiff
path: root/ipl/gprogs/trkvu.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/gprogs/trkvu.icn')
-rw-r--r--ipl/gprogs/trkvu.icn58
1 files changed, 43 insertions, 15 deletions
diff --git a/ipl/gprogs/trkvu.icn b/ipl/gprogs/trkvu.icn
index 9cd3c36..18c9f39 100644
--- a/ipl/gprogs/trkvu.icn
+++ b/ipl/gprogs/trkvu.icn
@@ -6,7 +6,7 @@
#
# Authors: Gregg M. Townsend
#
-# Date: October 1, 2005
+# Date: April 3, 2010
#
############################################################################
#
@@ -34,7 +34,7 @@
#
# Track log colorings are selected by pressing a key:
#
-# F color by File
+# F color by File (restricting legend to files in view)
# A color by Age
# O color by Orientation (direction of travel)
# V color by Velocity
@@ -105,7 +105,7 @@ record view( # one view of data
record point( # one point along a track
t, # time at point (real days & fraction since epoch)
x, y, # coordinates of point (longitude, latitude)
- fhue) # hue assigned to original source file
+ f) # file index
global viewlist # list of views (view records)
@@ -208,13 +208,10 @@ end
procedure load(fname) # load data from one file
local f, h, p, w, t, x, y, a, line, ptlist
- static n
- initial n := 0
f := open(fname) | stop("cannot open ", fname)
- h := huenum(n +:= 1)
put(fnlist, fname)
- put(fhlist, h)
+ put(fhlist, huenum(*fnlist))
while line := read(f) do {
every put(w := [], words(line))
if -90.0 <= numeric(w[-3]) <= 90.0 then
@@ -222,7 +219,7 @@ procedure load(fname) # load data from one file
if x := numeric(w[-1]) & y := numeric(w[-2]) then {
t := tcrack(w[-4], w[-3]) | &null
/ptlist := []
- put(ptlist, p := point(t, x, y, h))
+ put(ptlist, p := point(t, x, y, *fnlist))
}
else {
put(seglist, \ptlist)
@@ -245,7 +242,7 @@ procedure tcrack(date, time) # translate date + time into real value
if date[3] == "/" then
date := map("CcYy/Mm/Dd", "Mm/Dd/CcYy", date)
- if date == ("1989/12/31" | "1990/01/01") then
+ if date <<= "1990/01/01" then # if indicator of missing date
return &null
*time = 8 | fail
*date = 10 | fail
@@ -387,7 +384,7 @@ procedure draw(win, pjn, a) # display map using curview
GotoXY(2 * BORDER, lbase)
ltext(curview.ltitle)
ltext(": ")
- curview.lproc()
+ curview.lproc(pjn)
Clip ! mclip
every ptlist := !seglist do {
@@ -460,17 +457,48 @@ end
# F: color segments by source file, using colors set at load time
+#
+# show in the legend only those files containing a point in view
+# (note: won't show legend for tracks that "just pass through")
+
+procedure flegend(pjn)
+ local winlim, viewlim, fset, vset, i, seg, pt, x0, x1, y0, y1
+
+ fset := set() # set of potential file source indices
+ every insert(fset, 1 to *fnlist)
+ vset := set() # set of indices of files in view
+
+ # find limits of the current field of view
+ winlim := [mclip[1], mclip[2] + mclip[4], mclip[1] + mclip[3], mclip[2]]
+ viewlim := project(invp(pjn), winlim)
+ x0 := get(viewlim)
+ y0 := get(viewlim)
+ x1 := get(viewlim)
+ y1 := get(viewlim)
+
+ # find files in view
+ every seg := !seglist do {
+ pt := !seg # first pt
+ if member(fset, pt.f) then {
+ every pt := !seg do {
+ if x0 <= pt.x <= x1 & y0 <= pt.y <= y1 then {
+ delete(fset, pt.f)
+ insert(vset, pt.f)
+ if *fset = 0 then
+ break break
+ }
+ }
+ }
+ }
-procedure flegend()
- local i
-
- every i := 1 to *fnlist do
+ # now, finally draw the legend
+ every i := !sort(vset) do
lhue(fhlist[i], fnlist[i] || " ")
return
end
procedure byfile(p, q)
- return q.fhue
+ return fhlist[q.f]
end