package kr.gmtc.tss.data.vo;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

public class TrackVO implements Comparable<TrackVO> {

	private boolean inserted=false;

	public long timeStamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(9)).toEpochMilli();
	
	public TrackVO() {
	}

	protected LocalDateTime dateTime;
	
	@JsonProperty("trgt_id")
	private String targetId;
	@JsonProperty("recptn_dt")
    private String receptionDate;
	@JsonProperty("lat")
    private String latitude;
	@JsonProperty("lon")
    private String longitude;
	@JsonProperty("spd")
    private String speed;
	@JsonProperty("cos")
    private String course;
	@JsonProperty("trgt_ty")
    private String targetType;
	@JsonProperty("mode_s_cd")
    private String modeSCode;
	@JsonProperty("ssr_cd")
    private String ssrCode;
	@JsonProperty("clsgn")
    private String callsign;
	@JsonProperty("tail_no")
    private String tailNumber;
	@JsonProperty("crrct_lat")
    private String correctedLatitude;
	@JsonProperty("crrct_lon")
    private String correctedLongitude;
    private List<BoundingBox> bbox;
    @JsonProperty("alt")
    private String alt;
    @Override
    public String toString() {
		return "{" +
                "\"trgt_id\":\"" + targetId + "\"" +
                ",\"recptn_dt\":\"" + receptionDate + "\"" +
                ",\"lat\":\"" + latitude + "\"" +
                ",\"lon\":\"" + longitude + "\"" +
                ",\"spd\":\"" + speed + "\"" +
                ",\"cos\":\"" + course + "\"" +
                ",\"trgt_ty\":\"" + targetType + "\"" +
                ",\"mode_s_cd\":\"" + modeSCode + "\"" +
                ",\"ssr_cd\":\"" + ssrCode + "\"" +
                ",\"clsgn\":\"" + callsign + "\"" +
                ",\"tail_no\":\"" + tailNumber + "\"" +
                ",\"crrct_lat\":\"" + correctedLatitude + "\"" +
                ",\"crrct_lon\":\"" + correctedLongitude + "\"" +
                ",\"bbox\":" + bbox.toString() + 
            "}";
	}
    
	private boolean lstFlag;
	
	public boolean isInserted() {
		return inserted;
	}

	public void setInserted(boolean inserted) {
		this.inserted = inserted;
	}

	public long getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(long timeStamp) {
		this.timeStamp = timeStamp;
	}

	public LocalDateTime getDateTime() {
		return dateTime;
	}

	public void setDateTime(LocalDateTime dateTime) {
		this.dateTime = dateTime;
	}

	public boolean isLstFlag() {
		return lstFlag;
	}

	public void setLstFlag(boolean lstFlag) {
		this.lstFlag = lstFlag;
	}

	public String getTargetId() {
		return targetId;
	}

	public void setTargetId(String targetId) {
		this.targetId = targetId;
	}

	public String getReceptionDate() {
		return receptionDate;
	}

	public void setReceptionDate(String receptionDate) {
		this.receptionDate = receptionDate;
	}

	public String getLatitude() {
		return latitude;
	}

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

	public String getLongitude() {
		return longitude;
	}

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

	public String getSpeed() {
		return speed;
	}

	public void setSpeed(String speed) {
		this.speed = speed;
	}

	public String getCourse() {
		return course;
	}

	public void setCourse(String course) {
		this.course = course;
	}

	public String getTargetType() {
		return targetType;
	}

	public void setTargetType(String targetType) {
		this.targetType = targetType;
	}

	public String getModeSCode() {
		return modeSCode;
	}

	public void setModeSCode(String modeSCode) {
		this.modeSCode = modeSCode;
	}

	public String getSsrCode() {
		return ssrCode;
	}

	public void setSsrCode(String ssrCode) {
		this.ssrCode = ssrCode;
	}

	public String getCallsign() {
		return callsign;
	}

	public void setCallsign(String callsign) {
		this.callsign = callsign;
	}

	public String getTailNumber() {
		return tailNumber;
	}

	public void setTailNumber(String tailNumber) {
		this.tailNumber = tailNumber;
	}

	public String getCorrectedLatitude() {
		return correctedLatitude;
	}

	public void setCorrectedLatitude(String correctedLatitude) {
		this.correctedLatitude = correctedLatitude;
	}

	public String getCorrectedLongitude() {
		return correctedLongitude;
	}

	public void setCorrectedLongitude(String correctedLongitude) {
		this.correctedLongitude = correctedLongitude;
	}

	public List<BoundingBox> getBbox() {
		return bbox;
	}

	public void setBbox(List<BoundingBox> bbox) {
		this.bbox = bbox;
	}

	public String getAlt() {
		return alt;
	}

	public void setAlt(String alt) {
		this.alt = alt;
	}

	@Override
    public boolean equals(Object obj) {
        //p1.equals(p2)
        if(obj instanceof TrackVO) {
        	TrackVO p = (TrackVO)obj;
            return this.hashCode()==p.hashCode(); 
            
        }
        return false;
    }

	@Override
	public int compareTo(TrackVO o) {
		return 0;
	}
	
	public static class BoundingBox {
		@JsonProperty("cctv_id")
        private String cctvId;
		@JsonProperty("lt_x")
        private String leftTopX;
		@JsonProperty("lt_y")
        private String leftTopY;
		@JsonProperty("rb_x")
        private String rightBottomX;
		@JsonProperty("rb_y")
        private String rightBottomY;
        private String px;
        private String py;
        
        @Override
	    public String toString() {
			return "{" +
	                "\"cctv_id\":\"" + cctvId + "\"" +
	                ",\"lt_x\":\"" + leftTopX + "\"" +
	                ",\"lt_y\":\"" + leftTopY + "\"" +
	                ",\"rb_x\":\"" + rightBottomX + "\"" +
	                ",\"rb_y\":\"" + rightBottomY + "\"" +
	                ",\"px\":\"" + px + "\"" +
	                ",\"py\":\"" + py + "\"" +
                "}";
		}
        
        public String toDataFormat() {
			return cctvId+"@"+leftTopX+"@"+leftTopY+"@"+rightBottomX+"@"+rightBottomY+"@"+px+"@"+py;
		}
        
		public String getCctvId() {
			return cctvId;
		}
		public void setCctvId(String cctvId) {
			this.cctvId = cctvId;
		}
		public String getLeftTopX() {
			return leftTopX;
		}
		public void setLeftTopX(String leftTopX) {
			this.leftTopX = leftTopX;
		}
		public String getLeftTopY() {
			return leftTopY;
		}
		public void setLeftTopY(String leftTopY) {
			this.leftTopY = leftTopY;
		}
		public String getRightBottomX() {
			return rightBottomX;
		}
		public void setRightBottomX(String rightBottomX) {
			this.rightBottomX = rightBottomX;
		}
		public String getRightBottomY() {
			return rightBottomY;
		}
		public void setRightBottomY(String rightBottomY) {
			this.rightBottomY = rightBottomY;
		}
		public String getPx() {
			return px;
		}
		public void setPx(String px) {
			this.px = px;
		}
		public String getPy() {
			return py;
		}
		public void setPy(String py) {
			this.py = py;
		}
	}
}
