예제 #1
0
 static function dibuixarMapa()
 {
     return view('mapa')->with('mapa', GoogleMapsController::dibuixarMapa(UserProfile::perfilId(Auth::user()->id), 0));
 }
예제 #2
0
 static function dibuixarMapa($id, $tipus)
 {
     $llistat = "";
     $centre = "";
     $coordenades = null;
     $items = null;
     switch ($tipus) {
         case 0:
             //usuari
             $info['poble'] = UserProfile::poblacio($id);
             $llistat = HomeController::llistarCamps($id);
             $items = Camp::campsUsuari($id);
             $ubicacio_centre = 'no_valor';
             break;
         case 1:
             //camp
             $info = Camp::infoCamp($id);
             $ubicacio = Camp::coordenades($id);
             $llistat = CampController::llistarCultius($id);
             if (!is_null($ubicacio['ubicacio'])) {
                 $coordenades[] = ['punts' => GoogleMapsController::formarPoligon($ubicacio['ubicacio']), 'color' => '#FF0000', 'info' => GoogleMapsController::crearInfowindow($id, UserProfile::perfilId(Auth::user()->id))];
                 $ubicacio_centre['y'] = $ubicacio['centrey'];
                 $ubicacio_centre['x'] = $ubicacio['centrex'];
                 $items = Camp::campsVeins($id);
             } else {
                 $ubicacio_centre = 'no_valor';
             }
             break;
         default:
             return false;
             break;
     }
     foreach ($items as $item) {
         if (!is_null($temp = Camp::coordenades($item->id))) {
             $coordenades[] = ['punts' => GoogleMapsController::formarPoligon($temp['ubicacio']), 'color' => GoogleMapsController::getColor($item->id, UserProfile::perfilId(Auth::user()->id)), 'info' => GoogleMapsController::crearInfowindow($item->id, UserProfile::perfilId(Auth::user()->id))];
         }
     }
     $dades = ['ubicacio' => $info['poble'], 'ubicacio_centre' => $ubicacio_centre, 'info' => $info, 'id' => $id, 'cultius' => $llistat, 'coordenades' => $coordenades];
     return $dades;
 }
예제 #3
0
 static function dibuixarMapa($camp)
 {
     return view('mapa')->with('mapa', GoogleMapsController::dibuixarMapa($camp, 1));
 }
예제 #4
0
파일: Camp.php 프로젝트: vi1004t/pfg
    public static function campsVeins($id, $distancia = 1)
    {
        $results = Camp::select(DB::raw('X(centre) as centrex'), DB::raw('Y(centre) as centrey'))->where('id', '=', $id)->first();
        if (!is_null($results)) {
            $box = GoogleMapsController::getBoundaries($results->centrey, $results->centrex, 1);
            $dades = DB::select('select id, (6371 * ACOS(
											SIN(RADIANS(Y(centre)))
											* SIN(RADIANS(' . floatval($results->centrey) . '))
											+ COS(RADIANS(X(centre) - ' . floatval($results->centrex) . '))
											* COS(RADIANS(Y(centre)))
											* COS(RADIANS(' . floatval($results->centrey) . '))
											)
											) AS distance
											FROM camps

											WHERE (Y(centre) BETWEEN ' . $box['min_lat'] . ' AND ' . $box['max_lat'] . ')
			AND (X(centre) BETWEEN ' . $box['min_lng'] . ' AND ' . $box['max_lng'] . ')
			HAVING distance < ' . $distancia . ' AND distance > 0
			ORDER BY distance ASC');
            return $dades;
        }
    }