Statistics
| Revision:

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 @ 162

History | View | Annotate | Download (4.89 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.datastruct.ColorTableLibrary;
28
import org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory;
29
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
30
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
31
import org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange;
32
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
33
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
34
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
35
import org.gvsig.raster.impl.datastruct.persistence.DefaultColorTableLibrary;
36
import org.gvsig.raster.impl.store.DefaultMultiRasterStore;
37
import org.gvsig.raster.impl.store.properties.DataStoreStatistics;
38
import org.gvsig.raster.impl.store.properties.MultiDataStoreStatistics;
39

    
40
/**
41
 * Factory for data structures
42
 * @author Nacho Brodin (nachobrodin@gmail.com)
43
 *
44
 */
45
public class DefaultDataStructFactory implements DataStructFactory {
46

    
47
        /*
48
         * (non-Javadoc)
49
         * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createTransparencyRange()
50
         */
51
        public TransparencyRange createTransparencyRange() {
52
                return new TransparencyRangeImpl();
53
        }
54

    
55
   /*
56
    * (non-Javadoc)
57
    * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#getColorTableLibrary()
58
    */
59
    public ColorTableLibrary getColorTableLibrary() {
60
            return DefaultColorTableLibrary.getInstance();
61
    }
62
    
63
    /*
64
     * (non-Javadoc)
65
     * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(java.awt.geom.Point2D, java.awt.geom.Point2D)
66
     */
67
    public Extent createExtent(Point2D ul, Point2D lr) {
68
            return new ExtentImpl(ul, lr);
69
    }
70
    
71
    /*
72
     * (non-Javadoc)
73
     * @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)
74
     */
75
    public Extent createExtent(Point2D ul, Point2D lr, Point2D ur, Point2D ll) {
76
            return new ExtentImpl(ul, lr, ur, ll);
77
    }
78

    
79
    /*
80
     * (non-Javadoc)
81
     * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(double, double, double, double)
82
     */
83
    public Extent createExtent(double x1, double y1, double x2, double y2) {
84
            return new ExtentImpl(x1, y1, x2, y2);
85
    }
86

    
87
    /*
88
     * (non-Javadoc)
89
     * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent(java.awt.geom.Rectangle2D)
90
     */
91
    public Extent createExtent(Rectangle2D r) {
92
            return new ExtentImpl(r);
93
    }
94
    
95
   /*
96
    * (non-Javadoc)
97
    * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createExtent()
98
    */
99
    public Extent createExtent() {
100
            return new ExtentImpl();
101
    }
102
    
103
        /*
104
         * (non-Javadoc)
105
         * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#createNoData(double, int, int)
106
         */
107
        public NoData createNoData(double noData, int type, int dataType) {
108
                return new DefaultNoData(noData, type, dataType);
109
        }
110
        
111
        /*
112
         * (non-Javadoc)
113
         * @see org.gvsig.fmap.dal.coverage.datastruct.DataStructFactory#loadStatisticsFromStore(org.gvsig.fmap.dal.coverage.store.RasterDataStore)
114
         */
115
        public Statistics loadStatisticsFromStore(RasterDataStore store) throws RmfSerializerException {
116
                if(store instanceof DefaultMultiRasterStore) {
117
                        DataStoreStatistics[] stats = new DataStoreStatistics[store.getDataStoreCount()];
118

    
119
                        DefaultMultiRasterStore storeImpl = (DefaultMultiRasterStore)store;
120

    
121
                        for (int i = 0; i < storeImpl.getProviders().size(); i++) {
122
                                Statistics statFile = (storeImpl.getProvider(i)).getStatistics();
123
                                stats[i] = (DataStoreStatistics)(storeImpl.getProvider(i)).loadObjectFromRmf(Statistics.class, statFile);
124

    
125
                                //Con que un dataset no tenga la estadistica calculada se pone a no calculado el DatasetListStatistics
126
                                if(!stats[i].isCalculated())
127
                                        return null;
128
                        }
129
                        MultiDataStoreStatistics result = new MultiDataStoreStatistics(stats);
130
                        result.setCalculated(true);
131
                        return result;
132
                }
133
                return null;
134
                //TODO: Implementar para Mosaic
135
        }
136
}