[ create a new paste ] login | about

Project: python
Link: http://python.codepad.org/jCGkHvKW    [ raw code | output | fork ]

fedecarg - Python, pasted on Jun 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'''
Geo Proximity Search with Python and SQL
http://bit.ly/yAgbc
'''

from __future__ import division
import math

longitude = float(-2.708077)
latitude = float(53.754842)
radius = 20

lng_min = longitude - radius / abs(math.cos(math.radians(latitude)) * 69)
lng_max = longitude + radius / abs(math.cos(math.radians(latitude)) * 69)
lat_min = latitude - (radius / 69)
lat_max = latitude + (radius / 69)

print 'lng (min/max): %f %f' % (lng_min, lng_max)
print 'lat (min/max): %f %f' % (lat_min, lat_max)


Output:
1
2
lng (min/max): -3.198325 -2.217829
lat (min/max): 53.464987 54.044697


Create a new paste based on this one


Comments: