我有问题.我想在 android 应用程序中获取谷歌地图上最近的点.不同的点/坐标存储在 sqlite 数据库中.我必须从他们那里得到最近的 5 个.我正在使用的查询是:
I've a problem. I want to get the nearest points on google map in android app. Different points/coordinates are stored in sqlite database. And I have to get the nearest 5 from them. The Query I'm using is:
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 5;
但我收到一个错误,即没有这样的功能:acos 存在".它的正确解决方案是什么
But I'm getting an error i.e. "no such function: acos exists". What will be its proper solution
SQLite 默认不支持任何三角函数,所以你不能在 SQL 查询中使用它们.
SQLite doesn't support any trigonometric functions by default, so you can't use them in SQL queries.
您可以获取坐标列表并在应用程序代码中处理它,或者您可以尝试使用用户定义的函数在 SQLite 中公开 Java 的三角函数(请参阅 如何在 SQLite 中创建用户定义函数?).
You can either fetch the list of coordinates and process it in application code, or you can try and expose Java's trigonometric functions in SQLite with user defined functions (see How can I create a user-defined function in SQLite?).
这篇关于不存在这样的 acos 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!