views:

145

answers:

3

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?

+2  A: 

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

mefiX
As far I know in Android, you setup notification trigger in such way that you tell the system `to buzz me when phone reaches in coord x, y` You already tell the coords. I could setup notifications for all my pois, but that would probably not work well with hundreds of records. Listening for location updates could be battery draining process, and thus requires the app to be running.
Pentium10
Android SDK has an `addProximityAlert` method that can be used for this exact purpose.
Pentium10
A: 

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.

zed_0xff
I know about the existence of Locale, I want to do something very similar but for different purpose. I cant use the Locale's plugin sdk.
Pentium10
A: 

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.

erezny