google-cloud-vision 0.21.1 → 0.22.0
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 +4 -4
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +59 -0
- data/lib/google/cloud/vision.rb +2 -2
- data/lib/google/cloud/vision/annotate.rb +4 -4
- data/lib/google/cloud/vision/annotation/entity.rb +9 -9
- data/lib/google/cloud/vision/annotation/face.rb +23 -21
- data/lib/google/cloud/vision/annotation/properties.rb +2 -2
- data/lib/google/cloud/vision/annotation/safe_search.rb +1 -1
- data/lib/google/cloud/vision/annotation/text.rb +4 -2
- data/lib/google/cloud/vision/annotation/vertex.rb +2 -2
- data/lib/google/cloud/vision/image.rb +11 -10
- data/lib/google/cloud/vision/project.rb +5 -5
- data/lib/google/cloud/vision/service.rb +2 -2
- data/lib/google/cloud/vision/v1.rb +1 -1
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb +51 -0
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +481 -0
- data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +104 -0
- data/lib/google/cloud/vision/v1/doc/google/protobuf/wrappers.rb +89 -0
- data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/vision/v1/doc/google/type/color.rb +155 -0
- data/lib/google/cloud/vision/v1/doc/google/type/latlng.rb +64 -0
- data/lib/google/cloud/vision/v1/{image_annotator_api.rb → image_annotator_client.rb} +6 -5
- data/lib/google/cloud/vision/v1/image_annotator_client_config.json +0 -2
- data/lib/google/cloud/vision/version.rb +1 -1
- metadata +22 -54
@@ -0,0 +1,104 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# The pack methods provided by protobuf library will by default use
|
43
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
44
|
+
# methods only use the fully qualified type name after the last '/'
|
45
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
46
|
+
# name "y.z".
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# = JSON
|
50
|
+
#
|
51
|
+
# The JSON representation of an +Any+ value uses the regular
|
52
|
+
# representation of the deserialized, embedded message, with an
|
53
|
+
# additional field +@type+ which contains the type URL. Example:
|
54
|
+
#
|
55
|
+
# package google.profile;
|
56
|
+
# message Person {
|
57
|
+
# string first_name = 1;
|
58
|
+
# string last_name = 2;
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# {
|
62
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
63
|
+
# "firstName": <string>,
|
64
|
+
# "lastName": <string>
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# If the embedded message type is well-known and has a custom JSON
|
68
|
+
# representation, that representation will be embedded adding a field
|
69
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
70
|
+
# field. Example (for message Google::Protobuf::Duration):
|
71
|
+
#
|
72
|
+
# {
|
73
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
74
|
+
# "value": "1.212s"
|
75
|
+
# }
|
76
|
+
# @!attribute [rw] type_url
|
77
|
+
# @return [String]
|
78
|
+
# A URL/resource name whose content describes the type of the
|
79
|
+
# serialized protocol buffer message.
|
80
|
+
#
|
81
|
+
# For URLs which use the schema +http+, +https+, or no schema, the
|
82
|
+
# following restrictions and interpretations apply:
|
83
|
+
#
|
84
|
+
# * If no schema is provided, +https+ is assumed.
|
85
|
+
# * The last segment of the URL's path must represent the fully
|
86
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
87
|
+
# The name should be in a canonical form (e.g., leading "." is
|
88
|
+
# not accepted).
|
89
|
+
# * An HTTP GET on the URL must yield a Google::Protobuf::Type
|
90
|
+
# value in binary format, or produce an error.
|
91
|
+
# * Applications are allowed to cache lookup results based on the
|
92
|
+
# URL, or have them precompiled into a binary to avoid any
|
93
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
94
|
+
# on changes to types. (Use versioned type names to manage
|
95
|
+
# breaking changes.)
|
96
|
+
#
|
97
|
+
# Schemas other than +http+, +https+ (or the empty schema) might be
|
98
|
+
# used with implementation specific semantics.
|
99
|
+
# @!attribute [rw] value
|
100
|
+
# @return [String]
|
101
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
102
|
+
class Any; end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# Wrapper message for +double+.
|
18
|
+
#
|
19
|
+
# The JSON representation for +DoubleValue+ is JSON number.
|
20
|
+
# @!attribute [rw] value
|
21
|
+
# @return [Float]
|
22
|
+
# The double value.
|
23
|
+
class DoubleValue; end
|
24
|
+
|
25
|
+
# Wrapper message for +float+.
|
26
|
+
#
|
27
|
+
# The JSON representation for +FloatValue+ is JSON number.
|
28
|
+
# @!attribute [rw] value
|
29
|
+
# @return [Float]
|
30
|
+
# The float value.
|
31
|
+
class FloatValue; end
|
32
|
+
|
33
|
+
# Wrapper message for +int64+.
|
34
|
+
#
|
35
|
+
# The JSON representation for +Int64Value+ is JSON string.
|
36
|
+
# @!attribute [rw] value
|
37
|
+
# @return [Integer]
|
38
|
+
# The int64 value.
|
39
|
+
class Int64Value; end
|
40
|
+
|
41
|
+
# Wrapper message for +uint64+.
|
42
|
+
#
|
43
|
+
# The JSON representation for +UInt64Value+ is JSON string.
|
44
|
+
# @!attribute [rw] value
|
45
|
+
# @return [Integer]
|
46
|
+
# The uint64 value.
|
47
|
+
class UInt64Value; end
|
48
|
+
|
49
|
+
# Wrapper message for +int32+.
|
50
|
+
#
|
51
|
+
# The JSON representation for +Int32Value+ is JSON number.
|
52
|
+
# @!attribute [rw] value
|
53
|
+
# @return [Integer]
|
54
|
+
# The int32 value.
|
55
|
+
class Int32Value; end
|
56
|
+
|
57
|
+
# Wrapper message for +uint32+.
|
58
|
+
#
|
59
|
+
# The JSON representation for +UInt32Value+ is JSON number.
|
60
|
+
# @!attribute [rw] value
|
61
|
+
# @return [Integer]
|
62
|
+
# The uint32 value.
|
63
|
+
class UInt32Value; end
|
64
|
+
|
65
|
+
# Wrapper message for +bool+.
|
66
|
+
#
|
67
|
+
# The JSON representation for +BoolValue+ is JSON +true+ and +false+.
|
68
|
+
# @!attribute [rw] value
|
69
|
+
# @return [true, false]
|
70
|
+
# The bool value.
|
71
|
+
class BoolValue; end
|
72
|
+
|
73
|
+
# Wrapper message for +string+.
|
74
|
+
#
|
75
|
+
# The JSON representation for +StringValue+ is JSON string.
|
76
|
+
# @!attribute [rw] value
|
77
|
+
# @return [String]
|
78
|
+
# The string value.
|
79
|
+
class StringValue; end
|
80
|
+
|
81
|
+
# Wrapper message for +bytes+.
|
82
|
+
#
|
83
|
+
# The JSON representation for +BytesValue+ is JSON string.
|
84
|
+
# @!attribute [rw] value
|
85
|
+
# @return [String]
|
86
|
+
# The bytes value.
|
87
|
+
class BytesValue; end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Rpc
|
17
|
+
# The +Status+ type defines a logical error model that is suitable for different
|
18
|
+
# programming environments, including REST APIs and RPC APIs. It is used by
|
19
|
+
# {gRPC}[https://github.com/grpc]. The error model is designed to be:
|
20
|
+
#
|
21
|
+
# - Simple to use and understand for most users
|
22
|
+
# - Flexible enough to meet unexpected needs
|
23
|
+
#
|
24
|
+
# = Overview
|
25
|
+
#
|
26
|
+
# The +Status+ message contains three pieces of data: error code, error message,
|
27
|
+
# and error details. The error code should be an enum value of
|
28
|
+
# Google::Rpc::Code, but it may accept additional error codes if needed. The
|
29
|
+
# error message should be a developer-facing English message that helps
|
30
|
+
# developers *understand* and *resolve* the error. If a localized user-facing
|
31
|
+
# error message is needed, put the localized message in the error details or
|
32
|
+
# localize it in the client. The optional error details may contain arbitrary
|
33
|
+
# information about the error. There is a predefined set of error detail types
|
34
|
+
# in the package +google.rpc+ which can be used for common error conditions.
|
35
|
+
#
|
36
|
+
# = Language mapping
|
37
|
+
#
|
38
|
+
# The +Status+ message is the logical representation of the error model, but it
|
39
|
+
# is not necessarily the actual wire format. When the +Status+ message is
|
40
|
+
# exposed in different client libraries and different wire protocols, it can be
|
41
|
+
# mapped differently. For example, it will likely be mapped to some exceptions
|
42
|
+
# in Java, but more likely mapped to some error codes in C.
|
43
|
+
#
|
44
|
+
# = Other uses
|
45
|
+
#
|
46
|
+
# The error model and the +Status+ message can be used in a variety of
|
47
|
+
# environments, either with or without APIs, to provide a
|
48
|
+
# consistent developer experience across different environments.
|
49
|
+
#
|
50
|
+
# Example uses of this error model include:
|
51
|
+
#
|
52
|
+
# - Partial errors. If a service needs to return partial errors to the client,
|
53
|
+
# it may embed the +Status+ in the normal response to indicate the partial
|
54
|
+
# errors.
|
55
|
+
#
|
56
|
+
# - Workflow errors. A typical workflow has multiple steps. Each step may
|
57
|
+
# have a +Status+ message for error reporting purpose.
|
58
|
+
#
|
59
|
+
# - Batch operations. If a client uses batch request and batch response, the
|
60
|
+
# +Status+ message should be used directly inside batch response, one for
|
61
|
+
# each error sub-response.
|
62
|
+
#
|
63
|
+
# - Asynchronous operations. If an API call embeds asynchronous operation
|
64
|
+
# results in its response, the status of those operations should be
|
65
|
+
# represented directly using the +Status+ message.
|
66
|
+
#
|
67
|
+
# - Logging. If some API errors are stored in logs, the message +Status+ could
|
68
|
+
# be used directly after any stripping needed for security/privacy reasons.
|
69
|
+
# @!attribute [rw] code
|
70
|
+
# @return [Integer]
|
71
|
+
# The status code, which should be an enum value of Google::Rpc::Code.
|
72
|
+
# @!attribute [rw] message
|
73
|
+
# @return [String]
|
74
|
+
# A developer-facing error message, which should be in English. Any
|
75
|
+
# user-facing error message should be localized and sent in the
|
76
|
+
# Google::Rpc::Status#details field, or localized by the client.
|
77
|
+
# @!attribute [rw] details
|
78
|
+
# @return [Array<Google::Protobuf::Any>]
|
79
|
+
# A list of messages that carry the error details. There will be a
|
80
|
+
# common set of message types for APIs to use.
|
81
|
+
class Status; end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Type
|
17
|
+
# Represents a color in the RGBA color space. This representation is designed
|
18
|
+
# for simplicity of conversion to/from color representations in various
|
19
|
+
# languages over compactness; for example, the fields of this representation
|
20
|
+
# can be trivially provided to the constructor of "java.awt.Color" in Java; it
|
21
|
+
# can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
|
22
|
+
# method in iOS; and, with just a little work, it can be easily formatted into
|
23
|
+
# a CSS "rgba()" string in JavaScript, as well. Here are some examples:
|
24
|
+
#
|
25
|
+
# Example (Java):
|
26
|
+
#
|
27
|
+
# import com.google.type.Color;
|
28
|
+
#
|
29
|
+
# // ...
|
30
|
+
# public static java.awt.Color fromProto(Color protocolor) {
|
31
|
+
# float alpha = protocolor.hasAlpha()
|
32
|
+
# ? protocolor.getAlpha().getValue()
|
33
|
+
# : 1.0;
|
34
|
+
#
|
35
|
+
# return new java.awt.Color(
|
36
|
+
# protocolor.getRed(),
|
37
|
+
# protocolor.getGreen(),
|
38
|
+
# protocolor.getBlue(),
|
39
|
+
# alpha);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# public static Color toProto(java.awt.Color color) {
|
43
|
+
# float red = (float) color.getRed();
|
44
|
+
# float green = (float) color.getGreen();
|
45
|
+
# float blue = (float) color.getBlue();
|
46
|
+
# float denominator = 255.0;
|
47
|
+
# Color.Builder resultBuilder =
|
48
|
+
# Color
|
49
|
+
# .newBuilder()
|
50
|
+
# .setRed(red / denominator)
|
51
|
+
# .setGreen(green / denominator)
|
52
|
+
# .setBlue(blue / denominator);
|
53
|
+
# int alpha = color.getAlpha();
|
54
|
+
# if (alpha != 255) {
|
55
|
+
# result.setAlpha(
|
56
|
+
# FloatValue
|
57
|
+
# .newBuilder()
|
58
|
+
# .setValue(((float) alpha) / denominator)
|
59
|
+
# .build());
|
60
|
+
# }
|
61
|
+
# return resultBuilder.build();
|
62
|
+
# }
|
63
|
+
# // ...
|
64
|
+
#
|
65
|
+
# Example (iOS / Obj-C):
|
66
|
+
#
|
67
|
+
# // ...
|
68
|
+
# static UIColor* fromProto(Color* protocolor) {
|
69
|
+
# float red = [protocolor red];
|
70
|
+
# float green = [protocolor green];
|
71
|
+
# float blue = [protocolor blue];
|
72
|
+
# FloatValue* alpha_wrapper = [protocolor alpha];
|
73
|
+
# float alpha = 1.0;
|
74
|
+
# if (alpha_wrapper != nil) {
|
75
|
+
# alpha = [alpha_wrapper value];
|
76
|
+
# }
|
77
|
+
# return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
|
78
|
+
# }
|
79
|
+
#
|
80
|
+
# static Color* toProto(UIColor* color) {
|
81
|
+
# CGFloat red, green, blue, alpha;
|
82
|
+
# if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
|
83
|
+
# return nil;
|
84
|
+
# }
|
85
|
+
# Color* result = [Color alloc] init];
|
86
|
+
# [result setRed:red];
|
87
|
+
# [result setGreen:green];
|
88
|
+
# [result setBlue:blue];
|
89
|
+
# if (alpha <= 0.9999) {
|
90
|
+
# [result setAlpha:floatWrapperWithValue(alpha)];
|
91
|
+
# }
|
92
|
+
# [result autorelease];
|
93
|
+
# return result;
|
94
|
+
# }
|
95
|
+
# // ...
|
96
|
+
#
|
97
|
+
# Example (JavaScript):
|
98
|
+
#
|
99
|
+
# // ...
|
100
|
+
#
|
101
|
+
# var protoToCssColor = function(rgb_color) {
|
102
|
+
# var redFrac = rgb_color.red || 0.0;
|
103
|
+
# var greenFrac = rgb_color.green || 0.0;
|
104
|
+
# var blueFrac = rgb_color.blue || 0.0;
|
105
|
+
# var red = Math.floor(redFrac * 255);
|
106
|
+
# var green = Math.floor(greenFrac * 255);
|
107
|
+
# var blue = Math.floor(blueFrac * 255);
|
108
|
+
#
|
109
|
+
# if (!('alpha' in rgb_color)) {
|
110
|
+
# return rgbToCssColor_(red, green, blue);
|
111
|
+
# }
|
112
|
+
#
|
113
|
+
# var alphaFrac = rgb_color.alpha.value || 0.0;
|
114
|
+
# var rgbParams = [red, green, blue].join(',');
|
115
|
+
# return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
|
116
|
+
# };
|
117
|
+
#
|
118
|
+
# var rgbToCssColor_ = function(red, green, blue) {
|
119
|
+
# var rgbNumber = new Number((red << 16) | (green << 8) | blue);
|
120
|
+
# var hexString = rgbNumber.toString(16);
|
121
|
+
# var missingZeros = 6 - hexString.length;
|
122
|
+
# var resultBuilder = ['#'];
|
123
|
+
# for (var i = 0; i < missingZeros; i++) {
|
124
|
+
# resultBuilder.push('0');
|
125
|
+
# }
|
126
|
+
# resultBuilder.push(hexString);
|
127
|
+
# return resultBuilder.join('');
|
128
|
+
# };
|
129
|
+
#
|
130
|
+
# // ...
|
131
|
+
# @!attribute [rw] red
|
132
|
+
# @return [Float]
|
133
|
+
# The amount of red in the color as a value in the interval [0, 1].
|
134
|
+
# @!attribute [rw] green
|
135
|
+
# @return [Float]
|
136
|
+
# The amount of green in the color as a value in the interval [0, 1].
|
137
|
+
# @!attribute [rw] blue
|
138
|
+
# @return [Float]
|
139
|
+
# The amount of blue in the color as a value in the interval [0, 1].
|
140
|
+
# @!attribute [rw] alpha
|
141
|
+
# @return [Google::Protobuf::FloatValue]
|
142
|
+
# The fraction of this color that should be applied to the pixel. That is,
|
143
|
+
# the final pixel color is defined by the equation:
|
144
|
+
#
|
145
|
+
# pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
|
146
|
+
#
|
147
|
+
# This means that a value of 1.0 corresponds to a solid color, whereas
|
148
|
+
# a value of 0.0 corresponds to a completely transparent color. This
|
149
|
+
# uses a wrapper message rather than a simple float scalar so that it is
|
150
|
+
# possible to distinguish between a default value and the value being unset.
|
151
|
+
# If omitted, this color object is to be rendered as a solid color
|
152
|
+
# (as if the alpha value had been explicitly given with a value of 1.0).
|
153
|
+
class Color; end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Type
|
17
|
+
# An object representing a latitude/longitude pair. This is expressed as a pair
|
18
|
+
# of doubles representing degrees latitude and degrees longitude. Unless
|
19
|
+
# specified otherwise, this must conform to the
|
20
|
+
# <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
|
21
|
+
# standard</a>. Values must be within normalized ranges.
|
22
|
+
#
|
23
|
+
# Example of normalization code in Python:
|
24
|
+
#
|
25
|
+
# def NormalizeLongitude(longitude):
|
26
|
+
# """Wraps decimal degrees longitude to [-180.0, 180.0]."""
|
27
|
+
# q, r = divmod(longitude, 360.0)
|
28
|
+
# if r > 180.0 or (r == 180.0 and q <= -1.0):
|
29
|
+
# return r - 360.0
|
30
|
+
# return r
|
31
|
+
#
|
32
|
+
# def NormalizeLatLng(latitude, longitude):
|
33
|
+
# """Wraps decimal degrees latitude and longitude to
|
34
|
+
# [-90.0, 90.0] and [-180.0, 180.0], respectively."""
|
35
|
+
# r = latitude % 360.0
|
36
|
+
# if r <= 90.0:
|
37
|
+
# return r, NormalizeLongitude(longitude)
|
38
|
+
# elif r >= 270.0:
|
39
|
+
# return r - 360, NormalizeLongitude(longitude)
|
40
|
+
# else:
|
41
|
+
# return 180 - r, NormalizeLongitude(longitude + 180.0)
|
42
|
+
#
|
43
|
+
# assert 180.0 == NormalizeLongitude(180.0)
|
44
|
+
# assert -180.0 == NormalizeLongitude(-180.0)
|
45
|
+
# assert -179.0 == NormalizeLongitude(181.0)
|
46
|
+
# assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0)
|
47
|
+
# assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0)
|
48
|
+
# assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0)
|
49
|
+
# assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0)
|
50
|
+
# assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0)
|
51
|
+
# assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0)
|
52
|
+
# assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0)
|
53
|
+
# assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0)
|
54
|
+
# assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0)
|
55
|
+
# assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0)
|
56
|
+
# @!attribute [rw] latitude
|
57
|
+
# @return [Float]
|
58
|
+
# The latitude in degrees. It must be in the range [-90.0, +90.0].
|
59
|
+
# @!attribute [rw] longitude
|
60
|
+
# @return [Float]
|
61
|
+
# The longitude in degrees. It must be in the range [-180.0, +180.0].
|
62
|
+
class LatLng; end
|
63
|
+
end
|
64
|
+
end
|