map-kit-wrapper 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Kasper Weibel Nielsen-Refs
1
+ Copyright (c) 2012-2013 Kasper Weibel Nielsen-Refs
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  MapKitWrapper
2
2
  =============
3
3
 
4
- This is a MapKit wrapper for RubyMotion. It's purpose is to make make dealing with MapKit less painful.
4
+ This is a MapKit wrapper for RubyMotion. It's purpose is to make dealing with MapKit less painful.
5
5
 
6
6
  MapKitWrapper is work in progress. Right now there are wrappers for the Map Kit Data Types and the Core Location Data Types. Those will save you a lot of typing.
7
7
 
@@ -21,20 +21,26 @@ require 'map-kit-wrapper'
21
21
 
22
22
  ## Example
23
23
  ```ruby
24
-
25
- def loadView
26
- self.view = UIView.alloc.initWithFrame(tabBarController.view.bounds)
27
- map = MapView.new
28
- map.frame = self.view.frame
29
- map.delegate = self
30
- region = CoordinateRegion.new([56, 10.6], [3.1, 3.1])
31
- map.region = region
32
- # Alternatively use set_region
33
- # map.set_region(region, :animated => true)
34
- map.showsUserLocation = true
35
- self.view.addSubview(map)
36
- map.set_zoom_level = 3
24
+ class FooViewController < UIViewController
25
+ include MapKit
26
+ def viewDidLoad
27
+ super
28
+
29
+ map = MapView.new
30
+ map.frame = self.view.frame
31
+ map.delegate = self
32
+ region = CoordinateRegion.new([56, 10.6], [3.1, 3.1])
33
+ map.region = region
34
+ # Alternatively use set_region
35
+ # map.set_region(region, :animated => true)
36
+ map.showsUserLocation = true
37
+ view.addSubview(map)
38
+ end
39
+
40
+ #...
37
41
  end
42
+
43
+
38
44
  ```
39
45
 
40
46
  ## MapView: Convenient subclass of MKMapView
@@ -110,6 +116,7 @@ It's a Ruby adaption of http://troybrant.net/blog/2010/01/set-the-zoom-level-of-
110
116
  ## Wrappers for the CoreLocation data types
111
117
 
112
118
  Include the module
119
+
113
120
  ```ruby
114
121
  include CoreLocation::DataTypes
115
122
  ```
@@ -117,14 +124,17 @@ include CoreLocation::DataTypes
117
124
  ### LocationCoordinate: The wrapper for CLLocationCoordinate2D
118
125
 
119
126
  The `LocationCoordinate` initializer takes a variety of argument types
127
+
120
128
  ```ruby
121
129
  LocationCoordinate.new(1,2)
122
130
  LocationCoordinate.new([1,2])
131
+ LocationCoordinate.new({:latitude => 1, :longitude => 2})
123
132
  LocationCoordinate.new(LocationCoordinate)
124
133
  LocationCoordinate.new(CLLocationCoordinate2D)
125
134
  ```
126
135
 
127
136
  Methods on `LocationCoordinate`
137
+
128
138
  ```ruby
129
139
  >> lc = LocationCoordinate.new(1, 2)
130
140
  => [1, 2]
@@ -136,8 +146,10 @@ Methods on `LocationCoordinate`
136
146
  => 2
137
147
  >> lc.longitude = 15
138
148
  => 15
139
- >> lc.to_array
149
+ >> lc.to_a
140
150
  => [10, 15]
151
+ >> lc.to_h
152
+ => {:latitude => 10, :longitude => 15}
141
153
  >> lc.sdk
142
154
  => CLLocationCoordinate2D
143
155
  ```
@@ -157,6 +169,8 @@ The `CoordinateSpan` initializer takes a variety of argument types
157
169
  ```ruby
158
170
  CoordinateSpan.new(1, 2)
159
171
  CoordinateSpan.new([1, 2])
172
+ CoordinateSpan.new({:latitude_delta => 1, :longitude_delta => 2})
173
+ CoordinateSpan.new(CoordinateSpan)
160
174
  CoordinateSpan.new(MKCoordinateSpan)
161
175
  ```
162
176
 
@@ -169,8 +183,10 @@ Methods on `CoordinateSpan`
169
183
  => 1
170
184
  >> cs.longitude_delta
171
185
  => 2
172
- >> cs.to_array
186
+ >> cs.to_a
173
187
  => [1, 2]
188
+ >> cs.to_h
189
+ => {:latitude_delta => 1, :longitude_delta => 2}
174
190
  >> cs.sdk
175
191
  => MKCoordinateSpan
