Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/ComputeMinMaxFilter.java

View differences:

ComputeMinMaxFilter.java
1 1
/*
2 2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5 3
 *
4
 * Copyright (C) 2004-5.
5
 *
6 6
 * This program is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU General Public License
8 8
 * as published by the Free Software Foundation; either version 2
......
18 18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19 19
 *
20 20
 * For more information, contact:
21
 * 
21
 *
22 22
 * cresques@gmail.com
23 23
 */
24 24
package org.cresques.io.raster;
25 25

  
26 26

  
27 27
/**
28
 * Calcula el m?ximo y el m?nimo de un raster, As? como el segundo menor valor y 
28
 * Calcula el m?ximo y el m?nimo de un raster, As? como el segundo menor valor y
29 29
 * el segundo mayor valor.
30 30
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
31 31
 * @author Nacho Brodin (brodin_ign@gva.es)
32 32
 */
33 33
public abstract class ComputeMinMaxFilter extends RasterFilter {
34
	protected int [] min = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE};
35
	protected int [] max = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE};
36
	protected int [] secondMin = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE};
37
	protected int [] secondMax = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE};
38
	protected int [] tmpMin = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE};
39
	protected int [] tmpMax = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE};
40
	
41
	/**
42
	 * Constructor
43
	 *
44
	 */
45
	public ComputeMinMaxFilter(){
46
		super();
47
	}
48
	
49
	/**
50
	 * Operaciones que se realizan antes de la ejecuci?n del filtro
51
	 */
52
	public void pre(){
53
		//Obtenci?n de par?metros comunes a todos
54
		this.stats = (RasterStats)params.get("stats");
55
		this.stats.tailPercent = 0D;
56
		
57
		//Operaciones del filtro concreto
58
		this.min = new int[stats.minBandValue.length];
59
		this.max = new int[stats.maxBandValue.length];
60
		this.secondMin = new int[stats.minBandValue.length];
61
		this.secondMax = new int[stats.maxBandValue.length];
62
		this.tmpMin = new int[stats.minBandValue.length];
63
		this.tmpMax = new int[stats.maxBandValue.length];
64
		for (int i=0; i<min.length; i++) {
65
			secondMin[i] = tmpMin[i] = min[i] = Integer.MAX_VALUE;
66
			secondMax[i] = tmpMax[i] = max[i] = Integer.MIN_VALUE;
67
		}	
68
	}
69
		
70
	/**
71
	 * Operaciones que se realizan despu?s de la ejecuci?n del filtro
72
	 */
73
	public void post(){
34
    protected int[] min = {
35
                              Integer.MAX_VALUE, Integer.MAX_VALUE,
36
                              Integer.MAX_VALUE
37
                          };
38
    protected int[] max = {
39
                              Integer.MIN_VALUE, Integer.MIN_VALUE,
40
                              Integer.MIN_VALUE
41
                          };
42
    protected int[] secondMin = {
43
                                    Integer.MAX_VALUE, Integer.MAX_VALUE,
44
                                    Integer.MAX_VALUE
45
                                };
46
    protected int[] secondMax = {
47
                                    Integer.MIN_VALUE, Integer.MIN_VALUE,
48
                                    Integer.MIN_VALUE
49
                                };
50
    protected int[] tmpMin = {
51
                                 Integer.MAX_VALUE, Integer.MAX_VALUE,
52
                                 Integer.MAX_VALUE
53
                             };
54
    protected int[] tmpMax = {
55
                                 Integer.MIN_VALUE, Integer.MIN_VALUE,
56
                                 Integer.MIN_VALUE
57
                             };
74 58

  
75
		for (int i=0; i<3; i++) {
76
			stats.minBandValue[i] = min[i];
77
			stats.maxBandValue[i] = max[i];
78
			stats.secondMinBandValue[i] = secondMin[i];
79
			stats.secondMaxBandValue[i] = secondMax[i];
80
		}
81
	}
82
	
83
	/**
84
	 * Obtiene le m?nimo para una banda dada
85
	 * @param bandNr	banda
86
	 * @return	valor m?nimo
87
	 */
88
	public int getMin(int bandNr) { 
89
		return min[bandNr]; 
90
	}
59
    /**
60
     * Constructor
61
     *
62
     */
63
    public ComputeMinMaxFilter() {
64
        super();
65
    }
91 66

  
92
	/**
93
	 * Obtiene el m?ximo para una banda dada
94
	 * @param bandNr	banda
95
	 * @return	valor m?ximo
96
	 */
97
	public int getMax(int bandNr) { 
98
		return max[bandNr]; 
99
	}
100
		
101
	/**
102
	 * Obtiene el objeto stats con el calculo de m?ximos y m?nimos
103
	 */
104
	public Object getResult(String name){
105
		if(name.equals("stats"))
106
			return stats;
107
		else return null;
108
	}
109
		
67
    /**
68
     * Operaciones que se realizan antes de la ejecuci?n del filtro
69
     */
70
    public void pre() {
71
        //Obtenci?n de par?metros comunes a todos
72
        this.stats = (RasterStats) params.get("stats");
73
        this.stats.tailPercent = 0D;
74

  
75
        //Operaciones del filtro concreto
76
        this.min = new int[stats.minBandValue.length];
77
        this.max = new int[stats.maxBandValue.length];
78
        this.secondMin = new int[stats.minBandValue.length];
79
        this.secondMax = new int[stats.maxBandValue.length];
80
        this.tmpMin = new int[stats.minBandValue.length];
81
        this.tmpMax = new int[stats.maxBandValue.length];
82

  
83
        for (int i = 0; i < min.length; i++) {
84
            secondMin[i] = tmpMin[i] = min[i] = Integer.MAX_VALUE;
85
            secondMax[i] = tmpMax[i] = max[i] = Integer.MIN_VALUE;
86
        }
87
    }
88

  
89
    /**
90
     * Operaciones que se realizan despu?s de la ejecuci?n del filtro
91
     */
92
    public void post() {
93
        for (int i = 0; i < 3; i++) {
94
            stats.minBandValue[i] = min[i];
95
            stats.maxBandValue[i] = max[i];
96
            stats.secondMinBandValue[i] = secondMin[i];
97
            stats.secondMaxBandValue[i] = secondMax[i];
98
        }
99
    }
100

  
101
    /**
102
     * Obtiene le m?nimo para una banda dada
103
     * @param bandNr        banda
104
     * @return        valor m?nimo
105
     */
106
    public int getMin(int bandNr) {
107
        return min[bandNr];
108
    }
109

  
110
    /**
111
     * Obtiene el m?ximo para una banda dada
112
     * @param bandNr        banda
113
     * @return        valor m?ximo
114
     */
115
    public int getMax(int bandNr) {
116
        return max[bandNr];
117
    }
118

  
119
    /**
120
     * Obtiene el objeto stats con el calculo de m?ximos y m?nimos
121
     */
122
    public Object getResult(String name) {
123
        if (name.equals("stats")) {
124
            return stats;
125
        } else {
126
            return null;
127
        }
128
    }
110 129
}
111

  

Also available in: Unified diff