Class: Toybox::Position::Location

Inherits:
Lang::Object show all

Overview

The Location object represents a specific position.

Location objects provide methods for retrieving position coordinates in various formats.

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(options) ⇒ Location

Create a Location based on a set of coordinates.

Examples:

using Toybox.Position;
var myLocation = new Position.Location(
    {
        :latitude => 38.856147,
        :longitude => -94.800953,
        :format => :degrees
    }
);

Parameters:

Options Hash (options):

Since:

  • 1.0.0


9380
9381
# File 'Monkeybrains.rb', line 9380

def initialize(options)
end

Instance Method Details

getProjectedLocation(angle, distance) ⇒ Toybox::Position::Location

Get a Location object that is offset from the current position by a given distance and angle.

Parameters:

Returns:

Since:

  • 3.0.0


9442
9443
# File 'Monkeybrains.rb', line 9442

def getProjectedLocation(angle, distance)
end

toDegreesToybox::Lang::Array

Get a Location object's coordinates in degrees.

Examples:

using Toybox.Position;
using Toybox.System;
Position.enableLocationEvents(Position.LOCATION_ONE_SHOT, method(:onPosition));

function onPosition(info) {
    var myLocation = info.position.toDegrees();
    System.println(myLocation[0]); // latitude (e.g. 38.856147)
    System.println(myLocation[1]); // longitude (e.g -94.800953)
}

Returns:

Since:

  • 1.0.0


9397
9398
# File 'Monkeybrains.rb', line 9397

def toDegrees()
end

toGeoString(format) ⇒ Toybox::Lang::String

Get a String representation a Location object's coordinates.

Examples:

using Toybox.Position;
using Toybox.System;
var myLocation = new Position.Location(
    {
        :latitude => 38.856147,
        :longitude => -94.800953,
        :format => :degrees
    }
);
var locString = myLocation.toGeoString(Position.GEO_DMS); // N 38 51'22.13" W 94 45' 3.44"

Parameters:

Returns:

Since:

  • 1.0.0


9433
9434
# File 'Monkeybrains.rb', line 9433

def toGeoString(format)
end

toRadiansToybox::Lang::Array

Get a location object's coordinates in radians.

Examples:

using Toybox.Position;
using Toybox.System;
Position.enableLocationEvents(Position.LOCATION_ONE_SHOT, method(:onPosition));

function onPosition(info) {
    var myLocation = info.position.toRadians();
    System.println(myLocation[0]); // latitude (e.g. 0.678197)
    System.println(myLocation[1]); // longitude (e.g -1.654588)
}

Returns:

Since:

  • 1.0.0


9414
9415
# File 'Monkeybrains.rb', line 9414

def toRadians()
end