cloudmade 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/cloudmade.gemspec +2 -2
- data/lib/cloudmade/version.rb +1 -1
- data/test/mock_connection.rb +4 -1
- data/test/test_geocoding.rb +4 -4
- data/test/test_geometry.rb +18 -16
- data/test/test_routing.rb +9 -7
- data/test/test_tiles.rb +4 -2
- metadata +5 -5
data/cloudmade.gemspec
CHANGED
@@ -5,9 +5,9 @@ require "cloudmade/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "cloudmade"
|
7
7
|
s.version = Cloudmade::VERSION
|
8
|
-
s.authors = ["Klaus Zanders", "cloudmade.com"]
|
8
|
+
s.authors = ["Klaus Zanders", "forked from cloudmade.com"]
|
9
9
|
s.email = ["klaus.zanders@gmail.com", "ishubovych@cloudmade.com"]
|
10
|
-
s.homepage = "
|
10
|
+
s.homepage = "https://github.com/klaustopher/cloudmade"
|
11
11
|
s.summary = 'CloudMade Ruby API'
|
12
12
|
s.description = s.summary
|
13
13
|
|
data/lib/cloudmade/version.rb
CHANGED
data/test/mock_connection.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
2
|
+
$:.push File.expand_path("../..", __FILE__)
|
3
|
+
|
1
4
|
require 'cloudmade'
|
2
5
|
|
3
|
-
class MockConnection < Connection
|
6
|
+
class MockConnection < CloudMade::Connection
|
4
7
|
attr_accessor :return_data
|
5
8
|
attr_accessor :request
|
6
9
|
attr_accessor :server_url
|
data/test/test_geocoding.rb
CHANGED
@@ -44,10 +44,10 @@ class GeocodingServiceTest < Test::Unit::TestCase #:nodoc: all
|
|
44
44
|
def test_find
|
45
45
|
connection = MockConnection.new('FAKE-API-KEY', 'fake-cloudmade.com')
|
46
46
|
connection.return_data = RETURN_DATA_FIND
|
47
|
-
geocoding = GeocodingService.new(connection, 'geocoding')
|
47
|
+
geocoding = CloudMade::GeocodingService.new(connection, 'geocoding')
|
48
48
|
geo_results = geocoding.find('/geocoding/find/Oxford%20street%2CLondon.js?bbox_only=True&skip=0&return_location=True&results=2&return_geometry=True')
|
49
49
|
assert geo_results.found == 2
|
50
|
-
assert_equal geo_results.bounds, BBox.from_coordinates([[51.51341,-0.15853],[51.51722,-0.12261]])
|
50
|
+
assert_equal geo_results.bounds, CloudMade::BBox.from_coordinates([[51.51341,-0.15853],[51.51722,-0.12261]])
|
51
51
|
assert geo_results.results[0].properties["name"] == "New Oxford Street"
|
52
52
|
assert geo_results.results[1].properties["name"] == "Oxford Street"
|
53
53
|
assert_equal geo_results.results[1].geometry.class.to_s, 'CloudMade::MultiLine'
|
@@ -57,13 +57,13 @@ class GeocodingServiceTest < Test::Unit::TestCase #:nodoc: all
|
|
57
57
|
def test_closest
|
58
58
|
connection = MockConnection.new('FAKE-API-KEY', 'fake-cloudmade.com')
|
59
59
|
connection.return_data = RETURN_DATA_CLOSEST
|
60
|
-
geocoding = GeocodingService.new(connection, 'geocoding')
|
60
|
+
geocoding = CloudMade::GeocodingService.new(connection, 'geocoding')
|
61
61
|
geo_result = geocoding.find_closest("poi", 53.51722, -0.12312,
|
62
62
|
:options => { :return_location => true, :return_geometry => false})
|
63
63
|
assert_equal geo_result.class.to_s, 'CloudMade::GeoResult'
|
64
64
|
#assert_equal connection.uri, """/geocoding/closest/poi/53.51722,-0.12312.js?return_location=True&return_geometry=False"""
|
65
65
|
assert_nil geo_result.geometry
|
66
66
|
assert_equal geo_result.location.city, 'Kingston upon Hull'
|
67
|
-
assert_equal geo_result.centroid, Point.new(53.52435, -0.143)
|
67
|
+
assert_equal geo_result.centroid, CloudMade::Point.new(53.52435, -0.143)
|
68
68
|
end
|
69
69
|
end
|
data/test/test_geometry.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
-
|
1
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
2
|
+
$:.push File.expand_path("../..", __FILE__)
|
3
|
+
|
2
4
|
require 'cloudmade'
|
3
5
|
require 'test/unit'
|
4
6
|
|
5
7
|
class PointTest < Test::Unit::TestCase #:nodoc: all
|
6
8
|
|
7
9
|
def test_initialization
|
8
|
-
point = Point.new(1, 2)
|
10
|
+
point = CloudMade::Point.new(1, 2)
|
9
11
|
assert_equal point.lat, 1
|
10
12
|
assert_equal point.lon, 2
|
11
13
|
|
12
|
-
point = Point.new([1, 3])
|
14
|
+
point = CloudMade::Point.new([1, 3])
|
13
15
|
assert_equal point.lat, 1
|
14
16
|
assert_equal point.lon, 3
|
15
17
|
end
|
16
18
|
|
17
19
|
def test_equality
|
18
|
-
point1 = Point.new(1, 0)
|
19
|
-
point2 = Point.new(2/2, 1-1)
|
20
|
+
point1 = CloudMade::Point.new(1, 0)
|
21
|
+
point2 = CloudMade::Point.new(2/2, 1-1)
|
20
22
|
assert point1 == point2
|
21
23
|
|
22
|
-
point3 = Point.new(1.0, 0.1)
|
24
|
+
point3 = CloudMade::Point.new(1.0, 0.1)
|
23
25
|
assert point1 != point3
|
24
26
|
end
|
25
27
|
|
26
28
|
def test_to_latlon
|
27
|
-
point = Point.new(1, 2)
|
29
|
+
point = CloudMade::Point.new(1, 2)
|
28
30
|
assert_equal point.to_latlon, '1,2'
|
29
31
|
end
|
30
32
|
end
|
@@ -32,14 +34,14 @@ end
|
|
32
34
|
class LineTest < Test::Unit::TestCase #:nodoc: all
|
33
35
|
|
34
36
|
def test_initialization
|
35
|
-
line = Line.new([[1.1, 2.0], [0.1, 2.1]])
|
37
|
+
line = CloudMade::Line.new([[1.1, 2.0], [0.1, 2.1]])
|
36
38
|
assert_equal line.points.length, 2
|
37
39
|
assert_equal line.points[0].lat, 1.1
|
38
40
|
assert_equal line.points[0].lon, 2.0
|
39
41
|
assert_equal line.points[1].lat, 0.1
|
40
42
|
assert_equal line.points[1].lon, 2.1
|
41
43
|
|
42
|
-
line = Line.new([[1.1, 2.0], [0.1, 2.1], [0.5, 3.1], [3.1, 4.1]])
|
44
|
+
line = CloudMade::Line.new([[1.1, 2.0], [0.1, 2.1], [0.5, 3.1], [3.1, 4.1]])
|
43
45
|
assert_equal line.points.length, 4
|
44
46
|
end
|
45
47
|
end
|
@@ -47,7 +49,7 @@ end
|
|
47
49
|
class MultiLineTest < Test::Unit::TestCase #:nodoc: all
|
48
50
|
def test_initialization
|
49
51
|
coords = [[[0.2, 35.2], [4.3, 45.1], [5.7, 11.2]], [[1.1, 33.2], [5.3, 22.2]]]
|
50
|
-
ml = MultiLine.new(coords)
|
52
|
+
ml = CloudMade::MultiLine.new(coords)
|
51
53
|
assert_equal ml.lines.size, 2
|
52
54
|
assert_equal ml.lines[0].points.length, 3
|
53
55
|
assert_equal ml.lines[1].points.length, 2
|
@@ -58,7 +60,7 @@ end
|
|
58
60
|
class PolygonTest < Test::Unit::TestCase #:nodoc: all
|
59
61
|
def test_initialization
|
60
62
|
coords = [[[0.2, 35.2], [4.3, 45.1], [5.7, 11.2]], [[1.1, 33.2], [5.3, 22.2]]]
|
61
|
-
polygon = Polygon.new(coords)
|
63
|
+
polygon = CloudMade::Polygon.new(coords)
|
62
64
|
assert polygon.border_line != nil
|
63
65
|
assert_equal polygon.border_line.points.size, 3
|
64
66
|
assert polygon.holes != nil
|
@@ -69,7 +71,7 @@ end
|
|
69
71
|
class MultiPolygonTest < Test::Unit::TestCase #:nodoc: all
|
70
72
|
def test_initialization
|
71
73
|
coords = [[[[0.2, 35.2], [4.3, 45.1]]], [[[1.1, 33.2], [5.3, 22.2]]]]
|
72
|
-
mp = MultiPolygon.new(coords)
|
74
|
+
mp = CloudMade::MultiPolygon.new(coords)
|
73
75
|
assert_equal mp.polygons.size, 2
|
74
76
|
assert_equal mp.polygons[0].holes.size, 0
|
75
77
|
assert_equal mp.polygons[1].holes.size, 0
|
@@ -79,14 +81,14 @@ end
|
|
79
81
|
class BBoxTest < Test::Unit::TestCase #:nodoc: all
|
80
82
|
def test_initialization
|
81
83
|
coordinates = [[0.2, 35.2], [4.3, 45.1]]
|
82
|
-
point1 = Point.new(coordinates[0])
|
83
|
-
point2 = Point.new(coordinates[1])
|
84
|
-
bbox = BBox.from_points([point1, point2])
|
84
|
+
point1 = CloudMade::Point.new(coordinates[0])
|
85
|
+
point2 = CloudMade::Point.new(coordinates[1])
|
86
|
+
bbox = CloudMade::BBox.from_points([point1, point2])
|
85
87
|
assert_equal bbox.points.length, 2
|
86
88
|
assert_equal bbox.points[0], point1
|
87
89
|
assert_equal bbox.points[1], point2
|
88
90
|
|
89
|
-
bbox = BBox.from_coordinates(coordinates)
|
91
|
+
bbox = CloudMade::BBox.from_coordinates(coordinates)
|
90
92
|
assert_equal bbox.points.length, 2
|
91
93
|
assert_equal bbox.points[0], point1
|
92
94
|
assert_equal bbox.points[1], point2
|
data/test/test_routing.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
2
|
+
$:.push File.expand_path("../..", __FILE__)
|
3
|
+
|
2
4
|
require 'cloudmade'
|
3
5
|
require 'test/unit'
|
4
6
|
require 'test/mock_connection'
|
@@ -43,12 +45,12 @@ class RoutingServiceTest < Test::Unit::TestCase #:nodoc: all
|
|
43
45
|
eos
|
44
46
|
|
45
47
|
def test_empty_routing
|
46
|
-
transit_points = [Point.new([51.22, 4.41]), Point.new([51.2, 4.41])]
|
48
|
+
transit_points = [CloudMade::Point.new([51.22, 4.41]), CloudMade::Point.new([51.2, 4.41])]
|
47
49
|
connection = MockConnection.new('FAKE-API-KEY', 'fake-cloudmade.com')
|
48
50
|
connection.return_data = RETURN_DATA_EMPTY
|
49
|
-
routing = RoutingService.new(connection, 'routing')
|
51
|
+
routing = CloudMade::RoutingService.new(connection, 'routing')
|
50
52
|
begin
|
51
|
-
route = routing.route(Point.new([51.22545, 4.40730]), Point.new([51.23, 4.42]),
|
53
|
+
route = routing.route(CloudMade::Point.new([51.22545, 4.40730]), CloudMade::Point.new([51.23, 4.42]),
|
52
54
|
transit_points, 'car', 'shortest')
|
53
55
|
assert false
|
54
56
|
rescue RouteNotFound
|
@@ -57,12 +59,12 @@ class RoutingServiceTest < Test::Unit::TestCase #:nodoc: all
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def test_routing
|
60
|
-
transit_points = [Point.new([51.22, 4.41]), Point.new([51.2, 4.41])]
|
62
|
+
transit_points = [CloudMade::Point.new([51.22, 4.41]), CloudMade::Point.new([51.2, 4.41])]
|
61
63
|
connection = MockConnection.new('FAKE-API-KEY', 'fake-cloudmade.com')
|
62
64
|
connection.return_data = RETURN_DATA_ROUTING
|
63
|
-
routing = RoutingService.new(connection, 'routing')
|
65
|
+
routing = CloudMade::RoutingService.new(connection, 'routing')
|
64
66
|
begin
|
65
|
-
route = routing.route(Point.new([51.22545, 4.40730]), Point.new([51.23, 4.42]),
|
67
|
+
route = routing.route(CloudMade::Point.new([51.22545, 4.40730]), CloudMade::Point.new([51.23, 4.42]),
|
66
68
|
transit_points, 'car', 'shortest')
|
67
69
|
assert_equal route.version, '0.3'
|
68
70
|
assert_equal route.summary.total_time, 852
|
data/test/test_tiles.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
2
|
+
$:.push File.expand_path("../..", __FILE__)
|
3
|
+
|
2
4
|
require 'cloudmade'
|
3
5
|
require 'test/unit'
|
4
6
|
require 'test/mock_connection'
|
@@ -7,7 +9,7 @@ class TilesServiceTest < Test::Unit::TestCase #:nodoc: all
|
|
7
9
|
|
8
10
|
def setup
|
9
11
|
@connection = MockConnection.new('FAKE-API-KEY', 'fake-cloudmade.com')
|
10
|
-
@tiles = TilesService.new(@connection, 'tile')
|
12
|
+
@tiles = CloudMade::TilesService.new(@connection, 'tile')
|
11
13
|
end
|
12
14
|
|
13
15
|
def test_latlon2tilenums
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudmade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Klaus Zanders
|
9
|
-
- cloudmade.com
|
9
|
+
- forked from cloudmade.com
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
@@ -77,7 +77,7 @@ files:
|
|
77
77
|
- test/test_geometry.rb
|
78
78
|
- test/test_routing.rb
|
79
79
|
- test/test_tiles.rb
|
80
|
-
homepage:
|
80
|
+
homepage: https://github.com/klaustopher/cloudmade
|
81
81
|
licenses: []
|
82
82
|
post_install_message:
|
83
83
|
rdoc_options: []
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash:
|
94
|
+
hash: 2555345038746054796
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: 2555345038746054796
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project: cloudmade
|
106
106
|
rubygems_version: 1.8.21
|