Revision 6335
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/test/java/org/gvsig/raster/gdal/provider/RasterGdalStoreProviderTest.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
|
|
6 |
import org.cresques.cts.IProjection; |
|
7 |
import org.gvsig.fmap.crs.CRSFactory; |
|
8 |
import org.gvsig.fmap.dal.DALLocator; |
|
9 |
import org.gvsig.fmap.dal.DataManager; |
|
10 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
11 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
12 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
13 |
import org.gvsig.fmap.dal.raster.spi.NewRasterStoreParameters; |
|
14 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
15 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
|
16 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
17 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
|
18 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
19 |
|
|
20 |
public class RasterGdalStoreProviderTest extends AbstractLibraryAutoInitTestCase { |
|
21 |
|
|
22 |
@Override |
|
23 |
protected void doSetUp() throws Exception { |
|
24 |
|
|
25 |
|
|
26 |
} |
|
27 |
|
|
28 |
/** |
|
29 |
* Tries to copy an store into a new one using gdal provider |
|
30 |
* @throws Exception |
|
31 |
*/ |
|
32 |
public void testGdalCopyStore() throws Exception{ |
|
33 |
IProjection projection = CRSFactory.getCRS("EPSG:23030"); |
|
34 |
final URL url = this.getClass().getResource("/pathcv.png"); |
|
35 |
//The store is created using the PNG provider |
|
36 |
String openingProviderName="PNG"; |
|
37 |
File openedFile=new File(url.toURI()); |
|
38 |
//The store is copied using the GTiff provider |
|
39 |
String storingProviderName="GTiff"; |
|
40 |
String extension="tif"; |
|
41 |
File destFile=new File(openedFile.getParentFile(), "copiedFile."+extension); |
|
42 |
|
|
43 |
DataManager dataManager = DALLocator.getDataManager(); |
|
44 |
try { |
|
45 |
//Opening the store |
|
46 |
RasterGdalStoreProviderFactory gdalFactory= |
|
47 |
(RasterGdalStoreProviderFactory)dataManager.getStoreProviderFactory(openingProviderName); |
|
48 |
RasterGdalFileStoreParameters openParams = (RasterGdalFileStoreParameters)gdalFactory.createParameters(); |
|
49 |
openParams.setFile(openedFile); |
|
50 |
openParams.setCRS(projection); |
|
51 |
|
|
52 |
RasterStore store=null; |
|
53 |
store = (RasterStore) dataManager.openStore(openingProviderName,openParams); |
|
54 |
assertNotNull(store); |
|
55 |
|
|
56 |
//The store is opened and must be copied |
|
57 |
DataManagerProviderServices manager=DALSPILocator.getDataManagerProviderServices(); |
|
58 |
DataServerExplorerParameters eparams = manager.createServerExplorerParameters("FilesystemExplorer"); |
|
59 |
eparams.setDynValue("initialpath","/"); |
|
60 |
DataServerExplorer serverExplorer= manager.createServerExplorer(eparams); |
|
61 |
|
|
62 |
NewRasterStoreParameters newStoreParams =(NewRasterStoreParameters) serverExplorer.getAddParameters(storingProviderName); |
|
63 |
if (newStoreParams instanceof FilesystemStoreParameters) { |
|
64 |
((FilesystemStoreParameters) newStoreParams).setFile(destFile); |
|
65 |
} |
|
66 |
if (newStoreParams instanceof NewRasterStoreParameters) { |
|
67 |
Buffer buffer = store.getRasterSet().clip(store.getEnvelope()); |
|
68 |
((NewRasterStoreParameters) newStoreParams).setBuffer(buffer); |
|
69 |
} |
|
70 |
if (newStoreParams.hasDynValue("compress")) { |
|
71 |
newStoreParams.setDynValue("compress", "NONE"); |
|
72 |
} |
|
73 |
if (newStoreParams.hasDynValue("tfw")) { |
|
74 |
newStoreParams.setDynValue("tfw", true); |
|
75 |
} |
|
76 |
if (newStoreParams.hasDynValue("photometric")) { |
|
77 |
newStoreParams.setDynValue("photometric", "RGB"); |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
if (newStoreParams.isValid() ) { |
|
82 |
serverExplorer.add(storingProviderName, newStoreParams, true); |
|
83 |
} |
|
84 |
assert(destFile.exists()); |
|
85 |
|
|
86 |
}catch (Exception e){ |
|
87 |
fail("Exception happened: "+e.getMessage()); |
|
88 |
}finally{ |
|
89 |
if (destFile!=null && destFile.exists()){ |
|
90 |
destFile.delete(); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/resources/wms_gdal_input_data.xml | ||
---|---|---|
1 |
<GDAL_WMS> |
|
2 |
<Service name="WMS"> |
|
3 |
<Version>1.1.1</Version> |
|
4 |
<ServerUrl>http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx</ServerUrl> |
|
5 |
<SRS>EPSG:23030</SRS> |
|
6 |
<Layers>Catastro</Layers> |
|
7 |
</Service> |
|
8 |
<!--<Projection>EPSG:4326</Projection>--> |
|
9 |
<DataWindow> |
|
10 |
<UpperLeftX>727241.56</UpperLeftX> |
|
11 |
<UpperLeftY>4372203.95</UpperLeftY> |
|
12 |
<LowerRightX>728860.44</LowerRightX> |
|
13 |
<LowerRightY>4370797.69</LowerRightY> |
|
14 |
<SizeX>536</SizeX> |
|
15 |
<SizeY>463</SizeY> |
|
16 |
</DataWindow> |
|
17 |
<!--<BlockSizeX>256</BlockSizeX> |
|
18 |
<BlockSizeY>256</BlockSizeY>--> |
|
19 |
</GDAL_WMS> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/resources/org/gvsig/raster/gdal/provider/RasterGdalParameters.xml | ||
---|---|---|
2 | 2 |
<definitions> |
3 | 3 |
<version>1.0.0</version> |
4 | 4 |
<classes> |
5 |
|
|
6 |
<!-- Parent Classes --> |
|
5 | 7 |
<class name="RasterGdalStoreParameters"> |
6 | 8 |
<extends> |
7 |
<class namespace="dal" name="ProviderParameters"/>
|
|
9 |
<class namespace="dal" name="ProviderParameters"/>
|
|
8 | 10 |
</extends> |
9 |
<description>Store the parameters need to open a gdal file</description>
|
|
11 |
<description>Store the parameters need to open a non-file gdal</description>
|
|
10 | 12 |
<fields> |
11 |
<field name="file" type="file" mandatory="true" group="Basic"> |
|
12 |
<description>Raster Gdal file</description> |
|
13 |
</field> |
|
14 | 13 |
<field name="crs" type="crs" mandatory="true" group="Basic"> |
15 | 14 |
<description>The coordinate reference system used in this file</description> |
16 | 15 |
</field> |
... | ... | |
19 | 18 |
</field> |
20 | 19 |
</fields> |
21 | 20 |
</class> |
21 |
|
|
22 |
<class name="RasterGdalFileStoreParameters"> |
|
23 |
<extends> |
|
24 |
<class name="RasterGdalStoreParameters"/> |
|
25 |
</extends> |
|
26 |
<description>Store the parameters need to open a gdal file</description> |
|
27 |
<fields> |
|
28 |
<field name="file" type="file" mandatory="true" group="Basic"> |
|
29 |
<description>Raster Gdal file</description> |
|
30 |
</field> |
|
31 |
</fields> |
|
32 |
</class> |
|
33 |
|
|
34 |
<!-- Non-file classes --> |
|
35 |
<class name="RasterGdalStoreParameters_PostGISRaster"> |
|
36 |
<extends> |
|
37 |
<class name="RasterGdalStoreParameters"/> |
|
38 |
</extends> |
|
39 |
<description>Store the parameters need to open a raster using PostGISRaster driver</description> |
|
40 |
<fields> |
|
41 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
42 |
<description>Raster subdataset</description> |
|
43 |
</field> |
|
44 |
<field name="host" type="string" mandatory="true" group="OpenOptions"> |
|
45 |
<description>Database host where the raster can be found</description> |
|
46 |
</field> |
|
47 |
<field name="dbname" type="string" mandatory="true" group="OpenOptions"> |
|
48 |
<description>Database name where the raster can be found</description> |
|
49 |
</field> |
|
50 |
<field name="table" type="string" mandatory="true" group="OpenOptions"> |
|
51 |
<description>Database table where the raster can be found</description> |
|
52 |
</field> |
|
53 |
<field name="schema" type="string" mandatory="false" group="OpenOptions"> |
|
54 |
<description>Database schema where the raster can be found</description> |
|
55 |
</field> |
|
56 |
<field name="user" type="string" mandatory="false" group="OpenOptions"> |
|
57 |
<description>User for the Database where the raster can be found</description> |
|
58 |
</field> |
|
59 |
<field name="password" type="string" mandatory="false" group="OpenOptions"> |
|
60 |
<description>Password for the user</description> |
|
61 |
</field> |
|
62 |
<field name="port" type="integer" mandatory="false" group="OpenOptions"> |
|
63 |
<description>Port number for the Database where the raster can be found</description> |
|
64 |
</field> |
|
65 |
</fields> |
|
66 |
</class> |
|
67 |
|
|
68 |
<class name="RasterGdalStoreParameters_WCS"> |
|
69 |
<extends> |
|
70 |
<class name="RasterGdalStoreParameters"/> |
|
71 |
</extends> |
|
72 |
<description>Store the parameters need to open a raster using WCS driver</description> |
|
73 |
<fields> |
|
74 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
75 |
<description>Raster subdataset</description> |
|
76 |
</field> |
|
77 |
<field name="url" type="url" mandatory="true" group="OpenOptions"> |
|
78 |
<description>URL to access the raster</description> |
|
79 |
</field> |
|
80 |
<field name="coverage" type="string" mandatory="true" group="OpenOptions"> |
|
81 |
<description>Coverage name</description> |
|
82 |
</field> |
|
83 |
</fields> |
|
84 |
</class> |
|
85 |
|
|
86 |
<class name="RasterGdalStoreParameters_WMS"> |
|
87 |
<extends> |
|
88 |
<class name="RasterGdalStoreParameters"/> |
|
89 |
</extends> |
|
90 |
<description>Store the parameters need to open a raster using WMS driver</description> |
|
91 |
<fields> |
|
92 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
93 |
<description>Raster subdataset</description> |
|
94 |
</field> |
|
95 |
</fields> |
|
96 |
</class> |
|
97 |
|
|
98 |
|
|
99 |
<!-- File Classes --> |
|
100 |
|
|
101 |
<class name="RasterGdalFileStoreParameters_GTiff"> |
|
102 |
<tags> |
|
103 |
<valueItem name="validExtensions" value="tif,tiff"/> |
|
104 |
<valueItem name="wldExtension" value="tfw"/> |
|
105 |
</tags> |
|
106 |
<extends> |
|
107 |
<class name="RasterGdalFileStoreParameters"/> |
|
108 |
</extends> |
|
109 |
<description>Store the parameters need to open a gdal file using GTiff driver</description> |
|
110 |
<fields> |
|
111 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
112 |
<description>Raster subdataset</description> |
|
113 |
</field> |
|
114 |
</fields> |
|
115 |
</class> |
|
116 |
|
|
117 |
<class name="RasterGdalFileStoreParameters_JPEG"> |
|
118 |
<tags> |
|
119 |
<valueItem name="validExtensions" value="jpg,jpeg"/> |
|
120 |
<valueItem name="wldExtension" value="jpgw"/> |
|
121 |
</tags> |
|
122 |
<extends> |
|
123 |
<class name="RasterGdalFileStoreParameters"/> |
|
124 |
</extends> |
|
125 |
<description>Store the parameters need to open a jpeg file using JPEG driver</description> |
|
126 |
<fields> |
|
127 |
</fields> |
|
128 |
</class> |
|
129 |
|
|
130 |
<class name="RasterGdalFileStoreParameters_ILWIS"> |
|
131 |
<tags> |
|
132 |
<valueItem name="validExtensions" value="mpr,mpl"/> |
|
133 |
</tags> |
|
134 |
<extends> |
|
135 |
<class name="RasterGdalFileStoreParameters"/> |
|
136 |
</extends> |
|
137 |
<description>Store the parameters need to open files using ILWIS driver</description> |
|
138 |
<fields> |
|
139 |
</fields> |
|
140 |
</class> |
|
141 |
|
|
142 |
<class name="RasterGdalFileStoreParameters_PNM"> |
|
143 |
<tags> |
|
144 |
<valueItem name="validExtensions" value="pgm,ppm"/> |
|
145 |
</tags> |
|
146 |
<extends> |
|
147 |
<class name="RasterGdalFileStoreParameters"/> |
|
148 |
</extends> |
|
149 |
<description>Store the parameters need to open files using PNM driver</description> |
|
150 |
<fields> |
|
151 |
</fields> |
|
152 |
</class> |
|
153 |
|
|
154 |
<class name="RasterGdalFileStoreParameters_RMF"> |
|
155 |
<tags> |
|
156 |
<valueItem name="validExtensions" value="rmf"/> |
|
157 |
</tags> |
|
158 |
<extends> |
|
159 |
<class name="RasterGdalFileStoreParameters"/> |
|
160 |
</extends> |
|
161 |
<description>Store the parameters need to open files using RMF driver</description> |
|
162 |
<fields> |
|
163 |
</fields> |
|
164 |
</class> |
|
165 |
|
|
166 |
<class name="RasterGdalFileStoreParameters_PDF"> |
|
167 |
<extends> |
|
168 |
<class name="RasterGdalFileStoreParameters"/> |
|
169 |
</extends> |
|
170 |
<description>Store the parameters need to open a gdal file using PDF driver</description> |
|
171 |
<fields> |
|
172 |
<field name="subdataset" type="string" mandatory="false" group="OpenOptions"> |
|
173 |
<description>Raster subdataset</description> |
|
174 |
</field> |
|
175 |
</fields> |
|
176 |
</class> |
|
177 |
|
|
178 |
<class name="RasterGdalFileStoreParameters_NITF"> |
|
179 |
<extends> |
|
180 |
<class name="RasterGdalFileStoreParameters"/> |
|
181 |
</extends> |
|
182 |
<description>Store the parameters need to open a gdal file using NITF driver</description> |
|
183 |
<fields> |
|
184 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
185 |
<description>Raster subdataset</description> |
|
186 |
</field> |
|
187 |
</fields> |
|
188 |
</class> |
|
189 |
|
|
190 |
<class name="RasterGdalFileStoreParameters_RPFTOC"> |
|
191 |
<extends> |
|
192 |
<class name="RasterGdalFileStoreParameters"/> |
|
193 |
</extends> |
|
194 |
<description>Store the parameters need to open a gdal file using RPFTOC driver</description> |
|
195 |
<fields> |
|
196 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
197 |
<description>Raster subdataset</description> |
|
198 |
</field> |
|
199 |
</fields> |
|
200 |
</class> |
|
201 |
|
|
202 |
<class name="RasterGdalFileStoreParameters_ECRGTOC"> |
|
203 |
<extends> |
|
204 |
<class name="RasterGdalFileStoreParameters"/> |
|
205 |
</extends> |
|
206 |
<description>Store the parameters need to open a gdal file using ECRGTOC driver</description> |
|
207 |
<fields> |
|
208 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
209 |
<description>Raster subdataset</description> |
|
210 |
</field> |
|
211 |
</fields> |
|
212 |
</class> |
|
213 |
|
|
214 |
<class name="RasterGdalFileStoreParameters_OGDI"> |
|
215 |
<extends> |
|
216 |
<class name="RasterGdalFileStoreParameters"/> |
|
217 |
</extends> |
|
218 |
<description>Store the parameters need to open a gdal file using OGDI driver</description> |
|
219 |
<fields> |
|
220 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
221 |
<description>Raster subdataset</description> |
|
222 |
</field> |
|
223 |
</fields> |
|
224 |
</class> |
|
225 |
|
|
226 |
<class name="RasterGdalFileStoreParameters_RS2"> |
|
227 |
<extends> |
|
228 |
<class name="RasterGdalFileStoreParameters"/> |
|
229 |
</extends> |
|
230 |
<description>Store the parameters need to open a gdal file using RS2 driver</description> |
|
231 |
<fields> |
|
232 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
233 |
<description>Raster subdataset</description> |
|
234 |
</field> |
|
235 |
</fields> |
|
236 |
</class> |
|
237 |
|
|
238 |
<class name="RasterGdalFileStoreParameters_netCDF"> |
|
239 |
<extends> |
|
240 |
<class name="RasterGdalFileStoreParameters"/> |
|
241 |
</extends> |
|
242 |
<description>Store the parameters need to open a gdal file using netCDF driver</description> |
|
243 |
<fields> |
|
244 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
245 |
<description>Raster subdataset</description> |
|
246 |
</field> |
|
247 |
</fields> |
|
248 |
</class> |
|
249 |
|
|
250 |
<class name="RasterGdalFileStoreParameters_HDF4"> |
|
251 |
<extends> |
|
252 |
<class name="RasterGdalFileStoreParameters"/> |
|
253 |
</extends> |
|
254 |
<description>Store the parameters need to open a gdal file using HDF4 driver</description> |
|
255 |
<fields> |
|
256 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
257 |
<description>Raster subdataset</description> |
|
258 |
</field> |
|
259 |
</fields> |
|
260 |
</class> |
|
261 |
|
|
262 |
<class name="RasterGdalFileStoreParameters_L1B"> |
|
263 |
<extends> |
|
264 |
<class name="RasterGdalFileStoreParameters"/> |
|
265 |
</extends> |
|
266 |
<description>Store the parameters need to open a gdal file using L1B driver</description> |
|
267 |
<fields> |
|
268 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
269 |
<description>Raster subdataset</description> |
|
270 |
</field> |
|
271 |
</fields> |
|
272 |
</class> |
|
273 |
|
|
274 |
<class name="RasterGdalFileStoreParameters_NTv2"> |
|
275 |
<extends> |
|
276 |
<class name="RasterGdalFileStoreParameters"/> |
|
277 |
</extends> |
|
278 |
<description>Store the parameters need to open a gdal file using NTv2 driver</description> |
|
279 |
<fields> |
|
280 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
281 |
<description>Raster subdataset</description> |
|
282 |
</field> |
|
283 |
</fields> |
|
284 |
</class> |
|
285 |
|
|
286 |
<class name="RasterGdalFileStoreParameters_HDF5"> |
|
287 |
<extends> |
|
288 |
<class name="RasterGdalFileStoreParameters"/> |
|
289 |
</extends> |
|
290 |
<description>Store the parameters need to open a gdal file using HDF5 driver</description> |
|
291 |
<fields> |
|
292 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
293 |
<description>Raster subdataset</description> |
|
294 |
</field> |
|
295 |
</fields> |
|
296 |
</class> |
|
297 |
|
|
298 |
<class name="RasterGdalFileStoreParameters_ADRG"> |
|
299 |
<extends> |
|
300 |
<class name="RasterGdalFileStoreParameters"/> |
|
301 |
</extends> |
|
302 |
<description>Store the parameters need to open a gdal file using ADRG driver</description> |
|
303 |
<fields> |
|
304 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
305 |
<description>Raster subdataset</description> |
|
306 |
</field> |
|
307 |
</fields> |
|
308 |
</class> |
|
309 |
|
|
310 |
<class name="RasterGdalFileStoreParameters_SRP"> |
|
311 |
<extends> |
|
312 |
<class name="RasterGdalFileStoreParameters"/> |
|
313 |
</extends> |
|
314 |
<description>Store the parameters need to open a gdal file using SRP driver</description> |
|
315 |
<fields> |
|
316 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
317 |
<description>Raster subdataset</description> |
|
318 |
</field> |
|
319 |
</fields> |
|
320 |
</class> |
|
321 |
|
|
322 |
<class name="RasterGdalFileStoreParameters_Rasterlite"> |
|
323 |
<extends> |
|
324 |
<class name="RasterGdalFileStoreParameters"/> |
|
325 |
</extends> |
|
326 |
<description>Store the parameters need to open a gdal file using Rasterlite driver</description> |
|
327 |
<fields> |
|
328 |
<field name="subdataset" type="integer" mandatory="false" group="OpenOptions"> |
|
329 |
<description>Raster subdataset</description> |
|
330 |
</field> |
|
331 |
</fields> |
|
332 |
</class> |
|
333 |
|
|
22 | 334 |
</classes> |
23 | 335 |
</definitions> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/resources/org/gvsig/raster/gdal/provider/NewRasterGdalStoreParameters.xml | ||
---|---|---|
17 | 17 |
</class> |
18 | 18 |
|
19 | 19 |
<class namespace="dal" name="NewRasterGdalStoreParameters_GTiff"> |
20 |
<tags> |
|
21 |
<valueItem name="wldExtension" value="tfw"/> |
|
22 |
</tags> |
|
20 | 23 |
<extends> |
21 | 24 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
22 | 25 |
</extends> |
... | ... | |
43 | 46 |
<description>Predictor Type</description> |
44 | 47 |
</field> |
45 | 48 |
<field name="jpeg_quality" type="integer" mandatory="false" |
46 |
group="CreateOptions" minval="1" maxval="100" defaultValue="75">
|
|
49 |
group="CreateOptions" minValue="1" maxValue="100" defaultValue="75">
|
|
47 | 50 |
<description>JPEG quality</description> |
48 | 51 |
</field> |
49 | 52 |
<field name="zlevel" type="integer" mandatory="false" group="CreateOptions" |
50 |
minval="1" maxval="9" defaultValue="6">
|
|
53 |
minValue="1" maxValue="9" defaultValue="6">
|
|
51 | 54 |
<description>DEFLATE compression level 1-9 </description> |
52 | 55 |
</field> |
53 | 56 |
<field name="lzma_preset" type="integer" mandatory="false" group="CreateOptions" |
54 |
minval="0" maxval="9" defaultValue="6">
|
|
57 |
minValue="0" maxValue="9" defaultValue="6">
|
|
55 | 58 |
<description>LZMA compression level 0(fast)-9(slow)</description> |
56 | 59 |
</field> |
57 |
<field name="nbits" type="integer" mandatory="false" minval="1" maxval="31" group="CreateOptions">
|
|
60 |
<field name="nbits" type="integer" mandatory="false" minValue="1" maxValue="31" group="CreateOptions">
|
|
58 | 61 |
<description>BITS for sub-byte files (1-7), sub-uint16 (9-15), sub-uint32 (17-31)</description> |
59 | 62 |
</field> |
60 | 63 |
<field name="interleave" type="string" mandatory="false" group="CreateOptions" |
... | ... | |
203 | 206 |
<extends> |
204 | 207 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
205 | 208 |
</extends> |
206 |
<description>Store the parameters needed to create a new gdal file using |
|
207 |
netCDF driver |
|
209 |
<description>Store the parameters needed to create a new gdal file using netCDF driver |
|
208 | 210 |
</description> |
209 | 211 |
<fields> |
210 | 212 |
<field name="format" type="string" mandatory="true" defaultValue="NC" |
... | ... | |
233 | 235 |
</availableValues> |
234 | 236 |
</field> |
235 | 237 |
<field name="zlevel" type="integer" mandatory="false" |
236 |
minval="1" maxval="9" defaultValue="1" group="CreateOptions">
|
|
238 |
minValue="1" maxValue="9" defaultValue="1" group="CreateOptions">
|
|
237 | 239 |
<description>DEFLATE compression level 1-9 </description> |
238 | 240 |
</field> |
239 | 241 |
<field name="write_bottomup" type="boolean" mandatory="false" |
... | ... | |
253 | 255 |
<value label="IF_NEEDED">IF_NEEDED</value> |
254 | 256 |
</availableValues> |
255 | 257 |
</field> |
256 |
<field name="pixeltype" type="string" mandatory="false" |
|
257 |
defaultValuegroup="CreateOptions"> |
|
258 |
<field name="pixeltype" type="string" mandatory="false" group="CreateOptions"> |
|
258 | 259 |
<description>only used in Create()</description> |
259 | 260 |
<availableValues> |
260 | 261 |
<value label="DEFAULT">DEFAULT</value> |
... | ... | |
276 | 277 |
</fields> |
277 | 278 |
</class> |
278 | 279 |
|
280 |
<class namespace="dal" name="NewRasterGdalStoreParameters_HFA"> |
|
281 |
<extends> |
|
282 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
283 |
</extends> |
|
284 |
<description>Store the parameters needed to create a new gdal file using |
|
285 |
HFA driver |
|
286 |
</description> |
|
287 |
<fields> |
|
288 |
<field name="blocksize" type="integer" mandatory="false" |
|
289 |
group="CreateOptions" defaultValue="64"> |
|
290 |
<description>Tile width/height (32-2048)</description> |
|
291 |
</field> |
|
292 |
<field name="use_spill" type="boolean" mandatory="false" group="CreateOptions"> |
|
293 |
<description>Force use of spill file</description> |
|
294 |
</field> |
|
295 |
<field name="compressed" type="boolean" mandatory="false" group="CreateOptions"> |
|
296 |
<description>Compress blocks</description> |
|
297 |
</field> |
|
298 |
<field name="pixeltype" type="string" mandatory="false" group="CreateOptions"> |
|
299 |
<description>By setting this to SIGNEDBYTE, a new Byte file can be forced to be written as signed byte</description> |
|
300 |
</field> |
|
301 |
<field name="aux" type="boolean" mandatory="false" group="CreateOptions"> |
|
302 |
<description>Create an .aux file</description> |
|
303 |
</field> |
|
304 |
<field name="ignoreutm" type="boolean" mandatory="false" group="CreateOptions"> |
|
305 |
<description>Ignore UTM when selecting coordinate system - will use Transverse Mercator.</description> |
|
306 |
</field> |
|
307 |
<field name="nbits" type="integer" mandatory="false" group="CreateOptions"> |
|
308 |
<description>Create file with special sub-byte data type (1/2/4)</description> |
|
309 |
</field> |
|
310 |
<field name="statistics" type="boolean" mandatory="false" group="CreateOptions"> |
|
311 |
<description>Generate statistics and a histogram</description> |
|
312 |
</field> |
|
313 |
<field name="dependent_file" type="string" mandatory="false" group="CreateOptions"> |
|
314 |
<description>Name of dependent file (must not have absolute path)</description> |
|
315 |
</field> |
|
316 |
<field name="forcetopestring" type="boolean" mandatory="false" group="CreateOptions"> |
|
317 |
<description>Force use of ArcGIS PE String in file instead of Imagine coordinate system format</description> |
|
318 |
</field> |
|
319 |
</fields> |
|
320 |
</class> |
|
321 |
|
|
322 |
<class namespace="dal" name="NewRasterGdalStoreParameters_Terragen"> |
|
323 |
<extends> |
|
324 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
325 |
</extends> |
|
326 |
<description>Store the parameters needed to create a new gdal file using |
|
327 |
Terragen driver |
|
328 |
</description> |
|
329 |
<fields> |
|
330 |
<field name="minuserpixelvalue" type="float" mandatory="false" group="CreateOptions"> |
|
331 |
<description>Lowest logical elevation</description> |
|
332 |
</field> |
|
333 |
<field name="maxuserpixelvalue" type="float" mandatory="false" group="CreateOptions"> |
|
334 |
<description>Highest logical elevation</description> |
|
335 |
</field> |
|
336 |
</fields> |
|
337 |
</class> |
|
338 |
|
|
339 |
<class namespace="dal" name="NewRasterGdalStoreParameters_HDF4Image"> |
|
340 |
<extends> |
|
341 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
342 |
</extends> |
|
343 |
<description>Store the parameters needed to create a new gdal file using |
|
344 |
HDF4Image driver |
|
345 |
</description> |
|
346 |
<fields> |
|
347 |
<field name="rank" type="integer" mandatory="false" group="CreateOptions"> |
|
348 |
<description>Rank of output SDS</description> |
|
349 |
</field> |
|
350 |
</fields> |
|
351 |
</class> |
|
352 |
|
|
353 |
<class namespace="dal" name="NewRasterGdalStoreParameters_ENVI"> |
|
354 |
<extends> |
|
355 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
356 |
</extends> |
|
357 |
<description>Store the parameters needed to create a new gdal file using |
|
358 |
ENVI driver |
|
359 |
</description> |
|
360 |
<fields> |
|
361 |
<field name="suffix" type="string" mandatory="false" group="CreateOptions"> |
|
362 |
<description>Add suffix</description> |
|
363 |
<availableValues> |
|
364 |
<value label="ADD">ADD</value> |
|
365 |
</availableValues> |
|
366 |
</field> |
|
367 |
<field name="interleave" type="string" mandatory="false" group="CreateOptions"> |
|
368 |
<description>Interleave usage</description> |
|
369 |
<availableValues> |
|
370 |
<value label="BIP">BIP</value> |
|
371 |
<value label="BIL">BIL</value> |
|
372 |
<value label="BSQ">BSQ</value> |
|
373 |
</availableValues> |
|
374 |
</field> |
|
375 |
</fields> |
|
376 |
</class> |
|
377 |
|
|
378 |
<class namespace="dal" name="NewRasterGdalStoreParameters_EHdr"> |
|
379 |
<extends> |
|
380 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
381 |
</extends> |
|
382 |
<description>Store the parameters needed to create a new gdal file using |
|
383 |
EHdr driver |
|
384 |
</description> |
|
385 |
<fields> |
|
386 |
<field name="nbits" type="integer" minValue="1" maxValue="7" mandatory="false" group="CreateOptions"> |
|
387 |
<description>Special pixel bits (1-7)</description> |
|
388 |
</field> |
|
389 |
<field name="pixeltype" type="string" mandatory="false" group="CreateOptions"> |
|
390 |
<description>By setting this to SIGNEDBYTE, a new Byte file can be forced to be written as signed byte</description> |
|
391 |
</field> |
|
392 |
</fields> |
|
393 |
</class> |
|
394 |
|
|
395 |
<class namespace="dal" name="NewRasterGdalStoreParameters_PNG"> |
|
396 |
<extends> |
|
397 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
398 |
</extends> |
|
399 |
<description>Store the parameters needed to create a new gdal file using |
|
400 |
PNG driver |
|
401 |
</description> |
|
402 |
<fields> |
|
403 |
<field name="worldfile" type="boolean" mandatory="false" group="CreateOptions"> |
|
404 |
<description>Create world file</description> |
|
405 |
</field> |
|
406 |
<field name="zlevel" type="integer" mandatory="false" |
|
407 |
minValue="1" maxValue="9" defaultValue="6" group="CreateOptions"> |
|
408 |
<description>DEFLATE compression level 1-9</description> |
|
409 |
</field> |
|
410 |
<field name="source_icc_profile" type="string" mandatory="false" group="CreateOptions"> |
|
411 |
<description>ICC Profile</description> |
|
412 |
</field> |
|
413 |
<field name="source_icc_profile_name" type="string" mandatory="false" group="CreateOptions"> |
|
414 |
<description>ICC Profile name</description> |
|
415 |
</field> |
|
416 |
<field name="source_primaries_red" type="string" mandatory="false" group="CreateOptions"> |
|
417 |
<description>x,y,1.0 (xyY) red chromaticity</description> |
|
418 |
</field> |
|
419 |
<field name="source_primaries_green" type="string" mandatory="false" group="CreateOptions"> |
|
420 |
<description>x,y,1.0 (xyY) green chromaticity</description> |
|
421 |
</field> |
|
422 |
<field name="source_primaries_blue" type="string" mandatory="false" group="CreateOptions"> |
|
423 |
<description>x,y,1.0 (xyY) blue chromaticity</description> |
|
424 |
</field> |
|
425 |
<field name="source_whitepoint" type="string" mandatory="false" group="CreateOptions"> |
|
426 |
<description>x,y,1.0 (xyY) whitepoint</description> |
|
427 |
</field> |
|
428 |
<field name="png_gamma" type="string" mandatory="false" group="CreateOptions"> |
|
429 |
<description>Gamma</description> |
|
430 |
</field> |
|
431 |
</fields> |
|
432 |
</class> |
|
433 |
|
|
434 |
<class namespace="dal" name="NewRasterGdalStoreParameters_JPEG"> |
|
435 |
<tags> |
|
436 |
<valueItem name="wldExtension" value="jpgw"/> |
|
437 |
</tags> |
|
438 |
<extends> |
|
439 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
440 |
</extends> |
|
441 |
<description>Store the parameters needed to create a new gdal file using |
|
442 |
JPEG driver |
|
443 |
</description> |
|
444 |
<fields> |
|
445 |
<field name="progressive" type="boolean" defaultValue="false" mandatory="false" group="CreateOptions"> |
|
446 |
<description>Progressive?</description> |
|
447 |
</field> |
|
448 |
<field name="quality" type="integer" minValue="1" maxValue="100" defaultValue="75" |
|
449 |
mandatory="false" group="CreateOptions"> |
|
450 |
<description>good=100, bad=0, default=75</description> |
|
451 |
</field> |
|
452 |
<field name="worldfile" type="boolean" defaultValue="false" mandatory="false" group="CreateOptions"> |
|
453 |
<description>Worldfile?</description> |
|
454 |
</field> |
|
455 |
<field name="internal_mask" type="boolean" defaultValue="true" mandatory="false" group="CreateOptions"> |
|
456 |
<description>Internal mask?</description> |
|
457 |
</field> |
|
458 |
<field name="arithmetic" type="boolean" defaultValue="false" mandatory="false" group="CreateOptions"> |
|
459 |
<description>Arithmetic?</description> |
|
460 |
</field> |
|
461 |
<field name="source_icc_profile" type="string" mandatory="false" group="CreateOptions"> |
|
462 |
<description>ICC Profile</description> |
|
463 |
</field> |
|
464 |
</fields> |
|
465 |
</class> |
|
466 |
|
|
467 |
<class namespace="dal" name="NewRasterGdalStoreParameters_GIF"> |
|
468 |
<extends> |
|
469 |
<class namespace="dal" name="NewRasterGdalStoreParameters" /> |
|
470 |
</extends> |
|
471 |
<description>Store the parameters needed to create a new gdal file using |
|
472 |
GIF driver |
|
473 |
</description> |
|
474 |
<fields> |
|
475 |
<field name="interlacing" type="boolean" mandatory="false" group="CreateOptions"> |
|
476 |
<description>Interlacing?</description> |
|
477 |
</field> |
|
478 |
<field name="worldfile" type="boolean" mandatory="false" group="CreateOptions"> |
|
479 |
<description>Worldfile?</description> |
|
480 |
</field> |
|
481 |
</fields> |
|
482 |
</class> |
|
483 |
|
|
279 | 484 |
</classes> |
280 | 485 |
</definitions> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/java/org/gvsig/raster/gdal/provider/RasterGdalStoreProvider.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 |
package org.gvsig.raster.gdal.provider; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Arrays; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Vector; |
|
30 |
|
|
31 |
import org.apache.commons.io.FilenameUtils; |
|
32 |
import org.cresques.cts.IProjection; |
|
33 |
import org.gdal.gdal.Band; |
|
34 |
import org.gdal.gdal.Dataset; |
|
35 |
import org.gdal.gdal.GCP; |
|
36 |
import org.gdal.gdal.gdal; |
|
37 |
import org.gdal.gdalconst.gdalconstConstants; |
|
38 |
import org.gvsig.fmap.dal.DALLocator; |
|
39 |
import org.gvsig.fmap.dal.DataManager; |
|
40 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
41 |
import org.gvsig.fmap.dal.DataStore; |
|
42 |
import org.gvsig.fmap.dal.DataStoreNotification; |
|
43 |
import org.gvsig.fmap.dal.FileHelper; |
|
44 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
45 |
import org.gvsig.fmap.dal.exception.DataException; |
|
46 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
47 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
48 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
49 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
50 |
import org.gvsig.fmap.dal.raster.api.BandAttributeDescriptor; |
|
51 |
import org.gvsig.fmap.dal.raster.api.BandDescriptor; |
|
52 |
import org.gvsig.fmap.dal.raster.api.RasterQuery; |
|
53 |
import org.gvsig.fmap.dal.raster.spi.AbstractRasterStoreProvider; |
|
54 |
import org.gvsig.fmap.dal.resource.ResourceAction; |
|
55 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
56 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
|
57 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
58 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
59 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
60 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
61 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
62 |
import org.gvsig.fmap.geom.Geometry; |
|
63 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
64 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
65 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
66 |
import org.gvsig.metadata.MetadataLocator; |
|
67 |
import org.gvsig.metadata.MetadataManager; |
|
68 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
69 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
70 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
|
71 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
|
72 |
import org.gvsig.raster.lib.buffer.api.BufferManager; |
|
73 |
import org.gvsig.raster.lib.buffer.api.NoData; |
|
74 |
import org.gvsig.raster.lib.buffer.api.PageManager; |
|
75 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
|
76 |
import org.gvsig.tools.ToolsLocator; |
|
77 |
import org.gvsig.tools.dynobject.DynObject; |
|
78 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
79 |
import org.gvsig.tools.exception.BaseException; |
|
80 |
import org.gvsig.tools.locator.LocatorException; |
|
81 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
82 |
import org.gvsig.tools.task.TaskStatusManager; |
|
83 |
import org.slf4j.Logger; |
|
84 |
import org.slf4j.LoggerFactory; |
|
85 |
|
|
86 |
|
|
87 |
/** |
|
88 |
* Provider for Raster GDAL files |
|
89 |
* @author dmartinezizquierdo |
|
90 |
* |
|
91 |
*/ |
|
92 |
public class RasterGdalStoreProvider extends AbstractRasterStoreProvider implements |
|
93 |
ResourceConsumer{ |
|
94 |
|
|
95 |
private static final Logger logger = |
|
96 |
LoggerFactory.getLogger(RasterGdalStoreProvider.class); |
|
97 |
|
|
98 |
public static String NAME = "RasterGdal"; |
|
99 |
public static String DESCRIPTION = "Raster GDAL file"; |
|
100 |
public static final String METADATA_DEFINITION_NAME = NAME; |
|
101 |
|
|
102 |
private ResourceProvider resource; |
|
103 |
private final SimpleTaskStatus taskStatus; |
|
104 |
|
|
105 |
private Envelope envelope = null; |
|
106 |
private IProjection projection= null; |
|
107 |
private Dataset gdalDataSet; |
|
108 |
|
|
109 |
|
|
110 |
public Dataset getGdalDataSet() { |
|
111 |
return gdalDataSet; |
|
112 |
} |
|
113 |
|
|
114 |
protected static void registerMetadataDefinition() |
|
115 |
throws MetadataException { |
|
116 |
MetadataManager manager = MetadataLocator.getMetadataManager(); |
|
117 |
if (manager.getDefinition(METADATA_DEFINITION_NAME) == null) { |
|
118 |
manager.addDefinition(METADATA_DEFINITION_NAME, |
|
119 |
RasterGdalStoreProviderParameters.class |
|
120 |
.getResourceAsStream("RasterGdalMetadata.xml"), |
|
121 |
RasterGdalStoreProviderParameters.class.getClassLoader()); |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
public RasterGdalStoreProvider(RasterGdalStoreProviderParameters params, |
|
126 |
DataStoreProviderServices storeServices) |
|
127 |
throws InitializeException { |
|
128 |
super( |
|
129 |
params, |
|
130 |
storeServices, |
|
131 |
FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME) |
|
132 |
); |
|
133 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
|
134 |
this.taskStatus = manager.createDefaultSimpleTaskStatus("RasterGdal"); |
|
135 |
this.init(params, storeServices); |
|
136 |
} |
|
137 |
|
|
138 |
protected RasterGdalStoreProvider(RasterGdalStoreProviderParameters params, |
|
139 |
DataStoreProviderServices storeServices, DynObject metadata) |
|
140 |
throws InitializeException { |
|
141 |
super(params, storeServices, metadata); |
|
142 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
|
143 |
this.taskStatus = manager.createDefaultSimpleTaskStatus("RasterGdal"); |
|
144 |
this.init(params, storeServices); |
|
145 |
} |
|
146 |
|
|
147 |
protected void init(RasterGdalStoreProviderParameters params, |
|
148 |
DataStoreProviderServices storeServices) throws InitializeException { |
|
149 |
if (params == null) { |
|
150 |
throw new InitializeException( |
|
151 |
new NullPointerException("params is null")); |
|
152 |
} |
|
153 |
File file = getRasterGdalParameters().getFile(); |
|
154 |
if (file == null) { |
|
155 |
throw new InitializeException( |
|
156 |
new NullPointerException("Raster GDAL file is null")); |
|
157 |
} |
|
158 |
|
|
159 |
this.projection=params.getCRS(); |
|
160 |
|
|
161 |
resource = this.createResource( |
|
162 |
FileResource.NAME, |
|
163 |
new Object[] { file.getAbsolutePath() } |
|
164 |
); |
|
165 |
|
|
166 |
resource.addConsumer(this); |
|
167 |
|
|
168 |
} |
|
169 |
|
|
170 |
private RasterGdalStoreProviderParameters getRasterGdalParameters() { |
|
171 |
return (RasterGdalStoreProviderParameters) this.getParameters(); |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public Buffer createBuffer(RasterQuery rasterQuery) throws BufferException { |
|
176 |
int bandCount=gdalDataSet.getRasterCount(); |
|
177 |
BufferManager bufferManager=BufferLocator.getBufferManager(); |
|
178 |
int[] bandDataTypes=new int[bandCount]; |
|
179 |
NoData[] bandNoData=new NoData[bandCount]; |
|
180 |
List<PageManager> pageManagers=new ArrayList<PageManager>(); |
|
181 |
|
|
182 |
for (int i=0;i<bandCount;i++){ |
|
183 |
//Gdal bands begin count in 1 |
|
184 |
int gdalBandNumber=i+1; |
|
185 |
Band gdalBand=gdalDataSet.GetRasterBand(gdalBandNumber); |
|
186 |
bandDataTypes[i]=getRasterBufTypeFromGdalType(gdalBand.getDataType()); |
|
187 |
Double noData=getNoData(gdalBand); |
|
188 |
if (noData!=null){ |
|
189 |
bandNoData[i]=bufferManager.createNoData(noData, noData); |
|
190 |
}else{ |
|
191 |
bandNoData[i]=null; |
|
192 |
} |
|
193 |
pageManagers.add(new RasterGdalBandPageManager(gdalDataSet, gdalBandNumber)); |
|
194 |
} |
|
195 |
|
|
196 |
Buffer buffer = |
|
197 |
bufferManager.createBuffer(gdalDataSet.getRasterYSize(), gdalDataSet.getRasterXSize(), |
|
198 |
bandDataTypes, bandNoData, projection, envelope, pageManagers); |
|
199 |
|
|
200 |
return buffer; |
|
201 |
} |
|
202 |
|
|
203 |
@Override |
|
204 |
public BandInfo getBandInfo(int band) { |
|
205 |
RasterGdalBandPageManager gdalBandPageManager = |
|
206 |
new RasterGdalBandPageManager(gdalDataSet, band + 1); // Gdal bands start at 1 |
|
207 |
return gdalBandPageManager.getBandInfo(); |
|
208 |
} |
|
209 |
|
|
210 |
@Override |
|
211 |
public BandDescriptor getBandDescriptor(int band) { |
|
212 |
// Returns an empty band descriptor |
|
213 |
return getStoreServices().createBandDescriptor(band, |
|
214 |
new ArrayList<BandAttributeDescriptor>(0)); |
|
215 |
} |
|
216 |
|
|
217 |
@Override |
|
218 |
public int getBands() { |
|
219 |
return gdalDataSet.getRasterCount(); |
|
220 |
} |
|
221 |
|
|
222 |
private Double getNoData(Band gdalBand){ |
|
223 |
Double[] noDataValueResult=new Double[1]; |
|
224 |
gdalBand.GetNoDataValue(noDataValueResult); |
|
225 |
Double noData=noDataValueResult[0]; |
|
226 |
return noData; |
|
227 |
} |
|
228 |
|
|
229 |
@Override |
|
230 |
public DataServerExplorer getExplorer() |
|
231 |
throws ReadException, ValidateDataParametersException { |
|
232 |
DataManager manager = DALLocator.getDataManager(); |
|
233 |
FilesystemServerExplorerParameters params; |
|
234 |
try { |
|
235 |
params = (FilesystemServerExplorerParameters) manager |
|
236 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
237 |
params.setRoot(this.getRasterGdalParameters().getFile().getParent()); |
|
238 |
return manager.openServerExplorer(FilesystemServerExplorer.NAME,params); |
|
239 |
} catch (DataException e) { |
|
240 |
throw new ReadException(this.getProviderName(), e); |
|
241 |
} catch (ValidateDataParametersException e) { |
|
242 |
throw new ReadException(this.getProviderName(), e); |
|
243 |
} |
|
244 |
|
|
245 |
} |
|
246 |
|
|
247 |
public void open() throws OpenException { |
|
248 |
if (this.gdalDataSet != null) { |
|
249 |
return; |
|
250 |
} |
|
251 |
openEver(); |
|
252 |
} |
|
253 |
|
|
254 |
private void openEver() throws OpenException { |
|
255 |
try { |
|
256 |
getResource().execute(new ResourceAction() { |
|
257 |
|
|
258 |
public Object run() throws Exception { |
|
259 |
|
|
260 |
gdalDataSet = gdal.Open( |
|
261 |
getRasterGdalParameters().getFile().getAbsolutePath(), |
|
262 |
gdalconstConstants.GA_ReadOnly); |
|
263 |
|
|
264 |
resource.notifyOpen(); |
|
265 |
|
|
266 |
envelope = createEnvelope(getGeoTransform()); |
|
267 |
|
|
268 |
if (envelope == null) { |
|
269 |
// If couldn't be possible to create an envelope, |
|
270 |
// this is created at 0,0 coordinates. |
|
271 |
envelope = GeometryLocator.getGeometryManager() |
|
272 |
.createEnvelope(0, 0, gdalDataSet.getRasterXSize(), |
|
273 |
gdalDataSet.getRasterYSize(), |
|
274 |
Geometry.SUBTYPES.GEOM2D); |
|
275 |
} |
|
276 |
|
|
277 |
resource.notifyClose(); |
|
278 |
|
|
279 |
resource.setData(gdalDataSet); |
|
280 |
|
|
281 |
return null; |
|
282 |
} |
|
283 |
|
|
284 |
}); |
|
285 |
} catch (Exception e) { |
|
286 |
this.gdalDataSet = null; |
|
287 |
try { |
|
288 |
throw new OpenException(resource.getName(), e); |
|
289 |
} catch (AccessResourceException e1) { |
|
290 |
throw new OpenException(getProviderName(), e); |
|
291 |
} |
|
292 |
} finally { |
|
293 |
this.taskStatus.remove(); |
|
294 |
} |
|
295 |
} |
|
296 |
|
|
297 |
private double[] getGeoTransform(){ |
|
298 |
double[] geotransform = null; |
|
299 |
double[] defaultGeotransform = |
|
300 |
{ 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }; |
|
301 |
// Try to create an Envelope through geolocalization |
|
302 |
// methods |
|
303 |
if (getRasterGdalParameters().getWldParams() != null) { |
|
304 |
|
|
305 |
// Try to get a geotransform from wld file |
|
306 |
List<String> wldParams = |
|
307 |
getRasterGdalParameters().getWldParams(); |
|
308 |
double pixelSizeX = |
|
309 |
Double.valueOf(wldParams.get(0)); |
|
310 |
double rotationAxisY = |
|
311 |
Double.valueOf(wldParams.get(1)); |
|
312 |
double rotationAxisX = |
|
313 |
Double.valueOf(wldParams.get(2)); |
|
314 |
double pixelSizeY = |
|
315 |
-Double.valueOf(wldParams.get(3)); |
|
316 |
double upperLeftPixelCenterCoordX = |
|
317 |
Double.valueOf(wldParams.get(4)); |
|
318 |
double upperLeftPixelCenterCoordY = |
|
319 |
Double.valueOf(wldParams.get(5)); |
|
320 |
|
|
321 |
geotransform = new double[6]; |
|
322 |
// Info found at: |
|
323 |
// http://www.gdal.org/gdal_8h.html#adae2ed5807e4ec288812b54c6fccda1e |
|
324 |
// and http://www.gdal.org/gdal_tutorial.html |
|
325 |
// GDALReadWorldFile |
|
326 |
geotransform[0] = upperLeftPixelCenterCoordX |
|
327 |
- (pixelSizeX * 0.5) - (rotationAxisX * 0.5); |
|
328 |
geotransform[1] = pixelSizeX; |
|
329 |
geotransform[2] = rotationAxisX; |
|
330 |
geotransform[3] = upperLeftPixelCenterCoordY |
|
331 |
- (pixelSizeY * 0.5) - (rotationAxisY * 0.5); |
|
332 |
geotransform[4] = pixelSizeY; |
|
333 |
geotransform[5] = rotationAxisY; |
|
334 |
|
|
335 |
} else if (geotransform == null) { |
|
336 |
// Try to get a geotransform from the file |
|
337 |
geotransform = gdalDataSet.GetGeoTransform(); |
|
338 |
|
|
339 |
} |
|
340 |
|
|
341 |
// Try to get a geotransform from GCPs in the file |
|
342 |
if (Arrays.equals(defaultGeotransform, geotransform)) { |
|
343 |
Vector vectorGCPs = gdalDataSet.GetGCPs(); |
|
344 |
GCP[] gcps = new GCP[gdalDataSet.GetGCPCount()]; |
|
345 |
for (int i = 0; i < gdalDataSet |
|
346 |
.GetGCPCount(); i++) { |
|
347 |
gcps[i] = (GCP) vectorGCPs.get(i); |
|
348 |
} |
|
349 |
double[] gcpsGeotransform = new double[6]; |
|
350 |
int isOK = |
|
351 |
gdal.GCPsToGeoTransform(gcps, gcpsGeotransform); |
|
352 |
if (isOK != 0) { |
|
353 |
geotransform = gcpsGeotransform; |
|
354 |
} |
|
355 |
} |
|
356 |
|
|
357 |
return geotransform; |
|
358 |
} |
|
359 |
|
|
360 |
private Envelope createEnvelope(double[] geotransform){ |
|
361 |
|
|
362 |
double leftMostX = geotransform[0];/* top left x */ |
|
363 |
double pixelSizeX = geotransform[1];/* w-e pixel resolution */ |
|
364 |
double rotationAxisX = geotransform[2];/* 0 */ |
|
365 |
double upperMostY = geotransform[3];/* top left y */ |
|
366 |
double rotationAxisY = geotransform[4];/* 0 */ |
|
367 |
double pixelSizeY = geotransform[5];/* n-s pixel resolution (negative value) */ |
|
368 |
|
|
369 |
if (0.0 != rotationAxisX || 0.0 != rotationAxisY) { |
|
370 |
logger.warn( |
|
371 |
"Rotation in wld file not implemented yet. It will be ignored"); |
|
372 |
} |
|
373 |
|
|
374 |
double width =gdalDataSet.getRasterXSize()*pixelSizeX; |
|
375 |
double height=gdalDataSet.getRasterYSize()*pixelSizeY; |
|
376 |
|
|
377 |
// double minX, double minY, double maxX, double maxY, int subType |
|
378 |
try { |
|
379 |
envelope = GeometryLocator.getGeometryManager().createEnvelope( |
|
380 |
Math.min(leftMostX,leftMostX + width), |
|
381 |
Math.min(upperMostY,upperMostY + height), |
|
382 |
Math.max(leftMostX,leftMostX + width), |
|
383 |
Math.max(upperMostY,upperMostY + height), |
|
384 |
Geometry.SUBTYPES.GEOM2D); |
|
385 |
} catch (LocatorException | CreateEnvelopeException e) { |
|
386 |
logger.warn( |
|
387 |
"Failed to create envelope from wld file with coords: minx:"+leftMostX+ |
|
388 |
", miny:"+upperMostY+", maxX: "+leftMostX + width+", maxY: "+upperMostY + height); |
|
389 |
e.printStackTrace(); |
|
390 |
} |
|
391 |
|
|
392 |
return envelope; |
|
393 |
} |
|
394 |
|
|
395 |
@Override |
|
396 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
|
397 |
if( DataStore.METADATA_ENVELOPE.equalsIgnoreCase(name) ) { |
|
398 |
return this.envelope; |
|
399 |
} else if( DataStore.METADATA_CRS.equalsIgnoreCase(name) ) { |
|
400 |
IProjection pro = this.getRasterGdalParameters().getCRS(); |
|
401 |
if (pro != null) { |
|
402 |
return pro; |
|
403 |
} |
|
404 |
} |
|
405 |
return super.getDynValue(name); |
|
406 |
} |
|
407 |
|
|
408 |
@Override |
|
409 |
public void close() throws CloseException { |
|
410 |
this.gdalDataSet = null; |
|
411 |
} |
|
412 |
|
|
413 |
@Override |
|
414 |
public ResourceProvider getResource() { |
|
415 |
return this.resource; |
|
416 |
} |
|
417 |
|
|
418 |
|
|
419 |
@Override |
|
420 |
public Object getSourceId() { |
|
421 |
return this.getRasterGdalParameters().getFile(); |
|
422 |
} |
|
423 |
|
|
424 |
@Override |
|
425 |
public String getProviderName() { |
|
426 |
return NAME; |
|
427 |
} |
|
428 |
|
|
429 |
@Override |
|
430 |
public String getName() { |
|
431 |
String name = this.getRasterGdalParameters().getFile().getName(); |
|
432 |
return FilenameUtils.getBaseName(name); |
|
433 |
} |
|
434 |
|
|
435 |
@Override |
|
436 |
public String getFullName() { |
|
437 |
return this.getRasterGdalParameters().getFile().getAbsolutePath(); |
|
438 |
} |
|
439 |
|
|
440 |
@Override |
|
441 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
442 |
return true; |
|
443 |
} |
|
444 |
|
|
445 |
@Override |
|
446 |
/* |
|
447 |
* (non-Javadoc) |
|
448 |
* |
|
449 |
* @see |
|
450 |
* org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org. |
|
451 |
* gvsig.fmap.dal.resource.spi.ResourceProvider) |
|
452 |
*/ |
|
453 |
public void resourceChanged(ResourceProvider resource) { |
|
454 |
this.getStoreServices().notifyChange( |
|
455 |
DataStoreNotification.RESOURCE_CHANGED, |
|
456 |
resource); |
|
457 |
} |
|
458 |
|
|
459 |
@Override |
|
460 |
/* (non-Javadoc) |
|
461 |
* @see org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider#doDispose() |
|
462 |
*/ |
|
463 |
protected void doDispose() throws BaseException { |
|
464 |
super.doDispose(); |
|
465 |
resource.removeConsumer(this); |
|
466 |
} |
|
467 |
|
|
468 |
/** |
|
469 |
* Conversi?n de los tipos de datos de gdal a los tipos de datos de RasterBuf |
|
470 |
* @param gdalType Tipo de dato de gdal |
|
471 |
* @return Tipo de dato de RasterBuf |
|
472 |
*/ |
|
473 |
protected static int getRasterBufTypeFromGdalType(int gdalType) { |
|
474 |
switch (gdalType) { |
|
475 |
case 1:// Eight bit unsigned integer GDT_Byte = 1 |
|
476 |
return BufferManager.TYPE_BYTE; |
|
477 |
|
|
478 |
case 3:// Sixteen bit signed integer GDT_Int16 = 3, |
|
479 |
return BufferManager.TYPE_SHORT; |
|
480 |
|
|
481 |
case 2:// Sixteen bit unsigned integer GDT_UInt16 = 2 |
|
482 |
//return RasterBuffer.TYPE_USHORT; |
|
483 |
return BufferManager.TYPE_SHORT; //Apa?o para usar los tipos de datos que soportamos |
|
484 |
|
|
485 |
case 5:// Thirty two bit signed integer GDT_Int32 = 5 |
|
486 |
return BufferManager.TYPE_INT; |
|
487 |
|
|
488 |
case 6:// Thirty two bit floating point GDT_Float32 = 6 |
|
489 |
return BufferManager.TYPE_FLOAT; |
|
490 |
|
|
491 |
case 7:// Sixty four bit floating point GDT_Float64 = 7 |
|
492 |
return BufferManager.TYPE_DOUBLE; |
|
493 |
|
|
494 |
// TODO:Estos tipos de datos no podemos gestionarlos. Habria que definir |
|
495 |
// el tipo complejo y usar el tipo long que de momento no se gasta. |
|
496 |
case 4:// Thirty two bit unsigned integer GDT_UInt32 = 4, |
|
497 |
return BufferManager.TYPE_INT; |
|
498 |
//return RasterBuffer.TYPE_UNDEFINED; // Deberia devolver un Long |
|
499 |
|
|
500 |
case 8:// Complex Int16 GDT_CInt16 = 8 |
|
501 |
case 9:// Complex Int32 GDT_CInt32 = 9 |
|
502 |
case 10:// Complex Float32 GDT_CFloat32 = 10 |
|
503 |
case 11:// Complex Float64 GDT_CFloat64 = 11 |
|
504 |
return BufferManager.TYPE_UNDEFINED; |
|
505 |
} |
|
506 |
return BufferManager.TYPE_UNDEFINED; |
|
507 |
} |
|
508 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/java/org/gvsig/raster/gdal/provider/RasterGdalStoreProviderParameters.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 |
package org.gvsig.raster.gdal.provider; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.apache.commons.io.FileUtils; |
|
30 |
import org.apache.commons.io.FilenameUtils; |
|
31 |
import org.apache.commons.lang3.StringUtils; |
|
32 |
import org.cresques.cts.ICRSFactory; |
|
33 |
import org.cresques.cts.IProjection; |
|
34 |
import org.gdal.gdal.Dataset; |
|
35 |
import org.gdal.gdal.gdal; |
|
36 |
import org.gdal.gdalconst.gdalconstConstants; |
|
37 |
import org.gvsig.fmap.crs.CRSFactory; |
|
38 |
import org.gvsig.fmap.dal.FileHelper; |
|
39 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
40 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
41 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
42 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
43 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
|
|
47 |
/** |
|
48 |
* Parameters to create a JIMI Provider |
|
49 |
* @author dmartinezizquierdo |
|
50 |
* |
|
51 |
*/ |
|
52 |
public class RasterGdalStoreProviderParameters extends AbstractDataParameters implements |
|
53 |
OpenDataStoreParameters, FilesystemStoreParameters{ |
|
54 |
|
|
55 |
private static final Logger logger = LoggerFactory.getLogger(RasterGdalStoreProviderParameters.class); |
|
56 |
|
|
57 |
public static final String PARAMETERS_DEFINITION_NAME = "RasterGdalStoreProviderParameters"; |
|
58 |
public static final String FILE_PARAMTER_NAME = "file"; |
|
59 |
public static final String CRS_PARAMTER_NAME = "crs"; |
|
60 |
public static final String WLD_PARAMS_NAME= "wldParams"; |
|
61 |
|
|
62 |
|
|
63 |
private DelegatedDynObject parameters; |
|
64 |
|
|
65 |
/** |
|
66 |
* Constructor |
|
67 |
*/ |
|
68 |
public RasterGdalStoreProviderParameters() { |
|
69 |
this(PARAMETERS_DEFINITION_NAME); |
|
70 |
} |
|
71 |
|
|
72 |
protected RasterGdalStoreProviderParameters(String parametersDefinitionName) { |
|
73 |
this(parametersDefinitionName, RasterGdalStoreProvider.NAME); |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
/** |
|
78 |
* Constructor |
|
79 |
* @param parametersDefinitionName |
|
80 |
* @param name |
|
81 |
*/ |
|
82 |
public RasterGdalStoreProviderParameters(String parametersDefinitionName, String name) { |
|
83 |
super(); |
|
84 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
|
85 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name); |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public String getDataStoreName() { |
|
90 |
return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME); |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public boolean isValid() { |
|
95 |
if (this.getFile() != null){ |
|
96 |
try { |
|
97 |
gdal.Open(this.getFile().getAbsolutePath(),gdalconstConstants.GA_ReadOnly); |
|
98 |
} catch (Exception e) { |
|
99 |
return false; |
|
100 |
} |
|
101 |
return true; |
|
102 |
} |
|
103 |
return false; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public String getDescription() { |
|
108 |
return this.getDynClass().getDescription(); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public File getFile() { |
|
113 |
return (File) this.getDynValue(FILE_PARAMTER_NAME); |
|
114 |
} |
|
115 |
|
|
116 |
@Override |
|
117 |
public void setFile(File file) { |
|
118 |
this.setDynValue(FILE_PARAMTER_NAME, file); |
|
119 |
|
|
120 |
if (getCRS()==null){ |
|
121 |
loadPRJ(file); |
|
122 |
} |
|
123 |
if (getCRS()==null){ |
|
124 |
Dataset gdalDatasSet = gdal.Open(this.getFile().getAbsolutePath(),gdalconstConstants.GA_ReadOnly); |
|
125 |
String projection=gdalDatasSet.GetProjection(); |
|
126 |
if (StringUtils.isNotEmpty(projection)){ |
|
127 |
ICRSFactory crsFactory = CRSFactory.getCRSFactory(); |
|
128 |
IProjection crs=crsFactory.get(ICRSFactory.FORMAT_WKT, projection); |
|
129 |
setCRS(crs); |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* Sets CRS |
|
137 |
* @param crsCode |
|
138 |
*/ |
|
139 |
public void setCRS(String crsCode) { |
|
140 |
IProjection crs=CRSFactory.getCRS(crsCode); |
|
141 |
setDynValue(CRS_PARAMTER_NAME, crs); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Sets CRS |
|
146 |
* @param crs |
|
147 |
*/ |
|
148 |
public void setCRS(IProjection crs) { |
|
149 |
setDynValue(CRS_PARAMTER_NAME, crs); |
|
150 |
} |
|
151 |
|
|
152 |
|
|
153 |
/** |
|
154 |
* Gets CRS |
|
155 |
* @return IProjection |
|
156 |
*/ |
|
157 |
public IProjection getCRS() { |
|
158 |
return (IProjection) getDynValue(CRS_PARAMTER_NAME); |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* Gets the 6 params of a WLD file as Strings. |
|
163 |
* |
|
164 |
* @return A list with WLD parameters |
|
165 |
*/ |
|
166 |
public List<String> getWldParams() { |
|
167 |
return (List<String>) getDynValue(WLD_PARAMS_NAME); |
|
168 |
} |
|
169 |
|
|
170 |
/** |
|
171 |
* Sets the params of a wld file |
|
172 |
* @param wldParams |
|
173 |
*/ |
|
174 |
public void setWldParams(List<String> wldParams){ |
|
175 |
setDynValue(WLD_PARAMS_NAME,wldParams); |
|
176 |
} |
|
177 |
|
|
178 |
@Override |
|
179 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
180 |
return parameters; |
|
181 |
} |
|
182 |
|
|
183 |
|
|
184 |
private void loadPRJ(File file){ |
|
185 |
File prjFile = new File(FilenameUtils.removeExtension(file.getAbsolutePath())+".prj"); |
|
186 |
if (prjFile.exists()) { |
|
187 |
try { |
|
188 |
String contentFile = FileUtils.readFileToString(prjFile); |
|
189 |
if (StringUtils.isNotEmpty(contentFile)){ |
|
190 |
IProjection crs=CRSFactory.getCRSFactory().get(ICRSFactory.FORMAT_WKT_ESRI, contentFile); |
|
191 |
setCRS(crs); |
|
192 |
} |
|
193 |
|
|
194 |
} catch (IOException e) { |
|
195 |
logger.warn("Couldn't read wld file"); |
|
196 |
} |
|
197 |
} |
|
198 |
} |
|
199 |
|
|
200 |
private void loadWLD(File file){ |
|
201 |
File wldFile = new File(FilenameUtils.removeExtension(file.getAbsolutePath())+".wld"); |
|
202 |
if (wldFile.exists()) { |
|
203 |
try { |
|
204 |
List<String> lines = FileUtils.readLines(wldFile); |
|
205 |
if (lines!=null && lines.size()==6){ |
|
206 |
setWldParams(lines); |
|
207 |
} |
|
208 |
|
|
209 |
} catch (IOException e) { |
|
210 |
logger.warn("Couldn't read wld file"); |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/java/org/gvsig/raster/gdal/provider/DefaultRasterGdalStoreProvider.java | ||
---|---|---|
1 |
package org.gvsig.raster.gdal.provider; |
|
2 |
|
|
3 |
import org.gdal.gdal.Driver; |
|
4 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
5 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
6 |
import org.gvsig.tools.dynobject.DynObject; |
|
7 |
|
|
8 |
/** |
|
9 |
* Raster Gdal provider to raster files |
Also available in: Unified diff