/**
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getPath()
 {
     $iterinary_id = Input::get('iterinary_id');
     $iterinary = Iterinary::find($iterinary_id);
     $route = $iterinary->route;
     if (!$route) {
         return response()->json(['err' => 'route not found'], 404);
     }
     //        dd($iterinary)
     $segments = $route->segments()->get();
     if ($segments->isEmpty()) {
         return response()->json(['err' => 'no segments', 'center_lat' => ''], 400);
     }
     $activities = $iterinary->activities()->with('typable')->get();
     $points = [];
     foreach ($segments as $segment) {
         $points[] = GeolocationHelper::decode($segment->path);
     }
     $center[] = $points[0][0];
     $center[] += $points[0][1];
     $points = GeolocationHelper::flatten($points);
     $path = GeolocationHelper::encode($points);
     $data = ['center' => $center, 'path' => $path, 'activities' => $activities];
     return response()->json($data, 200);
 }