Example usage for android.location Location FORMAT_DEGREES

List of usage examples for android.location Location FORMAT_DEGREES

Introduction

In this page you can find the example usage for android.location Location FORMAT_DEGREES.

Prototype

int FORMAT_DEGREES

To view the source code for android.location Location FORMAT_DEGREES.

Click Source Link

Document

Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.DDDDD where D indicates degrees.

Usage

From source file:com.nextgis.ngm_clink_monitoring.fragments.StatusBarFragment.java

@Override
public void onLocationChanged(Location location) {
    if (location == null) {
        return;//from  www  . ja  v a 2s . c om
    }

    GISApplication app = (GISApplication) getActivity().getApplication();
    app.setCurrentLocation(location);
    mLastLocationMillis = SystemClock.elapsedRealtime();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    int nFormat = prefs.getInt(FoclSettingsConstantsUI.KEY_PREF_COORD_FORMAT + "_int", Location.FORMAT_DEGREES);

    mLatText = FoclLocationUtil.formatLatitude(location.getLatitude(), nFormat, getResources())
            + getString(R.string.coord_lat);

    mLongText = FoclLocationUtil.formatLongitude(location.getLongitude(), nFormat, getResources())
            + getString(R.string.coord_lon);

    DecimalFormat df = new DecimalFormat("0");

    double altitude = location.getAltitude();
    mAltText = df.format(altitude) + getString(R.string.altitude_unit);

    float accuracy = location.getAccuracy();
    mAccText = df.format(accuracy) + getString(R.string.accuracy_unit);

    // TODO: prevPointLocation
    Location prevPointLocation = new Location("");
    prevPointLocation.setLatitude(9);
    prevPointLocation.setLongitude(36);
    float distance = location.distanceTo(prevPointLocation);

    mDistText = df.format(distance) + getString(R.string.distance_unit);
    mDistView.setTextColor(distance > FoclConstants.MAX_DISTANCE_FROM_PREV_POINT ? 0xFF880000 : 0xFF008800);

    if (isVisible()) {
        setLocationViewsText();
    }
}

From source file:com.nextgis.firereporter.ScanexNotificationItem.java

public String formatLat(double lat) {
    return formatLat(lat, Location.FORMAT_DEGREES);
}

From source file:com.nextgis.firereporter.ScanexNotificationItem.java

public String formatLng(double lng) {
    return formatLng(lng, Location.FORMAT_DEGREES);
}

From source file:com.nextgis.uikobserver.MainActivity.java

public String formatLon(double lng) {
    return formatLon(lng, Location.FORMAT_DEGREES);
}

From source file:com.nextgis.forestinspector.fragment.MapFragment.java

@Override
public void onResume() {
    super.onResume();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    boolean showControls = prefs.getBoolean(SettingsConstants.KEY_PREF_SHOW_ZOOM_CONTROLS, false);
    showMapButtons(showControls, mMapRelativeLayout);

    Log.d(Constants.TAG, "KEY_PREF_SHOW_ZOOM_CONTROLS: " + (showControls ? "ON" : "OFF"));

    if (null != mMap) {
        float mMapZoom;
        try {// w w  w  .ja v a  2s  . c o m
            mMapZoom = prefs.getFloat(SettingsConstants.KEY_PREF_ZOOM_LEVEL, mMap.getMinZoom());
        } catch (ClassCastException e) {
            mMapZoom = mMap.getMinZoom();
        }

        double mMapScrollX;
        double mMapScrollY;
        try {
            mMapScrollX = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_X, 0));
            mMapScrollY = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_Y, 0));
        } catch (ClassCastException e) {
            mMapScrollX = 0;
            mMapScrollY = 0;
        }
        mMap.setZoomAndCenter(mMapZoom, new GeoPoint(mMapScrollX, mMapScrollY));

        mMap.addListener(this);
    }

    mCoordinatesFormat = prefs.getInt(SettingsConstants.KEY_PREF_COORD_FORMAT + "_int",
            Location.FORMAT_DEGREES);

    if (null != mCurrentLocationOverlay) {
        mCurrentLocationOverlay.updateMode(PreferenceManager.getDefaultSharedPreferences(getActivity())
                .getString(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC, "3"));
        mCurrentLocationOverlay.startShowingCurrentLocation();
    }
    if (null != mGpsEventSource) {
        mGpsEventSource.addListener(this);
    }

    mShowStatusPanel = prefs.getBoolean(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL, true);

    if (null != mStatusPanel) {
        if (mShowStatusPanel) {
            mStatusPanel.setVisibility(View.VISIBLE);
            fillStatusPanel(null);
        } else {
            mStatusPanel.removeAllViews();
        }
    }

    mCurrentCenter = null;
}

From source file:com.nextgis.mobile.fragment.AttributesFragment.java

protected String formatCoordinates(GeoPoint pt) {
    pt.setCRS(CRS_WEB_MERCATOR);//from  w  ww  . j ava2s . c o m
    pt.project(CRS_WGS84);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    int format = Integer
            .parseInt(prefs.getString(SettingsConstantsUI.KEY_PREF_COORD_FORMAT, Location.FORMAT_DEGREES + ""));
    int fraction = prefs.getInt(SettingsConstantsUI.KEY_PREF_COORD_FRACTION, 6);

    String lat = getString(com.nextgis.maplibui.R.string.latitude_caption_short) + ": "
            + LocationUtil.formatLatitude(pt.getY(), format, fraction, getResources());
    String lon = getString(com.nextgis.maplibui.R.string.longitude_caption_short) + ": "
            + LocationUtil.formatLongitude(pt.getX(), format, fraction, getResources());

    return lat + "<br \\>" + lon;
}

From source file:com.nextgis.ngm_clink_monitoring.fragments.CreateObjectFragment.java

