2010-03-02 83 views
3

如何以編程方式在使用GPS的黑莓上查找方向?如何以編程方式在黑莓上查找方向?

+1

以編程方式? – 2010-03-02 09:26:13

+0

是。像北方的 。 – nicky 2010-03-02 09:27:29

+1

用戶所面對的方向或用戶所在的方向?他們是兩個不同的概念。 – 2010-03-02 09:35:51

回答

3

有了GPS,最低分辨率可達3米。如果您連續獲取GPS讀數並在給定方向上查找重大變化,則可以粗略估算出行進方向,從而確定該人面臨的可能方向。

這並不像擁有磁羅盤一樣好,目前市場上沒有黑莓(Blackberrys?)。

一些GPS系統有兩個GPS接收器以已知的方向彼此相鄰放置。他們可以根據比較兩個GPS讀數來計算單位面對的方向。他們稱之爲GPS指南針。此外,these systems太笨重,無法在手機中加入。

您可以使用Blackberry API來查找GPS信息,包括製作好的標題(getCourse方法)。它會給你一個0.00爲北的指南針讀數。

1

GPS數據不能給你指示,它只給你位置。如果你有兩個職位(比如你1秒前的位置和你現在的位置),包括黑莓在內的大多數實施將會爲你提供從一個點到另一個點的方向。

Android設備,和IIRC iPHone 3Gs,數字磁羅盤可以給你方向。我不相信有任何黑莓配備羅盤。

0

The GPS API在java micro中,Blackberry使用它將爲您提供手機的方向。這裏是GPS類的一個片段,它檢索大部分基本的GPS信息:

/** 
* This will start the GPS 
*/ 
public GPS() { 
    // Start getting GPS data 
    if (currentLocation()) { 
     // This is going to start to try and get me some data! 
    } 
} 

private boolean currentLocation() { 
    boolean retval = true; 
    try { 
     LocationProvider lp = LocationProvider.getInstance(null); 
     if (lp != null) { 
      lp.setLocationListener(new LocationListenerImpl(), interval, 1, 1); 
     } else { 
      // GPS is not supported, that sucks! 
      // Here you may want to use UiApplication.getUiApplication() and post a Dialog box saying that it does not work 
      retval = false; 
     } 
    } catch (LocationException e) { 
     System.out.println("Error: " + e.toString()); 
    } 

    return retval; 
} 

private class LocationListenerImpl implements LocationListener { 
    public void locationUpdated(LocationProvider provider, Location location) { 
     if (location.isValid()) { 
      heading = location.getCourse(); 
      longitude = location.getQualifiedCoordinates().getLongitude(); 
      latitude = location.getQualifiedCoordinates().getLatitude(); 
      altitude = location.getQualifiedCoordinates().getAltitude(); 
      speed = location.getSpeed(); 

      // This is to get the Number of Satellites 
      String NMEA_MIME = "application/X-jsr179-location-nmea"; 
      satCountStr = location.getExtraInfo("satellites"); 
      if (satCountStr == null) { 
       satCountStr = location.getExtraInfo(NMEA_MIME); 
      } 

      // this is to get the accuracy of the GPS Cords 
      QualifiedCoordinates qc = location.getQualifiedCoordinates(); 
      accuracy = qc.getHorizontalAccuracy(); 
     } 
    } 

    public void providerStateChanged(LocationProvider provider, int newState) { 
     // no-op 
    } 
} 
相關問題