![]() ![]() Public static $closestXMaxDistanceKm = 1000 // Don't search beyond thisĪdd_management_page( 'Location closest test', 'Location closest test', 'edit_posts', _FILE_. Public static $closestXStartDistanceKm = 10 I added a full code example at Mike's related question, and here is an extension that gives you closest X locations (quick and barely tested): class Monkeyman_Geo_ClosestX extends Monkeyman_Geo Or log the number of queries needed and adapt over time. For this initial distance guess you once calculate the number of stores over the total area and use that. ![]() This will drastically improve processing time if you have a large number of stores.įor the related lookup ( "give the ten nearest stores") you can do a similar lookup, but with an initial distance guess (so you start with a 10km by 10km area, and if you don't have enough stores you expand it to 20km by 20km and so on). In the section layout setting you can select 'hidden' as an option to 'overflow'. Only calculate the distance (as the bird flies or with actual driving directions, as you prefer) for the few stores that are returned. There is now an option to hide the overflow. (So you might get a store that is 12km away from you if it is in the north-east corner of the bounding box, but we throw it out in the next step.) Do not yet use trigonometry functions in your database query, as this will prevent indexes from being used. Gather and discuss the best ways to work with your software. Get these bounding coordinates and query only stores between these latitudes and longitudes. Worldwide WordPress 611,231 members 1,004 groups Meet other local fans of WordPress, the Internet's classiest and fastest dynamic content management system. If you know the coordinates of the user and you know the maximum distance (say 10km), you can draw a bounding box that is 20km by 20km with the current location in the middle. I would modify the answer from gabrielk and the linked blog post by using database indexes and minimizing the number of actual distance calculations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |