Revision 5912 trunk/libraries/libCq CMS for java.old/src/org/cresques/io/Metadata.java
Metadata.java | ||
---|---|---|
52 | 52 |
*/ |
53 | 53 |
public class Metadata{ |
54 | 54 |
|
55 |
private ArrayList metadata = new ArrayList(); |
|
56 |
private ArrayList values = new ArrayList(); |
|
55 |
/** |
|
56 |
* Valores para los identificadores de los metadatos |
|
57 |
*/ |
|
58 |
private ArrayList metadata = new ArrayList(); |
|
59 |
/** |
|
60 |
* Valores de los metadatos |
|
61 |
*/ |
|
62 |
private ArrayList values = new ArrayList(); |
|
63 |
/** |
|
64 |
* Interpretaci?n de color para cada banda |
|
65 |
*/ |
|
66 |
private String[] colorInterpretation = null; |
|
67 |
/** |
|
68 |
* true si la imagen tiene una banda con el identificador de interpretaci?n de color a Alpha |
|
69 |
*/ |
|
70 |
private boolean isAlphaBand = false; |
|
71 |
/** |
|
72 |
* Valores no data para cada banda de la imagen (si los tiene) |
|
73 |
*/ |
|
74 |
private double[] noDataByBand = null; |
|
57 | 75 |
|
58 | 76 |
public Metadata(String[] metadata){ |
59 | 77 |
for(int i = 0;i<metadata.length;i++){ |
... | ... | |
64 | 82 |
} |
65 | 83 |
|
66 | 84 |
/** |
85 |
* Crea un objeto TransparencyRange a partir de los rangos de transparencia |
|
86 |
* @return |
|
87 |
*/ |
|
88 |
public TransparencyRange parserNodataByBand(){ |
|
89 |
if(noDataByBand == null) |
|
90 |
return null; |
|
91 |
|
|
92 |
//Si todos los valores nodata por banda son -1 es que no hay ninguno asignado |
|
93 |
int count =0; |
|
94 |
for(int i = 0; i < noDataByBand.length; i++) |
|
95 |
if(noDataByBand[i] == -1) |
|
96 |
count ++; |
|
97 |
|
|
98 |
if(count == noDataByBand.length) |
|
99 |
return null; |
|
100 |
|
|
101 |
TransparencyRange tr = new TransparencyRange(); |
|
102 |
int[] red = new int[2]; |
|
103 |
int[] green = new int[2]; |
|
104 |
int[] blue = new int[2]; |
|
105 |
|
|
106 |
red[0] = red[1] = (int)noDataByBand[getBand("Red")]; |
|
107 |
green[0] = green[1] = (int)noDataByBand[getBand("Green")]; |
|
108 |
blue[0] = blue[1] = (int)noDataByBand[getBand("Blue")]; |
|
109 |
|
|
110 |
tr.setAnd(true); |
|
111 |
tr.setRed(red); |
|
112 |
tr.setGreen(green); |
|
113 |
tr.setBlue(blue); |
|
114 |
tr.loadStrEntryFromValues(); |
|
115 |
|
|
116 |
return tr; |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
67 | 120 |
* Parsea los metadatos NODATA_VALUES si existe alguno y devuelve un objeto TransparencyRange. |
68 | 121 |
* @param nodata |
69 | 122 |
* @return Vector de enteros con los valores RGBA o null si no tiene este metadato o no es parseable |
70 | 123 |
* en este formato. |
71 | 124 |
*/ |
72 |
public TransparencyRange[] parserNodata(){ |
|
125 |
public TransparencyRange[] parserNodataInMetadata(){
|
|
73 | 126 |
int count = 0; |
74 | 127 |
for(int i = 0; i < metadata.size(); i++){ |
75 | 128 |
if(((String)metadata.get(i)).equals("NODATA_VALUES")) |
... | ... | |
110 | 163 |
|
111 | 164 |
return trList; |
112 | 165 |
} |
166 |
|
|
167 |
/** |
|
168 |
* Inicializa el vector de cadenas que contendr?n el nombre de la interpretaci?n |
|
169 |
* de color asignada a cada banda. Este valor es el devuelto por la imagen. |
|
170 |
* @param values N?mero de valores |
|
171 |
*/ |
|
172 |
public void initColorInterpretation(int values){ |
|
173 |
colorInterpretation = new String[values]; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* Asigna un valor para la interpretaci?n de color de una banda |
|
178 |
* @param band Banda |
|
179 |
* @param value valor |
|
180 |
*/ |
|
181 |
public void setColorInterpValue(int band, String value){ |
|
182 |
try{ |
|
183 |
colorInterpretation[band] = value; |
|
184 |
if(value.equals("Alpha")) |
|
185 |
isAlphaBand = true; |
|
186 |
}catch(ArrayIndexOutOfBoundsException ex){ |
|
187 |
//No asignamos el elemento |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Obtiene la posici?n de la banda que contiene el identificador pasado por par?metro |
|
193 |
* o -1 si no tiene dicho identificador. |
|
194 |
* @return Posici?n de la banda que contiene el identificador o -1 si no lo tiene. |
|
195 |
*/ |
|
196 |
public int getBand(String id){ |
|
197 |
if(colorInterpretation != null){ |
|
198 |
for(int i = 0; i < colorInterpretation.length; i++) |
|
199 |
if(colorInterpretation[i].equals(id)) |
|
200 |
return i; |
|
201 |
} |
|
202 |
return -1; |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* Obtiene true si existe una banda de alpha |
|
207 |
* @return |
|
208 |
*/ |
|
209 |
public boolean isAlphaBand() { |
|
210 |
return isAlphaBand; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Inicializa los valores no data; |
|
215 |
* @param values |
|
216 |
*/ |
|
217 |
public void initNoDataByBand(int values){ |
|
218 |
noDataByBand = new double[values]; |
|
219 |
for(int i = 0; i < values; i++) |
|
220 |
noDataByBand[i] = -1; |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Asigna un valor para el valor noData por banda |
|
225 |
* @param band Banda |
|
226 |
* @param value valor |
|
227 |
*/ |
|
228 |
public void setNoDataValue(int band, double value){ |
|
229 |
try{ |
|
230 |
noDataByBand[band] = value; |
|
231 |
}catch(ArrayIndexOutOfBoundsException ex){ |
|
232 |
//No asignamos el elemento |
|
233 |
} |
|
234 |
} |
|
113 | 235 |
} |
Also available in: Unified diff