LatLong

class LatLong

Parent: Object | Class Index
Methods: new, latitude, longitude, to_a, to_s, to_utm |
Sample Code: latlongtests.rb |

The LatLong class contains various methods for creating and manipulating latitude and longitude coordinates.

Class Methods

new
The new method creates a LatLong object
Syntax:
latlong = Geom::LatLong.new(latlong)
Arguments:
latlong - a latitude and longitude coordinate set
Return Value:
latlong - a LatLong object
Comments:
Example:

ll = [40.01700, 105.28300]
latlong = Geom::LatLong.new(ll)
if (latlong)
UI.messagebox latlong
else
UI.messagebox "Failure"
end

Instance Methods

latitude
The Latitude method retrieves the latitude coordinate from a LatLong object.
Syntax:
latitude = latlong.latitude
Arguments:
Return Value:
latitude - a latitude coordinate value
Comments:
Example:

coordinates = [10, 10, 10]
model = Sketchup.active_model
point = Geom::Point3d.new(coordinates)
latlong = model.point_to_latlong point
latitude = latlong.latitude
if (latitude)
UI.messagebox latitude
else
UI.messagebox "Failure"
end

longitude
The Latitude method retrieves the longitude coordinate from a LatLong object.
Syntax:
latitude = latlong.longitude
Arguments:
Return Value:
longitude - a latitude coordinate value
Comments:
Example:

coordinates = [10, 10, 10]
model = Sketchup.active_model
point = Geom::Point3d.new(coordinates)
latlong = model.point_to_latlong point
longitude = latlong.longitude
if (longitude)
UI.messagebox longitude
else
UI.messagebox "Failure"
end

to_a
The to_a method converts a LatLong object to an array of two values.
Syntax:
array = latlong.to_a
Arguments:
Return Value:
array - an array of two values: latitude and longitude
Comments:
Example:

coordinates = [10, 10, 10]
model = Sketchup.active_model
point = Geom::Point3d.new(coordinates)
latlong = model.point_to_latlong point
a = latlong.to_a
if (a)
UI.messagebox a
else
UI.messagebox "Failure"
end

to_s
The to_a method converts a LatLong object to a string.
Syntax:
string = latlong.to_s
Arguments:
Return Value:
string - a string representation of a LatLong object
Comments:
Example:

coordinates = [10, 10, 10]
model = Sketchup.active_model
point = Geom::Point3d.new(coordinates)
latlong = model.point_to_latlong point
s = latlong.to_s
if (s)
UI.messagebox s
else
UI.messagebox "Failure"

end

to_utm
The to_a method converts a LatLong object to a UTM object.
Syntax:
utm = latlong.to_utm
Arguments:
Return Value:
utm - a UTM object
Comments:
Example:

coordinates = [10, 10, 10]
model = Sketchup.active_model
point = Geom::Point3d.new(coordinates)
latlong = model.point_to_latlong point
utm = latlong.to_utm
if (utm)
text = utm.to_s
UI.messagebox text
else
UI.messagebox "Failure"
end