Skip to first unread message

Isaac Mercer

unread,
Apr 9, 2015, 7:20:11 PM4/9/15
to mitappinv...@googlegroups.com
I really like AppInventor and the way it makes programming easy but I have a question related to using a feature that i'm not sure really exists.

My app has a system which triggers a notification message every 15 minutes or so. What I would like to do is have it also trigger a message when the user enters a series of predefined areas or geofences. I have had a look at the LocationManager block but i'm not too sure how it works and if it could do what I achieve.

How can I go about getting the device to run commands if it enters a geofenced area? Potentially I have read that it is possible to regularly check for distances to a particular point and if it's within a certain distance then trigger something but i'm not too sure how to do that either.

Thanks for your help

SteveJG

unread,
Apr 9, 2015, 7:24:43 PM4/9/15
to mitappinv...@googlegroups.com
Perhaps reading Chapter 18 in the Inventor's Manual here   http://www.appinventor.org/bookChapters/chapter18.pdf  will get you started.  What you want is in the section Programming Complex Conditions.  I demonstrates how to establish a ring-fence using geolocation data.

Does that help?

Regards,
Steve

Isaac Mercer

unread,
Apr 10, 2015, 3:22:51 AM4/10/15
to mitappinv...@googlegroups.com
That does seem to do what I want to do but it appears that it doesn't work. When I use the blocks below it appears that it should work but when I go to the waypoint marked the notification doesn't trigger unless I am exactly at that point. Is there some way to allow it to register anyway if we are 5-10 meters away from that point just to get it to work as well.  

Ghica

unread,
Apr 10, 2015, 8:33:25 AM4/10/15
to mitappinv...@googlegroups.com
Well, this blok works of course only if you are close to  Harney Science Center at the University of San Francisco. If your waypoint is someplace else, you have to figure out what its latitude and logitude are, and adapt the values accordingly.
Cheers, Ghica.

Isaac Mercer

unread,
May 17, 2015, 12:37:39 AM5/17/15
to mitappinv...@googlegroups.com
I used some of Christophe's examples to create the geofences and now it works great. Thanks for pointing me in the right direction.

SteveJG

unread,
Apr 10, 2015, 9:23:24 AM4/10/15
to mitappinv...@googlegroups.com
I assume you are located in California. because the algorithm works for you sometimes.  This note may explain why.

"0.00001 of a degree of latitude is 0.006 of a nautical mile, or 3 feet, 7+3/4 inches."  Oh, about 1.1 meters.  Your ring fence is  0.00008 deg lat by 0.00026 long.     That is approximately  9 meters by about a little less than 28 meters (0.00001 of longitude at your longitude is a bit less than a meter I believe (the separation between longitude lines decreases pole-ward and the separation represented by 0.00001 longitude varies continuously) . Did I do that right?

Ask yourself, how accurate is your GPS reading?  When you read the LocationSensor tutorial 


you learned  of a GPS receiver property called Accuracy.  Accuracy varies depending on whether your device is in indoors, it is raining, how many satellites the gps can get a fix on etc.  Typically, Accuracy  is less than about four or five meters for most phones. If Accuracy is 5 meters and you are exactly in the center of your latitude boundaries, you may actually only be reported within your ring fence 68% of the time (a simplification, but the point I am making). The ability of the GPS to accurately resolve a location is in a constant state of flux. The GPS receiver in most phones is not precisely accurate. The positional information it provides may be only +/- 50 meters on average, perhaps as good as +/-5 meters on occasion. " and sometimes within a few meters.

The Android Developer Reference defines accuracy as “the radius of 68% confidence."  If you draw a circle centered at this location's latitude and longitude, and with a radius equal to the accuracy, then there is a 68% probability that the true location is inside the circle. In statistical terms, it is assumed that location errors are random with a normal distribution, so the 68% confidence circle represents one standard deviation. In practice, location errors do not always follow such a simple distribution. 

Your device may only tell you are within the boundaries or your existing ring fence (in the N/S dimensions)  68 percent of the time ; even though your device is physically within in the boundary. Thirty-two percent of the time, the GPS will report coordinates that are outside of the ring fence, even though the device is within it.

You ring fence is too tight in the N/S dimensions for precise measurement. A 7 1/2 minute USGS Quadrangle map would locate you more accurately.  :)  (The USGS has an office in Menlo Park)

A plot of GPS readings shown on a map  using a fairly good GPS receiver/device resting on a desk inside a frame house shows where the Android 'thinks' it is as Accuracy varies.

Screenshot_2017-11-14-13-39-19.png




You asked " Is there some way to allow it to register anyway if we are 5-10 meters away from that point just to get it to work as well.    Yes, increase the size of your ring fence by perhaps 0.00010  perhaps for your latitude (provided accuracy reported for your device's GPS is consistently 5 meters; more if accuracy is say 50 meters) .... Adjust the boundaries until you get the results you want..if you are using your GPS indoors...well, it could be hopeless, especially if the building has few windows and steel construction.

You have another tool that can help you determine proximity to a specific location.  The LocationSensor1.DistanceInterval property described in the location tutorial can be used.  read the posts by Christophe ... https://groups.google.com/forum/#!searchin/mitappinventortest/christophe    He built an app called Halte Alarm that tracks bus stop proximity. ... It is an AI2 app that uses the DistanceInterval property.  This technique is not slam/dunk either.

Did this help?


Regards,
Steve




Reply all
Reply to author
Forward
0 new messages