Fix bugs on normal search algorithm
parent
35e0954b58
commit
153985d834
|
@ -33,9 +33,11 @@ class UserPageController extends Controller
|
|||
private $mainFuel;
|
||||
private $latitudeOrigin;
|
||||
private $longitudeOrigin;
|
||||
private $searchingFlag= true;
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
$vehicles = Vehicle::join('vehicles', 'vehicle.id', 'vehicles.vehicle_id')
|
||||
->join('users', 'users.id', 'vehicles.user_id')
|
||||
|
@ -47,13 +49,15 @@ class UserPageController extends Controller
|
|||
$vehicleData = Vehicle::where('id', $request->upSelectVehicle)
|
||||
->first();
|
||||
Session::put('selectedVehicle', $request->upSelectVehicle);
|
||||
if ($request->points) {
|
||||
//var_dump($request->points);
|
||||
}
|
||||
|
||||
return view('planRoute', ['name'=>$user->name, 'vehicles' => $vehicles, 'vehicleData' => $vehicleData]);
|
||||
|
||||
|
||||
//$this->searchingFlag==true?$this->searchingFlag=false:$this->searchingFlag=true;
|
||||
return view('planRoute', ['name'=>$user->name, 'vehicles' => $vehicles, 'vehicleData' => $vehicleData, 'searchingFlag'=>$this->searchingFlag]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$data = ['brand' => $request->brand, 'model' => $request->model, 'consumption' => $request->consumption];
|
||||
|
@ -210,8 +214,8 @@ class UserPageController extends Controller
|
|||
$user = Auth::user();
|
||||
$vehicles = Vehicle::join('vehicles', 'vehicle.id', 'vehicles.vehicle_id')->join('users', 'users.id', 'vehicles.user_id')->where('users.email', $user->email)->get();
|
||||
|
||||
|
||||
return view('user_page', ['name'=>$user->name, 'stations' => $data, 'vehicles' => $vehicles]);
|
||||
$this->searchingFlag = $request->searching;
|
||||
return view('user_page', ['name'=>$user->name, 'stations' => $data, 'vehicles' => $vehicles, 'searchingFlag'=>$this->searchingFlag]);
|
||||
}
|
||||
|
||||
public function receiveStationCoordinates(Request $request) {
|
||||
|
@ -244,15 +248,6 @@ class UserPageController extends Controller
|
|||
$longitudeDestination = Session::get('longitudeDestination');
|
||||
$selectedVehicle = Session::get('selectedVehicle');
|
||||
|
||||
/* Session::forget('latitudeOrigin');
|
||||
Session::forget('longitudeOrigin');
|
||||
Session::forget('latitudeDestination');
|
||||
Session::forget('longitudeDestination');*/
|
||||
|
||||
/* echo "origin lat $latitudeOrigin<br>";
|
||||
echo "origin lng $longitudeOrigin<br>";
|
||||
echo "destination lat $latitudeDestination<br>";
|
||||
echo "destination lng $longitudeDestination<br>";*/
|
||||
$data = json_encode($data);
|
||||
$data = json_decode($data, true);
|
||||
|
||||
|
@ -265,13 +260,6 @@ class UserPageController extends Controller
|
|||
$latitude = $data[$key]["latitude"];
|
||||
$longitude = $data[$key]["longitude"];
|
||||
|
||||
/* echo "latitude: ".$latitude."<br>";
|
||||
echo $longitude."<br><br>";*/
|
||||
|
||||
|
||||
|
||||
//echo Auth::user()->id;
|
||||
|
||||
//user's vehicle fuel types
|
||||
$vehicleFuels = Vehicles::join('vehicle', 'vehicles.vehicle_id', 'vehicle.id')
|
||||
->join('fuels', 'fuels.vehicle_id', 'vehicle.id')
|
||||
|
@ -280,7 +268,6 @@ class UserPageController extends Controller
|
|||
->where('vehicle.id', '=', $selectedVehicle)
|
||||
->select('fuel.name as fuelName')
|
||||
->get();
|
||||
// echo $vehicleFuels;
|
||||
$stations = null;
|
||||
|
||||
if(empty($stationsArray)){
|
||||
|
@ -318,7 +305,6 @@ class UserPageController extends Controller
|
|||
$stations->select('station.name as stationName', 'station.brand as stationBrand', 'district.name as district', 'latitude', 'longitude', 'petrol_95_simple', 'petrol_95', 'petrol_98_simple', 'petrol_98', 'diesel_simple', 'diesel', 'gpl');
|
||||
$stationsResult = $stations->get();
|
||||
|
||||
//echo $stationsResult;
|
||||
//Create a stations array
|
||||
foreach($stationsResult as $stationResult){
|
||||
//echo $stationResult;
|
||||
|
@ -502,8 +488,7 @@ class UserPageController extends Controller
|
|||
/* echo "latitude destination: ".$latitudeDestination;
|
||||
echo "longitude destination: ".$longitudeDestination;*/
|
||||
$distance = $this->checkStationDistance($latitudeOrigin, $longitudeOrigin, $latitudeStation, $longitudeStation);
|
||||
/* echo "distance: $distance<br>";
|
||||
echo "autonomy data: $autonomyKmData";*/
|
||||
|
||||
if ($distance<$autonomyKmData) {
|
||||
|
||||
$outOfRange = false;
|
||||
|
@ -525,11 +510,8 @@ class UserPageController extends Controller
|
|||
$index++;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}while($outOfRange==true && $index<count($stationsArray));
|
||||
|
||||
//}
|
||||
// }
|
||||
}
|
||||
|
||||
private function checkStationDistance( $latitudeOrigin, $longitudeOrigin, $latitudeDestination, $longitudeDestination){
|
||||
|
|
|
@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
|
|||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'login', 'receiveCoords', '/api/receiveCoordinates'
|
||||
'login', 'receiveCoords', '/api/receiveCoordinates', '/userpage'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ return [
|
|||
*/
|
||||
|
||||
//'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||
'host' => env('MAIL_HOST', ''),
|
||||
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -43,7 +43,8 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
//'port' => env('MAIL_PORT', 587),
|
||||
'port' => env('MAIL_PORT', 465),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -57,8 +58,8 @@ return [
|
|||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', null),
|
||||
'name' => env('MAIL_FROM_NAME', null),
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'geo.comb.ipl@gmail.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'GeoComb'),
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
@ -368,10 +368,44 @@ var array2;
|
|||
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: '/userpage',//'http://geocomb.app/receiveCoords',
|
||||
type: 'POST',
|
||||
data: {"searching": true},
|
||||
//contentType: "application/json; charset=utf-8",
|
||||
|
||||
success: function (response) {
|
||||
console.log("data sent "+ response);
|
||||
},
|
||||
error: function(error){
|
||||
console.log("could not send data, error: ");
|
||||
console.table(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$('#upNewSearch').click(function(){
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: '/userpage',
|
||||
type: 'POST',
|
||||
data: {"searching": false},
|
||||
//contentType: "application/json; charset=utf-8",
|
||||
|
||||
success: function (response) {
|
||||
console.log("data sent "+ response);
|
||||
},
|
||||
error: function(error){
|
||||
console.log("could not send data, error: ");
|
||||
console.table(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#sendRouteEmail').click(function(){
|
||||
//console.table(routePoints);
|
||||
var start = routePoints["legs"][0]["start_address"];
|
||||
|
@ -389,7 +423,6 @@ var array2;
|
|||
var points = [];
|
||||
var key = "AIzaSyDsZDCiU1k6mSuywRRL88xxXY-81RMEU7s";
|
||||
coordinates = getCoordinates();
|
||||
var link = "https://maps.googleapis.com/maps/api/elevation/json?path="+coordinates.origin.latitude+","+coordinates.origin.longitude+"|"+coordinates.destination.latitude+","+coordinates.destination.longitude+"&samples=15&key="+key;
|
||||
var i, j, k, l;
|
||||
var multiplier=1;
|
||||
|
||||
|
@ -572,6 +605,7 @@ var array2;
|
|||
origin: $("#upOrigin").val(),
|
||||
destination: $("#upDestination").val(),
|
||||
waypoints: waypts,
|
||||
avoidTolls: $('#upPaidRoads').is(':checked'),
|
||||
optimizeWaypoints: true,
|
||||
travelMode: 'DRIVING'
|
||||
}, function(response, status) {
|
||||
|
@ -642,6 +676,7 @@ var array2;
|
|||
stopover: true,
|
||||
//location: new google.maps.LatLng(51.263439, 1.03489)
|
||||
}],*/
|
||||
avoidTolls: !$('#upPaidRoads').is(':checked'),
|
||||
travelMode: google.maps.TravelMode.DRIVING
|
||||
}, function(response, status) {
|
||||
if (status === google.maps.DirectionsStatus.OK) {
|
||||
|
@ -649,7 +684,7 @@ var array2;
|
|||
var polyline = new google.maps.Polyline({
|
||||
path: [],
|
||||
strokeColor: '#0000FF',
|
||||
strokeWeight: 3
|
||||
strokeWeight: 3,
|
||||
});
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
|
||||
|
@ -695,10 +730,7 @@ var array2;
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
console.table(pointsArray);
|
||||
//console.table(pointsArray);
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: "/api/receiveCoordinates",
|
||||
|
@ -729,6 +761,7 @@ console.table(pointsArray);
|
|||
dataType: "json",
|
||||
success: function (data) {
|
||||
stationsData = data["stations"];
|
||||
console.log("stationsData");
|
||||
console.table(stationsData);
|
||||
},
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
@if($fuels)
|
||||
@foreach($fuels as $fuel)
|
||||
<label><input type="checkbox" name="fuelType" value="{{$fuel->name}}">{{$fuel->name}}</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="{{$fuel->name}}">@if($fuel->name == "petrol_95") Gasolina 95 @elseif($fuel->name == "petrol_95_simple") Gasolina 95 Simples @elseif($fuel->name == "petrol_98") Gasolina 98 @elseif($fuel->name == "petrol_98_simple") Gasolina 98 Simples @elseif($fuel->name == "diesel") Diesel @elseif($fuel->name == "diesel_simple") Diesel Simples @elseif($fuel->name == "gpl") GPL @endif</label><br>
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</div>
|
||||
|
||||
<br><br>
|
||||
|
||||
@if($searchingFlag == true)
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-12" id="divPercurso" style="background-color: grey">
|
||||
|
@ -65,15 +65,21 @@
|
|||
<label for="inputdefault">Destino: </label>
|
||||
<input class="form-control" id="upDestination" name="upDestination" type="text">
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="inputdefault">Evitar Estradas Pagas: </label>
|
||||
<input class="form-control" id="upPaidRoads" name="upPaidRoads" type="checkbox">
|
||||
|
||||
</div>
|
||||
|
||||
<label>Autonomia (km):<br><input type="number" name="upAutonomyKm" id="upAutonomyKm"></label><br>
|
||||
|
||||
<br>
|
||||
|
||||
<button id="upSearch" class="btn btn-primary btn-lg">Pesquisar</button>
|
||||
<button id="cleanSearch" class="btn btn-danger btn-lg">Limpar Pesquisa</button><br><br>
|
||||
<a id="btnFeelingLucky" type="button" class="btn btn-primary btn-lg" <!--href="{{route('feelingLucky')}}"-->Pesquisa Automática</a>
|
||||
<button id="upSearch" class="btn btn-primary btn-lg">Pesquisar</button>
|
||||
<button id="cleanSearch" class="btn btn-danger btn-lg">Limpar Pesquisa</button><br><br>
|
||||
<button id="btnFeelingLucky" type="button" class="btn btn-primary btn-lg" >Pesquisa Automática</button>
|
||||
|
||||
<form id="formEmailLink" method="post" action="{{route('sendRouteEmail')}}">
|
||||
{{csrf_field()}}
|
||||
|
@ -107,7 +113,15 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
@elseif($searchingFlag == false)
|
||||
<p>Searching</p>
|
||||
<div class="col-lg-6">
|
||||
<div class="center-block" id="mapUP"></div>
|
||||
<br><br>
|
||||
</div>
|
||||
<a id="upNewSearch" class="btn btn-primary btn-lg" href="{{ route('planRoute') }}">Nova Pesquisa</a>
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ Route::post('/register', 'Auth\RegisterController@register');
|
|||
|
||||
Route::group(['middleware' => 'auth'], function () {
|
||||
Route::get('/userpage', 'UserPageController@index')->name('userpage');
|
||||
Route::post('/userpage', 'UserPageController@index');
|
||||
Route::post('/userpagerefresh', 'UserPageController@postUserPage');
|
||||
Route::post('/addvehicle', 'UserPageController@add')->name('addvehicle');
|
||||
|
||||
Route::get('/userpage/vehicles/edit/{id}', 'UserPageController@editVehicle')->name('editVehicle');
|
||||
|
@ -58,7 +58,7 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
Route::get('/userpage/info/edit/{id}', 'UserPageController@editInfo')->name('editInfo');
|
||||
Route::post('/userpage/info/edit/{id}', 'UserPageController@saveInfo')->name('postInfo');
|
||||
|
||||
Route::post('/userpage', 'UserPageController@postTripData')->name('sendTripData');
|
||||
Route::post('/userpage', 'UserPageController@postTripData')->name('postUserPAge');
|
||||
|
||||
Route::post('/userpage/editPass', 'UserPageController@postCredentials')->name('editPass');
|
||||
|
||||
|
|
Loading…
Reference in New Issue