English 中文(简体)
对地处附近的物品进行修饰?
原标题:Querying for things near a geolocation?

我有疑问,试图在某个地处找到事情,但是,它带来的结果是微乎其微的。

此前,我已经张贴了这一版面,社区帮助我找到了一个我所需要的公式:的纬度和纬度范围内,但现在的询问确实取得了令人沮丧的结果。

我的数据围绕着旧金山市,该城市有编号/编号<37.780182、-122.5173<49/code>。

<>质量:

SELECT
    id,
    hike_title,
    lat,
    lng,
    ( 3959 * acos(  cos( radians(37) )
                  * cos( radians( lat ) )
                  * cos( radians( lng ) - radians(37.780182) )
                  + sin( radians(-122.517349) ) * sin( radians( lat ) )
                 )
    ) AS distance
FROM
    my_awesome_table
HAVING
    distance < 10000
ORDER BY
    distance
LIMIT
    0 , 50

因此,正如你所看到的那样,即使我做了10 000篇大事,但我还是想到,我的问候是否消失了。 由此得出的一些结果甚至有0,0分/升,这是我用来表示这一记录没有相对/升。

这里,该公式应如何看待:

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 , 20;

感谢你们,并对痛苦的漫长问题表示担忧! 顺便提一下,我是利用我的SQL。


Hmmm,

我刚刚用你给出的准确询问进行了审判,并做了50%的准确工作。 这里的数据集样本:

    lat          lng    
| 37.223465 | -122.090363 |
| 39.320980 | -111.093735 |
| 38.031715 |  -84.495132 |
| 37.787144 | -122.493263 |
| 52.975361 |   -1.458620 |
| 40.848557 | -111.906883 |
| 40.572498 | -111.859718 |

因此,现在该询问还回去了几英里以外但距离100英里以外的所有物项。 同该项目(37.7144,122.493263)一样,即使距离原产地约50英里,也从未返回。 你们会知道为什么?

最佳回答

我认为,你推翻了你的核心位置(37.780182)和长途(122.517349),试图:

select
    id,
    hike_title,
    lat,
    lng,
    ( 3959 * acos(  cos( radians(37) )
                  * cos( radians( lat ) )
                  * cos( radians( lng ) - radians(-122.517349) )
                  + sin( radians(37.780182) ) * sin( radians( lat ) )
                 )
    ) AS distance
FROM
    my_awesome_table
HAVING
    distance < 10000
ORDER BY
    distance
LIMIT
    0 , 50
问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签