/** * */ package kr.ac.kaist.resl.lilliput.model; import java.util.ArrayList; import java.util.List; /** * @author Jaewook Byun, Ph.D Student, Department of Computer Science, KAIST * @email bjw0829@kaist.ac.kr */ public class ClusterRectangle { private double minLon; private double minLat; private double maxLon; private double maxLat; private List<GeoPoint> members; private List<Period> periods; @Override public String toString() { return minLon+"\t"+minLat+"\t"+maxLon+"\t"+maxLat; } /** * @return the periods */ public List<Period> getPeriods() { return periods; } /** * @param periods the periods to set */ public void setPeriods(List<Period> periods) { this.periods = periods; } /** * @return the members */ public List<GeoPoint> getMembers() { return members; } /** * @param members the members to set */ public void setMembers(List<GeoPoint> members) { this.members = members; } /** * @return the minLon */ public double getMinLon() { return minLon; } /** * @param minLon the minLon to set */ public void setMinLon(double minLon) { this.minLon = minLon; } /** * @return the minLat */ public double getMinLat() { return minLat; } /** * @param minLat the minLat to set */ public void setMinLat(double minLat) { this.minLat = minLat; } /** * @return the maxLon */ public double getMaxLon() { return maxLon; } /** * @param maxLon the maxLon to set */ public void setMaxLon(double maxLon) { this.maxLon = maxLon; } /** * @return the maxLat */ public double getMaxLat() { return maxLat; } /** * Make sure that members including timestamp were already included * @param term : minimal term differenciates periods */ public void computePeriods(int term) { // Phase 1: Creation for(int i = 0 ; i < this.members.size() ;i++) { GeoPoint gp = this.members.get(i); long timestamp = gp.getTimestamp(); if( this.periods.size() == 0 ) { Period period = new Period(timestamp, timestamp); this.periods.add(period); continue; } // 새로운 주기를 만드는 것으로 가정하고 들어 boolean createNew = true; for(int j = 0 ; j < this.periods.size() ; j++ ) { Period period = this.periods.get(j); // 이전일 확률이 있다. if( timestamp < period.getFrom() ) { // 현재 Period에서 주기보다 짧다면, 확장시킨후 종료 플래그를 넣음 if( ( period.getFrom() - timestamp ) <= term ) { period.setFrom(timestamp); createNew = false; break; } } else if( ( period.getFrom() <= timestamp ) && ( timestamp <= period.getTo())) // 안에 들어감 { // Break this timestamp createNew = false; break; } else //이후일 확률이 있음 { // 현재 Period에서 주기보다 짧다면, 확장시킨후 종료 플래그를 넣음 if( ( timestamp - period.getTo() ) <= term ) { period.setTo(timestamp); createNew = false; break; } } } if( createNew == true ) { Period period = new Period(timestamp, timestamp); this.periods.add(period); } } } /** * @param maxLat the maxLat to set */ public void setMaxLat(double maxLat) { this.maxLat = maxLat; } public ClusterRectangle(double minLon, double minLat, double maxLon, double maxLat) { this.minLon = minLon; this.minLat = minLat; this.maxLon = maxLon; this.maxLat = maxLat; this.members = new ArrayList<GeoPoint>(); this.periods = new ArrayList<Period>(); } }