14,335,049 members
Rate this:
See more:
I had made it an app which is for food basically what I want to do is know I want to show food stores as per user location for example

``` if (userlocation == "RAJAPARK") {
thencallThisfunction();
}

else (userlocation == "XYZ") {
Toast.makeText(getActivity(), "There is no food store around you",

}```

but i am not able to match a street name with my variable and i am not getting any proper guide for doing this so plz help me

What I have tried:

I tried to get user street name and matching with my variables but it does not work
Posted
Updated 13-Sep-16 0:17am

Rate this:

v2
Rate this:

## Solution 2

Quote:
I tried to get user street name and matching with my variables but it does not work

Using street name just feel like complicating things.
I would just use GPS user coordinates and calc distances with food shops and return only closest shops.

Distance calculation between 2 GPS coordinates is done with
Great-circle distance - Wikipedia, the free encyclopedia[^]

In order to reduce the number of distance calculations, you need a clever way of storing shops.
- The most simple way is to have all shops in a flat list, downside, you have to calculate distance to every shop every times.
- You can be more efficient by dividing the map in squares and note the square for each shop. Once you know which square you are, you just have to check shops in actual square and squares nearby.
Hilbert curve - Wikipedia, the free encyclopedia[^]
v2