7 attr_reader :possible_points
8 attr_reader :actual_points
22 reader = XML::Reader.io(@file)
27 if reader.node_type == XML::Reader::TYPE_ELEMENT
28 if reader.name == "trkpt"
29 point = TrkPt.new(@tracksegs, reader["lat"].to_f, reader["lon"].to_f)
31 elsif reader.name == "ele" && point
32 point.altitude = reader.read_string.to_f
33 elsif reader.name == "time" && point
34 point.timestamp = Time.parse(reader.read_string)
36 elsif reader.node_type == XML::Reader::TYPE_END_ELEMENT
37 if reader.name == "trkpt" && point && point.valid?
41 elsif reader.name == "trkseg"
48 def picture(min_lat, min_lon, max_lat, max_lon, num_points)
52 proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
54 linegc = Magick::Draw.new
55 linegc.stroke_linejoin("miter")
56 linegc.stroke_width(1)
57 linegc.stroke("#BBBBBB")
58 linegc.fill("#BBBBBB")
60 highlightgc = Magick::Draw.new
61 highlightgc.stroke_linejoin("miter")
62 highlightgc.stroke_width(3)
63 highlightgc.stroke("#000000")
64 highlightgc.fill("#000000")
66 images = Array(frames) do
67 Magick::Image.new(width, height) do |image|
68 image.background_color = "white"
79 px = proj.x(p.longitude)
80 py = proj.y(p.latitude)
90 gc.line(px, py, oldpx, oldpy)
97 mm += 1 if m > num_points.to_f / frames.to_f * (mm + 1)
103 il = Magick::ImageList.new
115 def icon(min_lat, min_lon, max_lat, max_lon)
118 proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
120 gc = Magick::Draw.new
121 gc.stroke_linejoin("miter")
126 image = Magick::Image.new(width, height) do |i|
127 i.background_color = "white"
137 px = proj.x(p.longitude)
138 py = proj.y(p.latitude)
140 gc.dup.line(px, py, oldpx, oldpy).draw(image) unless first
151 TrkPt = Struct.new(:segment, :latitude, :longitude, :altitude, :timestamp) do
153 latitude && longitude && timestamp &&
154 latitude >= -90 && latitude <= 90 &&
155 longitude >= -180 && longitude <= 180