1

I got a real-estate facing problem.

I've got a real-world address that I'm converting to earth coordinates (such as "London Eye" to "-0.119543;51.503324").

I also got a perimeter or area within I'm going to search (for example "10" is "10 km").

Now I got a bunch of coordinates (totally random around the earth) and I want to check if the current coordinate is within 10km of the coordinates of the london eye.

Is there any solution to this or maybe am I even facing a x-y-problem?

Community
  • 1
  • 1
SeToY
  • 5,777
  • 12
  • 54
  • 94
  • You can use Pythagoras to determine distance between two points - is that all you're asking? Or are you asking for a fast way to do it? (Do you have millions of points to check?) Or are you needing to convert between coordinate systems? – Matthew Watson Feb 20 '13 at 13:08
  • @MatthewWatson It's not about routing or anything, I just want to "draw an n-sized (ex: 10km) circle around my center-point and check whether any other point I'm checking is within that circle" – SeToY Feb 20 '13 at 13:11

3 Answers3

1

You could use the Haversine Formula to calculate the distance between two points:

http://www.stormconsultancy.co.uk/blog/development/code-snippets/the-haversine-formula-in-c-and-sql/

Nearest GPS coordinate based on distance from a given point

However for speed I think you need to calculate max/min longitude and latitude values (i.e a square around the London Eye) as this will be a lot quicker to calculate if there are lots of points to check. Then use the Haversine formula on this small subset of points (within your square) to find those within 10km.

Community
  • 1
  • 1
openshac
  • 4,966
  • 5
  • 46
  • 77
  • This has helped me a lot, thank you. I'm now just measuring the distance between the points and take them as granted. – SeToY Feb 20 '13 at 14:44
0

It seems like this could help you: http://www.doogal.co.uk/dotnetcoords.php

It is based on http://www.jstott.me.uk/jcoord, which allows distance calculation between points. Don't take my word for it though, haven't used either.

Machinarius
  • 3,637
  • 3
  • 30
  • 53
0

There is a well known solution to the problem. Haversine_formula

I think you can also search for C# code for the same. Hope it helps.

Apurv Gupta
  • 870
  • 7
  • 14