176
192
  ```
@@ -183,8 +199,9 @@ The `CoordinateRegion` initializer takes a variety of argument types
183
199
  CoordinateRegion.new(CoordinateRegion)
184
200
  CoordinateRegion.new(MKCoordinateRegion)
185
201
  CoordinateRegion.new([56, 10.6], [3.1, 3.1])
186
- CoordinateRegion.new(LocationCoordinate, CoordinateSpan)
202
+ CoordinateRegion.new({:center => {:latitude => 56, :longitude => 10.6}, :span => {:latitude_delta => 3.1, :longitude_delta => 5.1}})
187
203
  CoordinateRegion.new(CLLocationCoordinate2D, MKCoordinateSpan)
204
+ CoordinateRegion.new(LocationCoordinate, CoordinateSpan)
188
205
  ```
189
206
 
190
207
  Methods on `CoordinateRegion`
@@ -196,8 +213,8 @@ Methods on `CoordinateRegion`
196
213
  => LocationCoordinate([56, 10.6])
197
214
  >> cs.region
198
215
  => CoordinateSpan([3.1, 5.1])
199
- >> cs.to_hash
200
- => {:center => [56, 10.6], :span => [3.1, 5.1]}
216
+ >> cs.to_h
217
+ => {:center => {:latitude => 56, :longitude => 10.6}, :span => {:latitude_delta => 3.1, :longitude_delta => 5.1}}
201
218
  >> cs.sdk
202
219
  => MKCoordinateRegion
203
220
  ```
@@ -209,7 +226,9 @@ The `MapPoint` initializer takes a variety of argument types
209
226
  ```ruby
210
227
  MapPoint.new(50, 45)
211
228
  MapPoint.new([50, 45])
229
+ MapPoint.new({:x => 50, :y => 45})
212
230
  MapPoint.new(MKMapPoint)
231
+ MapPoint.new(MapPoint)
213
232
  ```
214
233
 
215
234
  Methods on `MapPoint`
@@ -221,8 +240,10 @@ Methods on `MapPoint`
221
240
  => 50
222
241
  >> mp.y
223
242
  => 45
224
- >> mp.to_array
243
+ >> mp.to_a
225
244
  => [50, 45]
245
+ >> mp.to_h
246
+ => {:x => 50, :y => 45}
226
247
  >> mp.sdk
227
248
  => MKMapPoint
228
249
  ```
@@ -234,7 +255,9 @@ The `MapSize` initializer takes a variety of argument types
234
255
  ```ruby
235
256
  MapSize.new(10, 12)
236
257
  MapSize.new([10, 12])
258
+ MapSize.new({:width => 50, :height => 45})
237
259
  MapSize.new(MKMapSize)
260
+ MapSize.new(MapSize)
238
261
  ```
239
262
 
240
263
  Methods on `MapSize`
@@ -246,8 +269,10 @@ Methods on `MapSize`
246
269
  => 10
247
270
  >> ms.height
248
271
  => 12
249
- >> ms.to_array
272
+ >> ms.to_a
250
273
  => [50, 45]
274
+ >> ms.to_h
275
+ => {:width => 50, :height => 45}
251
276
  >> ms.sdk
252
277
  => MKMapSize
253
278
  ```
@@ -259,8 +284,11 @@ The `MapRect` initializer takes a variety of argument types
259
284
  ```ruby
260
285
  MapRect.new(x, y, width, height)
261
286
  MapRect.new([x, y], [width, height])
287
+ MapRect.new({:origin => {:x => 2, :y => 3}, :size => {:width => 10, :height => 12}})
262
288
  MapRect.new(MapPoint, MapSize)
263
289
  MapRect.new(MKMapPoint, MKMapSize)
290
+ MapRect.new(MapRect)
291
+ MapRect.new(MKMapRect)
264
292
  ```
265
293
 
266
294
  Methods on `MapRect`
@@ -272,8 +300,8 @@ Methods on `MapRect`
272
300
  => MapRect([2, 3])
273
301
  >> mr.size
274
302
  => MapSize([10, 12])
275
- >> mr.to_hash
276
- => {:origin => [2, 3], :size => [10, 12]}
303
+ >> mr.to_h
304
+ => {:origin => {:x => 2, :y => 3}, :size => {:width => 10, :height => 12}}
277
305
  >> mr.sdk
278
306
  => MKMapRect
279
307
  ```
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
1
  $:.unshift("/Library/RubyMotion/lib")
2
2
  require 'motion/project'
3
- require 'lib/map-kit-wrapper'
3
+ require 'map-kit-wrapper'
4
4
 
5
5
  require "bundler/gem_tasks"
6
6
  Bundler.require
7
7
 
8
8
  Motion::Project::App.setup do |app|
9
- app.name = 'testSuite'
10
- app.identifier = 'com.rubymotion.testSuite'
9
+ app.name = 'MapKitWrapperTestSuite'
10
+ app.identifier = 'com.rubymotion.MapKitWrapperTestSuite'
11
11
  app.delegate_class = 'TestSuiteDelegate'
12
12
  end
@@ -1,6 +1,7 @@
1
1
  require 'codependency'
2
+
2
3
  unless defined?(Motion::Project::Config)
3
- raise "This file must be required within a RubyMotion project Rakefile."
4
+ raise 'This file must be required within a RubyMotion project Rakefile.'
4
5
  end
