cleanup search_json a bit

This commit is contained in:
Schuyler Erle 2011-09-01 16:56:02 -07:00
parent 494947c15b
commit eb9ee6965c

View File

@ -12,18 +12,18 @@ def search(request):
def search_json(request):
search_term = request.GET.get("q", "")
threshold = float(request.GET.get("threshold", '0.5'))
threshold = request.GET.get("threshold", '0.5')
bbox = request.GET.get("bbox", False)
page = int(request.GET.get("page", '1'))
count = int(request.GET.get("count", '100'))
country = request.GET.get("adm0", "US") # right now, unused
country = request.GET.get("cc", "US") # right now, unused
adm1 = request.GET.get("adm1", "")
adm2 = request.GET.get("adm2", "")
srid = int(request.GET.get("srid", 4326))
if threshold:
try:
threshold = float(threshold)
threshold = max(float(threshold), 0.1)
except ValueError:
return render_to_json_response({'error': 'threshold must be a float'})