I had to dig around in the code and do some hacking to find a way of doing exact lookups for latitude and longitude rather than proximate lookups based on zip code. It would be easier if this capability could be turned on or off via admin/settings/location.

Also, the exact lookup uses geocoder's free lookup feature, which works fine for doing sporadic lookups but won't work for doing more than a small number at any one time. (The free lookup is throttled to prevent bulk uses.) For my particular project, I needed to look up 8,000 addresses and was willing to pay for the privilege. In addition to turning on exact lookups, the settings page could also make it possible to turn on for-pay lookups and enter the username and password of a geocoder for-pay account.

If it would help, I'd be happy to share the code that I added to enable exact lookups in my project.

Comments

ankur’s picture

Thanks Sheldon,

I'm glad to know there're are other people interested in this. I've been planning to geocoder.us integration to the location module for a while. There's just been a few issues to get around (which I've made plans for gettng around):

(1) Terms of Use for http://geocoder.us is only usable for non-commercial purposes. Furthermore, I think only a certain number of lookups are allowed.
Codewise: I 've been thinking of adding something to the location module interface that allow for specifying a URL for a geocoder as well as a user/pass if one is necessary. This way, a site admin would be able to use http://geocoder.us, or if s/he wanted to, could set up their own geocoder on the same intranet as the CivicSpace site's server.
I've installed my own local geocoder server application and the documentation could use some work. Specifically, a little tutorial on CPAN and Perl might help. However, it's not that hard once you know what you need to do. I've been thinking that when we actually put in a patch to make use of the geocoder's rest api, we can put out some documentation to that explains how to download and install the geocoder app from geocoder.us.

(2) The other issue concerns the setup that the site admin goes for (using a remotely hosted geocoder or one hosted on the same ethernet). Right now, location module will check zip-based lat/lons upon node submissions/edits. So, contacting a remote geocoder isn't a problem in this case, since only one address is being checked at a time. The problem gets worrisome when we run cron jobs. A location module instance that accesses a geocoder on the same private network can definitely go through more request-reply cycles with the geocoder than if the geocoder were being hosted remotely. To deal with this problem, I've been thinking perhaps we can make the number configurable (with a little note about why it's not a good idea to look up 1000 addresses on each cron job for geocoders hosted remotely).

In anycase, I will be adding support to handling geocoding on node submissions/edits. What I do for cron jobs might require some more thought. There is also the possibility or adding a 'geocode' button on node views for permissioned users where a user can try to get an exact geocoding for a node's locaiton. However, this wouldn't work as well in the case where someone has a few hundred to do at once...

Anyone else's thoughts on these issues? Suggestions on what the interface might look like?

-Ankur

sheldon rampton’s picture

In this vein, you might be interested in the following thread at Civicspace labs:

http://civicspacelabs.org/home/node/14568

After I opined there that the Geocoder folks would probably be happy to have exact Geocoder lookups enabled in admin/settings/location (especially if it includes an option to turn on their for-pay lookups), I got a note from Rich Gibson (one of the Geocoder people), confirming that this is the case.

You might also be interested in taking a look at the following website that I created:

http://www.tennismeet.com/court/index.html

It includes a database of some 8,000 tennis courts in the United States. Users can do a zipcode search to create a Google map showing all of the courts within a specified radius. When I first set it up, I thought I could just use the free Geocoder to look up all of the addresses dynamically each time a user generates a map. I then realized that whenever I did a search returning more than a small number of courts, Geocoder hung things up. So, I plunked down $50 for a Geocoder account and tweaked the code in location.module to let me look up each court once and store the exact coordinates in my database. Now that I've got them, I can just pull from my database whenever I want to generate a map.

I can imagine a case like the one you described where someone's cron job would try and fail to do thousands of Geocoder lookups in a single pass, but for most people simply having the options of throttled Geocoder for free or for-pay Geocoder for larger lookups would probably suffice.

One of the other things I implemented with tennismeet.com is a geographical restriction on user lookups via the profile module. When someone registers, they can enter not just their address but also a "travel range" that limits the list of user profiles they see.

I noticed that location.module, in its current state, has an easy search function for NODES but not for USERS. I think finding users is just as important (although you'll need to be a little more careful about giving out users' exact addresses, for privacy/security reasons).

bjornarneson’s picture

The new Yahoo Maps API allows for some pretty slick geocoding based upon US addresses. See Rasmus' explanation.

http://toys.lerdorf.com/archives/35-GeoCool!.html

thinkinkless’s picture

Sheldon said:

If it would help, I'd be happy to share the code that I added to enable exact lookups in my project.

Are you still open to sharing your code? If yes I would LOVE to see it.
fyi to Sheldon - I tried contacting you directly via the contact form last night but i don't think it went through. Sorry if this is a repeat.

The inaccuracy of the lat/lon data in locations is the one thing holding us up on accurate street-level mapping for events. We are more than happy to use the paid geocoder.us service to get accurate data. Your posts above suggest that the lat/lon data for new locations is provided by geocoder rather than the zip code table - is that right?

I plan on integrating maps via a flexinode theme rather than googlemap.module (the fact that it posts the map code to all locative nodes is an issue for us) and will be very happy to share my code once it's ready.

RE the above post on yahoo maps, Rasmus' page is a fantastic way to familiarize yourself with the new api. The flash version is the only workaround i can find for street-level mapping fed from an address (vs) lat/lon. The problem is it's very slooooooow. This is a good post from him as well:
http://toys.lerdorf.com/archives/36-More-fun-with-the-Yahoo!-Maps-API.html

catch’s picture

Status: Active » Closed (duplicate)