<commit_before>package cgeo.geocaching.sensors;

import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.utils.Log;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;

public class GeoData extends Location {

    public static final String INITIAL_PROVIDER = "initial";
    public static final String FUSED_PROVIDER = "fused";
    public static final String LOW_POWER_PROVIDER = "low-power";

    // Some devices will not have the last position available (for example the emulator). In this case,
    // rather than waiting forever for a position update which might never come, we emulate it by placing
    // the user arbitrarly at Paris Notre-Dame, one of the most visited free tourist attractions in the world.
    final public static GeoData DUMMY_LOCATION = new GeoData(new Location(INITIAL_PROVIDER));

    static {
        DUMMY_LOCATION.setLatitude(48.85308);
        DUMMY_LOCATION.setLongitude(2.34962);
    }

    public GeoData(final Location location) {
        super(location);
    }

    @Nullable
    static Location best(@Nullable final Location gpsLocation, @Nullable final Location netLocation) {
        if (netLocation == null || (gpsLocation != null && System.currentTimeMillis() <= gpsLocation.getTime() + 30000)) {
            return gpsLocation;
        }
        if (gpsLocation == null) {
            return netLocation;
        }
        return gpsLocation.getTime() >= netLocation.getTime() ? gpsLocation : netLocation;
    }

    private static LocationProviderType getLocationProviderType(final String provider) {
        if (provider.equals(LocationManager.GPS_PROVIDER)) {
            return LocationProviderType.GPS;
        }
        if (provider.equals(LocationManager.NETWORK_PROVIDER)) {
            return LocationProviderType.NETWORK;
        }
        // LocationManager.FUSED_PROVIDER constant is not available at API level 9
        if (provider.equals(FUSED_PROVIDER)) {
            return LocationProviderType.FUSED;
        }
        if (provider.equals(LOW_POWER_PROVIDER)) {
            return LocationProviderType.LOW_POWER;
        }
        return LocationProviderType.LAST;
    }

    public LocationProviderType getLocationProvider() {
        return getLocationProviderType(getProvider());
    }

    @NonNull
    public Geopoint getCoords() {
        return new Geopoint(this);
    }

    @Nullable
    public static GeoData getInitialLocation(final Context context) {
        final LocationManager geoManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        if (geoManager == null) {
            Log.w("No LocationManager available");
            return null;<commit_msg>Inline once-used private method GeoData.getLocationProvider<commit_after>package cgeo.geocaching.sensors;

import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.utils.Log;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;

public class GeoData extends Location {

    public static final String INITIAL_PROVIDER = "initial";
    public static final String FUSED_PROVIDER = "fused";
    public static final String LOW_POWER_PROVIDER = "low-power";

    // Some devices will not have the last position available (for example the emulator). In this case,
    // rather than waiting forever for a position update which might never come, we emulate it by placing
    // the user arbitrarly at Paris Notre-Dame, one of the most visited free tourist attractions in the world.
    final public static GeoData DUMMY_LOCATION = new GeoData(new Location(INITIAL_PROVIDER));

    static {
        DUMMY_LOCATION.setLatitude(48.85308);
        DUMMY_LOCATION.setLongitude(2.34962);
    }

    public GeoData(final Location location) {
        super(location);
    }

    @Nullable
    static Location best(@Nullable final Location gpsLocation, @Nullable final Location netLocation) {
        if (netLocation == null || (gpsLocation != null && System.currentTimeMillis() <= gpsLocation.getTime() + 30000)) {
            return gpsLocation;
        }
        if (gpsLocation == null) {
            return netLocation;
        }
        return gpsLocation.getTime() >= netLocation.getTime() ? gpsLocation : netLocation;
    }

    public LocationProviderType getLocationProvider() {
        switch (getProvider()) {
            case LocationManager.GPS_PROVIDER:
                return LocationProviderType.GPS;
            case LocationManager.NETWORK_PROVIDER:
                return LocationProviderType.NETWORK;
            case FUSED_PROVIDER:
                // LocationManager.FUSED_PROVIDER constant is not available at API level 9
                return LocationProviderType.FUSED;
            case LOW_POWER_PROVIDER:
                return LocationProviderType.LOW_POWER;
            default:
                return LocationProviderType.LAST;
        }
    }

    @NonNull
    public Geopoint getCoords() {
        return new Geopoint(this);
    }

    @Nullable
    public static GeoData getInitialLocation(final Context context) {
        final LocationManager geoManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        if (geoManager == null) {
            Log.w("No LocationManager available");
            return null;
{'fraction_non_alphanumeric': 0.07682551186809204, 'fraction_numerical': 0.006885305308932777, 'mean_word_length': 3.0029006526468454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1780249', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1452, 'n_words': 400}