mapkit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/mapkit.rb +1 -1
  2. data/lib/tilekit.rb +19 -3
  3. metadata +2 -2
data/lib/mapkit.rb CHANGED
@@ -25,7 +25,7 @@ module MapKit
25
25
  RESOLUTION = 2 * Math::PI * EARTH_RADIUS / TILE_SIZE
26
26
 
27
27
  # version of MapKit
28
- VERSION = "0.0.1"
28
+ VERSION = "0.0.2"
29
29
 
30
30
  # The class represents an lat/lng point
31
31
  class Point
data/lib/tilekit.rb CHANGED
@@ -1,17 +1,27 @@
1
1
  require File.dirname(__FILE__) + "/mapkit"
2
2
  require "gd2"
3
3
 
4
+ # this module helps drawing icons on tile images
4
5
  module TileKit
6
+ # this class represents an icon that can be drawn on an Image
5
7
  class Icon
6
8
  attr_reader :image, :size
7
9
 
10
+ # initializes the icon with a path, image size [width, height], the peak#
11
+ # position (where the pointer should be placed) [x, y] and a bounding box
12
+ # that represents a clickable area
13
+ # path:: the path of the image (test.png)
14
+ # size:: the size of the immage as array [width, height]
15
+ # peak_position:: the peak position as array [x, y]
16
+ # clickable_area:: the clickable area of the icon as array [top, left, bottom, right]
8
17
  def initialize(path, size, peak_position, clickable_area)
9
- @image = GD2::Image.import("images/gas.png")
18
+ @image = GD2::Image.import(path)
10
19
  @size_x, @size_y = size
11
20
  @peak_x, @peak_y = peak_position
12
21
  @shift_x, @shift_y, @width, @height = clickable_area
13
22
  end
14
23
 
24
+ # draws the icon on the canvas at passed position (x, y)
15
25
  def draw(canvas, x, y)
16
26
  # position icon at peak point
17
27
  x, y = x - @peak_x, y - @peak_y
@@ -20,6 +30,8 @@ module TileKit
20
30
  canvas.copy_from(@image, x, y, 0, 0, @size_x, @size_y)
21
31
  end
22
32
 
33
+ # returns a boundingbox (with lat/lng) that contains the bounds of the
34
+ # image for the passed position
23
35
  def bounding_box(lat, lng, zoom)
24
36
  top, left = MapKit.shift_latlng(lat, lng, @shift_x - @peak_x, @shift_y - @peak_y, zoom)
25
37
  bottom, right = MapKit.shift_latlng(top, left, @width, @height, zoom)
@@ -27,9 +39,12 @@ module TileKit
27
39
  end
28
40
  end
29
41
 
42
+ # this image class represents a tile in the google maps
30
43
  class Image
31
44
  attr_reader :canvas, :bounding_box
32
45
 
46
+ # initialize the image with a (lat/lng) bounding box of the tile it
47
+ # represents
33
48
  def initialize(bounding_box)
34
49
  @bounding_box = bounding_box
35
50
 
@@ -44,12 +59,13 @@ module TileKit
44
59
  end
45
60
  end
46
61
 
47
- # draw icon at position
62
+ # draws passed icon at passed position
48
63
  def draw_icon(point, icon)
49
64
  x, y = point.pixel(@bounding_box)
50
65
  icon.draw(@canvas, x, y)
51
66
  end
52
-
67
+
68
+ # returns the png binary string of the image
53
69
  def png
54
70
  @canvas.png
55
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mapkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Landgraf
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-10 00:00:00 +01:00
12
+ date: 2010-02-11 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency