1 00:00:02,110 --> 00:00:07,090 Now in the last lecture, we answered the question which points are near to our point. 2 00:00:07,270 --> 00:00:13,660 Now another common question you want to answer is, hey I get this area, could be a sphere, could be any 3 00:00:13,660 --> 00:00:14,460 polygon, 4 00:00:14,500 --> 00:00:20,930 so I got this area, which points are inside of that area? That is another typical question 5 00:00:21,130 --> 00:00:26,960 and in order to answer this, let's add a bit more points to our database before we dive into that. 6 00:00:27,310 --> 00:00:34,060 So in our Golden Gate Park, we added the California Academy of Sciences, why don't we also add the Conservatory 7 00:00:34,060 --> 00:00:35,060 of Flowers 8 00:00:35,170 --> 00:00:37,460 and again, you'll find the coordinates 9 00:00:37,460 --> 00:00:39,160 in the URL up here. 10 00:00:39,310 --> 00:00:46,890 So let me grab that longitude and then move over to our database and there, in my places collection, 11 00:00:47,190 --> 00:00:52,310 I will insert one document and that'll have the same structure as the other document, 12 00:00:52,320 --> 00:00:53,500 I'll add a name here 13 00:00:53,550 --> 00:01:02,780 and that is the Conservatory of Flowers and I'll add my location which is a geo json object, 14 00:01:03,200 --> 00:01:13,230 where the type again is a point of course and where the coordinates are let's say my longitude obviously 15 00:01:13,860 --> 00:01:16,180 and then I also need the latitude, 16 00:01:16,260 --> 00:01:21,920 so let's grab the latitude from Google Maps and add this as a second value in the array. 17 00:01:22,200 --> 00:01:24,430 So now we added the Conservatory of Flowers, 18 00:01:24,540 --> 00:01:28,660 now let's add two more and definitely feel free to pick your own ones of course. 19 00:01:28,740 --> 00:01:38,840 Now I will also pick the Golden Gate Park Tennis Courts and again, it's the same game as before, pick 20 00:01:38,830 --> 00:01:40,440 the longitude and by the way important, 21 00:01:40,570 --> 00:01:45,810 what you see in the URL here of course is reflecting the center of your current screen, so if you're 22 00:01:45,810 --> 00:01:51,060 not centering perfectly on an item as I did before with the Conservatory of Flowers, you'll actually pick 23 00:01:51,060 --> 00:01:55,050 the center. For the purpose of this exercise here, this will be fine though, 24 00:01:55,170 --> 00:01:58,470 so it only matters that you have some points from inside this area, 25 00:01:58,500 --> 00:02:01,750 no matter if it's exactly that point or a little bit off. 26 00:02:01,770 --> 00:02:08,730 So for the Golden Gate Park Tennis Court, I did focus on it so this should be in the center and I will add 27 00:02:08,730 --> 00:02:13,960 this place therefore, simply edit my previous query, 28 00:02:15,720 --> 00:02:25,350 Golden Gate Tennis Park and I will override my longitude and of course also add my latitude here 29 00:02:25,360 --> 00:02:31,100 then. So let's replace that too, like this 30 00:02:31,290 --> 00:02:36,240 and now let's add a fourth place and that is why it won't matter because that fourth place will be from 31 00:02:36,300 --> 00:02:37,700 outside here. 32 00:02:37,830 --> 00:02:40,460 So let's say we take Nopa, whatever that is, 33 00:02:41,810 --> 00:02:48,020 so let's try to center on that and let's grab the longitude of course, 34 00:02:48,020 --> 00:02:49,500 again let's insert that, 35 00:02:51,240 --> 00:02:57,830 Nopa, let's replace the old longitude of the last query with the new longitude 36 00:02:57,990 --> 00:03:06,730 and of course grab the latitude too, so grab that from the URL and we're good to go. 37 00:03:06,750 --> 00:03:08,630 So now we've got four places in there, 38 00:03:08,790 --> 00:03:12,650 I can quickly find them all to show them to you, pretty. 39 00:03:12,660 --> 00:03:17,430 Now again the coordinates might be a bit off because I did not always center onto them but we got four 40 00:03:17,430 --> 00:03:20,160 different places with four different coordinates, 41 00:03:20,160 --> 00:03:22,660 that is what matters here and three of them, 42 00:03:22,680 --> 00:03:26,190 the first three are in the Golden Gate Park and one of them is outside. 43 00:03:26,580 --> 00:03:27,770 Now in the next lecture, 44 00:03:27,780 --> 00:03:32,150 let's run this query to find all places that are inside of a certain area.