package de.apps4ics.mountainnavigation.pois;

import org.osmdroid.bonuspack.location.POI;

/**
 * Created by Vinz on 06.10.2015.
 */
public class Poi {
    protected long _id;
    protected int _type;
    protected DbGeoPoint gp;
    protected long gpId;
    protected String infoFromOsm;

    public Poi() {
    }

    public Poi(POI p) {
        gp = new DbGeoPoint(p.mLocation);
        infoFromOsm = p.mCategory + ":" + p.mDescription + ":" + p.mType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Poi poi = (Poi) o;

        if (_id != poi._id) return false;
        if (_type != poi._type) return false;
        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) _id;
        result = 31 * result + _type;
        return result;
    }

    public long getGpId(){
        return gpId;
    }

    public DbGeoPoint getGp(){
        return gp;
    }

    public void setGpId(long gpId){
        this.gpId = gpId;
    }

    public void setGp(DbGeoPoint gp){
        this.gp = gp;
        this.gpId = gp.getId();
    }

    public Poi(int _type){
        this._type = _type;
    }

    public Poi(long _id, int _type){
        this._id = _id;
        this._type = _type;
    }

    public Poi(long _id, int _type, DbGeoPoint _gp){
        this(_id, _type);
        if(_gp != null){
            this.gp = _gp;
            this.gpId = _gp.getId();
        }
    }

    public void display() {
        //TODO display POI on map
    }

    public long getId(){
        return _id;
    }

    @Override
    public String toString() {
        return "Poi {" +
                "_id=" + _id +
                ", _type=" + _type +
                (infoFromOsm != null ? "infoFromOsm: " + infoFromOsm : "") +
                '}';
    }

    public int getType(){
        return _type;
    }

}
