Now in the last lecture, we answered the question which points are near to our point.
Now another common question you want to answer is, hey I get this area, could be a sphere, could be any
polygon,
so I got this area, which points are inside of that area? That is another typical question
and in order to answer this, let's add a bit more points to our database before we dive into that.
So in our Golden Gate Park, we added the California Academy of Sciences, why don't we also add the Conservatory
of Flowers
and again, you'll find the coordinates
in the URL up here.
So let me grab that longitude and then move over to our database and there, in my places collection,
I will insert one document and that'll have the same structure as the other document,
I'll add a name here
and that is the Conservatory of Flowers and I'll add my location which is a geo json object,
where the type again is a point of course and where the coordinates are let's say my longitude obviously
and then I also need the latitude,
so let's grab the latitude from Google Maps and add this as a second value in the array.
So now we added the Conservatory of Flowers,
now let's add two more and definitely feel free to pick your own ones of course.
Now I will also pick the Golden Gate Park Tennis Courts and again, it's the same game as before, pick
the longitude and by the way important,
what you see in the URL here of course is reflecting the center of your current screen, so if you're
not centering perfectly on an item as I did before with the Conservatory of Flowers, you'll actually pick
the center. For the purpose of this exercise here, this will be fine though,
so it only matters that you have some points from inside this area,
no matter if it's exactly that point or a little bit off.
So for the Golden Gate Park Tennis Court, I did focus on it so this should be in the center and I will add
this place therefore, simply edit my previous query,
Golden Gate Tennis Park and I will override my longitude and of course also add my latitude here
then. So let's replace that too, like this
and now let's add a fourth place and that is why it won't matter because that fourth place will be from
outside here.
So let's say we take Nopa, whatever that is,
so let's try to center on that and let's grab the longitude of course,
again let's insert that,
Nopa, let's replace the old longitude of the last query with the new longitude
and of course grab the latitude too, so grab that from the URL and we're good to go.
So now we've got four places in there,
I can quickly find them all to show them to you, pretty.
Now again the coordinates might be a bit off because I did not always center onto them but we got four
different places with four different coordinates,
that is what matters here and three of them,
the first three are in the Golden Gate Park and one of them is outside.
Now in the next lecture,
let's run this query to find all places that are inside of a certain area.