How to search in an area with gps coordinates (4 coordinates)

Does somebody know how to set bounderies for an area with coordinates (4 points to make a square) and then search in that area if found coordinates fit in this area.

I think just apply math’s logic

To make this question clearer for me: Can you provide an example of the coordinates of a square? Is this literally a square or is it just a four-sided figure? And is the square “orthogonal” to x and y axis?

For instance, a “square” that is orthogonal to the x and y axis can be completely specified with the coordinates of the left upper corner and the length of a side.

It would be easier for me to understand the question if I had a concrete example.

Maybe you could just use a GraphicsPath and Contains?
You would need to transform the geocoordinates into numbers fitting within a map projection and then:

Var p As New GraphicsPath
p.MoveToPoint(x1, y1) // 1st Corner
p.AddLineToPoint(x2, y2) //  2nd Corner
p.AddLineToPoint(x3, y3) // 3rd Corner
p.AddLineToPoint(x4, y4) // 4th Corner
g.DrawPath(p, True)

and then

Contains(x As Double, y As Double) As Boolean
Returns True if the coordinates passed are within bounds of the GraphicsPath.

Contains(pt As Point) As Boolean
Returns True if the point passed is within bounds of the GraphicsPath.
2 Likes

GPS co-ords are 2 decimal numbers, yes?
Like 40.741895 , -73.989308 for New York

if you apply the same translation to all 4 co-ordinates to make the numbers positive, and the same translation to the test point, then Contains() should work nicely, I expect.

[] 17.23,  100.23            [] 28.34,  100.23  
        
............[] 19.987, 117.3231.............                

[] 17.23,  150.23            [] 28.34,  150.23

There is an edge case to consider where the co-ordinates cover the international date line(?) at +/- 179.99, I’d guess.

2 Likes

Thank you. I was in this direction, but needed confirmation. This is the solution!

Thank you for the example. This is the solution I was looking for.