gvsig-raster / org.gvsig.raster.gdal / trunk / org.gvsig.raster.gdal / org.gvsig.raster.gdal.io / src / main / java / org / gvsig / raster / gdal / io / GdalFilesystemServerExplorer.java @ 488
History | View | Annotate | Download (5.04 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 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 IVER T.I {{Task}}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.raster.gdal.io; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.FileInputStream; |
32 |
|
33 |
import org.gvsig.fmap.dal.DALLocator; |
34 |
import org.gvsig.fmap.dal.DataManager; |
35 |
import org.gvsig.fmap.dal.DataServerExplorer; |
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
37 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
38 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
39 |
import org.gvsig.fmap.dal.exception.CreateException; |
40 |
import org.gvsig.fmap.dal.exception.DataException; |
41 |
import org.gvsig.fmap.dal.exception.RemoveException; |
42 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
43 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
44 |
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters; |
45 |
|
46 |
public class GdalFilesystemServerExplorer extends AbstractFilesystemServerExplorerProvider { |
47 |
|
48 |
/*
|
49 |
* (non-Javadoc)
|
50 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#canCreate()
|
51 |
*/
|
52 |
public boolean canCreate() { |
53 |
return false; |
54 |
} |
55 |
|
56 |
/*
|
57 |
* (non-Javadoc)
|
58 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#canCreate(org.gvsig.fmap.dal.NewDataStoreParameters)
|
59 |
*/
|
60 |
public boolean canCreate(NewDataStoreParameters parameters) { |
61 |
return false; |
62 |
} |
63 |
|
64 |
/*
|
65 |
* (non-Javadoc)
|
66 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#create(org.gvsig.fmap.dal.NewDataStoreParameters, boolean)
|
67 |
*/
|
68 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
69 |
throws CreateException {
|
70 |
throw new UnsupportedOperationException(); |
71 |
} |
72 |
|
73 |
/*
|
74 |
* (non-Javadoc)
|
75 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#getCreateParameters()
|
76 |
*/
|
77 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
78 |
return null; |
79 |
} |
80 |
|
81 |
/*
|
82 |
* (non-Javadoc)
|
83 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#initialize(org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices)
|
84 |
*/
|
85 |
public void initialize(FilesystemServerExplorerProviderServices serverExplorer) { |
86 |
} |
87 |
|
88 |
/*
|
89 |
* (non-Javadoc)
|
90 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#remove(org.gvsig.fmap.dal.DataStoreParameters)
|
91 |
*/
|
92 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
93 |
throw new UnsupportedOperationException(); |
94 |
} |
95 |
|
96 |
/*
|
97 |
* (non-Javadoc)
|
98 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter#getDataStoreProviderName()
|
99 |
*/
|
100 |
public String getDataStoreProviderName() { |
101 |
return GdalProvider.NAME;
|
102 |
} |
103 |
|
104 |
/*
|
105 |
* (non-Javadoc)
|
106 |
* @see java.io.FileFilter#accept(java.io.File)
|
107 |
*/
|
108 |
public boolean accept(File pathname) { |
109 |
if (pathname.getParentFile() != null && |
110 |
pathname.getParentFile().getName().equals("cellhd")) {
|
111 |
if (pathname.getName().endsWith(".rmf") |
112 |
|| pathname.getName().endsWith(".rmf~")) {
|
113 |
return false; |
114 |
} |
115 |
return true; |
116 |
} |
117 |
|
118 |
// Comprobamos que no sea un rmf propio, osea, que contenga xml
|
119 |
if (pathname.getName().toLowerCase().endsWith(".rmf")) { |
120 |
FileInputStream reader = null; |
121 |
try {
|
122 |
reader = new FileInputStream(pathname); |
123 |
String xml = ""; |
124 |
for (int i = 0; i < 6; i++) { |
125 |
xml += (char) reader.read();
|
126 |
} |
127 |
if (xml.equals("<?xml ")) { |
128 |
return false; |
129 |
} |
130 |
} catch (Exception e) { |
131 |
} finally {
|
132 |
try {
|
133 |
reader.close(); |
134 |
} catch (Exception e) { |
135 |
} |
136 |
} |
137 |
} |
138 |
return RasterLocator.getManager().isExtensionSupported(pathname.getAbsolutePath(), GdalProvider.class);
|
139 |
} |
140 |
|
141 |
/*
|
142 |
* (non-Javadoc)
|
143 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter#getDescription()
|
144 |
*/
|
145 |
public String getDescription() { |
146 |
return GdalProvider.DESCRIPTION;
|
147 |
} |
148 |
|
149 |
public DataStoreParameters getParameters(File file) throws DataException { |
150 |
DataManager manager = DALLocator.getDataManager(); |
151 |
AbstractRasterFileDataParameters params = (AbstractRasterFileDataParameters) manager |
152 |
.createStoreParameters(this.getDataStoreProviderName());
|
153 |
params.setFile(file); |
154 |
return params;
|
155 |
} |
156 |
|
157 |
public int getMode() { |
158 |
return DataServerExplorer.MODE_RASTER;
|
159 |
} |
160 |
|
161 |
} |