Class: GoogleMapsPlatform::DirectionsRoute
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::DirectionsRoute
- Defined in:
- lib/google_maps_platform/models/directions_route.rb
Overview
Routes consist of nested legs and steps.
Instance Attribute Summary collapse
-
#bounds ⇒ Bounds
A rectangle in geographical coordinates from points at the southwest and northeast corners.
-
#copyrights ⇒ String
Contains the copyright notices to be displayed for this route.
-
#fare ⇒ Fare
The total fare for the route.
-
#legs ⇒ Array[DirectionsLeg]
An array which contains information about a leg of the route, between two locations within the given route.
-
#overview_polyline ⇒ DirectionsPolyline
[Polyline encoding](developers.google.com/maps/documentation/utilities/polyl inealgorithm) is a lossy compression algorithm that allows you to store a series of coordinates as a single string.
-
#summary ⇒ String
Contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.
-
#warnings ⇒ Array[String]
Contains an array of warnings to be displayed when showing these directions.
-
#waypoint_order ⇒ Array[Integer]
An array indicating the order of any waypoints in the calculated route.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(legs:, bounds:, copyrights:, summary:, waypoint_order:, warnings:, overview_polyline:, fare: SKIP, additional_properties: nil) ⇒ DirectionsRoute
constructor
A new instance of DirectionsRoute.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(legs:, bounds:, copyrights:, summary:, waypoint_order:, warnings:, overview_polyline:, fare: SKIP, additional_properties: nil) ⇒ DirectionsRoute
Returns a new instance of DirectionsRoute.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 108 def initialize(legs:, bounds:, copyrights:, summary:, waypoint_order:, warnings:, overview_polyline:, fare: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @legs = legs @bounds = bounds @copyrights = copyrights @summary = summary @waypoint_order = waypoint_order @warnings = warnings @overview_polyline = overview_polyline @fare = fare unless fare == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#bounds ⇒ Bounds
A rectangle in geographical coordinates from points at the southwest and northeast corners.
23 24 25 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 23 def bounds @bounds end |
#copyrights ⇒ String
Contains the copyright notices to be displayed for this route. You must handle and display this information yourself. This content is meant to be read as-is. Do not programmatically parse this display-only content.
29 30 31 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 29 def copyrights @copyrights end |
#fare ⇒ Fare
The total fare for the route. “‘
"currency" : "USD",
"value" : 6,
"text" : "$6.00"
“‘
80 81 82 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 80 def fare @fare end |
#legs ⇒ Array[DirectionsLeg]
An array which contains information about a leg of the route, between two locations within the given route. A separate leg will be present for each waypoint or destination specified. (A route with no waypoints will contain exactly one leg within the legs array.) Each leg consists of a series of steps.
18 19 20 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 18 def legs @legs end |
#overview_polyline ⇒ DirectionsPolyline
[Polyline encoding](developers.google.com/maps/documentation/utilities/polyl inealgorithm) is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values. If you only have a few static points, you may also wish to use the interactive polyline encoding utility. The encoding process converts a binary value into a series of character codes for ASCII characters using the familiar base64 encoding scheme: to ensure proper display of these characters, encoded values are summed with 63 (the ASCII character ‘?’) before converting them into ASCII. The algorithm also checks for additional character codes for a given point by checking the least significant bit of each byte group; if this bit is set to 1, the point is not yet fully formed and additional data must follow. Additionally, to conserve space, points only include the offset from the previous point (except of course for the first point). All points are encoded in Base64 as signed integers, as latitudes and longitudes are signed values. The encoding format within a polyline needs to represent two coordinates representing latitude and longitude to a reasonable precision. Given a maximum longitude of +/- 180 degrees to a precision of 5 decimal places (180.00000 to -180.00000), this results in the need for a 32 bit signed binary integer value.
69 70 71 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 69 def overview_polyline @overview_polyline end |
#summary ⇒ String
Contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.
34 35 36 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 34 def summary @summary end |
#warnings ⇒ Array[String]
Contains an array of warnings to be displayed when showing these directions. You must handle and display these warnings yourself.
45 46 47 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 45 def warnings @warnings end |
#waypoint_order ⇒ Array[Integer]
An array indicating the order of any waypoints in the calculated route. This waypoints may be reordered if the request was passed optimize:true within its waypoints parameter.
40 41 42 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 40 def waypoint_order @waypoint_order end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 126 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it legs = nil unless hash['legs'].nil? legs = [] hash['legs'].each do |structure| legs << (DirectionsLeg.from_hash(structure) if structure) end end legs = nil unless hash.key?('legs') bounds = Bounds.from_hash(hash['bounds']) if hash['bounds'] copyrights = hash.key?('copyrights') ? hash['copyrights'] : nil summary = hash.key?('summary') ? hash['summary'] : nil waypoint_order = hash.key?('waypoint_order') ? hash['waypoint_order'] : nil warnings = hash.key?('warnings') ? hash['warnings'] : nil overview_polyline = DirectionsPolyline.from_hash(hash['overview_polyline']) if hash['overview_polyline'] fare = Fare.from_hash(hash['fare']) if hash['fare'] # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. DirectionsRoute.new(legs: legs, bounds: bounds, copyrights: copyrights, summary: summary, waypoint_order: waypoint_order, warnings: warnings, overview_polyline: overview_polyline, fare: fare, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 83 def self.names @_hash = {} if @_hash.nil? @_hash['legs'] = 'legs' @_hash['bounds'] = 'bounds' @_hash['copyrights'] = 'copyrights' @_hash['summary'] = 'summary' @_hash['waypoint_order'] = 'waypoint_order' @_hash['warnings'] = 'warnings' @_hash['overview_polyline'] = 'overview_polyline' @_hash['fare'] = 'fare' @_hash end |
.nullables ⇒ Object
An array for nullable fields
104 105 106 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 104 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
97 98 99 100 101 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 97 def self.optionals %w[ fare ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
179 180 181 182 183 184 185 186 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 179 def inspect class_name = self.class.name.split('::').last "<#{class_name} legs: #{@legs.inspect}, bounds: #{@bounds.inspect}, copyrights:"\ " #{@copyrights.inspect}, summary: #{@summary.inspect}, waypoint_order:"\ " #{@waypoint_order.inspect}, warnings: #{@warnings.inspect}, overview_polyline:"\ " #{@overview_polyline.inspect}, fare: #{@fare.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
170 171 172 173 174 175 176 |
# File 'lib/google_maps_platform/models/directions_route.rb', line 170 def to_s class_name = self.class.name.split('::').last "<#{class_name} legs: #{@legs}, bounds: #{@bounds}, copyrights: #{@copyrights}, summary:"\ " #{@summary}, waypoint_order: #{@waypoint_order}, warnings: #{@warnings},"\ " overview_polyline: #{@overview_polyline}, fare: #{@fare}, additional_properties:"\ " #{@additional_properties}>" end |