protected void setCoordinatesText() {
    if (null != mAccurateLocation) {

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

        int nFormat = prefs.getInt(FoclSettingsConstantsUI.KEY_PREF_COORD_FORMAT + "_int",
                Location.FORMAT_DEGREES);

        String latText = getString(R.string.latitude_caption) + " "
                + FoclLocationUtil.formatLatitude(mAccurateLocation.getLatitude(), nFormat, getResources())
                + getString(R.string.coord_lat);

        String longText = getString(R.string.longitude_caption) + " "
                + FoclLocationUtil.formatLongitude(mAccurateLocation.getLongitude(), nFormat, getResources())
                + getString(R.string.coord_lon);

        mCoordinates.setText(latText + ",  " + longText);

        if (FoclConstants.LAYERTYPE_FOCL_REAL_OPTICAL_CABLE_POINT == mFoclStructLayerType) {
            mDistance = getMinDistanceFromPrevPoints(getActivity(), mObjectLayerName, mAccurateLocation);
            mDistanceFromPrevPoint.setText(getDistanceText(getActivity(), mDistance));
            mDistanceFromPrevPoint.setTextColor(getDistanceTextColor(mDistance));
        }/*  w ww .  j  a v a2 s. c  o  m*/

    } else {
        mDistance = null;
        mCoordinates.setText(getText(R.string.coordinates_not_defined));
        //            mCoordinates.setGravity(Gravity.CENTER);
        mDistanceFromPrevPoint.setText("---");
        mDistanceFromPrevPoint.setTextColor(getResources().getColor(R.color.selected_object_text_color));
    }
}

From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java

private String formatCoordinates(double value, int caption) {
    String appendix;/*from  ww  w.  j a  v  a  2 s . c o m*/
    if (value != Double.NaN) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        int nFormat = Integer.parseInt(
                prefs.getString(SettingsConstantsUI.KEY_PREF_COORD_FORMAT, Location.FORMAT_DEGREES + ""));
        int nFraction = prefs.getInt(SettingsConstantsUI.KEY_PREF_COORD_FRACTION, 6);
        appendix = LocationUtil.formatLatitude(value, nFormat, nFraction, getResources());
    } else
        appendix = getString(R.string.n_a);

    return getString(caption) + ": " + appendix;
}

From source file:com.nextgis.mobile.fragment.MapFragment.java

@Override
public void onResume() {
    super.onResume();

    boolean showControls = mPreferences.getBoolean(KEY_PREF_SHOW_ZOOM_CONTROLS, false);
    showMapButtons(showControls, mMapRelativeLayout);

    if (Constants.DEBUG_MODE)
        Log.d(Constants.TAG, "KEY_PREF_SHOW_ZOOM_CONTROLS: " + (showControls ? "ON" : "OFF"));

    showControls = mPreferences.getBoolean(KEY_PREF_SHOW_SCALE_RULER, true);
    if (showControls)
        mScaleRulerLayout.setVisibility(View.VISIBLE);
    else/*from w  w w  .j av a  2s  . c  o m*/
        mScaleRulerLayout.setVisibility(View.GONE);

    showControls = mPreferences.getBoolean(KEY_PREF_SHOW_MEASURING, false);
    if (showControls)
        mRuler.setVisibility(View.VISIBLE);
    else
        mRuler.setVisibility(View.GONE);

    if (null != mMap) {
        mMap.getMap().setBackground(mApp.getMapBackground());
        mMap.addListener(this);
    }

    String coordinatesFormat = mPreferences.getString(SettingsConstantsUI.KEY_PREF_COORD_FORMAT,
            Location.FORMAT_DEGREES + "");
    if (FileUtil.isIntegerParseInt(coordinatesFormat))
        mCoordinatesFormat = Integer.parseInt(coordinatesFormat);
    else
        mCoordinatesFormat = Location.FORMAT_DEGREES;
    mCoordinatesFraction = mPreferences.getInt(SettingsConstantsUI.KEY_PREF_COORD_FRACTION, 6);

    if (null != mCurrentLocationOverlay) {
        mCurrentLocationOverlay
                .updateMode(mPreferences.getString(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC, "3"));
        mCurrentLocationOverlay.startShowingCurrentLocation();
    }
    if (null != mGpsEventSource) {
        mGpsEventSource.addListener(this);
        if (mGPSDialog == null || !mGPSDialog.isShowing())
            mGPSDialog = NotificationHelper.showLocationInfo(getActivity());
    }
    if (null != mEditLayerOverlay) {
        mEditLayerOverlay.addListener(this);
    }

    try {
        String statusPanelModeStr = mPreferences.getString(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL, "0");
        if (FileUtil.isIntegerParseInt(statusPanelModeStr))
            mStatusPanelMode = Integer.parseInt(statusPanelModeStr);
        else
            mStatusPanelMode = 0;
    } catch (ClassCastException e) {
        mStatusPanelMode = 0;
        if (Constants.DEBUG_MODE)
            Log.d(Constants.TAG,
                    "Previous version of KEY_PREF_SHOW_STATUS_PANEL of bool type. Let set it to 0");
    }

    if (null != mStatusPanel) {
        if (mStatusPanelMode != 0) {
            mStatusPanel.setVisibility(View.VISIBLE);
            fillStatusPanel(null);

            if (mMode != MODE_NORMAL && mStatusPanelMode != 3)
                mStatusPanel.setVisibility(View.INVISIBLE);
        } else {
            mStatusPanel.removeAllViews();
        }

        setMarginsToPanel();
    }

    boolean showCompass = mPreferences.getBoolean(KEY_PREF_SHOW_COMPASS, true);
    checkCompass(showCompass);

    mCurrentCenter = null;
}