Search by geographic address in Mapping module throws error

Among the search options that appear under the browse map (the one that appears at /map-browse of one’s website), there is a nice one called “Geographic address”. Then you have radius, and radius unit.

This looks interesting, but I don’t seem to be able to get this to work.

First, I don’t quite understand in which format I am supposed to give that “geographic address”. I suppose it’s decimal lat/lon, so I’d input, e.g. 48.2083537, 16.3725042 for Vienna, in Austria

If I then input a radius and hit search, I invariably get an error.

I couldn’t find any reference about the expected “geographic address” format (perhaps a quick hint below “Geographic address” would be useful), but anyway, this seems to be unrelated

Here’s the whole error message.

Any suggestion for troubleshooting further?

This is on an installation of Omeka S 3.0.1 (updated from an Omeka S 2), with the latest 1.4.0 version of the Mapping module (for the records, it didn’t work on my previous Omeka S 2 either, but that already does not matter)


Omeka S encountered an error

Doctrine\ORM\Query\QueryException
[Semantical Error] line 0, col 148 near 'distance <= ': Error: 'distance' is not defined.

Details:

Doctrine\ORM\Query\QueryException: SELECT 1 FROM Mapping\Entity\MappingMarker omeka_root INNER JOIN omeka_root.item omeka_0 WITH omeka_0.id IN(:omeka_1) GROUP BY omeka_root.id HAVING distance <= :omeka_4 in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:43
Stack trace:
#0 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(492): Doctrine\ORM\Query\QueryException::dqlError('SELECT 1 FROM M...')
#1 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(594): Doctrine\ORM\Query\Parser->semanticalError('line 0, col 148...', Array)
#2 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(265): Doctrine\ORM\Query\Parser->processDeferredIdentificationVariables()
#3 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(360): Doctrine\ORM\Query\Parser->getAST()
#4 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(286): Doctrine\ORM\Query\Parser->parse()
#5 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(298): Doctrine\ORM\Query->_parse()
#6 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(992): Doctrine\ORM\Query->_doExecute()
#7 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(947): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, 3)
#8 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(774): Doctrine\ORM\AbstractQuery->execute(NULL, 3)
#9 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php(125): Doctrine\ORM\AbstractQuery->getScalarResult()
#10 /var/www/html/application/src/Api/Adapter/AbstractEntityAdapter.php(310): Doctrine\ORM\Tools\Pagination\Paginator->count()
#11 /var/www/html/application/src/Api/Manager.php(221): Omeka\Api\Adapter\AbstractEntityAdapter->search(Object(Omeka\Api\Request))
#12 /var/www/html/application/src/Api/Manager.php(59): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#13 /var/www/html/application/src/Mvc/Controller/Plugin/Api.php(63): Omeka\Api\Manager->search('mapping_markers', Array, Array)
#14 /var/www/html/volume/modules/Mapping/src/Controller/Site/IndexController.php(42): Omeka\Mvc\Controller\Plugin\Api->search('mapping_markers', Array)
#15 /var/www/html/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(77): Mapping\Controller\Site\IndexController->browseAction()
#16 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch(Object(Laminas\Mvc\MvcEvent))
#17 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#18 /var/www/html/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(103): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#19 /var/www/html/vendor/laminas/laminas-mvc/src/DispatchListener.php(139): Laminas\Mvc\Controller\AbstractController->dispatch(Object(Laminas\Http\PhpEnvironment\Request), Object(Laminas\Http\PhpEnvironment\Response))
#20 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch(Object(Laminas\Mvc\MvcEvent))
#21 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#22 /var/www/html/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#23 /var/www/html/index.php(21): Laminas\Mvc\Application->run()
#24 {main}

Next Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 148 near 'distance <= ': Error: 'distance' is not defined. in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:65
Stack trace:
#0 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(492): Doctrine\ORM\Query\QueryException::semanticalError('line 0, col 148...', Object(Doctrine\ORM\Query\QueryException))
#1 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(594): Doctrine\ORM\Query\Parser->semanticalError('line 0, col 148...', Array)
#2 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(265): Doctrine\ORM\Query\Parser->processDeferredIdentificationVariables()
#3 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(360): Doctrine\ORM\Query\Parser->getAST()
#4 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(286): Doctrine\ORM\Query\Parser->parse()
#5 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(298): Doctrine\ORM\Query->_parse()
#6 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(992): Doctrine\ORM\Query->_doExecute()
#7 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(947): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, 3)
#8 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(774): Doctrine\ORM\AbstractQuery->execute(NULL, 3)
#9 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php(125): Doctrine\ORM\AbstractQuery->getScalarResult()
#10 /var/www/html/application/src/Api/Adapter/AbstractEntityAdapter.php(310): Doctrine\ORM\Tools\Pagination\Paginator->count()
#11 /var/www/html/application/src/Api/Manager.php(221): Omeka\Api\Adapter\AbstractEntityAdapter->search(Object(Omeka\Api\Request))
#12 /var/www/html/application/src/Api/Manager.php(59): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#13 /var/www/html/application/src/Mvc/Controller/Plugin/Api.php(63): Omeka\Api\Manager->search('mapping_markers', Array, Array)
#14 /var/www/html/volume/modules/Mapping/src/Controller/Site/IndexController.php(42): Omeka\Mvc\Controller\Plugin\Api->search('mapping_markers', Array)
#15 /var/www/html/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(77): Mapping\Controller\Site\IndexController->browseAction()
#16 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch(Object(Laminas\Mvc\MvcEvent))
#17 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#18 /var/www/html/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(103): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#19 /var/www/html/vendor/laminas/laminas-mvc/src/DispatchListener.php(139): Laminas\Mvc\Controller\AbstractController->dispatch(Object(Laminas\Http\PhpEnvironment\Request), Object(Laminas\Http\PhpEnvironment\Response))
#20 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch(Object(Laminas\Mvc\MvcEvent))
#21 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#22 /var/www/html/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#23 /var/www/html/index.php(21): Laminas\Mvc\Application->run()
#24 {main}


This is a @Daniel_KM module but (I think) the problem is that the alias distance is referenced in the HAVING clause, but in standard SQL logic the HAVING clause is evaluated before the SELECT clause. So, when the HAVING clause is evaluated, distance has not yet been defined. I confirmed this by moving the the Haversine formula that calculates the distance of markers into the having clause and then it works.

@Daniel_KM don’t fully understand how this was originally working with HAVING, but my solution in the end was to put the Haversine formula in a WHERE clause. I can submit a pull request if that is a solution you are interested in. I don’t know what kind of performance impact it would have but it does seem to work.

And @giocomai to answer your other question, you can input a regular address or lat/long coordinates. If you input an address then the module will use http://nominatim.openstreetmap.org/search to attempt to find the coordinates.

1 Like

Thanks for the clear explanation! And good to know about the integrated Nominatim lookup.

On the GitHub repo of the mapping module I see commits mostly by @jimsafley and @jflatnes, but anyway I suppose this will have to wait until everyone’s back from the Winter break.

Oh, you know what I have been working from Daniel_KM’s fork and I had forgotten that it was actually a core module. But it looks like the same issue is affecting the upstream, core version.

2 Likes

I can also reproduce the bug. @IOPNdev is correct that the distance alias does not exist when the HAVING clause is evaluated. This is due to an optimization change in Omeka that strips all columns from the SELECT clause when calculating the total count.

We should move discussion to the GitHub issue.

1 Like

Just for information, I don’t do a fork of Mapping. This is just a github fork: this is the way to suggest a fix on Github.

Thanks, @Daniel_KM. Yeah, I don’t know why I had it in my head that this was one of yours.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.