WEBVTT 00:05.110 --> 00:13.780 In this video we're going to translate the logic of our search process into peacoat. 00:14.050 --> 00:26.090 So first of all we are going to set the search radius the search radius is going to be 10 miles. 00:26.080 --> 00:32.340 You continue it as if you're like so let's define a variable. 00:32.400 --> 00:42.260 You're going to store these while you. 00:42.710 --> 00:46.250 So we're going to call it a search radius. 00:46.740 --> 00:49.520 We're going to set it to 10 miles for now. 00:52.320 --> 00:53.260 OK. 00:53.790 --> 01:01.470 So now we're going to calculate the tolerance for the departure longitude. 01:01.470 --> 01:12.320 So the way we did that earlier was by doing this calculation so we're going to need the latitude for 01:12.380 --> 01:13.140 this. 01:13.550 --> 01:14.100 OK. 01:14.370 --> 01:14.610 So 01:19.870 --> 01:21.260 what are you going here for the 01:24.000 --> 01:34.750 minimum and maximum for the departure longitude So you're calculating the tolerance first before we 01:34.750 --> 01:37.500 can find the min max values. 01:37.690 --> 01:47.400 So we get to call the tolerance for the departure longitude Delta longitude departure. 01:47.640 --> 01:48.290 OK. 01:48.780 --> 02:00.360 So it's going to be the search radius which is 10 miles multiplied by 360 degrees and divided by that 02:00.360 --> 02:04.940 number multiplied by the coastline of the latitude. 02:05.700 --> 02:19.070 So go ahead and put that in our code so search radius multiplied by 360 divided by twenty four thousand 02:19.070 --> 02:26.230 nine hundred one multiplied by the coastline of the latitude. 02:26.460 --> 02:30.080 So you'd be a lawsuit is 02:33.090 --> 02:34.620 stored inside that very well. 02:34.860 --> 02:40.880 OK so before using the coastline we will need to convert 02:43.830 --> 02:47.100 this angle which is in degrees to radians. 02:47.340 --> 02:47.730 OK. 02:47.730 --> 02:51.710 So make sure we do that before using the coastline function. 02:52.020 --> 03:03.750 So to convert this number to radians we're going to use a BHB function called degree to a region like 03:03.760 --> 03:04.580 that. 03:05.260 --> 03:06.920 OK. 03:06.920 --> 03:07.140 All right. 03:07.150 --> 03:12.280 So now we've got our tolerance for the departure longitude. 03:12.280 --> 03:18.000 Now we are ready to calculate the minimum longitude the maximum speed for the departure. 03:18.190 --> 03:23.980 So this goal the minimum 1 min longitude 03:26.290 --> 03:27.560 departure. 03:28.660 --> 03:35.890 So that's going to be the departure longitude minus the tolerance 03:45.040 --> 03:47.820 so in our example here we had London. 03:48.250 --> 03:54.790 So the departure longitude would be the DuPont the Lundy's the longitude of London. 03:54.790 --> 03:56.600 Mine is about tolerance. 03:56.760 --> 04:02.620 OK that's going to be the minimum one and then the maximum departure long the series gets to be that 04:02.920 --> 04:06.550 plus that's OK. 04:06.550 --> 04:09.930 So let's look for the departure 04:12.950 --> 04:13.670 luggage. 04:13.950 --> 04:14.890 I always thought variable 04:18.350 --> 04:20.380 mind is 0 Tollers 04:25.430 --> 04:27.670 OK then the maximum 04:39.590 --> 04:43.610 is going to be that plus That's all right. 04:43.940 --> 04:54.060 Now we will need to check if we are within the right range because if you remember we can always for 04:55.530 --> 05:05.340 an extreme extreme cases where the maximum is outside one hundred eighty or the minimum is outside minus 05:05.490 --> 05:06.850 minus 180. 05:07.200 --> 05:09.690 So are going to need to accommodate those cases as well. 05:09.960 --> 05:19.320 OK so once we define the minimum longitude we will check if the minimum longitude is within range or 05:19.320 --> 05:20.310 not. 05:20.310 --> 05:26.730 So we're going to check if that's minimum is too small. 05:26.810 --> 05:31.380 Meaning less than minus 180. 05:31.640 --> 05:40.050 OK so in that case we're going to change that's value. 05:40.540 --> 05:51.090 And I said earlier if you do a if you travel through a circle traveling through 360 degrees then you 05:51.090 --> 05:55.330 get the same value all the same points. 05:55.360 --> 05:57.550 All right very to. 05:57.580 --> 06:02.010 Same thing for the maximum. 06:02.590 --> 06:09.760 By this time we're going to check if the maximum is actually greater than 180. 06:10.210 --> 06:11.730 In that case if it's greater. 06:11.740 --> 06:19.570 We're going to reduce or remove 360 from this very well. 06:19.720 --> 06:22.500 So it's like traveling west. 06:22.540 --> 06:23.130 OK. 06:23.170 --> 06:26.320 And this one is like traveling east one whole circle. 06:26.950 --> 06:27.530 All right. 06:29.270 --> 06:38.170 Now when we are building our query we will need to know where that we have cases like this. 06:38.840 --> 06:46.970 So to make things easier for us I'm going to define a couple of variables. 06:47.900 --> 06:48.620 I'm going to call them 06:53.420 --> 06:54.170 departure 06:56.930 --> 07:00.100 longitude out of range. 07:00.650 --> 07:04.670 By default this is going to be false. 07:04.730 --> 07:10.370 The other one is going to be destination longitude out-of-range I'm going to use it when we get to the 07:10.370 --> 07:11.730 destination. 07:11.810 --> 07:16.610 So how are we going to use these two variables. 07:16.650 --> 07:24.450 So when we fall in a situation where we are out of range then we're going to turn one of these variables 07:25.020 --> 07:26.050 to true. 07:26.360 --> 07:34.110 And when we are building the query then we can refer to this variable to know whether we're going to 07:34.110 --> 07:42.580 be in the case using a between inside the query or using greater than a Cessna value and smaller than 07:42.610 --> 07:44.000 as a set of value. 07:44.060 --> 07:48.820 All right the same thing in the other case. 07:52.580 --> 07:53.350 OK. 07:53.640 --> 08:00.730 So now we've done with the departure longitude we're going to do exactly the same thing for the destination. 08:01.200 --> 08:26.000 I'm going to copy the code and just change anything saying departure to destination. 08:26.270 --> 08:26.890 All right. 08:28.740 --> 08:32.730 So now we've done with the departure along issued the situation issued.