distance between points
-
I am reading a list of x and y pairs from a database, creating points from them and adding them to a collection. Before I add these points to the collection however I would like to be able to check if there already is a point in the collection that is within a certain distance from the point I am about to add. Is there a way to do this without having to loop through the existing collection and check all the points individually or, if not, if you have 2 points in asp.net can you find the distance between them without having to check the x and y individually? Thanks If I had a better memory I would remember more.
-
I am reading a list of x and y pairs from a database, creating points from them and adding them to a collection. Before I add these points to the collection however I would like to be able to check if there already is a point in the collection that is within a certain distance from the point I am about to add. Is there a way to do this without having to loop through the existing collection and check all the points individually or, if not, if you have 2 points in asp.net can you find the distance between them without having to check the x and y individually? Thanks If I had a better memory I would remember more.
-
I am reading a list of x and y pairs from a database, creating points from them and adding them to a collection. Before I add these points to the collection however I would like to be able to check if there already is a point in the collection that is within a certain distance from the point I am about to add. Is there a way to do this without having to loop through the existing collection and check all the points individually or, if not, if you have 2 points in asp.net can you find the distance between them without having to check the x and y individually? Thanks If I had a better memory I would remember more.
Suzanne Boyle wrote: Is there a way to do this without having to loop through the existing collection and check all the points individually or, if not, if you have 2 points in asp.net can you find the distance between them without having to check the x and y individually? The ASP.NET framework does not have this kind of support, neither does the "greater" .NET Framework. If you need to do this quickly and efficiently you will need to implement a Quadtree algorithm. See the link below for details. However, if your set of points is small then you may be just as well to implement a brute force, check all previous instances, method as you have already suggested. http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u37.html[^]
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
Suzanne Boyle wrote: Is there a way to do this without having to loop through the existing collection and check all the points individually or, if not, if you have 2 points in asp.net can you find the distance between them without having to check the x and y individually? The ASP.NET framework does not have this kind of support, neither does the "greater" .NET Framework. If you need to do this quickly and efficiently you will need to implement a Quadtree algorithm. See the link below for details. However, if your set of points is small then you may be just as well to implement a brute force, check all previous instances, method as you have already suggested. http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u37.html[^]
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
Colin Angus Mackay wrote: if your set of points is small The points are actually the locations of stores on a map and there aren't too many at the moment. Colin Angus Mackay wrote: If you need to do this quickly and efficiently you will need to implement a Quadtree algorithm :eek: I hope they never open enough stores for it to come to this. If I had a better memory I would remember more.
-
Colin Angus Mackay wrote: if your set of points is small The points are actually the locations of stores on a map and there aren't too many at the moment. Colin Angus Mackay wrote: If you need to do this quickly and efficiently you will need to implement a Quadtree algorithm :eek: I hope they never open enough stores for it to come to this. If I had a better memory I would remember more.
* dreamy look * GIS applications - Maps - point-in-polygon algorithms.... 'twas my staple development work between 1995 to 2002.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
I am reading a list of x and y pairs from a database, creating points from them and adding them to a collection. Before I add these points to the collection however I would like to be able to check if there already is a point in the collection that is within a certain distance from the point I am about to add. Is there a way to do this without having to loop through the existing collection and check all the points individually or, if not, if you have 2 points in asp.net can you find the distance between them without having to check the x and y individually? Thanks If I had a better memory I would remember more.
Interesting question... There's no built-in function I know about to do this, and looping through all the records checking each distance is going to be dodgy. Finding the distance between points is simple enough: d=sqr((X2 - X1)^2 + (Y2 - Y1)^2) but using asp.net to calsulate this on the fly for every point in the database is awfully tedious. A possible improvement would be to maintain a table of precalculated distances between existing points. When considering a new point it would then only be necessary to calculate the distance once - from the origin to the target point - then query the table for any lesser value. If the new point is subsequently added, the distance table would have to be recalculated, but this can be done in a stored procedure on the database server. "My kid was Inmate of the Month at Adobe Mountain Juvenile Corrections Center" - Bumper Sticker in Bullhead City