Requesting hints / help for faster GPS updates and creating / searching a list of points on the canvas

I'm getting my "you are PacMan" app to work but I am seeking assistance in 2 areas:

  1. my PacMan does go to the correct location on the canvas dictated by GPS, but it doesn't update as rapidly as it does on Google Maps. I have LocationSensor called inside a clock loop on a 1-second interval, and I have set the LocationSensor time interval and distance interval to zero and also inside the blocks I set the time interval to 1000 milliseconds. It does update but not every second and it is generally about 15 feet between updates. I would like it to be a bit more fine than this. Any suggestions?

  2. now I want to generate 10 - 20 random points on my canvas and then eliminate them 1 by 1 as I (ie my PacMan) pass near them. I can figure out how to generate the points but what is the best way to store and rapidly access them for calculating my distance from each point?

Yes, The LocationSensor is incapable of updating (producing a LocationChanged event) more frequently than once every 20 seconds under ideal conditions. It takes a while to survey as many valid satellite fixes as possible. It takes a cell that long to acquire and get a fix on the necessary satellites to provide an accurate location determination For a partial explanation Tom, re-read the tutorial Using the Location Sensor
You are using a Clock AND the LocationSensor.TimeInterval together? Why? Use only one method. T

While it is possible to get an accurate location determination at less than 20 seconds; the determination will not guarantee Accuracy or firing a LocationChanged event. See * LocationSensor and specifically the advice: Values smaller than 30000ms (30 seconds) are not practical for most devices. Small values may drain battery and overwork the GPS.

Read about Accuracy and the maximum precision possible using the constellation used by the LocationSensor object when using the gps with a modern cell phone or tablet. 15 feet resolution is rarely possible using the LocationSensor. The best resolution possible using the LS is about 2 meters, achievable only during ideal conditions. You could try using a different 'LocationSensor':

Otherwise, consider * Advanced Location Sensor Extension by Niclas Gins which can report the results of NMEA sentences more frequently and those values can be used to trigger a LocationChanged event but at a consequence of reducing Accuracy. Sometimes you will get a great reading, other times not.

It depends. Use a distance calculation using Blocks or use the built-in capabilities of the Map component to calculate a straight line distance. My experiment indicate they are equally accurate and fast. Try both to determine which achieves your criteria.

The points are on a Canvas, not a Map component? If your points are on a Canvas makes this issue complex. Canvas coordinates do not map to geocoordinates. You should either use a Map component or write geocoordinate to Canvas x,y conversion code. Both are possible however a conversion from geocoordinates to Canvas x,y positions loses a lot of precision.

Regards,
Steve

Hi Steve - thanks (again) for the timely response. 2 things:

  1. I already am getting responses much faster than every 20 seconds. I have been testing my system walking rapidly - roughly 4 feet per second, so 15 feet equates to 3 - 4 seconds between updates, which is not terrible but I would like 1 Hz. When I use Google maps it appears that those updates are close to 1 Hz so the phone can handle it, the question is why can't appinventor access that update rate?

  2. yes, I know how to generate points randomly and calculate distance (ie pixel separation); the question is what is an efficient construct or structure to store them in and to access them for the purpose of making those calculations? Of course, I could brute force it by simply declaring 20 pairs of variables but that seems inelegant,

Regarding #1, I provided an explanation. Did you do the tutorials?
Your phone's gps maybe able to handle slightly faster, run the example and see exactly what happens as far as updates to your location. The probable issue is the inability of the ai2 to handle multiple satellite constellations and provide improved precision. Google Maps can provide enhanced precision using cell towers and can use multiple satellite constellations if the device gps has that feature ...the LocationSensor cannot. Use an extension and you might get better results as already suggested.

Regarding #2; are you using a Canvas or the Map component? The advice depends on that. Regardless you can store the geocoordinates on the device using a TinyDb or online using Google sheets or CloudDb or FirebaseDb.

OK, thanks - I will look into those