def move(self): mp = GEOSGeometry(self.track.route) lat = self.current_point[0] lon = self.current_point[1] point = Point(lat, lon) mp.append(point) self.track.route = mp self.track.save()
def set_point(self, request, pk): track = Track.objects.get(pk=pk) mp = GEOSGeometry(track.route) lat = request.data.get('lat') lon = request.data.get('lon') try: if lat is None or lon is None: raise ValueError('Переданы не валидные координаты') point = Point(lat, lon) mp.append(point) track.route = mp track.save() except ValueError: return Response('Переданы не валидные координаты') return Response(point)