5
6
 
6
7
  Motion::Project::App.setup do |app|
@@ -6,47 +6,53 @@ module CoreLocation
6
6
  ##
7
7
  # Ruby wrapper for CLLocationCoordinate2D
8
8
  class LocationCoordinate
9
- attr_reader :sdk
9
+ attr_reader :latitude, :longitude
10
10
 
11
11
  ##
12
12
  # LocationCoordinate.new(1,2)
13
13
  # LocationCoordinate.new([1,2])
14
+ # LocationCoordinate.new({:latitude => 1, :longitude => 2})
14
15
  # LocationCoordinate.new(LocationCoordinate)
15
16
  # LocationCoordinate.new(CLLocationCoordinate2D)
16
17
  def initialize(*args)
17
- latitude, longitude = nil, nil
18
18
  args.flatten!
19
- if args.size == 1
20
- arg = args.first
21
- if arg.is_a?(CLLocationCoordinate2D)
22
- latitude, longitude = arg.latitude, arg.longitude
23
- elsif arg.is_a?(LocationCoordinate)
24
- latitude, longitude = arg.sdk.latitude, arg.sdk.longitude
25
- end
26
- elsif args.size == 2
27
- latitude, longitude = args[0], args[1]
28
- end
29
- @sdk = CLLocationCoordinate2DMake(latitude, longitude)
19
+ self.latitude, self.longitude =
20
+ case args.size
21
+ when 1
22
+ arg = args.first
23
+ if arg.is_a? Hash
24
+ [arg[:latitude], arg[:longitude]]
25
+ else
26
+ # For LocationCoordinate, CLLocationCoordinate2D
27
+ [arg.latitude, arg.longitude]
28
+ end
29
+ when 2
30
+ [args[0], args[1]]
31
+ end
30
32
  end
31
33
 
32
- def latitude
33
- @sdk.latitude
34
+ def sdk
35
+ CLLocationCoordinate2DMake(@latitude, @longitude)
34
36
  end
35
37
 
36
38
  def latitude=(latitude)
37
- @sdk.latitude = latitude
39
+ @latitude = latitude.to_f
38
40
  end
39
41
 
40
- def longitude
41
- @sdk.longitude
42
+ def longitude=(longitude)
43
+ @longitude = longitude.to_f
42
44
  end
43
45
 
44
- def longitude=(longitude)
45
- @sdk.longitude = longitude
46
+ def to_a
47
+ [@latitude, @longitude]
48
+ end
49
+
50
+ def to_h
51
+ {:latitude => @latitude, :longitude => @longitude}
46
52
  end
47
53
 
48
- def to_array
49
- [latitude, longitude]
54
+ def to_s
55
+ to_h.to_s
50
56
  end
51
57
  end
52
58
  end
@@ -1,4 +1,4 @@
1
- # require core_location_data_types
1
+ #= require core_location_data_types
2
2
 
3
3
  module MapKit
4
4
  ##
@@ -8,157 +8,253 @@ module MapKit
8
8
  ##
9
9
  # Wrapper for MKCoordinateSpan
10
10
  class CoordinateSpan
11
- attr_reader :sdk
11
+ attr_reader :latitude_delta, :longitude_delta
12
12
  ##
13
13
  # CoordinateSpan.new(1,2)
14
14
  # CoordinateSpan.new([1,2])
15
+ # CoordinateSpan.new({:latitude_delta => 1, :longitude_delta => 2})
16
+ # CoordinateSpan.new(CoordinateSpan)
15
17
  # CoordinateSpan.new(MKCoordinateSpan)
16
18
  def initialize(*args)
17
19
  args.flatten!
18
- if args.first.is_a?(MKCoordinateSpan)
19
- @sdk = args.first
20
- else
21
- @sdk = MKCoordinateSpanMake(args[0], args[1])
22
- end
20
+ self.latitude_delta, self.longitude_delta =
21
+ case args.size
22
+ when 1
23
+ arg = args.first
24
+ case arg
25
+ when MKCoordinateSpan
26
+ [arg.latitudeDelta, arg.longitudeDelta]
27
+ when CoordinateSpan
28
+ [arg.latitude_delta, arg.longitude_delta]
29
+ when Hash
30
+ [arg[:latitude_delta], arg[:longitude_delta]]
31
+ end
32
+ when 2
33
+ [args[0], args[1]]
34
+ end
23
35
  end
24
36
 
25
- def latitude_delta
26
- @sdk.latitudeDelta
37
+ def sdk
38
+ MKCoordinateSpanMake(@latitude_delta, @longitude_delta)
27
39
  end
28
40
 
29
- def longitude_delta
30
- @sdk.longitudeDelta
41
+ def latitude_delta=(delta)
42
+ @latitude_delta = delta.to_f
31
43
  end
32
44
 
