Latitude/longitude not working ?
-
Hi all,
Has anyone ever got this working (out from the su-ruby api doc) ?
Assuming you have set the georeference of your model in the Model Info dialog:
coordinates = [10, 10, 10] # or whatever coordinate... 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
It doesn't return a latlon object, but a point3d object. And I need a latlon...
Help greatly appreciated !
-
The 3D point it returns is in the format 'long/lati/height'.
The 'X' is the longitude in degrees [actually it's in 'inches'!]
The 'Y' is the latitude in degrees [actually it's in 'inches'!]
The 'Z' is the point's height in inches.
To return the long/lati use
latlong = model.point_to_latlong(point)
(55, -1, 0)
- this is for the 'ORIGIN' where I live...
To set it as 'degrees' - for use in other methods you can use...
long = latlong.x.to_f lati = latlong.y.to_f high = latlong.z.to_l
[in current units]
-1.0, 55.0 and 0.0
You can then use
ll = [lati, long]
Note how perversely it takes 'lati/long' in the reversed order from the 'point' itself!
my_ll = Geom::LatLong.new(ll)
LatLong(55.00000N, 1.00000W)
my_ll.latitude
>>> 55.0
my_ll.longitude
>>> -1.0
It's not the easiest or most logical method in the API!
-
Thanks a million TIG
Advertisement