[英]Bounding box on flat map VS Spherical i.e. straight line vs great circle distance
I am designing an application in which I have to tell whether an item like fb video or instagram photo lies inside a region or originated from particular region for example Melbourne. 我正在设计一个应用程序,我必须告诉我,像fb视频或instagram照片这样的项目是在一个区域内还是来自特定区域,例如墨尔本。
So till now, when I want to find bounding box for some country for example: Australia, Melbourne. 所以到现在为止,我想找一些国家的边界盒子,例如:澳大利亚,墨尔本。
But, after reading great circle it says: 但是,在阅读了大圆后,它说:
Now, I am really confused, till now I thought bounding box is a rectangle and hence if I know diagonally opposite point I can draw it and any point inside it, will belong to the region rectangle encompasses. 现在,我真的很困惑,直到现在我认为边界框是一个矩形,因此如果我知道对角线相反的点我可以绘制它和它内部的任何点,将属于区域矩形包含。 But, with curved boundary the point can exist inside or outside.
但是,对于弯曲的边界,该点可以存在于内部或外部。
You need to make a distinction between the box itself and its representation on a flat surface. 您需要区分框本身及其在平面上的表示。 You can read about map projection to understand why/how a straight line on the curved hearth is represented as a curve on a flat sheet of paper.
您可以阅读有关地图投影的信息,以了解弯曲炉床上的直线为什么/如何在平面纸上表示为曲线。
Now, for your function to work, the most important thing is to be consistent and always use the same projection (or absence of projection!) between all of the data. 现在,为了使您的功能正常工作,最重要的是保持一致并始终在所有数据之间使用相同的投影(或没有投影!)。 You have an un-projected lat-long bounding box (so with coordinates expressed in degrees)?
你有一个未投影的lat-long边界框(坐标用度数表示)? Fine, just have your points in lat-long as well.
很好,也可以在lat-long中获得积分。 Then assess if the point is inside or not.
然后评估该点是否在内部。 The easiest is to use postgis functions like ST_WITHIN .
最简单的方法是使用像ST_WITHIN这样的postgis函数。 It is then up to you to display it or not, either as lat-long (straight line) or by first projecting it (curved line).
然后由您决定是否显示,无论是拉长(直线)还是首先投影(曲线)。
Just to make it easier to understand, think of a simpler question: Is a point south of the 30S parallel? 为了使其更容易理解,想一个更简单的问题:30S以南的一个点是否平行? If put on paper, the 30S will be a curved line, but you can still know you are south of it if you latitude is smaller than -30.
如果放在纸上,30S将是一条曲线,但如果你的纬度小于-30,你仍然可以知道你在它的南边。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.