Curious behavior for Location data type

Post your questions and help other users.

Moderator: Martin

Post Reply
98b427af

Curious behavior for Location data type

Post by 98b427af » 31 Jan 2014 05:38

Try running the following script and looking at the variables in a Debug Dialog:

loc = newLocation(40, -75);
loc2 = '"' + loc + '"';

You should see this:

loc is 40,-75
loc2 is "Location[mProvider=Script,mTime=0,mLatitude=40.0,mLongitude=-75.0,mHasAltitude=false,mAltitude=0.0,mHasSpeed=false,mSpeed=0.0,mHasBearing=false,mBearing=0.0,mHasAccuracy=false,mAccuracy=0.0,mExtras=null]"

Three questions:

1. Why does it do that instead of assigning "40,-75" (with the quotes) to loc2?

2. Is there another way to get the long form? (I found this by accident.)

3. Where can I find documentation on all the possible values for the long form, especially the "mExtras" parameter, which has its own sub-structure labeled "Bundle" when it has a value?

Thanks!

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Curious behavior for Location data type

Post by Martin » 31 Jan 2014 18:01

The function newLocation internally creates an object of type Location. It's the same type like the ones provided by Android in the location-triggers.
Automagic usually uses the regular string conversion function to convert such objects to a string so you see the string that would also be generated by a .toString() method call in java on this object. This string representation is only meant to be used for debugging purposes and might change between Android versions so I would not rely on the format of this string.
You can use a string inline expression to create a regular string "{location,locationformat,decimal}".

Post Reply