7 attr_reader :possible_points
8 attr_reader :actual_points
16 return enum_for(:points) unless block_given?
24 reader = XML::Reader.io(@file)
29 if reader.node_type == XML::Reader::TYPE_ELEMENT
30 if reader.name == "trkpt"
31 point = TrkPt.new(@tracksegs, reader["lat"].to_f, reader["lon"].to_f)
33 elsif reader.name == "ele" && point
34 point.altitude = reader.read_string.to_f
35 elsif reader.name == "time" && point
36 point.timestamp = Time.parse(reader.read_string)
38 elsif reader.node_type == XML::Reader::TYPE_END_ELEMENT
39 if reader.name == "trkpt" && point && point.valid?
43 elsif reader.name == "trkseg"
50 def picture(min_lat, min_lon, max_lat, max_lon, _num_points)
54 proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
56 # TODO: create animated gif
57 # https://github.com/openstreetmap/openstreetmap-website/issues/281
58 image = GD2::Image::IndexedColor.new(width, height)
60 black = image.palette.allocate(GD2::Color[0, 0, 0])
61 white = image.palette.allocate(GD2::Color[255, 255, 255])
65 pen.rectangle(0, 0, width, height, true)
70 pen.anti_aliasing = true
71 pen.dont_blend = false
79 px = proj.x(p.longitude)
80 py = proj.y(p.latitude)
82 pen.line(px, py, oldpx, oldpy) unless first
93 def icon(min_lat, min_lon, max_lat, max_lon)
96 proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
98 image = GD2::Image::IndexedColor.new(width, height)
100 black = image.palette.allocate(GD2::Color[0, 0, 0])
101 white = image.palette.allocate(GD2::Color[255, 255, 255])
105 pen.rectangle(0, 0, width, height, true)
110 pen.anti_aliasing = true
111 pen.dont_blend = false
119 px = proj.x(p.longitude)
120 py = proj.y(p.latitude)
122 pen.line(px, py, oldpx, oldpy) unless first
134 TrkPt = Struct.new(:segment, :latitude, :longitude, :altitude, :timestamp) do
136 latitude && longitude && timestamp &&
137 latitude >= -90 && latitude <= 90 &&
138 longitude >= -180 && longitude <= 180