1 / 9

第四組 停車場搜尋系統

第四組 停車場搜尋系統. 第四組 溫允中 陳欣暉 蕭積遠 李雅俐. 本週進度 20111024. 使用 MySQL 尋找鄰近的地點. 如果要在我們  markers  表格中尋找特定經、緯半徑距離內的地點,您可以使用包含半正矢公式 (Haversine Formula) 的  SELECT  陳述式。半正矢公式一般是用於計算一個球體上兩組座標之間的大圓距離。 維基百科 中提供較為深入的數學說明,另外  Movable Type 網站提供與程式設計有關的討論。

chelsa
Download Presentation

第四組 停車場搜尋系統

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第四組 停車場搜尋系統 第四組 溫允中 陳欣暉 蕭積遠 李雅俐

  2. 本週進度 20111024

  3. 使用 MySQL 尋找鄰近的地點 • 如果要在我們 markers 表格中尋找特定經、緯半徑距離內的地點,您可以使用包含半正矢公式 (Haversine Formula) 的 SELECT 陳述式。半正矢公式一般是用於計算一個球體上兩組座標之間的大圓距離。維基百科中提供較為深入的數學說明,另外 Movable Type 網站提供與程式設計有關的討論。 • 以下的 SQL 陳述式會尋找距離座標 (37, -122) 半徑距離 25 英哩之內最接近的 20 個地點。它會計算該資料列的經、緯度以及目標經、緯度之間的距離,然後要求距離值小於 25 的資料列,根據近到遠排列整個查詢並限制傳回 20 筆結果。如果要按照公里數而不是英哩數進行搜尋,可以將 3959 換成 6371。 • 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;

More Related