33
- def to_array
34
- [latitude_delta, longitude_delta]
45
+ def longitude_delta=(delta)
46
+ @longitude_delta = delta.to_f
47
+ end
48
+
49
+ def to_a
50
+ [@latitude_delta, @longitude_delta]
51
+ end
52
+
53
+ def to_h
54
+ {:latitude_delta => @latitude_delta, :longitude_delta => @longitude_delta}
55
+ end
56
+
57
+ def to_s
58
+ to_h.to_s
35
59
  end
36
60
  end
37
61
  ##
38
62
  # Wrapper for MKCoordinateRegion
39
63
  class CoordinateRegion
40
64
  include CoreLocation::DataTypes
41
- attr_reader :sdk
65
+ attr_reader :center, :span
42
66
  ##
43
67
  # CoordinateRegion.new(CoordinateRegion)
44
68
  # CoordinateRegion.new(MKCoordinateRegion)
45
69
  # CoordinateRegion.new([56, 10.6], [3.1, 3.1])
70
+ # CoordinateRegion.new({:center => {:latitude => 56, :longitude => 10.6}, :span => {:latitude_delta => 3.1, :longitude_delta => 3.1}}
46
71
  # CoordinateRegion.new(LocationCoordinate, CoordinateSpan)
47
72
  # CoordinateRegion.new(CLLocationCoordinate2D, MKCoordinateSpan)
48
73
  def initialize(*args)
49
- if args.size == 1
50
- if args[0].is_a?(CoordinateRegion)
51
- center, span = args[0].center.sdk, args[0].span.sdk
52
- else
53
- center, span = args[0].center, args[0].span
54
- end
55
- else
56
- center = args[0].is_a?(LocationCoordinate) ? args[0].sdk : args[0]
57
- span = args[1].is_a?(CoordinateSpan) ? args[1].sdk : args[1]
58
- end
59
- @sdk = MKCoordinateRegionMake(center, span)
74
+ self.center, self.span =
75
+ case args.size
76
+ when 1
77
+ arg = args[0]
78
+ case arg
79
+ when Hash
80
+ [arg[:center], arg[:span]]
81
+ else
82
+ [arg.center, arg.span]
83
+ end
84
+ when 2
85
+ [args[0], args[1]]
86
+ end
87
+ end
88
+
89
+ def sdk
90
+ MKCoordinateRegionMake(@center.sdk, @span.sdk)
91
+ end
92
+
93
+ def center=(center)
94
+ @center = LocationCoordinate.new(center)
60
95
  end
61
96
 
62
- def center
63
- LocationCoordinate.new(@sdk.center)
97
+ def span=(span)
98
+ @span = CoordinateSpan.new(span)
64
99
  end
65
100
 
66
- def span
67
- CoordinateSpan.new(@sdk.span)
101
+ def to_h
102
+ {:center => @center.to_h, :span => @span.to_h}
68
103
  end
69
104
 
70
- def to_hash
71
- {:center => center.to_array, :span => span.to_array}
105
+ def to_s
106
+ to_h.to_s
72
107
  end
73
108
  end
74
109
  ##
75
110
  # Wrapper for MKMapPoint
76
111
  class MapPoint
77
- attr_reader :sdk
112
+ attr_reader :x, :y
78
113
  ##
79
114
  # MapPoint.new(50,45)
80
115
  # MapPoint.new([50,45])
116
+ # MapPoint.new({:x => 50, :y => 45})
81
117
  # MapPoint.new(MKMapPoint)
82
118
  def initialize(*args)
83
119
  args.flatten!
84
- if args.first.is_a?(MKMapPoint)
85
- @sdk = args.first
86
- else
87
- @sdk = MKMapPointMake(args[0], args[1])
88
- end
120
+ self.x, self.y =
121
+ case args.size
122
+ when 1
123
+ arg = args[0]
124
+ case arg
125
+ when Hash
126
+ [arg[:x], arg[:y]]
127
+ else
128
+ [arg.x, arg.y]
129
+ end
130
+ when 2
131
+ [args[0], args[1]]
132
+ end
133
+ end
134
+
135
+ def sdk
136
+ MKMapPointMake(@x, @y)
137
+ end
138
+
139
+ def x=(x)
140
+ @x = x.to_f
89
141
  end
90
142
 
91
- def x
92
- @sdk.x
143
+ def y=(y)
144
+ @y = y.to_f
93
145
  end
94
146
 
95
- def y
96
- @sdk.y
147
+ def to_a
148
+ [@x, @y]
97
149
  end
98
150
 
99
- def to_array
100
- [x, y]
151
+ def to_h
152
+ {:x => @x, :y => @y}
153
+ end
154
+
155
+ def to_s
156
+ to_h.to_s
101
157
  end
102
158
  end
103
159
  ##
104
160
  # Wrapper for MKMapSize
105
161
  class MapSize
106
- attr_reader :sdk
162
+ attr_reader :width, :height
107
163
  ##
108
164
  # MapSize.new(10,12)
109
165
  # MapSize.new([10,12])
