I'm making an API call which should return a list of points within certain area.
This will be used on a map, so the call to API has coordinates of all four corner points.
The area will always be a rectangle and will not be rotated.
At the moment, I'm using the following algorithm for limiting the results:
$lat_limits = array(min($bottom_left_lat, $top_left_lat), max($bottom_left_lat, $top_left_lat));
$lon_limits = array(min($top_left_lon, $top_right_lon), max($top_left_lon, $top_right_lon));
My questions are:
- Is this an optimal way of searching?
- Are there any PHP libraries/helper functions that are better suited for this use?
Thanks!