package de.apps4ics.mountainnavigation.pois;

import org.osmdroid.bonuspack.location.POI;

/**
 * This file is part of MountainNavigation.
 *
 * MountainNavigation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MountainNavigation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MountainNavigation.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @copyright Copyright (c) 2016 Vinzenz Rosenkanz <vinzenz.rosenkranz@gmail.com>
 *
 * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
 */
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;
    }

}
