Lat-Lon Point is in rectangle defined by two other

2019-09-13 19:45发布

问题:

I would like to determine if a certain point is contained within a 'rectangle'. The 'rectangle' will be made up of latitude/longitude coordinates (given northWest and southEast coordinate points)... so basically here are the parameters:

public boolean hasPoint(LatLon northWest, LatLon southEast, LatLon point) {}

The LatLon class just has: double latitude; double longitude;

I have no idea how to start this... any help will be appreciated.

回答1:

Assuming this LatLon class just has an x and y value. How about just checking if your point x/y lies between the x/y from your other 2 positions ?