package com.kuartz.gps;

import android.location.Location;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.kuartz.domain.AccessPoint;
import com.kuartz.domain.DomainObject;

import java.util.Date;

@DatabaseTable
public class GpsLocation extends DomainObject {
    @DatabaseField
    private double longitude = 0;

    @DatabaseField
    private double latitude = 0;

    @DatabaseField
    private Date timestamp;

    @DatabaseField( foreign=true )
    private AccessPoint accessPoint;

    public GpsLocation() {
    }

    public GpsLocation( Location lastKnownLocation ) {
        if ( lastKnownLocation != null ) {
            latitude = lastKnownLocation.getLatitude();
            longitude = lastKnownLocation.getLongitude();
            timestamp = new Date();
        }
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude( double longitude ) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude( double latitude ) {
        this.latitude = latitude;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public AccessPoint getAccessPoint() {
        return accessPoint;
    }

    public void setAccessPoint(AccessPoint accessPoint) {
        this.accessPoint = accessPoint;
    }
}
