package com.mogo.cloud.location;

import com.elegant.spi.annotations.Service;
import com.mogo.cloud.location.third.core.LocationServiceProvider;

@Service(value = LocationServiceProvider.class)
public class MogoLocationSource extends LocationServiceProvider {

    @Override
    public float getBearing() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getBearing();
        }
        return 0;
    }

    @Override
    public float getAccuracy() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getAccuracy();
        }
        return 0;
    }

    @Override
    public String getProvider() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getProvider();
        }
        return null;
    }

    @Override
    public float getSpeed() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getSpeed();
        }
        return 0;
    }

    @Override
    public double getAltitude() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getAltitude();
        }
        return 0;
    }

    @Override
    public String getAdCode() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getAdCode();
        }
        return null;
    }

    @Override
    public int getLocType() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getLocType();
        }
        return 0;
    }

    @Override
    public double getLatitude() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getLatitude();
        }
        return 0;
    }

    @Override
    public double getLongitude() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getLongitude();
        }
        return 0;
    }

    @Override
    public long getTime() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getTime();
        }
        return 0;
    }

    @Override
    public String getCityCode() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getCityCode();
        }
        return null;
    }

    @Override
    public String getCityName() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getCityName();
        }
        return null;
    }

    @Override
    public int getGpsAccuracyStatus() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getGpsAccuracyStatus();
        }
        return 0;
    }

    @Override
    public int getSatellites() {
        if (MogoLocationInfoServices.getInstance().getLocation() != null) {
            return MogoLocationInfoServices.getInstance().getLocation().getSatellite();
        }
        return 0;
    }

    @Override
    public int getCarStatus() {
        // 常开状态
        return 1;
    }
}
