001    package org.wdssii.polarmerger;
002    
003    import org.wdssii.core.DataType;
004    
005    
006    /**
007     * Choose the observation with maximum weight (this is a nearest neighbor approach)
008     * 
009     * @author lakshman
010     * 
011     */
012    public class NearestNeighborObservationMerger extends AbstractWeightedObservationMerger {
013    
014            private static float MIN_WEIGHT = 0.5f;
015            
016            public void update(float[][][] values, int w_e, int w_az, int w_rn,
017                            Observation obs, float wt) {
018                    if ( weights[w_e][w_az][w_rn] < wt ){
019                            values[w_e][w_az][w_rn]  = obs.getValue();
020                            weights[w_e][w_az][w_rn] = wt ;
021                    }
022            }
023    
024            public void finishComputation(float[][][] values) {
025                    for (int i=0; i < weights.length; ++i){
026                            for (int j=0; j < weights[0].length; ++j){
027                                    for (int k=0; k < weights[0][0].length; ++k){
028                                            if (weights[i][j][k] < MIN_WEIGHT){
029                                                    values[i][j][k] = DataType.MissingData;
030                                            } 
031                                    }
032                            }
033                    }
034            }
035    }