简体   繁体   中英

Matching locations/coordinates in VBA

I am looking for some VBA code (algorithm) to match a list of GPS locations (in this case a ship track) to a given GPS location. That is to say all locations of the list which are located within the circle with a given radius around that location.

See the picture: so only the "green locations" match of all locations. Sorry for the poor picture, handmade in Windows Paint ;-)

All locations are given as latitude + longitude, for example 52.24782, 4.12082.

地点

The function

Public Function CheckCoords(x#, y#, radius#) As String
    ' x^2 + y^2 = r^2
    ' ==> results true if (p,q) fall outside of the circle
    CheckCoords = IIf((x ^ 2 + y ^ 2) < radius ^ 2, "outside circle", "inside circle")
End Function

unit conversion needed for practical implementation

Found this one: http://www.movable-type.co.uk/scripts/latlong.html

I only have to rewrite the code to VBA code and combine it with the code of @Cylian

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM