1

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.

So till now, when I want to find bounding box for some country for example: Australia, Melbourne.

  • I just go to this website http://boundingbox.klokantech.com/ .
  • Draw a rectangle encompassing Melbourne.
  • To know its GeoJson : [[[144.5937418,-38.4338593],[145.5125288,-38.4338593],[145.5125288,-37.5112737],[144.5937418,-37.5112737],[144.5937418,-38.4338593]]]

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.

  • So, in below image you can see, I will always be sure that point y, z will be in melbourne.
  • But, with curved bounding box, it may not cover whole melbourne and hence I am never sure whether point lies inside melbourne or not.

enter image description here

Arjun Chaudhary
  • 2,373
  • 2
  • 19
  • 36

1 Answers1

0

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)? Fine, just have your points in lat-long as well. Then assess if the point is inside or not. The easiest is to use postgis functions like ST_WITHIN. 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? 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.

JGH
  • 15,928
  • 4
  • 31
  • 48