Page 1 of 1

How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Wed Sep 11, 2019 10:36 am
by Peter@multidesk.se
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

Re: How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Thu Sep 12, 2019 1:36 am
by [-hh]
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.

Re: How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Thu Sep 12, 2019 9:31 am
by richmond62
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.
-
skool2b.gif
-
Then we do a spot of Pythagoras . . .

Oh, and let's pretend we don't know what negative numbers are. :wink:

890-407 = 483
359-137 = 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. :D

Now it shouldn't be particularly difficult to move from that sort of stuff
to GPS points and metres. 8)

Re: How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Thu Sep 12, 2019 9:49 am
by richmond62
Well, I had a spot of fun . . .
-
GPS.png
-
Even if I cannot spell "Calculate." 8)

I'm sure some Freudian psychologist will come up with something
there: "caculate", "cack", enough of that one!

Re: How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Thu Sep 12, 2019 2:06 pm
by [-hh]
What do you expect to get when you type cmd-C or ctrl-C?
I'm not a Freudian ;-)

Re: How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Thu Sep 12, 2019 2:11 pm
by richmond62
What do you expect to get when you type cmd-C or ctrl-C?
Well certainly not Cack. :D

Re: How do I calculate if I am within a radius of x meters from a given GPS point?

Posted: Thu Sep 12, 2019 8:58 pm
by [-hh]
Find the basicGeoLib (LiveCode only, no javascript) on "SampleStacks" or here
http://livecodeshare.runrev.com/stack/949/basicGeoLib