Needs work
Project:
Geocoder
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 Feb 2012 at 20:45 UTC
Updated:
6 Mar 2018 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
phayes commentedI'e started working on this and have merged it into my private working copy. There's a lot of refactoring here (good stuff!), so it will require some additional modifications before I push it back to the main dev branch.
Comment #2
phayes commentedThis patch is badly broken. Allowing multiple fields is a good idea, but I it'll take a bit more time for me to implement properly.
Selecting multiple fields should be just like geocoding from a single-field with multiple deltas. Concatenate should merely be another option in the mutiiple-values handling option that is only valid for text-fields (and term-name fields etc).
Comment #3
phayes commentedP.S I'm still going to do this and re-factoring the widget processor into child functions was a good idea!
Comment #5
phayes commentedOkay, I've added concatenation support. Right now only support concatenation across deltas. Mult-field support will come later.
Note that if you need this functionality now you can use Computed Field: http://drupal.org/project/computed_field
Comment #6
phayes commentedComment #7
zerkalica commentedi think, mult-field support not compatible with joining, It's different behaviours:
Create many geometries for each multi-field value of one field
Create one geometry for concatenation result of all multi-fields and single-fields values
In my example taxonomy field is multifield, but street and number is a single-value fileds.
Computed field powerfull, but uses php, it's hard to configure for non-php users.
Needed something like field parsing strategy presets or options. Geocoder sends array of fields with values and receives concatenated string and pass this string to handler plugin.
Comment #8
phayes commentedSo I took a stab at this and basically came to the conclusion that working with heterogenous field-types is more or less going to be impossible. So I think the way we will solve this problem is to provide really good documentation and examples on how to use geocoder in combination with computed field (http://drupal.org/project/computed_field)
Comment #9
kurageart commentedwould like to read some documentation as soon as possible...
Currently , i would need to geocode a computed field composed by a taxonomy reference and a text field...
Comment #10
farald commentedHey! Why not solve this issue with tokens instead?
Let's say you have 2 options:
- Geocode from field
- Geocode from tokens
Comment #11
philippejadin commentedGeocode from tokens is a great idea. What the maintainers think ?
Comment #12
phayes commentedYeah, definitely like the geocode from tokens. It's the right way to solve this problem. I'm updating the ticket name to reflect it.
Comment #13
bartezz commentedAn example is much welcomed!
I have set it up with a computed field and told the geocode field to geocode from that particular computed field. The output from the computed field is correct and nicely comme separated. When I check the output of the computed field here I get different lat/long figures than thru geocode field. Looks like geocode field somehow points to the city center.
Cheers
Comment #14
bartezz commentedI've done some debugging and when I change line #241 in geocoder.widget.inc and comment out
// return FALSE;then my computed field is taken into account.Not sure if I need to open a new topic for a bug report?
Cheers
Comment #15
floretan commentedI think that geocoding from tokens is a good step, but it'd be great if we could (re-)use some of the rules module interface to load the geocoding data using the entity metadata api, making it possible to use either arbitrary entity fields/properties or to create a compound using tokens.
Comment #16
philippejadin commentedOk, it took me some time to figure out, but here some nformations to geocode using computed field. This will allow you to geocode from multiple separated fields.
Let's say you want to geocode from 3 fields, simply concatenated like this :
[street] [postal_code] [city]
- Install the computed field module
- install the entity api module (I didn't find a way to make it otherwise. Drupal api to access field values is pita without it. Read this for background : http://drupal.stackexchange.com/questions/24699/whats-best-practice-when...)
- add a computed field to your node type
- add the following code to the computed field :
Then setup geocoder to geocode from your new computed field. Save a test node with the fields correctly filled, and you should have your data correctly geocoded.
And voila !
Comment #17
semei commentedThank you, this works. But as Bartezz mentioned, this only works if you change line #241 in geocoder.widget.inc and comment out
// return FALSE;. Otherwise computed fields are not taken into account. Can this be done without having to worry about any other issues?Comment #18
rudyard55 commentedI'm interested in the answer for this also.
Comment #19
semei commentedI am now using rules to set the value of a certain text field upon creation/update of a node. That way I built my own computed field which can then be used for geocoding without having to mess with the module first.
Comment #20
rudyard55 commentedOk. I got that to work. Thank you for your help.
at this juncture, i'm operating on the premise that computed fields and geocoder are not compatible, because I've yet to see anything to contrary.
But using rules appears to work nicely.
Comment #21
philippejadin commentedI still think that token support would be much easier. The proposed solution I gave on #16 doesn't work anymore on -dev.
If I could put something like :
geocode from [adress-field], [postcode-field] [city-field], [coutry-field]
...using token, it would be a life saver. Curently I have no solution.
Comment #22
zmove commentedSame here, tested solution of #16 and commented the return false; line 241 of geocoder.widget.inc file and it doesn't work.
My computed field have the correct informations, but the geocoder field is still empty.
I looked to all posts about this issue that is quite old now and still doesn't found a decent solution ?
Do we have to abandon geofield + geocoder combination to the benefit of location that seems more maintained ?
Comment #23
philippejadin commentedThis is very unfortunate that this issue is still open. I don't have the skills to work on it, and I guess the maintainer is too busy with other projects, which is understandable.
This module is critical for the future of geo in drupal. Together with geofield, this is the right mix of modularity and functionality, where other approach failed.
Any hope here ? :-)
Comment #24
s427 commentedI found this discussion while searching for a solution for a similar problem. I have two fields, one for latitude and one for longitude, that are automatically populated with data extracted from images (via the exif module), and I need to bring those values together (in one field) so that the geocoder field can use it to display a map.
The solution I finally found is to use the Field default token module. This will allow you to use tokens as default value for any field when creating content.
Then you just need to create a new text field, and set its default value to use whatever value you need from other fields. In my case, the default value was : [file:field-gps-gpslatitude] / [file:field_gps_gpslongitude]
And finally, set the geocoder field to use this new field's value as its source.
The only problem (that I see) for this solution is that, since we're using tokens as a default value, the value of the new field is only automatically generated when the content is created. Not when the content is updated --then you would have to update the value of the new field manually. (It's not an issue in my case, though)
So it's a workaround, but I hope it helps someone.
Comment #25
rudiedirkx commentedComment #26
rudiedirkx commentedWhen (if) #2159925 gets in, you should use that instead of tokens. I gave it a go anyway. Try this on. It's funky and kinda messy, but it works perfectly, with multi value fields too.
It creates a new widget "Geocode from tokens", which replaces the "Geocode from field" setting with a "Geocode from tokens" textfield, where you could type "[user:field_addresses:postal-code] [user:field_addresses:country]" eg.
It probably won't work for taxonomy terms like this, because Taxonomy is weird: tokens are machine named "term" and the entity type is "taxonomy_term", or something like that, I don't remember and I didn't test with taxonomy.
Comment #27
nwom commentedWas really looking forward to using your patch, but it seems it is limited to nodes. On an entity bundles created via Redhen CRM, the fields are not shown.
In the meantime, I will create a computed field, instead of using your provided patch, but can't wait to use it if you decide to implement the functionality for entity bundles.
Comment #28
rudiedirkx commentedYou should use #2159925: Geocode from virtual fields/entity property instead of just real fields to geocode from an entity property.
Comment #29
polYou forgot a dpm
Can you reroll the patch without the debug function ?
Thanks.
Comment #32
Koen.Pasman commentedI rerolled the patch to apply and work versus the latest 7.x-1.x branch for people who dont want to upgrade to 7.x-2.x.
Regarding the patch, some code improvements can be made I think, since I have no idea what the for() loop on line 232 is supposed to do.
Comment #33
polHi,
I really like the idea to geocode from token, but I also would like to have information on the for loop in the code.
Comment #34
nwom commented#32 still works and is in-use in my live environment without problems. @Pol, did you perhaps mean to change this to "Needs Work" based on your comment?