I suggest replacing the polygonal area of 8 vertices with a circle.
You can use the Haversine’s formula to calculate the distance between two geographical coordinates:
Once the distance between the customer and the calculated reference point, you are able to assess whether the customer is within the "radius" of the specified area.
from math import radians, cos, sin, asin, sqrt
# Formula de Haversine
def haversine( a, b ):
# Raio da Terra em Km
r = 6371
# Converte coordenadas de graus para radianos
lon1, lat1, lon2, lat2 = map(radians, [ a['longitude'], a['latitude'], b['longitude'], b['latitude'] ] )
# Formula de Haversine
dlon = lon2 - lon1
dlat = lat2 - lat1
hav = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
d = 2 * r * asin( sqrt(hav) )
return d
brasilia = {'latitude': -15.7801, 'longitude': -47.9292 }
goiania = {'latitude': -16.6799, 'longitude': -49.255}
paris = {'latitude': 48.85522811, 'longitude': 2.3493576 }
moscou = {'latitude': 55.75223582, 'longitude': 37.62182236 }
print "Brasilia-DF x Goiania-GO: " + str( haversine( brasilia, goiania) ) + " Km"
print "Brasilia-DF x Paris-Franca: " + str( haversine( brasilia, paris ) ) + " Km"
print "Moscou-Russia x Paris-Franca: " + str( haversine( moscou, paris ) ) + " Km"
print "Goiania-GO x Moscou-Russia: " + str( haversine( goiania, moscou ) ) + " Km"
Exit:
Brasilia-DF x Goiania-GO: 173.336761581 Km
Brasilia-DF x Paris-Franca: 8725.7318322 Km
Moscou-Russia x Paris-Franca: 2486.76670169 Km
Goiania-GO x Moscou-Russia: 11341.7186759 Km
Let’s understand..... Android sends the coordinates of the point where it is. Right? And you want to know if that coordinate is within what limits?
– Reginaldo Rigo
https://answall.com/questions/55669/identificar-se-conjuo-coordinatorsadas-est%C3%A1-within-a-radius-on-android? Rq=1
– Reginaldo Rigo
@Rodolfodonate: This "area" is an irregular opoligono ? a circle ?
– Lacobus
I ended up forgetting the shape of the area. An irregular polygon even, of 8 vertices
– Rodolfo Donato
https://stackoverflow.com/questions/13950062/checking-if-a-longitude-latitude-coordinate-resides-inside-a-complex-polygon-in
– Reginaldo Rigo