Trying to save a point with a high degree of accuracy, eg: POINT (-0.048065185546875 0.17715425874914836)
Causes a PDOException: in field_sql_storage_field_storage_write() .
Investigating the actual exception message reveals:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_location_geohash' at row 1
Turns out the above point generates the following geohash: ebpcnbhzzzzyrfpgzcxzrfxy which is 24chars long. Geofield's geohash column is limited to 16 characters.
Geofield should probably either be more lenient about geohash lengths or do some simplification before calculating the geohash to ensure its not trying to save data that excedes 16 chars.
Comments
Comment #1
tnightingale commentedChatted with phayes on IRC. He determined that a 16char geohash is accurate to the size of a dust mite and that it is safe to truncate geohashes to 16 chars. Here is a patch that does so.
Comment #2
tnightingale commentedComment #3
Brandonian commentedYeah, but we're all going to feel really dumb in a few months when somebody wants to accurately map the location of individual molecules... :-)
Commited. Nice work, @tnightingale.
http://drupalcode.org/project/geofield.git/commit/103c6cf
Comment #4
cesareaugusto commentedI got a similar failure error when update.php to the Nov 16th dev. After that first attempt, every db update I do it says I got a pending update:
Applying the update I got this geofield module message
Comment #5
mkostir commentedHi guys,
I have exactly the same problem as #4.
Comment #6
phayes commentedComment #7
cesareaugusto commentedDid someone find any solution?
Comment #8
dwadson commentedThe patch truncastes the existing geohash value to GEOFIELD_GEOHASH_LENGTH before populating the geohash column, which prevents the initial failure on updating.
The second error in #4 can be resolved by getting rid of the geohash field that the failed update added:
Comment #9
cesareaugusto commentedHow could I do that in PHPMyAdmin?
Comment #10
dwadson commentedTry this patch - it will delete the _geohash column if it already exists (from the original failed update).
Comment #11
Brandonian commentedThanks for the patch, @dwadson. I applied the patch from #8 (along with a followup modification for a typo introduced).
http://drupalcode.org/project/geofield.git/commit/e2ff6aa
Comment #12
cesareaugusto commented@dwadson to which version should I apply your patch? I just upgraded to the latest alpha2, but the update error is still here!
To fix it should I just delete the field_posizione_geohash field within the field_data_field_posizione and field_revision_field_posizionedrop tables?
Comment #13
dwadson commentedYes, the #8 patch got committed, not the #10 patch which only tries to add the _geohash column if it doesn't exist.
Yes, delete that field and then update.