Commit 0a057809 authored by Niklas Selke's avatar Niklas Selke
Browse files

modified the HTAP regions tier1 service

parent a3f54047
Pipeline #97101 passed with stages
in 49 seconds
"""serializer for HTAP regions tier 1
"""serializer for HTAP regions tier1 data
"""
from collections import OrderedDict
from rest_framework.serializers import BaseSerializer
# serializer classes
class AggSerializer(BaseSerializer):
""" see http://www.django-rest-framework.org/api-guide/serializers/#baseserializer """
......
......@@ -11,7 +11,7 @@ regions = dict(
np.genfromtxt('services/htap_regions_tier1/regions.csv',
delimiter=',',
skip_header=1,
converters={0: lambda x: x.decode('utf-8'), 1: lambda x: int(x)})
converters={0: lambda x: x.decode('utf-8'), 1: lambda x: float(x)})
)
......@@ -48,14 +48,14 @@ class HTAPRegionsTier1View(APIView):
def get(self, request, format=None):
lat, country = self.get_query_params(request.query_params, ['lat', 'country'])
if lat > 66.:
result = 16
result = 16.
elif lat < -66.:
result = 17
result = 17.
else:
try:
result = regions[country]
except KeyError:
result = -1
result = -1.
rawdata = OrderedDict([
("lat", lat),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment