Im using javascript. But even pseudocode works to solve this issue.
So I have a place located at a certain latitude/longitude. More exactly at:
latitude: 59.33312059999999
longitude: 18.0694596
I then have a list of latitude/longitude. These coordinates are the points for a polygon. In my test, the coordinates generated for a rectangle (that contains the place above) are:
lat:59.33494869033997
lng:18.076973852002993
lat:59.328907172141186
lng:18.076973852002993
lat:59.328907172141186
lng:18.055945333326235
lat:59.33494869033997
lng:18.055945333326235
What I wonder is how the if-statement should look like to understand if the place is inside the coordinates for the drawn rectangle.
In this case it is a rectangle, but it could be any geometrical shape (not circle though).
I was thinking I could extract the lowest and highest latitude/longitude and then just have:
IF latitude for place <= highest latitude
AND latitude for place >= lowest latitude
AND longitude for place <= highest longitude
AND longitude for place >= lowest longitude
THEN place is inside the coordinates
Or is there a better way?