Steps to reproduce:
1. Create a content type with some text field and Geospatial data field with "Latitude/Longtitude" widget.
2. Try after this to change the widget type to "Geocoded value from another field".
3. When trying to save the field settings, an error is shown: "Unable to parse WKT." and "The default value is invalid.".
The problem is in the validate code in geo_field.module:
// Convert to $wkt and validate it.
$wkt = $item['geo'];
if ($gis_input) {
$wkt = geo_value($wkt, 'wkt', $gis_input);
}
When changing the widget from "Latitude/Longtitude" to "Geocoded value from another field" widget, the $gis_input is empty and the geocoding doesn't take place.
On the other hand the $wkt in that case is an array (Array ( [lat] => [lon] => ) ) so it must be geocoded.
And since the $wkt is sent without been geocoded, the wkt_validate function returns an error.
One solution to this problem is to check if the $wkt is an array and to set the $gis_input if empty.
This is done by the patch I have attached. The patch is created against HEAD.
| Comment | File | Size | Author |
|---|---|---|---|
| geo_field.module.patch | 777 bytes | simosda |
Comments
Comment #1
gagarine commentedThis patch work perfectly for me thanks. I use http://drupal.org/project/addresses has the source to be geocoded.