问题描述
我有问题.我想在 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 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)