googlemaps-services 1.3.0 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a29bf1ab90463cf58a2920a07ea63a791cf6637
|
4
|
+
data.tar.gz: 27203036b8394d7f9bb304864f8156fd0c454ded
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cdbce608cb68fe2b5fb418e8f4193f0c8d137f1239ec26efa9c58919e1eac2099b1c2dd261fc4e729f3a096e01d32f93bd55bff66e22404299a500899b91d75
|
7
|
+
data.tar.gz: 9b6422d246c467abe6d29db91239e4f11abbf48e72c10584ba55e0f54234dc18fb60e8dca44661e6c840f6168f07acdf78254409e27c99294a3bee5494ae698e
|
@@ -105,9 +105,7 @@ module GoogleMaps
|
|
105
105
|
# @return [Hash, Array, nil] response body (either in JSON or XML) or nil.
|
106
106
|
def get(url:, params:, first_request_time: nil, retry_counter: nil, base_url: DEFAULT_BASE_URL,
|
107
107
|
accepts_clientid: true, extract_body: nil, request_headers: nil)
|
108
|
-
unless first_request_time
|
109
|
-
first_request_time = Util.current_time
|
110
|
-
end
|
108
|
+
first_request_time = Util.current_time unless first_request_time
|
111
109
|
|
112
110
|
elapsed = Time.now - first_request_time
|
113
111
|
if elapsed > self.retry_timeout
|
@@ -120,7 +118,7 @@ module GoogleMaps
|
|
120
118
|
# at 1, so subtract that first.
|
121
119
|
delay_seconds = 0.5 * 1.5 ** (retry_counter - 1)
|
122
120
|
# Jitter this value by 50% and pause.
|
123
|
-
sleep(delay_seconds * (
|
121
|
+
sleep(delay_seconds * (Random.rand + 0.5))
|
124
122
|
end
|
125
123
|
|
126
124
|
authed_url = generate_auth_url(url, params, accepts_clientid)
|
@@ -219,8 +217,6 @@ module GoogleMaps
|
|
219
217
|
|
220
218
|
if body.key?('error_message')
|
221
219
|
raise APIError.new(api_status), body['error_message']
|
222
|
-
else
|
223
|
-
raise APIError.new(api_status)
|
224
220
|
end
|
225
221
|
end
|
226
222
|
|
@@ -257,8 +253,6 @@ module GoogleMaps
|
|
257
253
|
error_message = doc.xpath('//error_message')
|
258
254
|
if error_message
|
259
255
|
raise APIError.new(api_status), error_message.text
|
260
|
-
else
|
261
|
-
raise APIError.new(api_status)
|
262
256
|
end
|
263
257
|
end
|
264
258
|
|
@@ -304,12 +298,10 @@ module GoogleMaps
|
|
304
298
|
return path + '&signature=' + sig
|
305
299
|
end
|
306
300
|
|
307
|
-
|
308
|
-
params['key'] = self.key
|
309
|
-
return path + '?' + Util.urlencode_params(params)
|
310
|
-
end
|
301
|
+
raise StandardError, 'Must provide API key for this API. It does not accept enterprise credentials.' unless self.key
|
311
302
|
|
312
|
-
|
303
|
+
params['key'] = self.key
|
304
|
+
return path + '?' + Util.urlencode_params(params)
|
313
305
|
end
|
314
306
|
|
315
307
|
private :get_json_body, :get_xml_body, :get_map_image, :get_redirection_url, :generate_auth_url
|
@@ -67,7 +67,7 @@ module GoogleMaps
|
|
67
67
|
# Performs requests to the Google Maps Geocoding API.
|
68
68
|
#
|
69
69
|
# @example
|
70
|
-
# reverse_geocode = GoogleMaps::Services::ReverseGeocode(client)
|
70
|
+
# reverse_geocode = GoogleMaps::Services::ReverseGeocode.new(client)
|
71
71
|
# result = reverse_geocode.query(latlng: {:lat => 52.520645, :lng => 13.409779}, language: "fr")
|
72
72
|
class ReverseGeocode
|
73
73
|
attr_accessor :client
|
@@ -42,6 +42,8 @@ module GoogleMaps
|
|
42
42
|
# @param [String, Array] path The single path of two or more connected points to overlay in the image at the specified locations.
|
43
43
|
# @param [String, Array] visible One or more locations that should remain visible on the map.
|
44
44
|
# @param [String] style A custom style to alter the presentation of a specific feature (roads, parks, and other features) of the map.
|
45
|
+
#
|
46
|
+
# @return [Hash] Hash with image URL, MIME type and its base64-encoded value.
|
45
47
|
def query(size:, center: nil, zoom: nil, scale: 1, format: "png", maptype: "roadmap",
|
46
48
|
language: nil, region: nil, markers: nil, path: nil, visible: nil, style: nil)
|
47
49
|
params = { 'size' => Convert.rectangular_dimensions(size) }
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'googlemaps/services/util'
|
2
|
+
|
3
|
+
module GoogleMaps
|
4
|
+
module Services
|
5
|
+
|
6
|
+
# Performs requests to the Google Street View Map API.
|
7
|
+
#
|
8
|
+
# @example Get the street view map image
|
9
|
+
# streetview = GoogleMaps::Services::StreetViewImage.new(client)
|
10
|
+
# map_img = streetview.query(size: {:length=>400, :width=>400}, location: "40.714728,-73.998672", heading: 151.78, pitch: -0.76)
|
11
|
+
# # {
|
12
|
+
# # :url => "https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.714728%2C-73.998672&heading=151.78&pitch=-0.76",
|
13
|
+
# # :mime_type => "image/jpeg",
|
14
|
+
# # :image_data => "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHR..."
|
15
|
+
# # }
|
16
|
+
class StreetViewImage
|
17
|
+
|
18
|
+
# @return [Symbol] The HTTP client.
|
19
|
+
attr_accessor :client
|
20
|
+
|
21
|
+
def initialize(client)
|
22
|
+
self.client = client
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get the street view map image.
|
26
|
+
#
|
27
|
+
# @param [Hash] size the rectangular dimensions of the street view image.
|
28
|
+
# @param [String, Hash] location The address or lat/lng value of the street view map.
|
29
|
+
# @param [String] pano A specific panorama ID.
|
30
|
+
# @param [Numeric] heading The compass heading of the camera. Accepted values are from 0 to 360.
|
31
|
+
# @param [Numeric] fov The horizontal field of view of the image. It is expressed in degrees, with a maximum allowed value of 120.
|
32
|
+
# @param [Numeric] pitch The up or down angle of the camera relative to the Street View vehicle.
|
33
|
+
# Positive values angle the camera up (with 90 degrees indicating straight up).
|
34
|
+
# Negative values angle the camera down (with -90 indicating straight down).
|
35
|
+
#
|
36
|
+
# @return [Hash] Hash with image URL, MIME type and its base64-encoded value.
|
37
|
+
def query(size:, location: nil, pano: nil, heading: nil, fov: nil, pitch: nil)
|
38
|
+
params = {
|
39
|
+
'size' => Convert.rectangular_dimensions(size)
|
40
|
+
}
|
41
|
+
|
42
|
+
if location
|
43
|
+
params['location'] = Convert.to_latlng(location)
|
44
|
+
end
|
45
|
+
|
46
|
+
if pano
|
47
|
+
params['pano'] = pano
|
48
|
+
end
|
49
|
+
|
50
|
+
if location && pano
|
51
|
+
raise StandardError, 'should not specify both location and panorama ID.'
|
52
|
+
end
|
53
|
+
|
54
|
+
if heading
|
55
|
+
raise StandardError, 'invalid compass heading value.' unless (0..360).include? heading
|
56
|
+
params['heading'] = heading
|
57
|
+
end
|
58
|
+
|
59
|
+
if fov
|
60
|
+
raise StandardError, 'invalid field of view (fov) value.' unless (0..120).include? fov
|
61
|
+
params['fov'] = fov
|
62
|
+
end
|
63
|
+
|
64
|
+
if pitch
|
65
|
+
raise StandardError, 'invalid pitch value.' unless (-90..90).include? pitch
|
66
|
+
params['pitch'] = pitch
|
67
|
+
end
|
68
|
+
|
69
|
+
self.client.get(url: "/maps/api/streetview", params: params)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: googlemaps-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Faissal Elamraoui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/googlemaps/services/places.rb
|
110
110
|
- lib/googlemaps/services/roads.rb
|
111
111
|
- lib/googlemaps/services/staticmap.rb
|
112
|
+
- lib/googlemaps/services/streetview.rb
|
112
113
|
- lib/googlemaps/services/timezone.rb
|
113
114
|
- lib/googlemaps/services/util.rb
|
114
115
|
- lib/googlemaps/services/version.rb
|