Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Lets say I have two locations, point A and B.

I would use a bounding circle formula to get (MinLat, MaxLat, MinLon, MaxLon) for both points.

Now consider we are plotting a route from point A to point B.

I know that there are many implementations for calculating a bounding circle for a given Lat/Lon pair, but what I want to do is Calculate all points that lie between path from circle surrounding A and B.

Example Figure: O====O Wanna find point between and inside those equal points.

Does anyone have any ideas about this? I'm using MapQuest and their hosted databases, but my boss wants for me to use Calculated formulae.

First I'm concerned with which direction to proceed in (any ideas appreciated). Second, would such manual formulae have performance issues? if run in code instead of SQL stored procedures?

Thanks for any suggestions or advice.
Posted
Comments
RedDk 25-Jun-13 15:08pm    
Your word "SQL". What's wrong with your word? (hint: ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_1devconc/html/b585851e-d15b-411f-adeb-aeabeb777c0b.htm) BOL -> SQLServer2008 help file

1 solution

Assuming that your data of Points of Interest are stored in a SQL database properly (i.e. latitude and longitude in separate numeric columns with indices), I'd suggest two steps:
- using a SQL query, filter for those POIs with MinLat<=latitude<=MaxLat AND MinLon<=longitude<=MaxLon
- in C# code, iterate thru the resulting candidates and calculate the bounding circle for your given two points plus the candidate: if the center of the bounding circle stays unchanged, the candidate is inside that circle. (You may need to allow for minor changes of the center due to rounding issues).
That's not a fast approach, but at least a start point.
 
Share this answer
 
Comments
robroysd 26-Jun-13 12:10pm    
Thanks for the suggestion. Currently my table - the one with locations, is not indexed, so will work on that, and then have a go at your idea. Thanks again.
Bernhard Hiller 27-Jun-13 2:25am    
A small optimization: you can assume the center of the bounding circle to be the arithmetic mean of latitude and longitude values, resp., for a pair of points. Then calculate the distance of the candidate from the center.
Just beware of pathologic cases around the poles, or when transgressing 180°West/East.
robroysd 1-Jul-13 10:40am    
Hi.. as I had mentioned before, we were using MapQuest api's for doing routing calls with their Proximity and Corridor search methods, which let you vary the radius around a route to search POI's for. With the above question, we tried to implement our own method for finding POI's but, getting way points in between Point A and Point B, proved to be difficult. Currently, we will be proceeding with MapQuest api's which already have been unit tested in our project. Maybe in the future, we can adapt our own scheme for doing routing calls and finding POI information from our custom database. Thanks again for all your advice and help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900