Statistics
| Revision:

gvsig-gdal / branches / org.gvsig.gdal-2018a / org.gvsig.gdal.prov / org.gvsig.gdal.raster / org.gvsig.gdal.raster.provider / src / main / java / org / gvsig / raster / gdal / provider / DisposableGdalDataSet.java @ 361

History | View | Annotate | Download (3.95 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2018 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
package org.gvsig.raster.gdal.provider;
24

    
25
import java.util.Vector;
26

    
27
import org.gdal.gdal.Dataset;
28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30

    
31
import org.gvsig.tools.dispose.impl.AbstractDisposable;
32

    
33

    
34
/**
35
 * @author fdiaz
36
 *
37
 */
38
public class DisposableGdalDataSet extends AbstractDisposable { // implements Disposable{
39

    
40
    private static final Logger LOG =
41
        LoggerFactory.getLogger(DisposableGdalDataSet.class);
42

    
43
//    private final Object lock = new Object();
44
//
45
//    private boolean disposed = false;
46

    
47
    private Dataset gdalDataSet;
48

    
49

    
50
    /**
51
     * @param cPtr
52
     * @param cMemoryOwn
53
     */
54
    public DisposableGdalDataSet(Dataset gdalDataSet) {
55
        super();
56

    
57
        this.gdalDataSet = gdalDataSet;
58
//        if(ToolsLocator.getDisposableManager() != null) {
59
//            ToolsLocator.getDisposableManager().bind(this);
60
//        } else {
61
//            LOG.warn("Can't retrieve the disposable manager,");
62
//        }
63

    
64
    }
65

    
66
//    @Override
67
//    public void dispose() {
68
//        synchronized (lock) {
69
//            // Check if we have already been disposed, and don't do it again
70
//            if (!disposed) {
71
//                if ( ToolsLocator.getDisposableManager().release(this) ) {
72
//                    try {
73
//                        doDispose();
74
//                    } catch (BaseException ex) {
75
//                        LOG.error("Error performing dispose", ex);
76
//                    }
77
//                    disposed = true;
78
//                }
79
//            }
80
//        }
81
//    }
82
//
83
//    protected void dispose(Disposable disposable) {
84
//        DisposeUtils.dispose(disposable);
85
//    }
86

    
87

    
88
    /**
89
     * @return the gdalDataSet
90
     */
91
    public Dataset getDataSet() {
92
        return gdalDataSet;
93
    }
94

    
95
//    /**
96
//     * @param gdalDataSet the gdalDataSet to set
97
//     */
98
//    public void setDataSet(Dataset gdalDataSet) {
99
//        this.gdalDataSet = gdalDataSet;
100
//    }
101

    
102
    @Override
103
    protected void doDispose() {
104
        if (this.gdalDataSet != null) {
105
            this.gdalDataSet.delete();
106
            gdalDataSet = null;
107
        }
108
    }
109

    
110
    /**
111
     * @return
112
     */
113
    public int getRasterYSize() {
114
        return getDataSet().getRasterYSize();
115
    }
116

    
117
    /**
118
     * @return
119
     */
120
    public int getRasterXSize() {
121
        return getDataSet().getRasterXSize();
122
    }
123

    
124
    /**
125
     * @return
126
     */
127
    public int getRasterCount() {
128
        return getDataSet().getRasterCount();
129
    }
130

    
131
    /**
132
     * @param gdalBandNumber
133
     * @return
134
     */
135
    public org.gdal.gdal.Band GetRasterBand(int gdalBandNumber) {
136
        return getDataSet().GetRasterBand(gdalBandNumber);
137
    }
138

    
139
    /**
140
     * @return
141
     */
142
    public double[] GetGeoTransform() {
143
        return getDataSet().GetGeoTransform();
144
    }
145

    
146
    /**
147
     * @return
148
     */
149
    public Vector<?> GetGCPs() {
150
        return getDataSet().GetGCPs();
151
    }
152

    
153
    /**
154
     * @return
155
     */
156
    public int GetGCPCount() {
157
        return getDataSet().GetGCPCount();
158
    }
159

    
160
    /**
161
     *
162
     */
163
    public void delete() {
164
        getDataSet().delete();
165
    }
166

    
167

    
168
}