SketchUp  Ruby API Reference 

Class Index

Method Index

Developers Guide

Examples

LatLong class

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

Parent: Object

Methods: new, latitude, longitude, to_a, to_s, to_utm

Example Code: latlongtests.rb

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

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

Return Value

latitude - a latitude coordinate value

 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

Return Value

longitude - a latitude coordinate value

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

Return Value

array - an array of two values: latitude and longitude

 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

Return Value

string - a string representation of a LatLong object

 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

Return Value

utm - a UTM object

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