WEBVTT 00:05.450 --> 00:05.760 All right. 00:05.760 --> 00:10.730 Now let's move to the departure longitude and the destination. 00:11.170 --> 00:15.880 So I mean Max of the departure 00:19.390 --> 00:19.880 is huge. 00:19.900 --> 00:23.340 So two storms we're going to define the tolerance. 00:23.440 --> 00:31.540 OK I'm going to call is Delta latitude departure OK. 00:31.780 --> 00:44.910 So the way to calculate that was by doing these calculations so 10 multiplied by eighty divided by 12000 00:44.930 --> 00:45.540 430 00:48.780 --> 01:00.460 search radius case 10 multiplied by 180 divided by 12 430. 01:00.780 --> 01:02.950 That's the losses you'd tolerance. 01:03.040 --> 01:13.130 OK so now let's define the minimum latitude for departure and when to coordinates mean latitude departure. 01:14.070 --> 01:17.860 So it's going to be the actual deep and latitude of the departure 01:22.970 --> 01:25.950 minus the tolerance. 01:25.970 --> 01:31.010 Now we need to check if we are within the right range. 01:31.010 --> 01:36.570 So if this is too small meaning that it's less than 90 degrees. 01:37.370 --> 01:38.140 OK. 01:38.150 --> 01:42.830 So if you go below that minus 90 then we're going to need to 01:47.370 --> 01:56.090 guys in our case when we looking at the lassitude when we went when we went beyond 90 we ended up with 01:56.090 --> 01:57.730 the maximum at 90. 01:58.070 --> 02:02.830 And if you go below 90 it would end up with the minimum minus 90. 02:03.220 --> 02:04.680 OK. 02:04.700 --> 02:20.610 So if this value is too small meaning less than minus 90 then we're just going to turn it to minus 90. 02:20.730 --> 02:30.700 Now if we are in that case then we're going to use the variable we defined earlier to say that's the 02:30.700 --> 02:34.960 best situation well not really. 02:34.970 --> 02:35.590 We're going to use the 02:41.550 --> 02:45.500 now we're going to do the same thing with the maximum lassitude for the departure 02:50.580 --> 03:02.200 Mike's last issued departure and it's going to be the departure lassitude Plus the tolerance and in 03:02.200 --> 03:10.420 our case we're going to check if this variable is too big meaning that it's greater than 90. 03:11.380 --> 03:14.130 If that's the case then we're going to turn it to 90 03:18.250 --> 03:18.890 OK. 03:19.360 --> 03:28.570 And the query is going to be the same whether we are within the range or outside the range unlike what 03:28.570 --> 03:30.220 we did with the launch to shoot. 03:30.550 --> 03:33.640 OK so we don't need to define a couple of variables. 03:33.670 --> 03:39.310 OK two to determine whether we are within the range or not for the latitude. 03:39.310 --> 03:42.190 What we really need is for the longitude. 03:42.580 --> 03:47.740 OK so now we are going to build our query 03:51.380 --> 03:53.180 so the query is going to start 03:57.360 --> 04:08.530 with something saying select all the records from our table which is cochere trips where OK and now 04:08.530 --> 04:12.120 we going to add the conditions. 04:12.120 --> 04:18.620 So let's start with the departure longitude. 04:20.650 --> 04:21.540 OK. 04:21.750 --> 04:33.450 Now we need to be specific we're going to check the departure longitude variable to check whether we 04:33.450 --> 04:35.780 are out of range of or not. 04:35.970 --> 04:45.430 So if we are out of range then queery is going to look like something. 04:45.610 --> 04:49.540 Otherwise it's going to look like something else. 04:49.600 --> 04:50.060 OK. 04:50.170 --> 04:57.930 So if we are out of range this means that we are in a situation like 05:00.690 --> 05:08.970 this one so we are going to have two intervals and we can look for locations with a longitude greater 05:09.180 --> 05:13.960 than that's mean or smaller than that pneumatics. 05:14.240 --> 05:20.060 OK so if we look at our example here this is what we're getting. 05:20.110 --> 05:28.330 So in the query the second line or the second condition is departure longitude greater than this main 05:28.720 --> 05:29.960 or departure lawyers. 05:30.040 --> 05:32.230 Smaller than this. 05:32.260 --> 05:34.560 All this new Max. 05:34.670 --> 05:34.890 OK 05:38.480 --> 05:43.480 so we're going to add to the query something saying 05:56.330 --> 05:56.690 so 06:02.460 --> 06:07.360 we look at the departure longitude. 06:08.390 --> 06:14.310 Ok either greater than the min wage is 06:17.640 --> 06:17.980 that's what 06:21.750 --> 06:23.260 it says put this in inside 06:26.100 --> 06:27.280 princess. 06:33.930 --> 06:34.530 OK. 06:34.830 --> 06:35.250 All 06:43.370 --> 06:45.890 smaller than the max 06:49.340 --> 06:50.090 OK. 06:50.800 --> 06:54.250 Else we're going to have a regular one which is 07:06.580 --> 07:25.610 departure longitude between the min and max. 07:25.820 --> 07:32.420 All right so now let's move to the departure longitude 07:38.710 --> 07:43.860 Well this one is going to be pretty easy because we have the same case all the time. 07:44.050 --> 07:45.010 OK. 07:45.010 --> 07:49.510 So we're just going to have to Mary 07:53.500 --> 07:59.860 something saying that's the departure longitude is just between the min and max. 08:00.010 --> 08:01.480 So going to need and here 08:06.290 --> 08:16.890 and wants the departure latitude to be between the min and max. 08:17.210 --> 08:19.820 So the mean lassitude for the departure 08:37.100 --> 08:45.410 and Max. 08:45.690 --> 08:55.200 OK so before going ahead I'm missing here the main Monk's destination lassitude OK. 08:55.320 --> 09:00.990 So we've done the departure but we didn't do the destination solely just copy that. 09:01.020 --> 09:08.720 And I'm just going to change everything here saying departure to destination. 09:08.970 --> 09:15.570 Said he's going to pause the video and change all the parties to destinations in the code. 09:15.990 --> 09:16.990 All right. 09:17.970 --> 09:33.570 OK so now we're going to move to the destination so it starts with the luggage Eudes. 09:34.000 --> 09:39.010 So are we going to have a similar code to the departure longitude 09:41.730 --> 09:47.520 nobody's going to change anything saying departure to destination 09:55.410 --> 09:56.950 is going to pause the video again. 09:57.320 --> 09:58.270 OK. 09:58.510 --> 10:01.940 And we're going to have one change to the query. 10:01.960 --> 10:03.080 We just need to add. 10:03.220 --> 10:13.350 And at the beginning of the query because we would have something else right before. 10:13.360 --> 10:14.420 OK so you have. 10:14.450 --> 10:17.060 And right there because that was the first one. 10:17.270 --> 10:18.450 The first condition. 10:18.860 --> 10:22.850 OK so no we we're going to move to the destination 10:27.380 --> 10:28.460 longitude. 10:28.770 --> 10:28.990 OK. 10:29.000 --> 10:35.400 So that's supposed to say departure lawsuit and this one is the destination. 10:35.450 --> 10:36.090 Unless. 10:41.540 --> 10:44.160 So the code is going to be similar to that. 10:44.760 --> 11:04.990 It's going to change the departure to destination. 11:05.110 --> 11:08.790 Right now we've course our query. 11:08.830 --> 11:09.650 All right. 11:09.700 --> 11:19.240 So out to just you have a quick look and make sure that there are no errors OK or anything that you 11:19.240 --> 11:29.560 mistyped and once you're happy with everything then you can run the query. 11:29.740 --> 11:35.440 So we're going to store the results inside the results variable. 11:35.710 --> 11:42.060 We're going to use again the function MS Kali queery which takes a couple of promises. 11:42.160 --> 11:45.110 The connection link and the query itself. 11:46.180 --> 11:49.410 So if the query is not successful 11:52.910 --> 11:55.130 we're just going to echo an error. 11:55.340 --> 11:56.410 OK. 11:56.420 --> 11:59.320 So for now we're going to do this for debugging. 11:59.480 --> 12:01.610 So I'm going to echo 12:05.210 --> 12:09.500 error unable to execute the query. 12:12.050 --> 12:14.530 And I want to show the query 12:17.520 --> 12:24.210 and I want to show the error just for debugging purposes 12:30.660 --> 12:32.650 and then again exit the code. 12:32.700 --> 12:35.550 So basically you would do this just for debugging. 12:35.550 --> 12:36.090 OK. 12:36.360 --> 12:41.670 So you don't need to do it for the final Web sites since the query is quite big. 12:41.670 --> 12:44.550 There are chances that you miss something there. 12:44.610 --> 12:46.560 OK. 12:46.560 --> 12:53.090 So just make sure that you use this syntax to get the error OK corresponding to the query. 12:54.350 --> 13:01.110 So it's in the next video we're going to retrieve records from the results variable. 13:01.130 --> 13:03.950 If there are any then print the trips on our page.