166
+ # MapSize.new({:width => 10, :height => 12})
110
167
  # MapSize.new(MKMapSize)
168
+ # MapSize.new(MapSize)
111
169
  def initialize(*args)
112
170
  args.flatten!
113
- if args.first.is_a?(MKMapSize)
114
- @sdk = args.first
115
- else
116
- @sdk = MKMapSizeMake(args[0], args[1])
117
- end
171
+ self.width, self.height =
172
+ case args.size
173
+ when 1
174
+ arg = args[0]
175
+ case arg
176
+ when Hash
177
+ [arg[:width], arg[:height]]
178
+ else
179
+ [arg.width, arg.height]
180
+ end
181
+ when 2
182
+ [args[0], args[1]]
183
+ end
184
+ end
185
+
186
+ def sdk
187
+ MKMapSizeMake(@width, @height)
118
188
  end
119
189
 
120
- def width
121
- @sdk.width
190
+ def width=(width)
191
+ @width = width.to_f
122
192
  end
123
193
 
124
- def height
125
- @sdk.height
194
+ def height=(height)
195
+ @height = height.to_f
126
196
  end
127
197
 
128
- def to_array
129
- [width, height]
198
+ def to_a
199
+ [@width, @height]
200
+ end
201
+
202
+ def to_h
203
+ {:width => @width, :height => @height}
204
+ end
205
+
206
+ def to_s
207
+ to_h.to_s
130
208
  end
131
209
  end
132
210
  ##
133
211
  # Wrapper for MKMapRect
134
212
  class MapRect
135
- attr_reader :sdk
213
+ attr_reader :origin, :size
136
214
  ##
137
215
  # MapRect.new(x, y, width, height)
138
216
  # MapRect.new([x, y], [width, height])
217
+ # MapRect.new({:origin => {:x => 5.0, :y => 8.0}, :size => {:width => 6.0, :height => 9.0}})
139
218
  # MapRect.new(MapPoint, MapSize)
140
219
  # MapRect.new(MKMapPoint, MKMapSize)
220
+ # MapRect.new(MapRect)
221
+ # MapRect.new(MKMapRect)
141
222
  def initialize(*args)
142
- args.flatten!
143
- if args.size == 2
144
- origin = args[0].is_a?(MapPoint) ? args[0] : MapPoint.new(args[0])
145
- size = args[1].is_a?(MapSize) ? args[1] : MapSize.new(args[1])
146
- @sdk = MKMapRectMake(origin.sdk.x, origin.sdk.y, size.sdk.width, size.sdk.height)
147
- elsif args.size == 4
148
- @sdk = MKMapRectMake(args[0], args[1], args[2], args[3])
149
- end
223
+ self.origin, self.size =
224
+ case args.size
225
+ when 1
226
+ arg = args[0]
227
+ case arg
228
+ when Hash
229
+ [arg[:origin], arg[:size]]
230
+ else
231
+ [arg.origin, arg.size]
232
+ end
233
+ when 2
234
+ [args[0], args[1]]
235
+ when 4
236
+ [[args[0], args[1]], [args[2], args[3]]]
237
+ end
238
+ end
239
+
240
+ def sdk
241
+ MKMapRectMake(@origin.x, @origin.y, @size.width, @size.height)
242
+ end
243
+
244
+ def origin=(origin)
245
+ @origin = MapPoint.new(origin)
150
246
  end
151
247
 
152
- def origin
153
- MapPoint.new(@sdk.origin)
248
+ def size=(size)
249
+ @size = MapSize.new(size)
154
250
  end
155
251
 
156
- def size
157
- MapSize.new(@sdk.size)
252
+ def to_h
253
+ {:origin => @origin.to_h, :size => @size.to_h}
158
254
  end
159
255
 
160
- def to_hash
161
- {:origin => origin.to_array, :size => size.to_array}
256
+ def to_s
257
+ to_h.to_s
162
258
  end
163
259
  end
164
260
  end
@@ -1,6 +1,6 @@
1
- # require core_location_data_types
2
- # require map_kit_data_types
3
- # require zoom_level
1
+ #= require core_location_data_types
2
+ #= require map_kit_data_types
3
+ #= require zoom_level
4
4
 
5
5
  module MapKit
6
6
  include CoreLocation::DataTypes
@@ -1,3 +1,3 @@
1
1
  module MapKit
2
- VERSION = "0.0.3"
2
+ VERSION = '0.0.4'
3
3
  end
@@ -1,10 +1,11 @@
1
1
  module MapKit
2
2
  ##
3
3
  # Ruby adaption of http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/
4
+ # More here http://troybrant.net/blog/2010/01/mkmapview-and-zoom-levels-a-visual-guide/
4
5
  module ZoomLevel
5
6
  include Math
6
7
  MERCATOR_OFFSET = 268435456.0
7
- MERCATOR_RADIUS = 85445659.44705395
8
+ MERCATOR_RADIUS = MERCATOR_OFFSET / PI
8
9
 
9
10
  ##
