2017-07-19 70 views
0

我有一个地方的坐标点,例如:检查坐标点是在于某些框区域蟒蛇

point_coord = [-7.7938593,110.3634829] 

我也有一个区域的viewport包含两个点corrdinates,例如:

northeast = [5.9052479,141.0194444] 
southwest = [-11.005261,95.01106190000002] 

如果我说明这一点,这将是这个样子: enter image description here

的问题是,我怎么CH eck如果point_coord落在或位于使用Python的盒子区域的某个地方?

感谢

回答

1

对不起,没有地图和视口太多的经验,但不应简单地说是:

def isInside(point_coord, northeast, southwest): 
    return southwest[0]<point_coord[0]<northeast[0] and\ 
      southwest[1]<point_coord[1]<northeast[1] 

唯一可能的边缘情况下,我能想到的是南北两极。你可能只需编码特殊情况来处理它们。

编辑:一些错别字和不链接比较。