001    /**
002     * 
003     */
004    package org.wdssii.polarmerger;
005    
006    import java.util.Comparator;
007    import java.util.Date;
008    
009    /**
010     * Observation at a particular grid point
011     * 
012     * @author lakshman
013     *
014     */
015    public class Observation {
016            private int eIndex;
017            private int azIndex;
018            private int rnIndex;
019            private float value;
020            private Date  time;
021            
022            public Observation(int index, int azIndex, int rnIndex, float value, Date time) {
023                    eIndex = index;
024                    this.azIndex = azIndex;
025                    this.rnIndex = rnIndex;
026                    this.value = value;
027                    this.time = time;
028            }
029            
030            protected int getAzIndex() {
031                    return azIndex;
032            }
033            protected int getEIndex() {
034                    return eIndex;
035            }
036            protected int getRnIndex() {
037                    return rnIndex;
038            }
039            protected Date getTime() {
040                    return time;
041            }
042            protected float getValue() {
043                    return value;
044            }
045    
046            public static class PositionOrderComparator implements Comparator<Observation>{
047    
048                    public int compare(Observation a, Observation b) {
049                            int eDiff = a.eIndex - b.eIndex;
050                            if (eDiff == 0){
051                                    int azDiff = a.azIndex - b.azIndex;
052                                    if (azDiff == 0){
053                                            return (a.rnIndex - b.rnIndex);
054                                    } else {
055                                            return azDiff;
056                                    }
057                            } else {
058                                    return eDiff;
059                            }
060                    }
061                    
062            }
063            
064            
065    }