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 / datastruct / DefaultDataStructFactory.java @ 859
History | View | Annotate | Download (6.24 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.datastruct; |
23 |
|
24 |
import java.awt.geom.Point2D; |
25 |
import java.awt.geom.Rectangle2D; |
26 |
|
27 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
28 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
29 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorTableLibrary; |
30 |
import org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory; |
31 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
32 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
33 |
import org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange; |
34 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
35 |
import org.gvsig.raster.impl.datastruct.persistence.DefaultColorTableLibrary; |
36 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
37 |
|
38 |
/**
|
39 |
* Factory for data structures
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
41 |
*
|
42 |
*/
|
43 |
public class DefaultDataStructFactory implements DataStructFactory { |
44 |
|
45 |
/*
|
46 |
* (non-Javadoc)
|
47 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createTransparencyRange()
|
48 |
*/
|
49 |
public TransparencyRange createTransparencyRange() {
|
50 |
return new TransparencyRangeImpl(); |
51 |
} |
52 |
|
53 |
/*
|
54 |
* (non-Javadoc)
|
55 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#getColorTableLibrary()
|
56 |
*/
|
57 |
public ColorTableLibrary getColorTableLibrary() {
|
58 |
return DefaultColorTableLibrary.getInstance();
|
59 |
} |
60 |
|
61 |
/*
|
62 |
* (non-Javadoc)
|
63 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(java.awt.geom.Point2D, java.awt.geom.Point2D)
|
64 |
*/
|
65 |
public Extent createExtent(Point2D ul, Point2D lr) { |
66 |
return new ExtentImpl(ul, lr); |
67 |
} |
68 |
|
69 |
/*
|
70 |
* (non-Javadoc)
|
71 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(java.awt.geom.Point2D, java.awt.geom.Point2D, java.awt.geom.Point2D, java.awt.geom.Point2D)
|
72 |
*/
|
73 |
public Extent createExtent(Point2D ul, Point2D lr, Point2D ur, Point2D ll) { |
74 |
return new ExtentImpl(ul, lr, ur, ll); |
75 |
} |
76 |
|
77 |
/*
|
78 |
* (non-Javadoc)
|
79 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(double, double, double, double)
|
80 |
*/
|
81 |
public Extent createExtent(double x1, double y1, double x2, double y2) { |
82 |
return new ExtentImpl(x1, y1, x2, y2); |
83 |
} |
84 |
|
85 |
/*
|
86 |
* (non-Javadoc)
|
87 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(java.awt.geom.Rectangle2D)
|
88 |
*/
|
89 |
public Extent createExtent(Rectangle2D r) { |
90 |
return new ExtentImpl(r); |
91 |
} |
92 |
|
93 |
/*
|
94 |
* (non-Javadoc)
|
95 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent()
|
96 |
*/
|
97 |
public Extent createExtent() {
|
98 |
return new ExtentImpl(); |
99 |
} |
100 |
|
101 |
/*
|
102 |
* (non-Javadoc)
|
103 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createNoData(java.lang.Number, java.lang.Number, java.lang.String, int)
|
104 |
*/
|
105 |
public NoData createNoData(Number noData, Number nativeNoData, String fileName, int bandCount) { |
106 |
return new DefaultNoData(noData, nativeNoData, fileName, bandCount); |
107 |
} |
108 |
|
109 |
/*
|
110 |
* (non-Javadoc)
|
111 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createNoData(java.lang.Number, java.lang.Number, java.lang.String)
|
112 |
*/
|
113 |
public NoData createNoData(Number noData, Number nativeNoData, String fileName) { |
114 |
return new DefaultNoData(noData, nativeNoData, fileName); |
115 |
} |
116 |
|
117 |
/*
|
118 |
* (non-Javadoc)
|
119 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createDefaultNoData(int, int)
|
120 |
*/
|
121 |
public NoData createDefaultNoData(int bandCount, int dataType) { |
122 |
switch (dataType) {
|
123 |
case Buffer.TYPE_BYTE: |
124 |
return new DefaultNoData(new Byte(RasterLibrary.defaultByteNoDataValue), new Byte(RasterLibrary.defaultByteNoDataValue), null); |
125 |
case Buffer.TYPE_SHORT: |
126 |
return new DefaultNoData(new Short(RasterLibrary.defaultShortNoDataValue), new Short(RasterLibrary.defaultShortNoDataValue), null); |
127 |
case Buffer.TYPE_INT: |
128 |
return new DefaultNoData(new Integer(RasterLibrary.defaultIntegerNoDataValue), new Integer(RasterLibrary.defaultIntegerNoDataValue), null); |
129 |
case Buffer.TYPE_FLOAT: |
130 |
return new DefaultNoData(new Float(RasterLibrary.defaultFloatNoDataValue), new Float(RasterLibrary.defaultFloatNoDataValue), null); |
131 |
case Buffer.TYPE_DOUBLE: |
132 |
return new DefaultNoData(new Double(RasterLibrary.defaultDoubleNoDataValue), new Double(RasterLibrary.defaultDoubleNoDataValue), null); |
133 |
} |
134 |
return null; |
135 |
} |
136 |
|
137 |
/*
|
138 |
* (non-Javadoc)
|
139 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createDataStore()
|
140 |
*/
|
141 |
public RasterDataStore createDataStore() {
|
142 |
return new DefaultRasterStore(); |
143 |
} |
144 |
|
145 |
/*
|
146 |
* (non-Javadoc)
|
147 |
* @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#loadStatisticsFromStore(org.gvsig.fmap.dal.coverage.store.RasterDataStore)
|
148 |
*/
|
149 |
/*public Statistics loadStatisticsFromStore(RasterDataStore store) throws RmfSerializerException {
|
150 |
SimpleProviderStatistics[] stats = new SimpleProviderStatistics[store.getProviderCount()];
|
151 |
|
152 |
RasterProvider prov = (RasterProvider)store.getProvider();
|
153 |
|
154 |
for (int i = 0; i < prov.getInternalProviderCount(); i++) {
|
155 |
Statistics statFile = prov.getInternalProvider(i).getStatistics();
|
156 |
stats[i] = (SimpleProviderStatistics)prov.getInternalProvider(i).loadObjectFromRmf(Statistics.class, statFile);
|
157 |
|
158 |
//Con que un dataset no tenga la estadistica calculada se pone a no calculado el DatasetListStatistics
|
159 |
if(!stats[i].isCalculated())
|
160 |
return null;
|
161 |
}
|
162 |
MultiProviderStatistics result = new MultiProviderStatistics(stats, prov.getBandCount());
|
163 |
result.setCalculated(true);
|
164 |
return result;
|
165 |
}*/
|
166 |
|
167 |
} |