performant-software / Neatline

A lightweight framework for building interactive maps and publishing them on the web.
www.neatline.org
Other
105 stars 34 forks source link

Unable to save Neatline item without geometry... #379

Open mikesname opened 8 years ago

mikesname commented 8 years ago

Using Neatline 2.5.1 with Omeka 2.3.1 on Mysql 5.7.10 and am unable to save a Neatline item unless I have added geometry. My logs show this error:

2016-01-07T14:58:30+00:00 ERR (3): exception 'Zend_Db_Statement_Mysqli_Exception' with message 'Mysqli statement execute error : Invalid GIS data provided to function st_geometryfromtext.' in /var/www/html/omeka/application/libraries/Zend/Db/Statement/Mysqli.php:214
Stack trace:
#0 /var/www/html/omeka/application/libraries/Zend/Db/Statement.php(303): Zend_Db_Statement_Mysqli->_execute(Array)
#1 /var/www/html/omeka/application/libraries/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#2 /var/www/html/omeka/plugins/Neatline/models/abstract/Neatline_Row_Abstract.php(170): Zend_Db_Adapter_Abstract->query('INSERT INTO `om...', Array)
#3 /var/www/html/omeka/plugins/Neatline/models/abstract/Neatline_Row_Abstract.php(111): Neatline_Row_Abstract->insertOrUpdate(Array)
#4 /var/www/html/omeka/plugins/Neatline/models/abstract/Neatline_Row_Expandable.php(75): Neatline_Row_Abstract->save(false)
#5 /var/www/html/omeka/plugins/Neatline/models/NeatlineRecord.php(319): Neatline_Row_Expandable->save()
#6 /var/www/html/omeka/plugins/Neatline/models/NeatlineRecord.php(139): NeatlineRecord->save()
#7 /var/www/html/omeka/plugins/Neatline/controllers/RecordsController.php(58): NeatlineRecord->saveForm(Array)
#8 /var/www/html/omeka/application/libraries/Zend/Controller/Action.php(516): Neatline_RecordsController->postAction()
#9 /var/www/html/omeka/application/libraries/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch('postAction')
#10 /var/www/html/omeka/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#11 /var/www/html/omeka/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
#12 /var/www/html/omeka/application/libraries/Zend/Application.php(382): Zend_Application_Bootstrap_Bootstrap->run()
#13 /var/www/html/omeka/application/libraries/Omeka/Application.php(79): Zend_Application->run()
#14 /var/www/html/omeka/index.php(23): Omeka_Application->run()
#15 {main}

The workaround appears to be to draw, e.g. a point on the map, at which point it will save okay. This is however, more of a problem for my users who want to import Neatline items via CSV.

On investigation it appears that Mysql 5.6.27 the expression GeomFromText('') returns NULL, whereas on 5.7.10 it throws ERROR 3037 (22023): Invalid GIS data provided to function st_geometryfromtext instead.

I have temporarily hacked my instance of the plugin to fix this my changing nl_setGeometry in helpers/Mysql.php like so:

function nl_setGeometry($coverage)
{
    $coverage_or_default = $coverage ?: "POINT(0 0)";
    return new Zend_Db_Expr("COALESCE(
        GeomFromText('{$coverage_or_default}'), GeomFromText('POINT(0 0)')
    )");
 }

This will still fail with invalid geometry (and the user won't know why) so I'm sure there's a better solution.

erochest commented 8 years ago

Thanks for the report. Hopefully I'll have a chance to look at this issue this afternoon.