gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / store / properties / MultiDataStoreMetadata.java @ 2443
History | View | Annotate | Download (3.93 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.impl.store.properties; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
|
26 |
import org.gvsig.fmap.dal.coverage.store.props.Metadata; |
27 |
|
28 |
/**
|
29 |
* Class to store metadata in a RasterDataset
|
30 |
*
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
32 |
*/
|
33 |
public class MultiDataStoreMetadata extends ArrayList<Metadata> implements Metadata { |
34 |
private static final long serialVersionUID = 1L; |
35 |
private int[] nBand = null; |
36 |
|
37 |
public MultiDataStoreMetadata(int[] bands) { |
38 |
this.nBand = bands;
|
39 |
} |
40 |
|
41 |
/*
|
42 |
* (non-Javadoc)
|
43 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#initNoDataByBand(int)
|
44 |
*/
|
45 |
public void initNoDataByBand(int values) { |
46 |
if(size() != nBand.length)
|
47 |
return;
|
48 |
|
49 |
for (int i = 0; i < size(); i++) |
50 |
get(i).initNoDataByBand(nBand[i]); |
51 |
} |
52 |
|
53 |
/*
|
54 |
* (non-Javadoc)
|
55 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#setNoDataValue(int, double)
|
56 |
*/
|
57 |
public void setNoDataValue(int band, double value){ |
58 |
if(size() != nBand.length)
|
59 |
return;
|
60 |
int acc = 0; |
61 |
int bandParcial = band;
|
62 |
for (int i = 0; i < size(); i++) { |
63 |
acc += nBand[i]; |
64 |
if(band < acc) {
|
65 |
get(i).setNoDataValue(bandParcial, value); |
66 |
return;
|
67 |
} |
68 |
bandParcial -= nBand[i]; |
69 |
} |
70 |
} |
71 |
|
72 |
/*
|
73 |
* (non-Javadoc)
|
74 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#getNoDataValue(int)
|
75 |
*/
|
76 |
public double getNoDataValue(int band) { |
77 |
if(size() != nBand.length)
|
78 |
return 0; |
79 |
int acc = 0; |
80 |
int bandParcial = band;
|
81 |
for (int i = 0; i < size(); i++) { |
82 |
acc += nBand[i]; |
83 |
if(band < acc)
|
84 |
return get(i).getNoDataValue(bandParcial);
|
85 |
bandParcial -= nBand[i]; |
86 |
} |
87 |
return 0; |
88 |
} |
89 |
|
90 |
/*
|
91 |
* (non-Javadoc)
|
92 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#getNoDataValue()
|
93 |
*/
|
94 |
public double[] getNoDataValue() { |
95 |
if(size() != nBand.length)
|
96 |
return null; |
97 |
|
98 |
int bandCount = 0; |
99 |
for (int i = 0; i < size(); i++) |
100 |
bandCount += nBand[i]; |
101 |
|
102 |
int cont = 0; |
103 |
double[] res = new double[bandCount]; |
104 |
for (int i = 0; i < size(); i++) { |
105 |
double[] p = get(i).getNoDataValue(); |
106 |
for (int j = 0; j < p.length; j++) { |
107 |
res[cont] = p[j]; |
108 |
cont ++; |
109 |
} |
110 |
} |
111 |
return res;
|
112 |
} |
113 |
|
114 |
/*
|
115 |
* (non-Javadoc)
|
116 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#getMetadataString()
|
117 |
*/
|
118 |
public String[] getMetadataString() { |
119 |
if(size() != nBand.length)
|
120 |
return null; |
121 |
|
122 |
int bandCount = 0; |
123 |
for (int i = 0; i < size(); i++) |
124 |
bandCount += nBand[i]; |
125 |
|
126 |
int cont = 0; |
127 |
String[] res = new String[bandCount]; |
128 |
for (int i = 0; i < size(); i++) { |
129 |
String[] p = get(i).getMetadataString(); |
130 |
for (int j = 0; j < p.length; j++) { |
131 |
res[cont] = p[j]; |
132 |
cont ++; |
133 |
} |
134 |
} |
135 |
return res;
|
136 |
} |
137 |
|
138 |
/*
|
139 |
* (non-Javadoc)
|
140 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#isNoDataEnabled()
|
141 |
*/
|
142 |
public boolean isNoDataEnabled() { |
143 |
if(size() != nBand.length)
|
144 |
return true; |
145 |
return get(0).isNoDataEnabled(); |
146 |
} |
147 |
|
148 |
/*
|
149 |
* (non-Javadoc)
|
150 |
* @see org.gvsig.fmap.dal.coverage.dataset.Metadata#setNoDataEnabled(boolean)
|
151 |
*/
|
152 |
public void setNoDataEnabled(boolean noDataEnabled) { |
153 |
if(size() != nBand.length)
|
154 |
return;
|
155 |
|
156 |
for (int i = 0; i < size(); i++) |
157 |
get(i).setNoDataEnabled(noDataEnabled); |
158 |
} |
159 |
} |