コード例 #1
0
 /**
  * Display the specified resource.
  *
  * @param  $request
  * @return Response
  */
 public function addPathToPath(Request $request)
 {
     $first = $request['first_path'];
     $second = $request['second_path'];
     return GeoHelper::addPathToPath($first, $second);
 }
コード例 #2
0
 public static function updateIterinary($token)
 {
     $iterinary = self::getUserCurrentIterinary($token);
     $distance = 0;
     $duration = 0;
     $price = 0;
     $activities = $iterinary->activities;
     foreach ($activities as $activity) {
         $start_time = Carbon::parse($activity->start_time);
         $end_time = Carbon::parse($activity->end_time);
         $distance += GeolocationHelper::resolveDistance($activity);
         $duration += $end_time->diffInMinutes($start_time);
         $price += $activity->typable->price;
     }
     $iterinary->distance = $distance;
     $iterinary->duration = $duration;
     $iterinary->price = $price;
     $iterinary->save();
 }
コード例 #3
0
 /**
  * @param $origin
  * @param $destination
  * @return string
  */
 public static function getFlightPath($origin, $destination)
 {
     $array = [];
     // FORMAT
     //        $array = [
     //            0 => [lat,lng],
     //            1 => [lat,lng]
     //        ];
     $array[0] = Geohelper::parseLongLat($origin);
     $array[1] = Geohelper::parseLongLat($destination);
     $path = Geohelper::encode($array);
     return $path;
 }
コード例 #4
0
 /**
  * @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);
 }