SHARE
TWEET

Untitled

a guest Aug 26th, 2018 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PointsInterestList(generics.ListCreateAPIView):
  2.     serializer_class = PointsInterestSerializer
  3.  
  4.     def get_queryset(self):
  5.         queryset = PointsInterestData.objects.all()
  6.         return queryset
  7.  
  8.  
  9.     def post(self, request, *args, **kwargs):
  10.         """
  11.        To ma byc obsłużone w exceptionach
  12.        if self.post(request=self.request)['user_latitude'] == None \
  13.        and self.post(request=self.request)['user_longtitude'] == None:
  14.    distance = None
  15.    return distance"""
  16.  
  17.  
  18.         user_latitude = request.POST.get('user_latitude', None)
  19.         user_longtitude = request.POST.get('user_longtitude', None)
  20.         geodata = PointsInterestData.get_coordinates()
  21.  
  22.        
  23.         latitude = geodata.get('latitude')
  24.         longtitude = geodata.get("longtitude")
  25.  
  26.         x = longtitude - user_longtitude
  27.         y = latitude - user_latitude
  28.         distance = ((x ** 2) + (y ** 2)) ** (1 / 2)
  29.         return distance
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top