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 # TODO: create animated gif
55 # https://github.com/openstreetmap/openstreetmap-website/issues/281
56 image = GD2::Image::IndexedColor.new(width, height)
58 black = image.palette.allocate(GD2::Color[0, 0, 0])
59 white = image.palette.allocate(GD2::Color[255, 255, 255])
63 pen.rectangle(0, 0, width, height, true)
68 pen.anti_aliasing = true
69 pen.dont_blend = false
77 px = proj.x(p.longitude)
78 py = proj.y(p.latitude)
80 pen.line(px, py, oldpx, oldpy) unless first
91 def icon(min_lat, min_lon, max_lat, max_lon)
94 proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
96 image = GD2::Image::IndexedColor.new(width, height)
98 black = image.palette.allocate(GD2::Color[0, 0, 0])
99 white = image.palette.allocate(GD2::Color[255, 255, 255])
103 pen.rectangle(0, 0, width, height, true)
108 pen.anti_aliasing = true
109 pen.dont_blend = false
117 px = proj.x(p.longitude)
118 py = proj.y(p.latitude)
120 pen.line(px, py, oldpx, oldpy) unless first
132 TrkPt = Struct.new(:segment, :latitude, :longitude, :altitude, :timestamp) do
134 latitude && longitude && timestamp &&
135 latitude >= -90 && latitude <= 90 &&
136 longitude >= -180 && longitude <= 180