[openstreetmap/openstreetmap-website] Status of picture/icon methods in lib/gpx.rb (#281)
mmd
notifications at github.com
Sun Oct 7 13:10:14 UTC 2018
Rendering a GPX trace icon isn't too difficult using gd2-ffij:
```ruby
require 'gd2-ffij'
[...]
def icon(min_lat, min_lon, max_lat, max_lon)
width = 50
height = 50
proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
image = GD2::Image::IndexedColor.new(width, height)
black = image.palette.allocate(GD2::Color[0, 0, 0])
white = image.palette.allocate(GD2::Color[255, 255, 255])
image.draw do |pen|
pen.color = white
pen.rectangle(0, 0, width, height, true)
end
image.draw do |pen|
pen.color = black
pen.anti_aliasing = true
pen.dont_blend = false
oldpx = 0.0
oldpy = 0.0
first = true
points do |p|
px = proj.x(p.longitude)
py = proj.y(p.latitude)
pen.line(px, py, oldpx, oldpy) unless first
first = false
oldpy = py
oldpx = px
end
end
image.gif
end
end
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/281#issuecomment-427652304
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20181007/1ad3126f/attachment.html>
More information about the rails-dev
mailing list