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" endIt 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

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement