Click here to Skip to main content
15,888,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm working on a gps-project.

I have a database with about 70 000 coordinates. I need to find the closest coordinate to my actual position.

This has to update every 1 sec. Any suggestions how to do this?

What I have tried:

Right now i load the database to a Datagridview.

Thinking about caluculating the distance to every point and sorting them by distance. But i think this will be to slow couse i have to update every second.
Posted
Updated 5-Feb-17 23:46pm
Comments
Maciej Los 6-Feb-17 5:46am    
And what is your issue?
chrilleb 6-Feb-17 7:00am    
The problem is that it takes 4810,5093miliseconds to update the datagridview. I only have 1 sec to do it.

1 solution

You need database indices on latitude and longitude of your coordinates. Now do database query to get coordinates within a small delta for your current latitude/longitude. Then filter for the closest position.
 
Share this answer
 

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