Posted by mtndan on October 31, 2008 at 3:20am
Hi folks,
I'm trying to research the best way to accomplish this (hopefully in D6):
- Two CCK content types: Stores and Customers
- Store nodes and Customer nodes have addresses/locative information associated with them
- When a new customer node is added, there needs to be a geo-lookup function that assigns them a related store node that is closest to their location.
Any help would be appreciated. Thanks in advance!

Comments
D6 proximity search
i think this would be good reading to start:
http://drupal.org/node/321114
location has provided views support to do proximity searches and filtering. as you will read in the linked thread bdragon is on it. not sure if it's working in the latest dev release but you might want to check it out and help bdragon test it for your use case.
r,
coby
[edit]
and Geo may help handle this use case as well but i have yet to check it out. someone smarter than me can weigh in on Geo...
Thanks Coby, I did read
Thanks Coby, I did read that.
I'm wondering specifically how I can build a query that I could use in a computed cck field, something like this:
SELECT nid FROM {content_type_stores} WHERE "the location of the store node" is "closest to" "the location of the customer I am adding";
I just don't know the mechanics of searching by proximity at all - any help would be appreciated. I know in the database locations are stored as lat/lon, but I don't know where to start to learn how I can query that information in a way that will return results based on proximity.
Granted, I haven't dug into the code of location just yet (I'm a php hack at best)...
--
Dan Katz
Solutions Architect, Acquia