Revision 6302
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/DefaultRasterQuery.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.dal.raster.impl; |
24 | 24 |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.Collections; |
|
25 | 27 |
import java.util.HashMap; |
28 |
import java.util.List; |
|
26 | 29 |
import java.util.Map; |
27 | 30 |
import java.util.Map.Entry; |
28 | 31 |
import java.util.Set; |
29 | 32 |
|
33 |
import org.gvsig.fmap.dal.raster.api.BandQuery; |
|
30 | 34 |
import org.gvsig.fmap.dal.raster.api.RasterQuery; |
31 | 35 |
import org.gvsig.fmap.geom.primitive.Envelope; |
36 |
import org.gvsig.tools.ToolsLocator; |
|
37 |
import org.gvsig.tools.dynobject.DynStruct; |
|
38 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
32 | 39 |
import org.gvsig.tools.persistence.PersistentState; |
33 | 40 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
34 | 41 |
|
35 | 42 |
/** |
36 | 43 |
* Implements RasterQuery |
44 |
* |
|
37 | 45 |
* @author dmartinezizquierdo |
38 | 46 |
* |
39 | 47 |
*/ |
40 |
public class DefaultRasterQuery implements RasterQuery{ |
|
48 |
public class DefaultRasterQuery implements RasterQuery {
|
|
41 | 49 |
|
42 |
double scale; |
|
43 |
Map<String,Object> queryParameters= new HashMap<String, Object>();; |
|
44 |
int[] bands; |
|
45 |
Envelope clip; |
|
50 |
private static final String PERSISTENCE_NAME = "RasterQuery"; |
|
51 |
private static final String PERSISTENCE_DESCRIPTION = ""; |
|
46 | 52 |
|
53 |
private static final String SCALE_FIELD_NAME = "scale"; |
|
54 |
private static final String PARAMETERS_FIELD_NAME = "queryParameters"; |
|
55 |
private static final String BAND_QUERIES_FIELD_NAME = "bandQueries"; |
|
56 |
private static final String CLIP_FIELD_NAME = "clip"; |
|
47 | 57 |
|
48 |
@Override |
|
49 |
public void setScale(double scale) { |
|
50 |
this.scale=scale; |
|
58 |
private double scale; |
|
59 |
private Map<String, Object> queryParameters; |
|
60 |
private List<BandQuery> bandQueries; |
|
61 |
private Envelope clip; |
|
51 | 62 |
|
63 |
/** |
|
64 |
* @param store |
|
65 |
* |
|
66 |
*/ |
|
67 |
public DefaultRasterQuery() { |
|
68 |
this.queryParameters = new HashMap<String, Object>(); |
|
69 |
this.bandQueries = new ArrayList<BandQuery>(); |
|
52 | 70 |
} |
53 | 71 |
|
54 | 72 |
@Override |
55 |
public double getScale() {
|
|
56 |
return scale;
|
|
73 |
public List<BandQuery> getBands() {
|
|
74 |
return Collections.unmodifiableList(this.bandQueries);
|
|
57 | 75 |
} |
58 | 76 |
|
59 | 77 |
@Override |
60 |
public Object getQueryParameter(String name) {
|
|
61 |
return queryParameters.get(name);
|
|
78 |
public void addBand(BandQuery query) {
|
|
79 |
this.bandQueries.add(query);
|
|
62 | 80 |
} |
63 | 81 |
|
64 | 82 |
@Override |
65 |
public void setQueryParameter(String name, Object value) {
|
|
66 |
queryParameters.put(name, value);
|
|
83 |
public void clearBands() {
|
|
84 |
this.bandQueries.clear();
|
|
67 | 85 |
} |
68 | 86 |
|
69 | 87 |
@Override |
70 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
71 |
state.set("queryParameters", this.queryParameters); |
|
72 |
state.set("scale", this.scale); |
|
73 |
state.set("bands", this.bands); |
|
74 |
state.set("clip", this.clip); |
|
88 |
public void setScale(double scale) { |
|
89 |
this.scale = scale; |
|
75 | 90 |
|
76 | 91 |
} |
77 | 92 |
|
78 | 93 |
@Override |
79 |
public void loadFromState(PersistentState state) |
|
80 |
throws PersistenceException { |
|
81 |
this.queryParameters = (Map<String, Object>) state.get("queryParameters"); |
|
82 |
this.scale = state.getDouble("scale"); |
|
83 |
this.bands = (int[])state.get("bands"); |
|
84 |
this.clip = (Envelope) state.get("clip"); |
|
85 |
|
|
94 |
public double getScale() { |
|
95 |
return scale; |
|
86 | 96 |
} |
87 | 97 |
|
88 | 98 |
@Override |
89 |
public int[] getBands() {
|
|
90 |
return bands;
|
|
99 |
public Object getQueryParameter(String name) {
|
|
100 |
return queryParameters.get(name);
|
|
91 | 101 |
} |
92 | 102 |
|
93 | 103 |
@Override |
94 |
public RasterQuery setBands(int[] bands) { |
|
95 |
this.bands=bands; |
|
96 |
return this; |
|
104 |
public void setQueryParameter(String name, Object value) { |
|
105 |
queryParameters.put(name, value); |
|
97 | 106 |
} |
98 | 107 |
|
99 | 108 |
@Override |
... | ... | |
103 | 112 |
|
104 | 113 |
@Override |
105 | 114 |
public RasterQuery setClip(Envelope clip) { |
106 |
this.clip=clip;
|
|
115 |
this.clip = clip;
|
|
107 | 116 |
return this; |
108 | 117 |
} |
109 | 118 |
|
119 |
public static void registerPersistenceDefinition() { |
|
120 |
|
|
121 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
122 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_NAME); |
|
123 |
if (definition == null) { |
|
124 |
|
|
125 |
definition = |
|
126 |
persistenceManager.addDefinition(RasterQuery.class, PERSISTENCE_NAME, |
|
127 |
PERSISTENCE_DESCRIPTION, null, null); |
|
128 |
definition.addDynFieldDouble(SCALE_FIELD_NAME); |
|
129 |
definition.addDynFieldMap(PARAMETERS_FIELD_NAME); |
|
130 |
definition.addDynFieldList(BAND_QUERIES_FIELD_NAME).setClassOfItems(BandQuery.class); |
|
131 |
definition.addDynField(CLIP_FIELD_NAME).setClassOfValue(Envelope.class); |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
110 | 135 |
@Override |
111 |
public DefaultRasterQuery clone() throws CloneNotSupportedException{ |
|
112 |
DefaultRasterQuery rq=new DefaultRasterQuery(); |
|
136 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
137 |
state.set("scale", this.scale); |
|
138 |
state.set("queryParameters", this.queryParameters); |
|
139 |
state.set("bands", this.bandQueries); |
|
140 |
state.set("clip", this.clip); |
|
141 |
} |
|
113 | 142 |
|
114 |
rq.setBands(this.getBands().clone()); |
|
115 |
rq.setClip((Envelope)this.getClip().clone()); |
|
143 |
@Override |
|
144 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
145 |
this.queryParameters = |
|
146 |
new HashMap<String, Object>((Map<String, Object>) state.get("queryParameters")); |
|
147 |
this.scale = state.getDouble("scale"); |
|
148 |
this.bandQueries = new ArrayList<BandQuery>((List<BandQuery>) state.get("bands")); |
|
149 |
this.clip = (Envelope) state.get("clip"); |
|
150 |
|
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
154 |
public Object clone() throws CloneNotSupportedException { |
|
155 |
RasterQuery rq = new DefaultRasterQuery(); |
|
156 |
|
|
157 |
for (BandQuery bandQuery : this.getBands()) { |
|
158 |
rq.addBand((BandQuery) bandQuery.clone()); |
|
159 |
} |
|
160 |
rq.setClip((Envelope) this.getClip().clone()); |
|
116 | 161 |
Set<Entry<String, Object>> entries = queryParameters.entrySet(); |
117 |
for (Entry<String, Object> entry : entries){ |
|
162 |
for (Entry<String, Object> entry : entries) {
|
|
118 | 163 |
rq.setQueryParameter(entry.getKey(), entry.getValue()); |
119 | 164 |
} |
120 | 165 |
rq.setScale(scale); |
121 | 166 |
|
122 | 167 |
return rq; |
123 | 168 |
} |
124 |
|
|
125 | 169 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/DefaultBandAttributeDescriptor.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.raster.impl; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Collections; |
|
28 |
import java.util.List; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.raster.api.BandAttributeDescriptor; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.dynobject.DynStruct; |
|
33 |
import org.gvsig.tools.lang.Cloneable; |
|
34 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
35 |
import org.gvsig.tools.persistence.PersistentState; |
|
36 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
37 |
|
|
38 |
/** |
|
39 |
* Default implementation of {@link BandAttributeDescriptor}. |
|
40 |
* |
|
41 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
42 |
* |
|
43 |
*/ |
|
44 |
public class DefaultBandAttributeDescriptor implements BandAttributeDescriptor { |
|
45 |
|
|
46 |
private static final String PERSISTENCE_NAME = "BandAttributeDescriptor"; |
|
47 |
private static final String PERSISTENCE_DESCRIPTION = ""; |
|
48 |
|
|
49 |
private static final String BAND_FIELD_NAME = "band"; |
|
50 |
private static final String NAME_FIELD_NAME = "name"; |
|
51 |
private static final String DESCRIPTION_FIELD_NAME = "description"; |
|
52 |
private static final String VALUES_FIELD_NAME = "values"; |
|
53 |
|
|
54 |
private int band; |
|
55 |
private String name; |
|
56 |
private String description; |
|
57 |
private List<Object> values; |
|
58 |
|
|
59 |
/** |
|
60 |
* |
|
61 |
* @param band |
|
62 |
* @param name |
|
63 |
* @param description |
|
64 |
* @param values |
|
65 |
*/ |
|
66 |
public DefaultBandAttributeDescriptor(int band, String name, String description, |
|
67 |
List<Object> values) { |
|
68 |
super(); |
|
69 |
this.band = band; |
|
70 |
this.name = name; |
|
71 |
this.values = values; |
|
72 |
this.description = description; |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
public int getBand() { |
|
77 |
return this.band; |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public String getName() { |
|
82 |
return this.name; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public String getDescription() { |
|
87 |
return this.description; |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public List<Object> getValues() { |
|
92 |
return Collections.unmodifiableList(this.values); |
|
93 |
} |
|
94 |
|
|
95 |
public static void registerPersitenceDefinition() { |
|
96 |
|
|
97 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
98 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_NAME); |
|
99 |
if (definition == null) { |
|
100 |
|
|
101 |
definition = |
|
102 |
persistenceManager.addDefinition(BandAttributeDescriptor.class, PERSISTENCE_NAME, |
|
103 |
PERSISTENCE_DESCRIPTION, null, null); |
|
104 |
definition.addDynFieldInt(BAND_FIELD_NAME); |
|
105 |
definition.addDynFieldString(NAME_FIELD_NAME); |
|
106 |
definition.addDynFieldString(DESCRIPTION_FIELD_NAME); |
|
107 |
definition.addDynFieldList(VALUES_FIELD_NAME).setClassOfItems(Object.class); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
113 |
state.set(BAND_FIELD_NAME, this.getBand()); |
|
114 |
state.set(NAME_FIELD_NAME, this.getName()); |
|
115 |
state.set(DESCRIPTION_FIELD_NAME, this.getDescription()); |
|
116 |
state.set(VALUES_FIELD_NAME, this.getValues()); |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
121 |
this.band = state.getInt(BAND_FIELD_NAME); |
|
122 |
this.name = state.getString(NAME_FIELD_NAME); |
|
123 |
this.description = state.getString(DESCRIPTION_FIELD_NAME); |
|
124 |
this.values = new ArrayList<Object>(state.getList(VALUES_FIELD_NAME)); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public Object clone() throws CloneNotSupportedException { |
|
129 |
List<Object> newValues = new ArrayList<Object>(); |
|
130 |
for (Object object : values) { |
|
131 |
if( object instanceof Cloneable){ |
|
132 |
newValues.add(((Cloneable) object).clone()); |
|
133 |
} else { |
|
134 |
newValues.add(object); |
|
135 |
} |
|
136 |
} |
|
137 |
return new DefaultBandAttributeDescriptor(this.band, this.name, this.description, newValues); |
|
138 |
} |
|
139 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/DefaultBandQuery.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.raster.impl; |
|
25 |
|
|
26 |
import java.util.HashMap; |
|
27 |
import java.util.Map; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.raster.api.BandDescriptor; |
|
30 |
import org.gvsig.fmap.dal.raster.api.BandQuery; |
|
31 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DynStruct; |
|
34 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
35 |
import org.gvsig.tools.persistence.PersistentState; |
|
36 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
37 |
|
|
38 |
/** |
|
39 |
* Default implementation of {@link BandQuery}. |
|
40 |
* |
|
41 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
42 |
* |
|
43 |
*/ |
|
44 |
public class DefaultBandQuery implements BandQuery { |
|
45 |
|
|
46 |
private static final String PERSISTENCE_NAME = "BandQuery"; |
|
47 |
private static final String PERSISTENCE_DESCRIPTION = ""; |
|
48 |
|
|
49 |
private static final String BAND_FIELD_NAME = "band"; |
|
50 |
private static final String BAND_DESCRIPTOR_FIELD_NAME = "bandDescriptor"; |
|
51 |
private static final String VALUES_FIELD_NAME = "values"; |
|
52 |
|
|
53 |
private int band; |
|
54 |
private BandDescriptor bandDescriptor; |
|
55 |
private Map<String, Object> values; |
|
56 |
|
|
57 |
/** |
|
58 |
* Empty constructor |
|
59 |
*/ |
|
60 |
public DefaultBandQuery() { |
|
61 |
|
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Default constructor |
|
66 |
* |
|
67 |
* @param band |
|
68 |
* Band of this BandQuery |
|
69 |
* @param bandDescriptor |
|
70 |
* Descriptor of band |
|
71 |
*/ |
|
72 |
public DefaultBandQuery(int band, BandDescriptor bandDescriptor) { |
|
73 |
super(); |
|
74 |
this.band = band; |
|
75 |
this.bandDescriptor = bandDescriptor; |
|
76 |
this.values = new HashMap<String, Object>(); |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public int getBand() { |
|
81 |
return this.band; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public BandDescriptor getDescriptor() { |
|
86 |
return this.bandDescriptor; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public void setValue(String name, Object value) { |
|
91 |
// TODO Validate name and value |
|
92 |
this.values.put(name, value); |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public Object getValue(String name) { |
|
97 |
return this.values.get(name); |
|
98 |
} |
|
99 |
|
|
100 |
public static void registerPersistenceDefinition(){ |
|
101 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
102 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_NAME); |
|
103 |
if(definition == null){ |
|
104 |
|
|
105 |
definition = persistenceManager.addDefinition(BandQuery.class, PERSISTENCE_NAME, |
|
106 |
PERSISTENCE_DESCRIPTION, null, null); |
|
107 |
definition.addDynFieldInt(BAND_FIELD_NAME); |
|
108 |
definition.addDynField(BAND_DESCRIPTOR_FIELD_NAME).setClassOfValue(BandDescriptor.class); |
|
109 |
definition.addDynFieldMap(VALUES_FIELD_NAME); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
115 |
state.set(BAND_FIELD_NAME, this.getBand()); |
|
116 |
state.set(BAND_DESCRIPTOR_FIELD_NAME, this.getDescriptor()); |
|
117 |
state.set(VALUES_FIELD_NAME, this.values); |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
122 |
this.band = state.getInt(BAND_FIELD_NAME); |
|
123 |
this.bandDescriptor = (BandDescriptor) state.get(BAND_DESCRIPTOR_FIELD_NAME); |
|
124 |
this.values = new HashMap<String, Object>(state.getMap(VALUES_FIELD_NAME)); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public Object clone() throws CloneNotSupportedException { |
|
129 |
return new DefaultBandQuery(this.band, (BandDescriptor) this.getDescriptor().clone()); |
|
130 |
} |
|
131 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/DefaultRasterSet.java | ||
---|---|---|
58 | 58 |
|
59 | 59 |
/** |
60 | 60 |
* Implements RasterSet |
61 |
* |
|
61 | 62 |
* @author dmartinezizquierdo |
62 | 63 |
* |
63 | 64 |
*/ |
64 |
public class DefaultRasterSet extends AbstractIndexedVisitable |
|
65 |
implements RasterSet, Observer{ |
|
65 |
public class DefaultRasterSet extends AbstractIndexedVisitable implements RasterSet, Observer { |
|
66 | 66 |
|
67 | 67 |
private DefaultRasterStore store; |
68 | 68 |
protected RasterQuery query; |
69 | 69 |
protected Buffer buffer; |
70 | 70 |
|
71 |
|
|
72 | 71 |
/** |
73 | 72 |
* Creates a RasterSet with the raster filtered by the query |
73 |
* |
|
74 | 74 |
* @param store |
75 | 75 |
* @param query |
76 | 76 |
* @throws DataException |
77 | 77 |
*/ |
78 |
public DefaultRasterSet(RasterStore store, RasterQuery query) |
|
79 |
throws DataException { |
|
78 |
public DefaultRasterSet(RasterStore store, RasterQuery query) throws DataException { |
|
80 | 79 |
|
81 |
this.store = (DefaultRasterStore)store; |
|
80 |
this.store = (DefaultRasterStore) store;
|
|
82 | 81 |
this.query = query; |
83 | 82 |
RasterStoreProvider provider = this.store.getProvider(); |
84 | 83 |
|
85 | 84 |
try { |
86 |
buffer=provider.createBuffer(query);
|
|
87 |
//Filter buffer by raster query |
|
88 |
if (query!=null){
|
|
89 |
if (query.getClip()!=null){
|
|
85 |
buffer = provider.createBuffer(query);
|
|
86 |
// Filter buffer by raster query
|
|
87 |
if (query != null) {
|
|
88 |
if (query.getClip() != null) {
|
|
90 | 89 |
buffer = buffer.clip(query.getClip()); |
91 | 90 |
} |
92 |
if (query.getBands()!=null){ |
|
93 |
buffer = orderBands(buffer,query.getBands()); |
|
94 |
} |
|
95 |
|
|
96 | 91 |
} |
97 | 92 |
} catch (BufferException e) { |
98 | 93 |
throw new RasterSetInitializeException(e); |
... | ... | |
101 | 96 |
this.store.addObserver(this); |
102 | 97 |
} |
103 | 98 |
|
104 |
private Buffer orderBands(Buffer buffer,int[]bandsOrder){ |
|
105 |
Band[] originalBands = buffer.getBands(); |
|
106 |
int bandCount=buffer.getBandCount(); |
|
107 |
for (int i=0;i<bandCount;i++){ |
|
108 |
buffer.removeBand(i); |
|
109 |
} |
|
110 |
for (int bandIndex:bandsOrder){ |
|
111 |
buffer.addBand(originalBands[bandIndex]); |
|
112 |
} |
|
113 |
return buffer; |
|
114 |
} |
|
115 |
|
|
116 | 99 |
@Override |
117 | 100 |
public void filter(FilterList filterList) { |
118 | 101 |
this.buffer.filter(filterList); |
... | ... | |
215 | 198 |
} |
216 | 199 |
|
217 | 200 |
@Override |
218 |
public Buffer createInterpolated(int rows, int columns, |
|
219 |
int interpolationMode, SimpleTaskStatus status) |
|
220 |
throws LocatorException, BufferException { |
|
201 |
public Buffer createInterpolated(int rows, int columns, int interpolationMode, |
|
202 |
SimpleTaskStatus status) throws LocatorException, BufferException { |
|
221 | 203 |
return this.buffer.createInterpolated(rows, columns, interpolationMode, status); |
222 | 204 |
} |
223 | 205 |
|
224 | 206 |
@Override |
225 |
public Buffer convert(ICoordTrans ct, SimpleTaskStatus status) |
|
226 |
throws BufferException { |
|
207 |
public Buffer convert(ICoordTrans ct, SimpleTaskStatus status) throws BufferException { |
|
227 | 208 |
return this.buffer.convert(ct, status); |
228 | 209 |
} |
229 | 210 |
|
... | ... | |
294 | 275 |
|
295 | 276 |
@Override |
296 | 277 |
public void update(Observable observable, Object notification) { |
297 |
//Do nothing |
|
278 |
// Do nothing
|
|
298 | 279 |
} |
299 | 280 |
|
300 | 281 |
@Override |
301 |
protected void doAccept(Visitor visitor, long firstValueIndex) |
|
302 |
throws VisitCanceledException, BaseException {
|
|
282 |
protected void doAccept(Visitor visitor, long firstValueIndex) throws VisitCanceledException,
|
|
283 |
BaseException { |
|
303 | 284 |
|
304 | 285 |
DefaultRasterKernel kernel = new DefaultRasterKernel(this.buffer); |
305 |
for( int row=0; row<this.buffer.getRows(); row++ ) {
|
|
306 |
for( int column=0; column<this.buffer.getColumns(); column++ ) {
|
|
307 |
kernel.set(row,column); |
|
286 |
for (int row = 0; row < this.buffer.getRows(); row++) {
|
|
287 |
for (int column = 0; column < this.buffer.getColumns(); column++) {
|
|
288 |
kernel.set(row, column);
|
|
308 | 289 |
visitor.visit(kernel); |
309 | 290 |
} |
310 | 291 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/DefaultRasterStore.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.util.Collection; |
26 | 26 |
import java.util.Iterator; |
27 |
import java.util.List; |
|
27 | 28 |
import java.util.Set; |
28 | 29 |
|
29 | 30 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
41 | 42 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
42 | 43 |
import org.gvsig.fmap.dal.feature.exception.PersistenceStoreAlreadyLoadedException; |
43 | 44 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
45 |
import org.gvsig.fmap.dal.raster.api.BandAttributeDescriptor; |
|
46 |
import org.gvsig.fmap.dal.raster.api.BandDescriptor; |
|
47 |
import org.gvsig.fmap.dal.raster.api.BandQuery; |
|
44 | 48 |
import org.gvsig.fmap.dal.raster.api.RasterQuery; |
45 | 49 |
import org.gvsig.fmap.dal.raster.api.RasterSet; |
46 | 50 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
... | ... | |
55 | 59 |
import org.gvsig.metadata.MetadataLocator; |
56 | 60 |
import org.gvsig.metadata.MetadataManager; |
57 | 61 |
import org.gvsig.metadata.exceptions.MetadataException; |
62 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
58 | 63 |
import org.gvsig.timesupport.Interval; |
59 | 64 |
import org.gvsig.tools.ToolsLocator; |
60 | 65 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
... | ... | |
174 | 179 |
|
175 | 180 |
@Override |
176 | 181 |
public String getFullName() { |
177 |
try { |
|
178 |
return this.provider.getFullName(); |
|
179 |
} catch(Throwable th) { |
|
180 |
return null; |
|
181 |
} |
|
182 |
return this.provider.getFullName(); |
|
182 | 183 |
} |
183 | 184 |
|
184 | 185 |
@Override |
... | ... | |
467 | 468 |
@Override |
468 | 469 |
public Object invokeDynMethod(int code, Object[] args) |
469 | 470 |
throws DynMethodException { |
470 |
|
|
471 | 471 |
return this.metadata.invokeDynMethod(this, code, args); |
472 | 472 |
} |
473 | 473 |
|
... | ... | |
531 | 531 |
|
532 | 532 |
} |
533 | 533 |
|
534 |
// |
|
535 |
// ==================================================================== |
|
536 |
// Gestion de notificaciones |
|
537 |
// |
|
538 | 534 |
/** |
539 | 535 |
* Notifies change |
540 | 536 |
* @param notification |
... | ... | |
572 | 568 |
public Envelope getEnvelope() throws DataException { |
573 | 569 |
return this.getRasterSet().getEnvelope(); |
574 | 570 |
} |
571 |
|
|
572 |
@Override |
|
573 |
public BandInfo getBandInfo(int band) { |
|
574 |
return this.provider.getBandInfo(band); |
|
575 |
} |
|
575 | 576 |
|
577 |
@Override |
|
578 |
public BandDescriptor getBandDescriptor(int band) { |
|
579 |
return this.provider.getBandDescriptor(band); |
|
580 |
} |
|
576 | 581 |
|
577 | 582 |
@Override |
583 |
public BandQuery createBandQuery(int band) { |
|
584 |
return new DefaultBandQuery(band, getBandDescriptor(band)); |
|
585 |
} |
|
586 |
|
|
587 |
@Override |
|
588 |
public int getBands() { |
|
589 |
return this.provider.getBands(); |
|
590 |
} |
|
591 |
|
|
592 |
@Override |
|
593 |
public BandDescriptor createBandDescriptor(int band, List<BandAttributeDescriptor> attributes) { |
|
594 |
return new DefaultBandDescriptor(band, attributes); |
|
595 |
} |
|
596 |
|
|
597 |
@Override |
|
598 |
public BandAttributeDescriptor createBandAttributeDescriptor(int band, String name, |
|
599 |
String description, List<Object> values) { |
|
600 |
return new DefaultBandAttributeDescriptor(band, name, description, values); |
|
601 |
} |
|
602 |
|
|
603 |
@Override |
|
578 | 604 |
public void notifyChange(String notification, Resource resource) { |
579 | 605 |
notifyChange(new DefaultRasterStoreNotification(this, |
580 | 606 |
DataStoreNotification.RESOURCE_CHANGED)); |
581 |
|
|
582 | 607 |
} |
583 | 608 |
|
584 | 609 |
@Override |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/RasterLibrary.java | ||
---|---|---|
54 | 54 |
|
55 | 55 |
@Override |
56 | 56 |
protected void doInitialize() throws LibraryException { |
57 |
|
|
58 |
//Register persistence definition |
|
59 |
DefaultRasterQuery.registerPersistenceDefinition(); |
|
60 |
DefaultBandQuery.registerPersistenceDefinition(); |
|
61 |
DefaultBandDescriptor.registerPersitenceDefinition(); |
|
62 |
DefaultBandAttributeDescriptor.registerPersitenceDefinition(); |
|
57 | 63 |
} |
58 | 64 |
|
59 | 65 |
@Override |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.impl/src/main/java/org/gvsig/fmap/dal/raster/impl/DefaultBandDescriptor.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.raster.impl; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Iterator; |
|
28 |
import java.util.List; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.raster.api.BandAttributeDescriptor; |
|
31 |
import org.gvsig.fmap.dal.raster.api.BandDescriptor; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DynStruct; |
|
34 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
35 |
import org.gvsig.tools.persistence.PersistentState; |
|
36 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
37 |
|
|
38 |
/** |
|
39 |
* Default implementation of {@link BandDescriptor}. |
|
40 |
* |
|
41 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
42 |
* |
|
43 |
*/ |
|
44 |
public class DefaultBandDescriptor implements BandDescriptor { |
|
45 |
|
|
46 |
private static final String PERSISTENCE_NAME = "BandDescriptor"; |
|
47 |
private static final String PERSISTENCE_DESCRIPTION = ""; |
|
48 |
|
|
49 |
private static final String BAND_FIELD_NAME = "band"; |
|
50 |
private static final String BAND_ATTRIBUTE_DESCRIPTORS_FIELD_NAME = "bandAttributeDescriptors"; |
|
51 |
|
|
52 |
private List<BandAttributeDescriptor> bandAttributeDescriptors; |
|
53 |
private int band; |
|
54 |
|
|
55 |
/** |
|
56 |
* |
|
57 |
* @param band |
|
58 |
* @param attributeDescriptors |
|
59 |
*/ |
|
60 |
public DefaultBandDescriptor(int band, List<BandAttributeDescriptor> attributeDescriptors) { |
|
61 |
this.band = band; |
|
62 |
this.bandAttributeDescriptors = attributeDescriptors; |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public int getBand() { |
|
67 |
return this.band; |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public BandAttributeDescriptor get(int index) { |
|
72 |
if (index >= 0 && index < bandAttributeDescriptors.size()) { |
|
73 |
return bandAttributeDescriptors.get(index); |
|
74 |
} |
|
75 |
return null; |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public BandAttributeDescriptor get(String name) { |
|
80 |
for (BandAttributeDescriptor bandAttributeDescriptor : bandAttributeDescriptors) { |
|
81 |
if (bandAttributeDescriptor.getName().equals(name)) { |
|
82 |
return bandAttributeDescriptor; |
|
83 |
} |
|
84 |
} |
|
85 |
return null; |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public int size() { |
|
90 |
return bandAttributeDescriptors.size(); |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public Iterator<BandAttributeDescriptor> iterator() { |
|
95 |
return bandAttributeDescriptors.iterator(); |
|
96 |
} |
|
97 |
|
|
98 |
public static void registerPersitenceDefinition() { |
|
99 |
|
|
100 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
101 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_NAME); |
|
102 |
|
|
103 |
if (definition == null) { |
|
104 |
definition = |
|
105 |
persistenceManager.addDefinition(BandDescriptor.class, PERSISTENCE_NAME, |
|
106 |
PERSISTENCE_DESCRIPTION, null, null); |
|
107 |
definition.addDynFieldInt(BAND_FIELD_NAME); |
|
108 |
definition.addDynFieldList(BAND_ATTRIBUTE_DESCRIPTORS_FIELD_NAME).setClassOfItems( |
|
109 |
BandAttributeDescriptor.class); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
115 |
state.set(BAND_FIELD_NAME, this.getBand()); |
|
116 |
state.set(BAND_ATTRIBUTE_DESCRIPTORS_FIELD_NAME, this.bandAttributeDescriptors); |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
121 |
this.band = state.getInt(BAND_FIELD_NAME); |
|
122 |
this.bandAttributeDescriptors = |
|
123 |
new ArrayList<BandAttributeDescriptor>( |
|
124 |
state.getList(BAND_ATTRIBUTE_DESCRIPTORS_FIELD_NAME)); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public Object clone() throws CloneNotSupportedException { |
|
129 |
|
|
130 |
List<BandAttributeDescriptor> newAttributeDescriptors = |
|
131 |
new ArrayList<BandAttributeDescriptor>(); |
|
132 |
|
|
133 |
for (BandAttributeDescriptor bandAttributeDescriptor : this.bandAttributeDescriptors) { |
|
134 |
newAttributeDescriptors.add((BandAttributeDescriptor) bandAttributeDescriptor.clone()); |
|
135 |
} |
|
136 |
|
|
137 |
return new DefaultBandDescriptor(this.band, newAttributeDescriptors); |
|
138 |
} |
|
139 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.api/src/main/java/org/gvsig/fmap/dal/raster/api/BandQuery.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.raster.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.lang.Cloneable; |
|
27 |
import org.gvsig.tools.persistence.Persistent; |
|
28 |
|
|
29 |
/** |
|
30 |
* Band query to filter raster band values by {@link BandAttributeDescriptor} |
|
31 |
* values described by the {@link BandDescriptor}. |
|
32 |
* |
|
33 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
34 |
* |
|
35 |
*/ |
|
36 |
public interface BandQuery extends Persistent, Cloneable { |
|
37 |
|
|
38 |
/** |
|
39 |
* Band of this query band. |
|
40 |
* |
|
41 |
* @return Band Band of this query band |
|
42 |
*/ |
|
43 |
public int getBand(); |
|
44 |
|
|
45 |
/** |
|
46 |
* Gets {@link BandDescriptor} of this query. |
|
47 |
* |
|
48 |
* @return descriptor Descriptor of this band |
|
49 |
*/ |
|
50 |
public BandDescriptor getDescriptor(); |
|
51 |
|
|
52 |
/** |
|
53 |
* Sets filter raster band value. This value has to be accepted by the |
|
54 |
* {@link BandAttributeDescriptor} with the name received as parameter. |
|
55 |
* |
|
56 |
* @param name |
|
57 |
* Name of {@link BandAttributeDescriptor} to check if value is |
|
58 |
* accepted by it. |
|
59 |
* @param value |
|
60 |
* Value to apply filter. |
|
61 |
*/ |
|
62 |
public void setValue(String name, Object value); |
|
63 |
|
|
64 |
/** |
|
65 |
* Gets the defined filter value of {@link BandAttributeDescriptor} with the |
|
66 |
* name received as parameter. |
|
67 |
* |
|
68 |
* @param name |
|
69 |
* Name of {@link BandAttributeDescriptor} |
|
70 |
* @return value Value defined |
|
71 |
*/ |
|
72 |
public Object getValue(String name); |
|
73 |
|
|
74 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.api/src/main/java/org/gvsig/fmap/dal/raster/api/RasterStore.java | ||
---|---|---|
26 | 26 |
import org.gvsig.fmap.dal.DataStoreParameters; |
27 | 27 |
import org.gvsig.fmap.dal.exception.DataException; |
28 | 28 |
import org.gvsig.fmap.geom.primitive.Envelope; |
29 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
29 | 30 |
import org.gvsig.tools.lang.Cloneable; |
30 | 31 |
|
31 | 32 |
/** |
... | ... | |
79 | 80 |
* @return RasterQuery |
80 | 81 |
*/ |
81 | 82 |
RasterQuery createRasterQuery(); |
82 |
|
|
83 |
|
|
83 | 84 |
/** |
84 | 85 |
* Returns the envelope associated to this store buffer |
85 | 86 |
* @return Envelope |
86 | 87 |
* @throws DataException |
87 | 88 |
*/ |
88 | 89 |
Envelope getEnvelope() throws DataException; |
90 |
|
|
91 |
/** |
|
92 |
* Creates a {@link BandQuery} from band received as parameter. |
|
93 |
* |
|
94 |
* @param band |
|
95 |
* Band to create BandQuery |
|
96 |
* @return BandQuery |
|
97 |
*/ |
|
98 |
public BandQuery createBandQuery(int band); |
|
99 |
|
|
100 |
/** |
|
101 |
* Gets information about the specified band. If band does not have |
|
102 |
* information, it will return <code>null</code> |
|
103 |
* |
|
104 |
* @param band |
|
105 |
* The specified band |
|
106 |
* @return Returns information about specified band. |
|
107 |
*/ |
|
108 |
public BandInfo getBandInfo(int band); |
|
89 | 109 |
|
110 |
/** |
|
111 |
* Gets {@link BandDescriptor} of band received as parameter. If band does |
|
112 |
* not have {@link BandAttributeDescriptor}, this method will return an |
|
113 |
* empty {@link BandDescriptor}. |
|
114 |
* |
|
115 |
* @param band |
|
116 |
* Band to get its {@link BandDescriptor} |
|
117 |
* @return BandDescriptor |
|
118 |
*/ |
|
119 |
public BandDescriptor getBandDescriptor(int band); |
|
120 |
|
|
121 |
/** |
|
122 |
* Gets number of total bands |
|
123 |
* |
|
124 |
* @return Number of bands |
|
125 |
*/ |
|
126 |
public int getBands(); |
|
127 |
|
|
90 | 128 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.api/src/main/java/org/gvsig/fmap/dal/raster/api/BandDescriptor.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.raster.api; |
|
25 |
|
|
26 |
import java.util.Iterator; |
|
27 |
|
|
28 |
import org.gvsig.tools.lang.Cloneable; |
|
29 |
import org.gvsig.tools.persistence.Persistent; |
|
30 |
|
|
31 |
/** |
|
32 |
* This class describes the available {@link BandAttributeDescriptor} of a band. |
|
33 |
* |
|
34 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
35 |
* |
|
36 |
*/ |
|
37 |
public interface BandDescriptor extends Iterable<BandAttributeDescriptor>, Persistent, Cloneable { |
|
38 |
|
|
39 |
/** |
|
40 |
* Gets band of this descriptor. |
|
41 |
* |
|
42 |
* @return Band |
|
43 |
*/ |
|
44 |
public int getBand(); |
|
45 |
|
|
46 |
/** |
|
47 |
* Gets the {@link BandAttributeDescriptor} by index. |
|
48 |
* |
|
49 |
* @param index |
|
50 |
* Index of {@link BandAttributeDescriptor} |
|
51 |
* @return BandAttributeDescriptor The {@link BandAttributeDescriptor} |
|
52 |
* located at index. If there are not |
|
53 |
* {@link BandAttributeDescriptor} at index, null will be returned. |
|
54 |
*/ |
|
55 |
public BandAttributeDescriptor get(int index); |
|
56 |
|
|
57 |
/** |
|
58 |
* Gets the {@link BandAttributeDescriptor} by name. |
|
59 |
* |
|
60 |
* @param name |
|
61 |
* Name of {@link BandAttributeDescriptor} |
|
62 |
* @return BandAttributeDescriptor The {@link BandAttributeDescriptor} |
|
63 |
* located at index. If there are not |
|
64 |
* {@link BandAttributeDescriptor} whit the name, null will be returned. |
|
65 |
*/ |
|
66 |
public BandAttributeDescriptor get(String name); |
|
67 |
|
|
68 |
/** |
|
69 |
* Number of {@link BandAttributeDescriptor}. |
|
70 |
* |
|
71 |
* @return size Number of band attribute descriptor. |
|
72 |
*/ |
|
73 |
public int size(); |
|
74 |
|
|
75 |
/** |
|
76 |
* @return Returns an iterator over the elements in this list in proper |
|
77 |
* sequence. |
|
78 |
*/ |
|
79 |
public Iterator<BandAttributeDescriptor> iterator(); |
|
80 |
|
|
81 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.api/src/main/java/org/gvsig/fmap/dal/raster/api/RasterQuery.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
package org.gvsig.fmap.dal.raster.api; |
25 | 25 |
|
26 |
import java.util.List; |
|
27 |
|
|
26 | 28 |
import org.gvsig.fmap.dal.DataQuery; |
27 | 29 |
import org.gvsig.fmap.geom.primitive.Envelope; |
28 | 30 |
import org.gvsig.tools.lang.Cloneable; |
... | ... | |
33 | 35 |
* @author dmartinezizquierdo |
34 | 36 |
* |
35 | 37 |
*/ |
36 |
public interface RasterQuery extends DataQuery,Cloneable { |
|
38 |
public interface RasterQuery extends DataQuery, Cloneable {
|
|
37 | 39 |
|
38 |
//TODO: |
|
39 |
// /** |
|
40 |
// * Bands to be queried and their order |
|
41 |
// * @return int[] |
|
42 |
// */ |
|
43 |
// List<BandQuery> getBands(); |
|
44 |
// |
|
45 |
// /** |
|
46 |
// * Sets the bands to be queried and their order |
|
47 |
// * @param bands |
|
48 |
// * @return RasterQuery |
|
49 |
// */ |
|
50 |
// RasterQuery addBand(int band); |
|
51 |
// |
|
52 |
// RasterQuery addBand(BandQuery query); |
|
53 |
// |
|
54 |
// RasterQuery clearBands(); |
|
55 |
//... and remove this band methods: |
|
56 |
public int[] getBands(); |
|
57 |
public RasterQuery setBands(int[] bands); |
|
40 |
/** |
|
41 |
* Get added band queries to this {@link RasterQuery} |
|
42 |
* |
|
43 |
* @return A unmodifiable list with added band queries. |
|
44 |
*/ |
|
45 |
public List<BandQuery> getBands(); |
|
58 | 46 |
|
59 | 47 |
/** |
48 |
* Adds {@link BandQuery} to this raster query |
|
49 |
* |
|
50 |
* @param query |
|
51 |
* Query to be added |
|
52 |
*/ |
|
53 |
public void addBand(BandQuery query); |
|
54 |
|
|
55 |
/** |
|
56 |
* Clears all add band queries |
|
57 |
*/ |
|
58 |
public void clearBands(); |
|
59 |
|
|
60 |
/** |
|
60 | 61 |
* Returns a clip from the raster |
61 | 62 |
* @return Envelope |
62 | 63 |
*/ |
63 |
Envelope getClip(); |
|
64 |
public Envelope getClip();
|
|
64 | 65 |
|
65 | 66 |
/** |
66 | 67 |
* Sets the envelope to clip from the raster |
67 | 68 |
* @param clip |
68 | 69 |
* @return RasterQuery |
69 | 70 |
*/ |
70 |
RasterQuery setClip(Envelope clip); |
|
71 |
public RasterQuery setClip(Envelope clip);
|
|
71 | 72 |
|
72 | 73 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.api/src/main/java/org/gvsig/fmap/dal/raster/api/BandAttributeDescriptor.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.raster.api; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.tools.lang.Cloneable; |
|
29 |
import org.gvsig.tools.persistence.Persistent; |
|
30 |
|
|
31 |
/** |
|
32 |
* This class describes an attribute of band. This attribute is defined by a |
|
33 |
* name, description and a list with the available values. |
|
34 |
* |
|
35 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
36 |
* |
|
37 |
*/ |
|
38 |
public interface BandAttributeDescriptor extends Persistent, Cloneable { |
|
39 |
|
|
40 |
/** |
|
41 |
* Gets band of this attribute descriptor |
|
42 |
* |
|
43 |
* @return band Attribute descriptor band |
|
44 |
*/ |
|
45 |
public int getBand(); |
|
46 |
|
|
47 |
/** |
|
48 |
* Name of attribute |
|
49 |
* |
|
50 |
* @return Attribute name |
|
51 |
*/ |
|
52 |
public String getName(); |
|
53 |
|
|
54 |
/** |
|
55 |
* Description of attribute |
|
56 |
* |
|
57 |
* @return Attribute description |
|
58 |
*/ |
|
59 |
public String getDescription(); |
|
60 |
|
|
61 |
/** |
|
62 |
* Available values of this attribute band |
|
63 |
* |
|
64 |
* @return values A list with attribute band values |
|
65 |
*/ |
|
66 |
public List<Object> getValues(); |
|
67 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.spi/src/main/java/org/gvsig/fmap/dal/raster/spi/RasterStoreProvider.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.dal.raster.spi; |
24 | 24 |
|
25 |
import org.gvsig.fmap.dal.raster.api.BandAttributeDescriptor; |
|
26 |
import org.gvsig.fmap.dal.raster.api.BandDescriptor; |
|
25 | 27 |
import org.gvsig.fmap.dal.raster.api.RasterQuery; |
26 | 28 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
29 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
27 | 30 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
28 | 31 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
29 | 32 |
|
... | ... | |
41 | 44 |
* @throws BufferException |
42 | 45 |
*/ |
43 | 46 |
Buffer createBuffer(RasterQuery rasterQuery) throws BufferException; |
47 |
|
|
48 |
/** |
|
49 |
* Gets information about the specified band. If band does not have |
|
50 |
* information, it will return <code>null</code> |
|
51 |
* |
|
52 |
* @param band |
|
53 |
* The specified band |
|
54 |
* @return Returns information about specified band. |
|
55 |
*/ |
|
56 |
public BandInfo getBandInfo(int band); |
|
57 |
|
|
58 |
/** |
|
59 |
* Gets {@link BandDescriptor} of band received as parameter. If band does |
|
60 |
* not have {@link BandAttributeDescriptor}, this method will return an |
|
61 |
* empty {@link BandDescriptor}. |
|
62 |
* |
|
63 |
* @param band |
|
64 |
* Band to get its {@link BandDescriptor} |
|
65 |
* @return BandDescriptor |
|
66 |
*/ |
|
67 |
public BandDescriptor getBandDescriptor(int band); |
|
68 |
|
|
69 |
/** |
|
70 |
* Gets bands of raster provider source |
|
71 |
* |
|
72 |
* @return Number of available bands from source |
|
73 |
*/ |
|
74 |
public int getBands(); |
|
44 | 75 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.raster/org.gvsig.fmap.dal.raster.spi/src/main/java/org/gvsig/fmap/dal/raster/spi/RasterStoreProviderServices.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.dal.raster.spi; |
24 | 24 |
|
25 |
import java.util.List; |
|
26 |
|
|
25 | 27 |
import org.gvsig.fmap.dal.DataManager; |
28 |
import org.gvsig.fmap.dal.raster.api.BandAttributeDescriptor; |
|
29 |
import org.gvsig.fmap.dal.raster.api.BandDescriptor; |
|
26 | 30 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
27 | 31 |
import org.gvsig.fmap.dal.resource.Resource; |
28 | 32 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
... | ... | |
41 | 45 |
* @param data |
42 | 46 |
*/ |
43 | 47 |
public void notifyChange(String notification, ResourceProvider data); |
44 |
|
|
45 |
|
|
48 |
|
|
46 | 49 |
/** |
47 | 50 |
* Call this to send a notification to observers of this store relative to |
48 | 51 |
* Resources |
49 | 52 |
* |
50 | 53 |
* @param notification |
54 |
* @param resource |
|
51 | 55 |
*/ |
52 | 56 |
public void notifyChange(String notification, Resource resource); |
53 | 57 |
|
54 |
|
|
55 | 58 |
/** |
56 |
* Reaturn {@link DataManager} instance. |
|
57 |
* |
|
58 |
* @return |
|
59 |
* @return Returns {@link DataManager} instance. |
|
59 | 60 |
*/ |
60 | 61 |
public DataManager getManager(); |
61 | 62 |
|
62 |
|
|
63 | 63 |
/** |
64 |
* Return the instance of {@link RasterStoreProvider} for this store. |
|
65 |
* |
|
66 |
* @return |
|
64 |
* @return Returns the instance of {@link RasterStoreProvider} for this store. |
|
67 | 65 |
*/ |
68 | 66 |
public RasterStoreProvider getProvider(); |
69 | 67 |
|
70 |
|
|
71 | 68 |
/** |
72 |
* Return current RasterStore |
|
73 |
* |
|
74 |
* @return |
|
69 |
* @return Returns current RasterStore |
|
75 | 70 |
*/ |
76 | 71 |
public RasterStore getRasterStore(); |
77 | 72 |
|
78 | 73 |
/** |
79 |
* Return current FeatureStore name. |
|
80 |
* |
|
81 |
* @return |
|
74 |
* @return Returns current FeatureStore name. |
|
82 | 75 |
*/ |
83 | 76 |
public String getName(); |
77 |
|
|
78 |
/** |
|
79 |
* Creates a {@link BandDescriptor} object. |
|
80 |
* |
|
81 |
* @param band |
|
82 |
* BandDescriptor band |
|
83 |
* @param attributes |
|
84 |
* A list with available {@link BandAttributeDescriptor}. |
|
85 |
* @return New instance of band descriptor |
|
86 |
*/ |
|
87 |
public BandDescriptor createBandDescriptor(int band, List<BandAttributeDescriptor> attributes); |
|
84 | 88 |
|
89 |
/** |
|
90 |
* Creates a {@link BandAttributeDescriptor}. |
|
91 |
* |
|
92 |
* @param band |
|
93 |
* Band of attribute descriptor. |
|
94 |
* @param name |
|
95 |
* Name of attribute |
|
96 |
* @param description |
|
97 |
* Descriptor of attribute |
|
98 |
* @param values |
|
99 |
* Values of band attribute descriptor |
|
100 |
* @return A new {@link BandAttributeDescriptor} |
|
101 |
*/ |
|
102 |
public BandAttributeDescriptor createBandAttributeDescriptor(int band, String name, |
|
103 |
String description, List<Object> values); |
|
85 | 104 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.mapcontext.raster/org.gvsig.fmap.mapcontext.raster.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/impl/DefaultRasterLayer.java | ||
---|---|---|
30 | 30 |
import java.awt.image.IndexColorModel; |
31 | 31 |
import java.util.ArrayList; |
32 | 32 |
import java.util.List; |
33 |
import java.util.Map.Entry; |
|
33 | 34 |
import java.util.Observable; |
34 | 35 |
import java.util.Observer; |
35 | 36 |
import java.util.Set; |
... | ... | |
43 | 44 |
import org.gvsig.fmap.dal.file.jimi.JimiRasterStoreProvider; |
44 | 45 |
import org.gvsig.fmap.dal.file.jimi.MemoryImage; |
45 | 46 |
import org.gvsig.fmap.dal.raster.api.RasterQuery; |
47 |
import org.gvsig.fmap.dal.raster.api.RasterSet; |
|
46 | 48 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
47 | 49 |
import org.gvsig.fmap.dal.raster.api.RasterStoreNotification; |
48 | 50 |
import org.gvsig.fmap.dal.raster.impl.DefaultRasterStore; |
... | ... | |
58 | 60 |
import org.gvsig.fmap.mapcontext.raster.api.RasterLayer; |
59 | 61 |
import org.gvsig.fmap.mapcontext.raster.api.RasterLegendChangedListener; |
60 | 62 |
import org.gvsig.metadata.exceptions.MetadataException; |
61 |
import org.gvsig.raster.lib.legend.api.ColorInterpretation; |
|
63 |
import org.gvsig.raster.lib.buffer.api.Band; |
|
64 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
62 | 65 |
import org.gvsig.raster.lib.legend.api.ColorTable; |
63 | 66 |
import org.gvsig.raster.lib.legend.api.ColorTableClass; |
64 | 67 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
65 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
66 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
67 | 68 |
import org.gvsig.tools.ToolsLocator; |
68 | 69 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
69 | 70 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
... | ... | |
92 | 93 |
|
93 | 94 |
/** |
94 | 95 |
* Creates a new DefaultRasterLayer |
95 |
* @param store |
|
96 |
* @param legend |
|
97 |
* @throws |
|
96 |
* @throws LoadLayerException |
|
98 | 97 |
*/ |
99 | 98 |
public DefaultRasterLayer() throws LoadLayerException{ |
100 | 99 |
super(); |
... | ... | |
177 | 176 |
|
178 | 177 |
//Should be moved to mapContextManager when RasterLegend implements ILegend |
179 | 178 |
if (legend == null) { |
180 |
try {
|
|
179 |
try { |
|
181 | 180 |
legend = (RasterLegend) store.invokeDynMethod(RasterStore.DYNMETHOD_GETLEGEND_NAME, null); |
182 |
} catch (DynMethodNotSupportedException e) { |
|
183 |
logger.debug("This store {} does not provide a legend.", |
|
184 |
store.getName()); |
|
185 |
} catch (DynMethodException e) { |
|
186 |
logger.error( |
|
187 |
"Can't load the specific legend provided for the store {}.", |
|
188 |
store.getName(), e); |
|
189 |
} |
|
181 |
} catch (DynMethodNotSupportedException e) { |
|
182 |
logger.debug("This store {} does not provide a legend.", |
|
183 |
store.getName()); |
|
184 |
} catch (DynMethodException e) { |
|
185 |
logger.error( |
|
186 |
"Can't load the specific legend provided for the store {}.", |
|
187 |
store.getName(), e); |
|
190 | 188 |
} |
189 |
} |
|
191 | 190 |
|
192 | 191 |
|
193 | 192 |
if (legend == null) { |
... | ... | |
254 | 253 |
SimpleTaskStatus taskStatus = manager.createDefaultSimpleTaskStatus("Draw "+getDataStore().getName()); |
255 | 254 |
|
256 | 255 |
((RasterLegend) legend).draw(g, getRasterStore().getRasterSet(rasterQuery), viewPort, taskStatus); |
257 |
|
|
256 |
|
|
258 | 257 |
logger.debug("Layer " + this.getName() + " drawn in " |
259 | 258 |
+ (System.currentTimeMillis() - tini) + " milliseconds."); |
260 | 259 |
|
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/AbstractBand.java | ||
---|---|---|
1 | 1 |
package org.gvsig.raster.lib.buffer.impl; |
2 | 2 |
|
3 | 3 |
import org.gvsig.raster.lib.buffer.api.Band; |
4 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
4 | 5 |
import org.gvsig.raster.lib.buffer.api.BandNotification; |
5 | 6 |
import org.gvsig.raster.lib.buffer.api.NoData; |
6 | 7 |
import org.gvsig.raster.lib.buffer.api.exceptions.BandException; |
... | ... | |
16 | 17 |
int rows; |
17 | 18 |
int columns; |
18 | 19 |
NoData noData; |
20 |
BandInfo bandInfo; |
|
19 | 21 |
|
20 | 22 |
@Override |
21 | 23 |
public int getColumns() { |
... | ... | |
31 | 33 |
public NoData getNoData() { |
32 | 34 |
return this.noData; |
33 | 35 |
} |
36 |
|
|
37 |
@Override |
|
38 |
public BandInfo getBandInfo(){ |
|
39 |
return this.bandInfo; |
|
40 |
} |
|
34 | 41 |
|
35 | 42 |
public Object clone() throws CloneNotSupportedException { |
36 | 43 |
AbstractBand cloned = (AbstractBand) super.clone(); |
... | ... | |
86 | 93 |
} |
87 | 94 |
|
88 | 95 |
protected abstract void doPutRow(int row, Object rowBuffer); |
89 |
|
|
90 |
|
|
91 |
|
|
92 | 96 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/AbstractPaginatedBand.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
Also available in: Unified diff