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" and point
32 point.altitude = reader.read_string.to_f
33 elsif reader.name == "time" and point
34 point.timestamp = DateTime.parse(reader.read_string)
36 elsif reader.node_type == XML::Reader::TYPE_END_ELEMENT
37 if reader.name == "trkpt" and point and 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')
69 image = Magick::Image.new(width, height) do |image|
70 image.background_color = 'white'
85 px = proj.x(p.longitude)
86 py = proj.y(p.latitude)
96 gc.line(px, py, oldpx, oldpy)
103 if m > num_points.to_f / frames.to_f * (mm+1)
111 il = Magick::ImageList.new
123 def icon(min_lat, min_lon, max_lat, max_lon)
126 proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
128 gc = Magick::Draw.new
129 gc.stroke_linejoin('miter')
134 image = Magick::Image.new(width, height) do |image|
135 image.background_color = 'white'
145 px = proj.x(p.longitude)
146 py = proj.y(p.latitude)
148 gc.dup.line(px, py, oldpx, oldpy).draw(image) unless first
161 class TrkPt < Struct.new(:segment, :latitude, :longitude, :altitude, :timestamp)
163 self.latitude and self.longitude and self.timestamp and
164 self.latitude >= -90 and self.latitude <= 90 and
165 self.longitude >= -180 and self.longitude <= 180