Pentium10
Pentium10

Reputation: 207912

Do something when phone reaches a set of location?

I have a list of coordinates in the database identified as POI. For a city could be >100 records.

I would like to get notified when the phone gets in 150 meters range of one of the location. The location coordinates too has an error/radius, usually 10 to 100meters. Since I don't find it good to add each location(could be hundreds) for a trigger, how can I optimize the wake-up code?

Also do I have options to remove a previously setup notification from the queue?

Upvotes: 5

Views: 461

Answers (3)

erezny
erezny

Reputation: 46

This problem reminds me of graphics in video games. There's no need to load the points that are well outside your range of movement. I'd break down the map into a grid, set triggers for the 8 adjecent grid blocks and then for each of the POI within the current grid block. When a new grid block is reached the triggers are updated. It'd probably be smart to overlap the grid blocks considering the range of error.

Upvotes: 0

zed_0xff
zed_0xff

Reputation: 33217

There's an app named Locale, that can toggle various events based on your GPS location OR available Wifi network OR cell-station id, etc

It also has a plugins interface. It could be useful for you to examine that app and, maybe, write a plugin for it.

Upvotes: 0

mefiX
mefiX

Reputation: 1307

You could store your POIs in some sort of intelligent Hash-Table using the coordinates to compute a unique hash. Each time a location update arrives you make a lookup in your hash-table to see if there are POIs near the current location. This lookup should only take O(1), since it is a hash-lookup.

The desired range should be taken into account when computing the hashes and storing the POIs.

Just an idea!

Kind regards, mefiX

Upvotes: 2

Related Questions