Class: GoogleMapsPlatform::SnappedPoint

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/google_maps_platform/models/snapped_point.rb

Overview

SnappedPoint Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(location:, place_id:, original_index: SKIP, additional_properties: nil) ⇒ SnappedPoint

Returns a new instance of SnappedPoint.



55
56
57
58
59
60
61
62
63
64
# File 'lib/google_maps_platform/models/snapped_point.rb', line 55

def initialize(location:, place_id:, original_index: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @location = location
  @original_index = original_index unless original_index == SKIP
  @place_id = place_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#locationLatitudeLongitudeLiteral

An object describing a specific location with Latitude and Longitude in decimal degrees.



15
16
17
# File 'lib/google_maps_platform/models/snapped_point.rb', line 15

def location
  @location
end

#original_indexFloat

An integer that indicates the corresponding value in the original request. Each value in the request should map to a snapped value in the response. However, if you’ve set interpolate=true or if you’re using nearest roads, then it’s possible that the response will contain more coordinates than the request. Interpolated values will not have an originalIndex. These values are indexed from 0, so a point with an originalIndex of 4 will be the snapped value of the 5th latitude/longitude passed to the path parameter. Nearest Roads points may contain several points for single coordinates with differing location or placeId.

Returns:

  • (Float)


27
28
29
# File 'lib/google_maps_platform/models/snapped_point.rb', line 27

def original_index
  @original_index
end

#place_idString

A unique identifier for a place. All place IDs returned by the Roads API correspond to road segments.

Returns:

  • (String)


32
33
34
# File 'lib/google_maps_platform/models/snapped_point.rb', line 32

def place_id
  @place_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/google_maps_platform/models/snapped_point.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  location = LatitudeLongitudeLiteral.from_hash(hash['location']) if hash['location']
  place_id = hash.key?('placeId') ? hash['placeId'] : nil
  original_index = hash.key?('originalIndex') ? hash['originalIndex'] : SKIP

  # 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.
  SnappedPoint.new(location: location,
                   place_id: place_id,
                   original_index: original_index,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
# File 'lib/google_maps_platform/models/snapped_point.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['location'] = 'location'
  @_hash['original_index'] = 'originalIndex'
  @_hash['place_id'] = 'placeId'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/google_maps_platform/models/snapped_point.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
# File 'lib/google_maps_platform/models/snapped_point.rb', line 44

def self.optionals
  %w[
    original_index
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



97
98
99
100
101
# File 'lib/google_maps_platform/models/snapped_point.rb', line 97

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} location: #{@location.inspect}, original_index: #{@original_index.inspect},"\
  " place_id: #{@place_id.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



90
91
92
93
94
# File 'lib/google_maps_platform/models/snapped_point.rb', line 90

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} location: #{@location}, original_index: #{@original_index}, place_id:"\
  " #{@place_id}, additional_properties: #{@additional_properties}>"
end