I suggest replacing the 8-vertex polygon area with a circle.
You can use the Haversine Formula to calculate the distance between two geographic coordinates:
Oncewiththedistancebetweentheclientandthecalculatedreferencepoint,youareabletoevaluateiftheclientiswithinthe"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"
Output:
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