Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

 Subscribe to receive our newsletter. Subscribe Unsubscribe

## Find 3 closest matches

This is a discussion on Find 3 closest matches within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have to make a website where user can look for the stores closest to their address. So I have ...

1. Junior Member White Belt
Join Date
Feb 2005
Posts
8

## Find 3 closest matches

I have to make a website where user can look for the stores closest to their address.

So I have a database with all the store addresses and I need to find the 3 closest matches to the clients home address. What would be the best approach?

I was thinking :
- get all latitude and longitude coordinates of the stores and store them locally in a database.
- get the latitude and longitude coordinates of the home address of the client
- find the 3 nearest matches in the database.

Am I thinking in the right way?

2. Senior Member Black Belt
Join Date
Nov 2004
Location
Belgium
Posts
2,433
Hi,

Yes. I assume you mean the most close in a strait line. And to avoid to much calculations (dont know how many stores there are) you kan seek in the database the store with the most close longitude, then also the record with the most close latitude. Then 1 of these 2 is really the most close. So for each of the 3 you have to do 2 database seek and 2 calculations. If you index on lat and an index on long this can go pretty fast.

3. Junior Member White Belt
Join Date
Feb 2005
Posts
8
Originally Posted by Wilfried

Yes. I assume you mean the most close in a strait line. And to avoid to much calculations (dont know how many stores there are) you kan seek in the database the store with the most close longitude, then also the record with the most close latitude. Then 1 of these 2 is really the most close. So for each of the 3 you have to do 2 database seek and 2 calculations. If you index on lat and an index on long this can go pretty fast.
Hey, thanks for the reply.
Yes in straight line would do. If I have found those 3 most close stores. How would I get a map from MapPoint on which all 3 stores are located? Is there any function to get like a rectangle from MapPoint? So I could set the boundaries of the rectangle to the two farest stores relative from the users home place. I have been going through the documentation but I couldn't find something like this? How is this done?

Thanks again!!

4. Senior Member Black Belt
Join Date
Nov 2004
Location
Belgium
Posts
2,433
Hi,

Yes, like this:

Code:
`MP.ActiveMap.DataSets.ZoomTo&#40;&#41;;`

5. Junior Member White Belt
Join Date
Feb 2005
Posts
8
Originally Posted by Wilfried
Yes, like this:

Code:
`MP.ActiveMap.DataSets.ZoomTo&#40;&#41;;`
Very nice, thx. I can start developing my application now, I think Thanks for enlightening me!

Btw. Groeten vanuit Gent!

Thanks again!

6. Senior Member Black Belt
Join Date
Nov 2004
Location
Belgium
Posts
2,433
Hi,

Btw. Groeten vanuit Gent!
Almost neighbours and talking to each other on a server somewhere in US Happy coding !

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•