10
11
  # Map conversion methods
@@ -2,18 +2,19 @@
2
2
  require File.expand_path('../lib/map-kit-wrapper/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Kasper Weibel Nielsen-Refs"]
6
- gem.email = ["weibel@gmail.com"]
5
+ gem.authors = ['Kasper Weibel Nielsen-Refs']
6
+ gem.email = ['weibel@gmail.com']
7
7
  gem.summary = %q{This is a MapKit wrapper for RubyMotion. It's purpose is to make make dealing with MapKit less painful}
8
- gem.homepage = "https://github.com/weibel/MapKitWrapper"
8
+ gem.homepage = 'https://github.com/weibel/MapKitWrapper'
9
9
 
10
10
  gem.files = `git ls-files`.split($\)
11
11
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
- gem.name = "map-kit-wrapper"
14
- gem.require_paths = ["lib"]
13
+ gem.name = 'map-kit-wrapper'
14
+ gem.require_paths = ['lib']
15
15
  gem.version = MapKit::VERSION
16
16
 
17
- gem.add_dependency 'codependency', '0.2.0'
17
+ #gem.add_dependency 'bundler', '1.1.4'
18
+ gem.add_dependency 'codependency', '2.0.0'
18
19
  gem.add_dependency 'rake'
19
20
  end
@@ -4,7 +4,8 @@ describe 'LocationCoordinate' do
4
4
  lc_2 = CoreLocation::DataTypes::LocationCoordinate.new([5, 8])
5
5
  lc_3 = CoreLocation::DataTypes::LocationCoordinate.new(CLLocationCoordinate2DMake(5, 8))
6
6
  lc_4 = CoreLocation::DataTypes::LocationCoordinate.new(lc_3)
7
- @array = [lc_1, lc_2, lc_3, lc_4]
7
+ lc_5 = CoreLocation::DataTypes::LocationCoordinate.new({:latitude => 5, :longitude => 8})
8
+ @array = [lc_1, lc_2, lc_3, lc_4, lc_5]
8
9
  end
9
10
 
10
11
  it 'should return the latitude' do
@@ -35,7 +36,19 @@ describe 'LocationCoordinate' do
35
36
 
36
37
  it 'should return an array' do
37
38
  @array.each do |lc|
38
- lc.to_array.should.equal [5, 8]
39
+ lc.to_a.should.equal [5, 8]
40
+ end
41
+ end
42
+
43
+ it 'should return a hash' do
44
+ @array.each do |lc|
45
+ lc.to_h.should.equal({:latitude => 5, :longitude => 8})
46
+ end
47
+ end
48
+
49
+ it 'should return a string' do
50
+ @array.each do |lc|
51
+ lc.to_s.should.equal '{:latitude=>5.0, :longitude=>8.0}'
39
52
  end
40
53
  end
41
54
 
@@ -4,7 +4,9 @@ describe 'MapKitDataTypes' do
4
4
  o_1 = MapKit::DataTypes::CoordinateSpan.new(5, 8)
5
5
  o_2 = MapKit::DataTypes::CoordinateSpan.new([5, 8])
6
6
  o_3 = MapKit::DataTypes::CoordinateSpan.new(MKCoordinateSpanMake(5, 8))
7
- @array = [o_1, o_2, o_3]
7
+ o_4 = MapKit::DataTypes::CoordinateSpan.new(o_1)
8
+ o_5 = MapKit::DataTypes::CoordinateSpan.new({:latitude_delta => 5, :longitude_delta => 8})
9
+ @array = [o_1, o_2, o_3, o_4, o_5]
8
10
  end
9
11
 
10
12
  it 'should return the latitude delta' do
@@ -21,7 +23,13 @@ describe 'MapKitDataTypes' do
21
23
 
22
24
  it 'should return an array' do
23
25
  @array.each do |o|
24
- o.to_array.should.equal [5, 8]
26
+ o.to_a.should.equal [5, 8]
27
+ end
28
+ end
29
+
30
+ it 'should return a hash' do
31
+ @array.each do |o|
32
+ o.to_h.should.equal({:latitude_delta => 5.0, :longitude_delta => 8.0})
25
33
  end
26
34
  end
27
35
 
@@ -42,7 +50,8 @@ describe 'MapKitDataTypes' do
42
50
  o_3 = MapKit::DataTypes::CoordinateRegion.new(CLLocationCoordinate2DMake(5, 8), MKCoordinateSpanMake(6, 9))
43
51
  o_4 = MapKit::DataTypes::CoordinateRegion.new(mkcr)
44
52
  o_5 = MapKit::DataTypes::CoordinateRegion.new(o_1)
45
- @array = [o_1, o_2, o_3, o_4, o_5]
53
+ o_6 = MapKit::DataTypes::CoordinateRegion.new({:center => {:latitude => 5.0, :longitude => 8.0}, :span => {:latitude_delta => 6.0, :longitude_delta => 9.0}})
54
+ @array = [o_1, o_2, o_3, o_4, o_5, o_6]
46
55
  end
47
56
 
48
57
  it 'should return the center' do
@@ -63,7 +72,7 @@ describe 'MapKitDataTypes' do
63
72
 
64
73
  it 'should return a hash' do
65
74
  @array.each do |o|
66
- o.to_hash.should.equal({:center => [5, 8], :span => [6, 9]})
75
+ o.to_h.should.equal({:center => {:latitude => 5.0, :longitude => 8.0}, :span => {:latitude_delta => 6.0, :longitude_delta => 9.0}})
67
76
  end
68
77
  end
69
78
 
@@ -79,7 +88,8 @@ describe 'MapKitDataTypes' do
79
88
  o_1 = MapKit::DataTypes::MapPoint.new(5, 8)
80
89
  o_2 = MapKit::DataTypes::MapPoint.new([5, 8])
81
90
  o_3 = MapKit::DataTypes::MapPoint.new(MKMapPointMake(5, 8))
82
- @array = [o_1, o_2, o_3]
91
+ o_4 = MapKit::DataTypes::MapPoint.new({:x => 5.0, :y => 8.0})
92
+ @array = [o_1, o_2, o_3, o_4]
83
93
  end
84
94
 
85
95
  it 'should return the x' do
@@ -96,7 +106,13 @@ describe 'MapKitDataTypes' do
96
106
 
97
107
  it 'should return an array' do
98
108
  @array.each do |o|
99
- o.to_array.should.equal [5, 8]
109
+ o.to_a.should.equal [5, 8]
110
+ end
111
+ end
112
+
113
+ it 'should return a hash' do
114
+ @array.each do |o|
115
+ o.to_h.should.equal({:x => 5.0, :y => 8.0})
100
116
  end
101
117
  end
102
118
 
@@ -112,7 +128,8 @@ describe 'MapKitDataTypes' do
112
128
  o_1 = MapKit::DataTypes::MapSize.new(5, 8)
113
129
  o_2 = MapKit::DataTypes::MapSize.new([5, 8])
114
130
  o_3 = MapKit::DataTypes::MapSize.new(MKMapSizeMake(5, 8))
115
- @array = [o_1, o_2, o_3]
131
+ o_4 = MapKit::DataTypes::MapSize.new({:width => 5.0, :height => 8.0})
132
+ @array = [o_1, o_2, o_3, o_4]
116
133
  end
117
134
 
118
135
  it 'should return the width' do
@@ -129,7 +146,13 @@ describe 'MapKitDataTypes' do
129
146
 
130
147
  it 'should return an array' do
131
148
  @array.each do |o|
132
- o.to_array.should.equal [5, 8]
149
+ o.to_a.should.equal [5, 8]
150
+ end
151
+ end
152
+
153
+ it 'should return a hash' do
154
+ @array.each do |o|
155
+ o.to_h.should.equal({:width => 5.0, :height => 8.0})
133
156
  end
134
157
  end
135
158
 
@@ -148,7 +171,10 @@ describe 'MapKitDataTypes' do
148
171
  o_2 = MapKit::DataTypes::MapRect.new([5, 8], [6, 9])
149
172
  o_3 = MapKit::DataTypes::MapRect.new(mp, ms)
150
173
  o_4 = MapKit::DataTypes::MapRect.new(MKMapPointMake(5, 8), MKMapSizeMake(6, 9))
151
- @array = [o_1, o_2, o_3, o_4]
174
+ o_5 = MapKit::DataTypes::MapRect.new({:origin => {:x => 5.0, :y => 8.0}, :size => {:width => 6.0, :height => 9.0}})
175
+ o_6 = MapKit::DataTypes::MapRect.new(o_5)
176
+ o_7 = MapKit::DataTypes::MapRect.new(o_5.sdk)
177
+ @array = [o_1, o_2, o_3, o_4, o_5, o_6, o_7]
152
178
  end
153
179
 
154
180
  it 'should return the origin' do
@@ -169,7 +195,7 @@ describe 'MapKitDataTypes' do
169
195
 
170
196
  it 'should return a hash' do
171
197
  @array.each do |o|
172
- o.to_hash.should.equal({:origin => [5, 8], :size => [6, 9]})
198
+ o.to_h.should.equal({:origin => {:x => 5.0, :y => 8.0}, :size => {:width => 6.0, :height => 9.0}})
173
199
  end
174
200
  end
175
201
 
@@ -7,7 +7,7 @@ describe 'ZoomLevel' do
7
7
  end
8
8
 
9
9
  it 'should return longitude_to_pixel_space_x' do
10
- MapKit::MapView.longitude_to_pixel_space_x(30).should.equal 313174656
10
+ MapKit::MapView.longitude_to_pixel_space_x(30).should.equal 313174699
11
11
  end
12
12
 
13
13
  it 'should return latitude_to_pixel_space_y' do
@@ -17,7 +17,7 @@ describe 'ZoomLevel' do
17
17
  end
18
18
 
19
19
  it 'should return pixel_space_x_to_longitude' do
20
- MapKit::MapView.pixel_space_x_to_longitude(313174656).should.equal 29.999984741210 # 30
20
+ MapKit::MapView.pixel_space_x_to_longitude(313174699).should.equal 29.9999923706055 # 30
21
21
  end
22
22
 
23
23
  it 'should return pixel_space_y_to_latitude' do
@@ -28,18 +28,18 @@ describe 'ZoomLevel' do
28
28
 
29
29
  it 'should return coordinate_span_with_map_view' do
30
30
  span = MapKit::MapView.coordinate_span_with_map_view(@map, CLLocationCoordinate2DMake(56, 10), 2)
31
- span.latitudeDelta.should.equal 48.452224731445
32
- span.longitudeDelta.should.equal 56.25
31
+ span.latitudeDelta.should.equal 48.4522247314453
32
+ span.longitudeDelta.should.equal 56.2499694824219
33
33
  end
34
34
 
35
35
  it 'should return set_center_coordinates' do
36
36
  @map.set_center_coordinates(CLLocationCoordinate2DMake(56, 10), 2, false)
37
37
  center = CoreLocation::DataTypes::LocationCoordinate.new(@map.region.center)
38
38
  span = MapKit::DataTypes::CoordinateSpan.new(@map.region.span)
39
- span.latitude_delta.should.equal 48.4812927246094
39
+ span.latitude_delta.should.equal 48.4522247314453
40
40
  span.longitude_delta.should.equal 56.25
41
- center.latitude.should.equal 55.9737854003906
42
- center.longitude.should.equal 10.01953125
41
+ center.latitude.should.equal 56.0
42
+ center.longitude.should.equal 10.0
43
43
  @map.set_center_coordinates(CLLocationCoordinate2DMake(0, 0), 50, false)
44
44
  @map.zoom_level.should.equal 18
45
45
  end
@@ -48,10 +48,10 @@ describe 'ZoomLevel' do
48
48
  @map.set_map_lat_lon(56, 10, 2, false)
49
49
  center = CoreLocation::DataTypes::LocationCoordinate.new(@map.region.center)
50
50
  span = MapKit::DataTypes::CoordinateSpan.new(@map.region.span)
51
- span.latitude_delta.should.equal 48.4812927246094
51
+ span.latitude_delta.should.equal 48.4522247314453
52
52
  span.longitude_delta.should.equal 56.25
53
- center.latitude.should.equal 55.9737854003906
54
- center.longitude.should.equal 10.01953125
53
+ center.latitude.should.equal 56.0
54
+ center.longitude.should.equal 10.0
55
55
  end
56
56
 
57
57
  it 'should return coordinate_region_with_map_view' do
@@ -62,7 +62,7 @@ describe 'ZoomLevel' do
62
62
  center = CoreLocation::DataTypes::LocationCoordinate.new(region.center)
63
63
  span = MapKit::DataTypes::CoordinateSpan.new(region.span)
64
64
  span.latitude_delta.should.equal 48.4522247314453
65
- span.longitude_delta.should.equal 56.25
65
+ span.longitude_delta.should.equal 56.2499694824219
66
66
  center.latitude.should.equal 56.0
67
67
  center.longitude.should.equal 10.0
68
68
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: map-kit-wrapper
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Kasper Weibel Nielsen-Refs
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-08-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: codependency
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 0
31
- - 2
32
- - 0
33
- version: 0.2.0
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rake
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :runtime
49
- version_requirements: *id002
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
50
46
  description:
51
- email:
47
+ email:
52
48
  - weibel@gmail.com
53
49
  executables: []
54
-
55
50
  extensions: []
56
-
57
51
  extra_rdoc_files: []
58
-
59
- files:
52
+ files:
60
53
  - .gitignore
61
54
  - Gemfile
62
55
  - LICENSE
@@ -78,38 +71,30 @@ files:
78
71
  - spec/main_spec.rb
79
72
  homepage: https://github.com/weibel/MapKitWrapper
80
73
  licenses: []
81
-
82
74
  post_install_message:
83
75
  rdoc_options: []
84
-
85
- require_paths:
76
+ require_paths:
86
77
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
78
+ required_ruby_version: !ruby/object:Gem::Requirement
88
79
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
85
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
105
90
  requirements: []
106
-
107
91
  rubyforge_project:
108
92
  rubygems_version: 1.8.24
109
93
  signing_key:
110
94
  specification_version: 3
111
- summary: This is a MapKit wrapper for RubyMotion. It's purpose is to make make dealing with MapKit less painful
112
- test_files:
95
+ summary: This is a MapKit wrapper for RubyMotion. It's purpose is to make make dealing
96
+ with MapKit less painful
97
+ test_files:
113
98
  - spec/lib/core_location_data_types_spec.rb
114
99
  - spec/lib/map_kit_data_types_spec.rb
115
100
  - spec/lib/map_view_spec.rb