Hi,
I tested your module, I created different CCK textfield :
address
postal code
City
Country
And I added a Geospatial data "Geocoded value from another field". I checked all values above and validate.
When I create my node, My addresses are correctly geocoded, but not to the right place. (For example I tried an address in france, and I get a point into the ocean in the south of africa.)
It's quite difficult to setup and to understand how it works. I imagine I made something wrong but a little documentation would be really usefull.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | geocode-624800.patch | 5.23 KB | simosda |
| #16 | screenshot.png | 80.08 KB | simosda |
| #15 | geocode_widget.zip | 3.97 KB | archnode |
Comments
Comment #1
allie mickaHi zmove,
That point off the western coast of Africa is actually the coordinates (0, 0). It may mean that no geocoding occurred at all, or it may mean that your field formatter is not displaying it properly.
To see if it's your field fomatter, go to "Administer -> Content Management -> Content Types -> [your content type] -> Display Fields" and select a formatter other than a map one. Well Known Text, for example. When you view your node, you should see something like POINT(123, 123). If you see POINT(0, 0) or nothing at all then it's on Geo/Geocode's side.
If you see something that looks more responsible then you should file an issue with whatever module is providing that mapping output.
Thanks!
Comment #2
zmove commentedHi, thank you for your quick answer.
You are right, I tried to copy/paste the points into google map to see where it was, but it seems that google map don't understand well the "Well know text" default format. With latitude / longitude I got better results.
To avoid copy/paste each time into google map, I installed the geo + gmap module to directly see the result and I begin to understand what happen.
The geocoding works only when I write the full address into only one textfield for example :
field_address : 50 rue des champs élysées, 75000, Paris.
But If I have different fields to separate informations like :
field_address : 50 rue des champs élysées
field_postal_code : 75000
field_city : Paris
The geocoding is wrong, even if I check all fields into the geocode field configuration. It seems it only take the first value. (So if there is another address in another city that it will find first, it will display the marker to the wrong city).
It is a bug or the module is not designed to be able to geocode several field ? If not, do you have some advices to give to be able to do that ? I really need to separate addresses for usability.
Regards,
zmove
Comment #3
zmove commentedHi again,
I have an idea about the way to do that.
Maybe this is quite difficult to change the module code to allow users to separate an address into multiple fields.
I tried to use computed field module to put into one field, the full address that is registered in my another fields, and it works well.
The only problem is that this module don't support computed field, so, instead of doing a heavy code change to allow that, I think it will be far more easy to integrate computed field as supported field (maybe a copy of the textfield support with small modifications will be enought).
In addition, even if it's a little more complex for website manager who have to create a computed field, this is very flexible and probably more inline with the drupal philosophy.
What about this idea ?
Comment #4
zmove commentedForgot to change status
Comment #5
allie mickaHi zmove,
You can check the multiple boxes, but this means that geocode will attempt to use these fields *sequentially*, until it gets a result, and does not combine them. You're right in thinking that a particular field type needs to accepted by the geocoder.
Please test this for me:
On line 75 of geocode.module, change this code:
To this:
If that works for compound fields i'll make that change.
Thanks!
Comment #6
zmove commentedHi,
The new checkbox don't appear with this line
But it appears with this one
However, the data are not correctly geocoded. I'm in the ocean near africa ;). Don't know why. I tried to put an higher weight to the geocode module in the system table, I first thought that it was a problem about the order things are executed, but that not resolved the problem.
Comment #7
gagarine commentedThey have a difference if you store or not the computed field in the database?
Comment #8
zmove commentedI tried to change some settings in computed fields. Tried to store in the database or not, Not null or not. I couldn't get a working setting.
I looked in the database itself to see how the data was stored, I didn't see big differences between a computed or a core cck textfield, so I don't know.
Comment #9
allie mickaCan you see if this works better with the latest version of Geocode? (alpha2)
Comment #10
gagarine commented@Allie They should be work with computed field module or without?
Comment #11
henrrrik commentedUsing computed_field.module works great with geocode 6.x-1.0-alpha2 with the change in #6 (should be computed, not compound).
Comment #12
henrrrik commentedNOTE: You need to make sure that the Geo field is ABOVE the Computed field in the Manage fields list, or nothing gets geocoded. You'd think it was the other way around, but hey.
Comment #13
henrrrik commentedNOTE 2: Actually, that might not be true. It seems that the node needs to be saved twice. Once to get the computed field saved, once more to get the computed field geocoded.
Comment #14
gagarine commentedComment #15
archnode commentedI made a very rough hack of the geocode widget that adds a checkbox in the widget field settings, that allows to use the default sequential geocode behaviour. This version uses all of the values that are checked in the field settings at once as an input for the geocode function.
It should work with select lists and input fields as cck fields, but defaults to "point" for type and the handler of the last checked field.
Comment #16
simosda commentedI created a patch which changes a little bit the existing functionality and adds a new one.
It adds a new column in the Geospatial data's configuration page - Field type.
Now if we have a content type with several address fields and one "Geocoded value another field" field, in the configuration page of the "Geocoded value another field" widget we can set all these fields to be used in computing the coordinates and we can set the type of each field: generic, street, street number, zip code, city, country. That way when the user fills in for example a zip code field and a country field, he automatically gets the coordinates from these fields. If the "generic" type is used, then the user fills in the whole address in only one field and the coordinates are calculated from this field.
The patch is tested and it works fine. It is created against HEAD.
I've attached the patch and a screenshot of the settings page.
Comment #17
mrtorrent commentedsimosda's patch from #16 works great for me, thank you!
I have a lot of address data already stored in nodes; is there anyway to trigger a mass geocode of all the nodes? At the moment, the only way I can see is to save each one again manually.
Comment #18
mrtorrent commentedI tried using Views Bulk Operations to accomplish this, but any bulk operation seems to have the reverse of the desired effect -- the geodata is completely wiped!
Comment #19
gagarine commentedI like patch in #16 too
Comment #20
gagarine commented#16 can't not applied anymore on head
Comment #21
aprice42 commentedreplacing the geocode widget module with the code from #15 worked great for me. I am using geocode 6.x.1.0-alpha2.
Thanks @archnode :)
Comment #22
cwithout commented@simosda - I'd love for geocode to be able to do what your patch does. I've tried using Addresses and Postal but both are limiting and have required extensive tweeks via custom modules to accomplish what I need. It would be a lot easier to just use CCK fields. (Based on some of the comments in Postal, it will be much more useful once fully developed, but it's just not there yet.)
I'm using 6.x-1.0-alpha2 and the patch in #16 is not working. I get a lat and lon, but they're slightly off, about a mile or less.
Does no one else have this issue? I have a Street Number, Street, City, and Zip Code field, each are text fields with the corresponding field type assigned. I tried with and without a Country field.
When I enter the same address using a Postal field with a 'Generic' field type on the same node, I get the correct lat and lon.
For anyone who wants to test their coordinates without setting up a full map, here's something that help with that: http://itouchmap.com/latlong.html
Comment #23
cwithout commentedOops. Didn't mean to change the version
Comment #24
BenK commentedSubscribing
Comment #25
basvredelingThanks for all your pointers in this thread. I finally got it to work. I applied the computed field patch from #6. Then I ran a bulk update on a geocoded field generated from a computed field, which in turn was generated by multiple address cck text fields. I also used the snippet here: http://drupal.org/node/905814#comment-3513678
Comment #26
gagarine commentedhttp://drupal.org/project/addresses also work now with geocode can be an alternative...
Comment #27
henrrrik commentedAs an aside, I gave up on this approach and ended up writing Rules Geocoder to solve this problem on our sites.