Sha256: 52c4778c88b504650a93616080c5102f15b8f35af9a333d4f4371cd551efebc6

Contents?: true

Size: 1.89 KB

Versions: 5

Compression:

Stored size: 1.89 KB

Contents

module GoogleMapsService::Apis
  # Performs requests to the Google Maps Elevation API.
  module Elevation
    # Provides elevation data for locations provided on the surface of the
    # earth, including depth locations on the ocean floor (which return negative
    # values).
    #
    # @example Single point elevation
    #   results = client.elevation({latitude: 40.714728, longitude: -73.998672})
    #
    # @example Multiple points elevation
    #   locations = [[40.714728, -73.998672], [-34.397, 150.644]]
    #   results = client.elevation(locations)
    #
    # @param [Array] locations A single latitude/longitude hash, or an array of
    #         latitude/longitude hash from which you wish to calculate
    #         elevation data.
    #
    # @return [Array] Array of elevation data responses
    def elevation(locations)
      params = {
        locations: GoogleMapsService::Convert.waypoints(locations)
      }

      get("/maps/api/elevation/json", params)[:results]
    end

    # Provides elevation data sampled along a path on the surface of the earth.
    #
    # @example Elevation along path
    #   locations = [[40.714728, -73.998672], [-34.397, 150.644]]
    #   results = client.elevation_along_path(locations, 5)
    #
    # @param [String, Array] path A encoded polyline string, or a list of
    #         latitude/longitude pairs from which you wish to calculate
    #         elevation data.
    # @param [Integer] samples The number of sample points along a path for which to
    #         return elevation data.
    #
    # @return [Array] Array of elevation data responses
    def elevation_along_path(path, samples)
      path = if path.is_a?(String)
        "enc:%s" % path
      else
        GoogleMapsService::Convert.waypoints(path)
      end

      params = {
        path: path,
        samples: samples
      }

      get("/maps/api/elevation/json", params)[:results]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
google_maps_service_ruby-0.7.0 lib/google_maps_service/apis/elevation.rb
google_maps_service_ruby-0.6.3 lib/google_maps_service/apis/elevation.rb
google_maps_service_ruby-0.6.2 lib/google_maps_service/apis/elevation.rb
google_maps_service_ruby-0.6.1 lib/google_maps_service/apis/elevation.rb
google_maps_service_ruby-0.6.0 lib/google_maps_service/apis/elevation.rb