How do I calculate if I am within a radius of x meters from a given GPS point?
Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

 Posts: 126
 Joined: Fri Oct 14, 2011 6:53 am
How do I calculate if I am within a radius of x meters from a given GPS point?
I need to determine if the unit has returned to its original position to calculate the elapsed time.
This has to be done with a certain generosity as it is completely impossible to return to exactly the same position as the starting point.
Therefore, I need to set up something similar to a geo fence and then see if the unit is within this barrier, then I am back to my starting position
I would appreciate if anyone could give an example of how this could be done.
///Peter
This has to be done with a certain generosity as it is completely impossible to return to exactly the same position as the starting point.
Therefore, I need to set up something similar to a geo fence and then see if the unit is within this barrier, then I am back to my starting position
I would appreciate if anyone could give an example of how this could be done.
///Peter
/*Whats all the fuss with c# ?*/

 VIP Livecode Opensource Backer
 Posts: 2093
 Joined: Thu Feb 28, 2013 11:52 pm
 Location: Göttingen, DE
Re: How do I calculate if I am within a radius of x meters from a given GPS point?
Currently I am porting a great deal of geoLib ( https://github.com/manuelbieh/geolib ) to LiveCode.
Will publish it in "Sample Stacks"/livecodeshare until Sep 12 in the evening.
Will publish it in "Sample Stacks"/livecodeshare until Sep 12 in the evening.
shiftLock happens

 Livecode Opensource Backer
 Posts: 3480
 Joined: Fri Feb 19, 2010 10:17 am
 Location: Bulgaria
Re: How do I calculate if I am within a radius of x meters from a given GPS point?
Why don't you start by trying something rather basic out?
Make a stack and put a graphic object that is 1x1 pixels anywhere on the stack
(frankly that is daft as the point will not be visible: make it 4x4), via the Preferences
palette write down its location on a bit of paper (retro tech).
Do the same for a second graphic object . . .
I called my first graphic "gPOINT1" and my second, "gPOINT2".
Now my "gPOINT1" is located at 407,359,
"gPOINT2" is located at 890,137.
 
Then we do a spot of Pythagoras . . .
Oh, and let's pretend we don't know what negative numbers are.
890407 = 483
359137 = 222
483 squared = 233289
222 squared = 49284
233289 + 49284 = 282573
square root 282572 = 531.576
so the linear distance (i.e. what you call the 'radius') from
"gPOINT1" to "gPOINT2" is about 532 pixels.
Of course, if you want you can do all "that" in a button in LiveCode.
Now it shouldn't be particularly difficult to move from that sort of stuff
to GPS points and metres.
Make a stack and put a graphic object that is 1x1 pixels anywhere on the stack
(frankly that is daft as the point will not be visible: make it 4x4), via the Preferences
palette write down its location on a bit of paper (retro tech).
Do the same for a second graphic object . . .
I called my first graphic "gPOINT1" and my second, "gPOINT2".
Now my "gPOINT1" is located at 407,359,
"gPOINT2" is located at 890,137.
 
Then we do a spot of Pythagoras . . .
Oh, and let's pretend we don't know what negative numbers are.
890407 = 483
359137 = 222
483 squared = 233289
222 squared = 49284
233289 + 49284 = 282573
square root 282572 = 531.576
so the linear distance (i.e. what you call the 'radius') from
"gPOINT1" to "gPOINT2" is about 532 pixels.
Of course, if you want you can do all "that" in a button in LiveCode.
Now it shouldn't be particularly difficult to move from that sort of stuff
to GPS points and metres.

 Livecode Opensource Backer
 Posts: 3480
 Joined: Fri Feb 19, 2010 10:17 am
 Location: Bulgaria
Re: How do I calculate if I am within a radius of x meters from a given GPS point?
Well, I had a spot of fun . . .
 
Even if I cannot spell "Calculate."
I'm sure some Freudian psychologist will come up with something
there: "caculate", "cack", enough of that one!
 
Even if I cannot spell "Calculate."
I'm sure some Freudian psychologist will come up with something
there: "caculate", "cack", enough of that one!
 Attachments

 JEE PEE ESS.livecode.zip
 Here's the stack.
 (13.8 KiB) Downloaded 1 time

 VIP Livecode Opensource Backer
 Posts: 2093
 Joined: Thu Feb 28, 2013 11:52 pm
 Location: Göttingen, DE
Re: How do I calculate if I am within a radius of x meters from a given GPS point?
What do you expect to get when you type cmdC or ctrlC?
I'm not a Freudian
I'm not a Freudian
shiftLock happens

 Livecode Opensource Backer
 Posts: 3480
 Joined: Fri Feb 19, 2010 10:17 am
 Location: Bulgaria
Re: How do I calculate if I am within a radius of x meters from a given GPS point?
Well certainly not Cack.What do you expect to get when you type cmdC or ctrlC?

 VIP Livecode Opensource Backer
 Posts: 2093
 Joined: Thu Feb 28, 2013 11:52 pm
 Location: Göttingen, DE
Re: How do I calculate if I am within a radius of x meters from a given GPS point?
Find the basicGeoLib (LiveCode only, no javascript) on "SampleStacks" or here
http://livecodeshare.runrev.com/stack/949/basicGeoLib
http://livecodeshare.runrev.com/stack/949/basicGeoLib
shiftLock happens