How to programmatically find a direction on a blackberry?

How to programmatically find directions on a blackberry using GPS?

+3
source share
3 answers

With GPS, the minimum resolution is 3 meters. If you take consistent GPS readings and look for significant changes in this direction, this will give you an approximate estimate of the direction of movement and, therefore, the probable direction that a person is facing.

This is not as good as having a magnetic compass, which currently has none of the Blackberry (Blackberrys?) On the market.

GPS- GPS, . , , GPS. GPS-. , , .

Blackberry API, GPS, , ( getCourse). 0.00, .

+3

GPS , . (, 1 ), , Blackberry, () .

Android- IIRC iPhone 3Gs . , , .

+1

The GPS API in java micro, which uses Blackberry, will give you the direction the phone is moving. Here is a snippet of the GPS class that extracts most of the basic GPS information:

/**
 * 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
    }
}
0
source

Source: https://habr.com/ru/post/1735016/


All Articles