53 |
53 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
|
54 |
54 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
|
55 |
55 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
|
|
56 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
|
56 |
57 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
|
57 |
58 |
import org.gvsig.fmap.dal.exception.OpenException;
|
58 |
59 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
|
... | ... | |
74 |
75 |
import org.gvsig.tools.dynobject.DynObject;
|
75 |
76 |
import org.gvsig.tools.extensionpoint.ExtensionPoint;
|
76 |
77 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
|
|
78 |
|
|
79 |
|
77 |
80 |
/**
|
78 |
81 |
* This class represents the data access for gdal formats.
|
79 |
82 |
*
|
80 |
83 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
81 |
84 |
*/
|
82 |
85 |
public class GdalProvider extends AbstractRasterProvider {
|
83 |
|
public static String NAME = "Gdal Store";
|
84 |
|
public static String DESCRIPTION = "Gdal Raster file";
|
85 |
|
public static final String METADATA_DEFINITION_NAME = "GdalStore";
|
86 |
|
private static final Logger logger = LoggerFactory.getLogger(GdalProvider.class);
|
87 |
86 |
|
88 |
|
public static final String FORMAT_GTiff = "GTiff";
|
89 |
|
public static final String FORMAT_VRT = "VRT";
|
90 |
|
public static final String FORMAT_NITF = "NITF";
|
91 |
|
public static final String FORMAT_HFA = "HFA";
|
92 |
|
public static final String FORMAT_ELAS = "ELAS";
|
93 |
|
public static final String FORMAT_MEM = "MEM";
|
94 |
|
public static final String FORMAT_BMP = "BMP";
|
95 |
|
public static final String FORMAT_PCIDSK = "PCIDSK";
|
96 |
|
public static final String FORMAT_ILWIS = "ILWIS";
|
97 |
|
public static final String FORMAT_HDF4 = "HDF4Image";
|
98 |
|
public static final String FORMAT_PNM = "PNM";
|
99 |
|
public static final String FORMAT_ENVI = "ENVI";
|
100 |
|
public static final String FORMAT_EHDR = "EHdr";
|
101 |
|
public static final String FORMAT_PAUX = "PAux";
|
102 |
|
public static final String FORMAT_MFF = "MFF";
|
103 |
|
public static final String FORMAT_MFF2 = "MFF2";
|
104 |
|
public static final String FORMAT_BT = "BT";
|
105 |
|
public static final String FORMAT_IDA = "IDA";
|
106 |
|
public static final String FORMAT_RMF = "RMF";
|
107 |
|
public static final String FORMAT_RST = "RST";
|
108 |
|
public static final String FORMAT_LEVELLER = "Leveller";
|
109 |
|
public static final String FORMAT_TERRAGEN = "Terragen";
|
110 |
|
public static final String FORMAT_ERS = "ERS";
|
111 |
|
public static final String FORMAT_INGR = "INGR";
|
112 |
|
public static final String FORMAT_GSAG = "GSAG";
|
113 |
|
public static final String FORMAT_GSBG = "GSBG";
|
114 |
|
public static final String FORMAT_ADRG = "ADRG";
|
115 |
|
public static final String FORMAT_JP2 = "JPEG2000";
|
116 |
|
public static final String FORMAT_GRD = "GRD";
|
117 |
|
public static final int BAND_HEIGHT = 64;
|
118 |
|
protected GdalDataSource file = null;
|
119 |
|
private Extent viewRequest = null;
|
120 |
|
protected static String[][] formatList = null;
|
|
87 |
public static String NAME = "Gdal Store";
|
|
88 |
public static String DESCRIPTION = "Gdal Raster file";
|
|
89 |
public static final String METADATA_DEFINITION_NAME = "GdalStore";
|
|
90 |
private static final Logger logger = LoggerFactory.getLogger(GdalProvider.class);
|
121 |
91 |
|
122 |
|
public static void register() {
|
123 |
|
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
|
124 |
|
registerFormats();
|
|
92 |
public static final String FORMAT_GTiff = "GTiff";
|
|
93 |
public static final String FORMAT_VRT = "VRT";
|
|
94 |
public static final String FORMAT_NITF = "NITF";
|
|
95 |
public static final String FORMAT_HFA = "HFA";
|
|
96 |
public static final String FORMAT_ELAS = "ELAS";
|
|
97 |
public static final String FORMAT_MEM = "MEM";
|
|
98 |
public static final String FORMAT_BMP = "BMP";
|
|
99 |
public static final String FORMAT_PCIDSK = "PCIDSK";
|
|
100 |
public static final String FORMAT_ILWIS = "ILWIS";
|
|
101 |
public static final String FORMAT_HDF4 = "HDF4Image";
|
|
102 |
public static final String FORMAT_PNM = "PNM";
|
|
103 |
public static final String FORMAT_ENVI = "ENVI";
|
|
104 |
public static final String FORMAT_EHDR = "EHdr";
|
|
105 |
public static final String FORMAT_PAUX = "PAux";
|
|
106 |
public static final String FORMAT_MFF = "MFF";
|
|
107 |
public static final String FORMAT_MFF2 = "MFF2";
|
|
108 |
public static final String FORMAT_BT = "BT";
|
|
109 |
public static final String FORMAT_IDA = "IDA";
|
|
110 |
public static final String FORMAT_RMF = "RMF";
|
|
111 |
public static final String FORMAT_RST = "RST";
|
|
112 |
public static final String FORMAT_LEVELLER = "Leveller";
|
|
113 |
public static final String FORMAT_TERRAGEN = "Terragen";
|
|
114 |
public static final String FORMAT_ERS = "ERS";
|
|
115 |
public static final String FORMAT_INGR = "INGR";
|
|
116 |
public static final String FORMAT_GSAG = "GSAG";
|
|
117 |
public static final String FORMAT_GSBG = "GSBG";
|
|
118 |
public static final String FORMAT_ADRG = "ADRG";
|
|
119 |
public static final String FORMAT_JP2 = "JPEG2000";
|
|
120 |
public static final String FORMAT_GRD = "GRD";
|
|
121 |
public static final int BAND_HEIGHT = 64;
|
|
122 |
protected GdalDataSource file = null;
|
|
123 |
private Extent viewRequest = null;
|
|
124 |
protected static String[][] formatList = null;
|
125 |
125 |
|
126 |
|
ExtensionPoint point = extensionPoints.get("DefaultRasterProvider");
|
127 |
|
point.append("reader", GdalProvider.NAME, GdalProvider.class);
|
|
126 |
public static void register() {
|
|
127 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
|
|
128 |
registerFormats();
|
128 |
129 |
|
129 |
|
RasterLocator.getManager().getProviderServices().registerFileProvidersTiled(GdalProvider.class);
|
|
130 |
ExtensionPoint point = extensionPoints.get("DefaultRasterProvider");
|
|
131 |
point.append("reader", GdalProvider.NAME, GdalProvider.class);
|
130 |
132 |
|
131 |
|
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
|
132 |
|
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
|
133 |
|
dataman.registerStoreProvider(NAME,
|
134 |
|
GdalProvider.class, GdalDataParameters.class);
|
135 |
|
}
|
|
133 |
RasterLocator.getManager().getProviderServices().registerFileProvidersTiled(GdalProvider.class);
|
136 |
134 |
|
137 |
|
if(DALFileLocator.getFilesystemServerExplorerManager() != null)
|
138 |
|
DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
|
139 |
|
NAME, DESCRIPTION,
|
140 |
|
GdalFilesystemServerExplorer.class);
|
|
135 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
|
|
136 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
|
|
137 |
dataman.registerStoreProvider(NAME,
|
|
138 |
GdalProvider.class, GdalDataParameters.class);
|
|
139 |
}
|
141 |
140 |
|
142 |
|
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
|
143 |
|
}
|
|
141 |
if (DALFileLocator.getFilesystemServerExplorerManager() != null) {
|
|
142 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
|
|
143 |
NAME, DESCRIPTION,
|
|
144 |
GdalFilesystemServerExplorer.class);
|
|
145 |
}
|
144 |
146 |
|
145 |
|
private static void registerFormats() {
|
146 |
|
formatList = new String[][] {
|
147 |
|
new String[] {"bmp","image/bmp" },
|
148 |
|
new String[] {"gif","image/gif" },
|
149 |
|
new String[] {"tif","image/tiff" },
|
150 |
|
new String[] {"tiff","image/tiff" },
|
151 |
|
new String[] {"jpg","image/jpeg" },
|
152 |
|
new String[] {"jpeg","image/jpeg" },
|
153 |
|
new String[] {"png","image/png" },
|
154 |
|
new String[] {"vrt","image/vrt" },
|
155 |
|
new String[] {"dat","image/dat" }, // Envi
|
156 |
|
new String[] {"lan","image/lan" }, // Erdas
|
157 |
|
new String[] {"gis","image/gis" }, // Erdas
|
158 |
|
new String[] {"img","image/img" }, // Erdas
|
159 |
|
new String[] {"pix", "image/pix" },// PCI Geomatics
|
160 |
|
new String[] {"aux","image/aux" }, // PCI Geomatics
|
161 |
|
new String[] {"adf","image/adf" }, // ESRI Grids
|
162 |
|
new String[] {"mpr","image/mpr" }, // Ilwis
|
163 |
|
new String[] {"mpl","image/mpl" }, // Ilwis
|
164 |
|
new String[] {"map", "image/map" },// PC Raster
|
165 |
|
new String[] {"asc","image/asc" },
|
166 |
|
new String[] {"pgm", "image/pgn" },//Ficheros PNM en escala de grises
|
167 |
|
new String[] {"ppm", "image/ppm" },//Ficheros PNM en RGB
|
168 |
|
new String[] {"rst", "image/rst" },//IDRISIS
|
169 |
|
new String[] {"rmf", "image/rmf" },//Raster Matrix Format
|
170 |
|
new String[] {"nos","image/nos" },
|
171 |
|
new String[] {"kap","image/kap" },
|
172 |
|
new String[] {"hdr","image/hdr" },
|
173 |
|
new String[] {"raw","image/raw" },
|
174 |
|
new String[] {"ers","image/ers" },
|
175 |
|
new String[] {"xml","image/xml" },
|
176 |
|
new String[] {"grd","image/grd" },
|
177 |
|
/*
|
178 |
|
new String[] {"jp2","image/jp2" },
|
179 |
|
new String[] {"mrsid","image/mrsid" },
|
180 |
|
new String[] {"ecw","image/ecw" },
|
181 |
|
*/
|
182 |
|
new String[] {"txt","image/txt" }
|
183 |
|
};
|
184 |
|
for (int i = 0; i < formatList.length; i++)
|
185 |
|
RasterLocator.getManager().getProviderServices().addFormat(formatList[i][0], GdalProvider.class);
|
186 |
|
}
|
|
147 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
|
|
148 |
}
|
187 |
149 |
|
188 |
|
public String[] getFormatList() {
|
189 |
|
String[] fl = new String[formatList.length];
|
190 |
|
for( int i=0; i<fl.length; i++) {
|
191 |
|
fl[i] = formatList[i][0];
|
|
150 |
private static void registerFormats() {
|
|
151 |
formatList = new String[][]{
|
|
152 |
new String[]{"bmp", "image/bmp"},
|
|
153 |
new String[]{"gif", "image/gif"},
|
|
154 |
new String[]{"tif", "image/tiff"},
|
|
155 |
new String[]{"tiff", "image/tiff"},
|
|
156 |
new String[]{"jpg", "image/jpeg"},
|
|
157 |
new String[]{"jpeg", "image/jpeg"},
|
|
158 |
new String[]{"png", "image/png"},
|
|
159 |
new String[]{"vrt", "image/vrt"},
|
|
160 |
new String[]{"dat", "image/dat"}, // Envi
|
|
161 |
new String[]{"lan", "image/lan"}, // Erdas
|
|
162 |
new String[]{"gis", "image/gis"}, // Erdas
|
|
163 |
new String[]{"img", "image/img"}, // Erdas
|
|
164 |
new String[]{"pix", "image/pix"},// PCI Geomatics
|
|
165 |
new String[]{"aux", "image/aux"}, // PCI Geomatics
|
|
166 |
new String[]{"adf", "image/adf"}, // ESRI Grids
|
|
167 |
new String[]{"mpr", "image/mpr"}, // Ilwis
|
|
168 |
new String[]{"mpl", "image/mpl"}, // Ilwis
|
|
169 |
new String[]{"map", "image/map"},// PC Raster
|
|
170 |
new String[]{"asc", "image/asc"},
|
|
171 |
new String[]{"pgm", "image/pgn"},//Ficheros PNM en escala de grises
|
|
172 |
new String[]{"ppm", "image/ppm"},//Ficheros PNM en RGB
|
|
173 |
new String[]{"rst", "image/rst"},//IDRISIS
|
|
174 |
new String[]{"rmf", "image/rmf"},//Raster Matrix Format
|
|
175 |
new String[]{"nos", "image/nos"},
|
|
176 |
new String[]{"kap", "image/kap"},
|
|
177 |
new String[]{"hdr", "image/hdr"},
|
|
178 |
new String[]{"raw", "image/raw"},
|
|
179 |
new String[]{"ers", "image/ers"},
|
|
180 |
new String[]{"xml", "image/xml"},
|
|
181 |
new String[]{"grd", "image/grd"},
|
|
182 |
/*
|
|
183 |
new String[] {"jp2","image/jp2" },
|
|
184 |
new String[] {"mrsid","image/mrsid" },
|
|
185 |
new String[] {"ecw","image/ecw" },
|
|
186 |
*/
|
|
187 |
new String[]{"txt", "image/txt"}
|
|
188 |
};
|
|
189 |
for (int i = 0; i < formatList.length; i++) {
|
|
190 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i][0], GdalProvider.class);
|
|
191 |
}
|
|
192 |
}
|
|
193 |
|
|
194 |
public String[] getFormatList() {
|
|
195 |
String[] fl = new String[formatList.length];
|
|
196 |
for (int i = 0; i < fl.length; i++) {
|
|
197 |
fl[i] = formatList[i][0];
|
|
198 |
}
|
|
199 |
return fl;
|
|
200 |
}
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Returns true if the extension is supported and false if doesn't
|
|
204 |
*
|
|
205 |
* @param ext
|
|
206 |
* @return
|
|
207 |
*/
|
|
208 |
public boolean isExtensionSupported(String ext) {
|
|
209 |
if (ext.indexOf(".") != -1) {
|
|
210 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length());
|
|
211 |
}
|
|
212 |
for (int i = 0; i < formatList.length; i++) {
|
|
213 |
if (formatList[i][0].compareTo(ext) == 0) {
|
|
214 |
return true;
|
192 |
215 |
}
|
193 |
|
return fl;
|
194 |
|
}
|
|
216 |
}
|
|
217 |
return false;
|
|
218 |
}
|
195 |
219 |
|
196 |
|
/**
|
197 |
|
* Returns true if the extension is supported and false if doesn't
|
198 |
|
* @param ext
|
199 |
|
* @return
|
200 |
|
*/
|
201 |
|
public boolean isExtensionSupported(String ext) {
|
202 |
|
if(ext.indexOf(".") != -1)
|
203 |
|
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length());
|
204 |
|
for (int i = 0; i < formatList.length; i++) {
|
205 |
|
if(formatList[i][0].compareTo(ext) == 0)
|
206 |
|
return true;
|
207 |
|
}
|
208 |
|
return false;
|
209 |
|
}
|
|
220 |
/**
|
|
221 |
* Mandatory constructor to instantiate an empty provider
|
|
222 |
*/
|
|
223 |
public GdalProvider() {
|
|
224 |
}
|
210 |
225 |
|
211 |
|
/**
|
212 |
|
* Mandatory constructor to instantiate an empty provider
|
213 |
|
*/
|
214 |
|
public GdalProvider() {
|
215 |
|
}
|
216 |
|
|
217 |
|
/**
|
218 |
|
* Constructor. Abre el dataset.
|
|
226 |
/**
|
|
227 |
* Constructor. Abre el dataset.
|
|
228 |
*
|
219 |
229 |
* @param params
|
220 |
|
* @throws NotSupportedExtensionException
|
221 |
|
* @throws OpenException
|
222 |
|
* @deprecated use {@link #GdalProvider(URI)}, this constructor will be removed in gvSIG 2.5
|
223 |
|
*/
|
224 |
|
public GdalProvider(String params) throws NotSupportedExtensionException, OpenException {
|
225 |
|
super(params);
|
|
230 |
* @throws NotSupportedExtensionException
|
|
231 |
* @throws OpenException
|
|
232 |
* @deprecated use {@link #GdalProvider(URI)}, this constructor will be
|
|
233 |
* removed in gvSIG 2.5
|
|
234 |
*/
|
|
235 |
public GdalProvider(String params) throws NotSupportedExtensionException, OpenException {
|
|
236 |
super(params);
|
226 |
237 |
logger.info("Deprecated use of GdalProvider constructor");
|
227 |
|
if(params instanceof String) {
|
228 |
|
GdalDataParameters p = new GdalDataParameters();
|
229 |
|
URI uriParam;
|
|
238 |
if (params instanceof String) {
|
|
239 |
GdalDataParameters p = new GdalDataParameters();
|
|
240 |
URI uriParam;
|
230 |
241 |
try {
|
231 |
|
uriParam = new URI((String)params);
|
|
242 |
uriParam = new URI((String) params);
|
232 |
243 |
} catch (URISyntaxException e) {
|
233 |
|
throw new OpenException("Can't create uri from "+(String)params, e);
|
|
244 |
throw new OpenException("Can't create uri from " + (String) params, e);
|
234 |
245 |
}
|
235 |
|
p.setURI(uriParam);
|
236 |
|
super.init(p, null, ToolsLocator.getDynObjectManager()
|
237 |
|
.createDynObject(
|
238 |
|
MetadataLocator.getMetadataManager().getDefinition(
|
239 |
|
DataStore.METADATA_DEFINITION_NAME)));
|
240 |
|
init(p, null);
|
241 |
|
}
|
242 |
|
}
|
|
246 |
p.setURI(uriParam);
|
|
247 |
super.init(p, null, ToolsLocator.getDynObjectManager()
|
|
248 |
.createDynObject(
|
|
249 |
MetadataLocator.getMetadataManager().getDefinition(
|
|
250 |
DataStore.METADATA_DEFINITION_NAME)));
|
|
251 |
init(p, null);
|
|
252 |
}
|
|
253 |
}
|
243 |
254 |
|
244 |
|
/**
|
|
255 |
/**
|
245 |
256 |
* Constructor. Abre el dataset.
|
|
257 |
*
|
246 |
258 |
* @param uri
|
247 |
259 |
* @throws NotSupportedExtensionException
|
248 |
260 |
*/
|
... | ... | |
251 |
263 |
GdalDataParameters p = new GdalDataParameters();
|
252 |
264 |
p.setURI(uri);
|
253 |
265 |
super.init(
|
254 |
|
p,
|
255 |
|
null,
|
256 |
|
ToolsLocator.getDynObjectManager().createDynObject(
|
257 |
|
MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME)));
|
|
266 |
p,
|
|
267 |
null,
|
|
268 |
ToolsLocator.getDynObjectManager().createDynObject(
|
|
269 |
MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME)));
|
258 |
270 |
init(p, null);
|
259 |
271 |
}
|
260 |
272 |
|
261 |
|
public GdalProvider (GdalDataParameters params,
|
262 |
|
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
263 |
|
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
264 |
|
.createDynObject(
|
265 |
|
MetadataLocator.getMetadataManager().getDefinition(
|
266 |
|
DataStore.METADATA_DEFINITION_NAME)));
|
267 |
|
init(params, storeServices);
|
268 |
|
}
|
|
273 |
public GdalProvider(GdalDataParameters params,
|
|
274 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
|
275 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
|
276 |
.createDynObject(
|
|
277 |
MetadataLocator.getMetadataManager().getDefinition(
|
|
278 |
DataStore.METADATA_DEFINITION_NAME)));
|
|
279 |
init(params, storeServices);
|
|
280 |
}
|
269 |
281 |
|
270 |
|
public GdalProvider(AbstractRasterDataParameters params,
|
271 |
|
DataStoreProviderServices storeServices, DynObject metadata) {
|
272 |
|
super(params, storeServices, metadata);
|
273 |
|
}
|
|
282 |
public GdalProvider(AbstractRasterDataParameters params,
|
|
283 |
DataStoreProviderServices storeServices, DynObject metadata) {
|
|
284 |
super(params, storeServices, metadata);
|
|
285 |
}
|
274 |
286 |
|
275 |
|
/**
|
276 |
|
* Creates file references and loads structures with the information and metadata
|
277 |
|
* @param params load parameters
|
|
287 |
/**
|
|
288 |
* Creates file references and loads structures with the information and
|
|
289 |
* metadata
|
|
290 |
*
|
|
291 |
* @param params load parameters
|
278 |
292 |
* @param storeServices
|
279 |
|
* @throws NotSupportedExtensionException
|
280 |
|
*/
|
281 |
|
public void init (AbstractRasterDataParameters params,
|
282 |
|
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
283 |
|
try {
|
284 |
|
setParam(storeServices, params);
|
285 |
|
validRmf(params.getURI().getPath());
|
286 |
|
String translatedFileName = translateFileName(params.getURI().getPath());
|
287 |
|
setFName(translatedFileName);
|
288 |
|
file = new GdalDataSource(translatedFileName);
|
289 |
|
setColorInterpretation(file.colorInterpr);
|
290 |
|
setColorTable(file.palette);
|
291 |
|
noData = file.getNoDataValue();
|
|
293 |
* @throws NotSupportedExtensionException
|
|
294 |
*/
|
|
295 |
public void init(AbstractRasterDataParameters params,
|
|
296 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
|
297 |
try {
|
|
298 |
setParam(storeServices, params);
|
|
299 |
String fname = getFileName(params);
|
|
300 |
setFName(fname);
|
|
301 |
file = new GdalDataSource(fname);
|
|
302 |
setColorInterpretation(file.colorInterpr);
|
|
303 |
setColorTable(file.palette);
|
|
304 |
noData = file.getNoDataValue();
|
292 |
305 |
|
293 |
|
IProjection proj = null;
|
294 |
|
File prjFile = getPrjFile(params.getURI());
|
295 |
|
if(prjFile.exists()){
|
296 |
|
String wktEsri = loadPrj(prjFile);
|
297 |
|
if (wktEsri != null) {
|
298 |
|
proj = CRSFactory.getCRSFactory().get(ICRSFactory.FORMAT_WKT_ESRI, wktEsri);
|
299 |
|
}
|
|
306 |
IProjection proj = null;
|
|
307 |
File prjFile = getPrjFile(params.getURI());
|
|
308 |
if (prjFile.exists()) {
|
|
309 |
String wktEsri = loadPrj(prjFile);
|
|
310 |
if (wktEsri != null) {
|
|
311 |
proj = CRSFactory.getCRSFactory().get(ICRSFactory.FORMAT_WKT_ESRI, wktEsri);
|
|
312 |
}
|
300 |
313 |
}
|
301 |
|
if (proj==null) {
|
|
314 |
if (proj == null) {
|
302 |
315 |
String wktProjection = file.getProjectionRef();
|
303 |
316 |
if (!StringUtils.isEmpty(wktProjection)) {
|
304 |
317 |
try {
|
... | ... | |
312 |
325 |
setProjection(proj, false);
|
313 |
326 |
}
|
314 |
327 |
|
315 |
|
ownTransformation = file.getOwnTransformation();
|
316 |
|
externalTransformation = (AffineTransform)ownTransformation.clone();
|
317 |
|
load();
|
|
328 |
ownTransformation = file.getOwnTransformation();
|
|
329 |
externalTransformation = (AffineTransform) ownTransformation.clone();
|
|
330 |
load();
|
318 |
331 |
|
319 |
|
if(file != null)
|
320 |
|
bandCount = file.getRasterCount();
|
321 |
|
} catch (GdalException e) {
|
322 |
|
throw new NotSupportedExtensionException("Extension not supported", e);
|
323 |
|
} catch(Exception e) {
|
324 |
|
System.out.println("Error en GdalOpen");
|
325 |
|
e.printStackTrace();
|
326 |
|
file = null;
|
327 |
|
}
|
|
332 |
if (file != null) {
|
|
333 |
bandCount = file.getRasterCount();
|
|
334 |
}
|
|
335 |
} catch (GdalException e) {
|
|
336 |
throw new NotSupportedExtensionException("Extension not supported", e);
|
|
337 |
} catch (Exception e) {
|
|
338 |
System.out.println("Error en GdalOpen");
|
|
339 |
e.printStackTrace();
|
|
340 |
file = null;
|
|
341 |
}
|
328 |
342 |
|
329 |
|
//Obtenemos el tipo de dato de gdal y lo convertimos el de RasterBuf
|
330 |
|
int[] dt = new int[file.getDataType().length];
|
331 |
|
for (int i = 0; i < dt.length; i++)
|
332 |
|
dt[i] = GdalDataSource.getRasterBufTypeFromGdalType(file.getDataType()[i]);
|
333 |
|
setDataType(dt);
|
|
343 |
//Obtenemos el tipo de dato de gdal y lo convertimos el de RasterBuf
|
|
344 |
int[] dt = new int[file.getDataType().length];
|
|
345 |
for (int i = 0; i < dt.length; i++) {
|
|
346 |
dt[i] = GdalDataSource.getRasterBufTypeFromGdalType(file.getDataType()[i]);
|
|
347 |
}
|
|
348 |
setDataType(dt);
|
334 |
349 |
|
335 |
|
super.init();
|
|
350 |
super.init();
|
336 |
351 |
|
337 |
|
try {
|
338 |
|
loadFromRmf(getRmfBlocksManager());
|
339 |
|
} catch (ParsingException e) {
|
340 |
|
//No lee desde rmf
|
341 |
|
logger.debug("Problems reading from the RMF file", e);
|
342 |
|
}
|
343 |
|
}
|
|
352 |
try {
|
|
353 |
loadFromRmf(getRmfBlocksManager());
|
|
354 |
} catch (ParsingException e) {
|
|
355 |
//No lee desde rmf
|
|
356 |
logger.debug("Problems reading from the RMF file", e);
|
|
357 |
}
|
|
358 |
}
|
344 |
359 |
|
|
360 |
private String getFileName(RasterDataParameters params) throws GdalException {
|
|
361 |
File f = new File(params.getURI());
|
|
362 |
validRmf(f.getAbsolutePath());
|
|
363 |
return translateFileName(f.getAbsolutePath());
|
|
364 |
}
|
|
365 |
|
345 |
366 |
public String getMimeType() {
|
346 |
367 |
try {
|
347 |
368 |
File f = ((FilesystemStoreParameters) (this.getDataStoreParameters())).getFile();
|
... | ... | |
352 |
373 |
}
|
353 |
374 |
}
|
354 |
375 |
} catch (Exception ex) {
|
355 |
|
logger.warn("Can't get mime type for GDAL archive.",ex);
|
|
376 |
logger.warn("Can't get mime type for GDAL archive.", ex);
|
356 |
377 |
}
|
357 |
378 |
return "image";
|
358 |
379 |
}
|
359 |
380 |
|
360 |
|
/**
|
361 |
|
* Comprueba si el fichero abierto es un RasterMetaFile o una imagen
|
362 |
|
* raster.
|
363 |
|
* @throws GdalException
|
364 |
|
*/
|
365 |
|
private void validRmf(String file) throws GdalException {
|
366 |
|
if(file.endsWith(".rmf")) {
|
367 |
|
File f = new File(file);
|
368 |
|
try {
|
369 |
|
FileReader fr = new FileReader(f);
|
370 |
|
BufferedReader br = new BufferedReader(fr);
|
371 |
|
char[] buffer = new char[5];
|
372 |
|
br.read(buffer);
|
373 |
|
StringBuffer st = new StringBuffer(new String(buffer));
|
374 |
|
br.close();
|
375 |
|
fr.close();
|
376 |
|
if(st.toString().equals("<?xml"))
|
377 |
|
throw new GdalException("RasterMetaFile");
|
378 |
|
} catch (FileNotFoundException e) {
|
379 |
|
throw new GdalException("File Not Found");
|
380 |
|
} catch (IOException e) {
|
381 |
|
throw new GdalException("");
|
382 |
|
}
|
383 |
|
}
|
384 |
|
}
|
|
381 |
/**
|
|
382 |
* Comprueba si el fichero abierto es un RasterMetaFile o una imagen raster.
|
|
383 |
*
|
|
384 |
* @throws GdalException
|
|
385 |
*/
|
|
386 |
private void validRmf(String file) throws GdalException {
|
|
387 |
if (file.endsWith(".rmf")) {
|
|
388 |
File f = new File(file);
|
|
389 |
try {
|
|
390 |
FileReader fr = new FileReader(f);
|
|
391 |
BufferedReader br = new BufferedReader(fr);
|
|
392 |
char[] buffer = new char[5];
|
|
393 |
br.read(buffer);
|
|
394 |
StringBuffer st = new StringBuffer(new String(buffer));
|
|
395 |
br.close();
|
|
396 |
fr.close();
|
|
397 |
if (st.toString().equals("<?xml")) {
|
|
398 |
throw new GdalException("RasterMetaFile");
|
|
399 |
}
|
|
400 |
} catch (FileNotFoundException e) {
|
|
401 |
throw new GdalException("File Not Found");
|
|
402 |
} catch (IOException e) {
|
|
403 |
throw new GdalException("");
|
|
404 |
}
|
|
405 |
}
|
|
406 |
}
|
385 |
407 |
|
386 |
|
public RasterProvider load() {
|
387 |
|
return this;
|
388 |
|
}
|
|
408 |
public RasterProvider load() {
|
|
409 |
return this;
|
|
410 |
}
|
389 |
411 |
|
390 |
|
public boolean isOpen() {
|
391 |
|
if(file != null && file.isOpen())
|
392 |
|
return true;
|
393 |
|
return false;
|
394 |
|
}
|
|
412 |
public boolean isOpen() {
|
|
413 |
if (file != null && file.isOpen()) {
|
|
414 |
return true;
|
|
415 |
}
|
|
416 |
return false;
|
|
417 |
}
|
395 |
418 |
|
396 |
|
public URI translateURI(URI uri) {
|
|
419 |
public URI translateURI(URI uri) {
|
397 |
420 |
if ("hdr".equalsIgnoreCase(FilenameUtils.getExtension(uri.getPath()))) {
|
398 |
421 |
File file = new File(FilenameUtils.removeExtension(uri.getPath()));
|
399 |
422 |
return file.toURI();
|
400 |
423 |
}
|
401 |
|
return uri;
|
402 |
|
}
|
|
424 |
return uri;
|
|
425 |
}
|
403 |
426 |
|
404 |
|
/**
|
405 |
|
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n
|
406 |
|
* de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v)
|
407 |
|
* ha de estar en coordenadas del fichero.
|
|
427 |
/**
|
|
428 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer
|
|
429 |
* una transformaci?n de la vista asignada ya que la petici?n viene en
|
|
430 |
* coordenadas del fichero .rmf y la vista (v) ha de estar en coordenadas
|
|
431 |
* del fichero.
|
|
432 |
*
|
408 |
433 |
* @param e
|
409 |
|
*/
|
410 |
|
public void setView(Extent e) {
|
411 |
|
viewRequest = new ExtentImpl(e);
|
412 |
|
}
|
|
434 |
*/
|
|
435 |
public void setView(Extent e) {
|
|
436 |
viewRequest = new ExtentImpl(e);
|
|
437 |
}
|
413 |
438 |
|
414 |
|
public Extent getView() {
|
415 |
|
return viewRequest;
|
416 |
|
}
|
|
439 |
public Extent getView() {
|
|
440 |
return viewRequest;
|
|
441 |
}
|
417 |
442 |
|
418 |
|
public double getWidth() {
|
419 |
|
return file.width;
|
420 |
|
}
|
|
443 |
public double getWidth() {
|
|
444 |
return file.width;
|
|
445 |
}
|
421 |
446 |
|
422 |
|
public double getHeight() {
|
423 |
|
return file.height;
|
424 |
|
}
|
|
447 |
public double getHeight() {
|
|
448 |
return file.height;
|
|
449 |
}
|
425 |
450 |
|
426 |
|
/**
|
427 |
|
* Read a line from the file
|
428 |
|
* @param line
|
429 |
|
* @param band
|
430 |
|
* @return
|
431 |
|
* @throws InvalidSetViewException
|
432 |
|
* @throws FileNotOpenException
|
433 |
|
* @throws RasterDriverException
|
434 |
|
* @Deprecated This operation is deprecated because is not useful and in the future
|
435 |
|
* it will not be maintained. The abstract operation has dissapear
|
436 |
|
*/
|
437 |
|
public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
438 |
|
if(line > this.getHeight() || band > this.getBandCount())
|
439 |
|
throw new InvalidSetViewException("Request out of grid");
|
|
451 |
/**
|
|
452 |
* Read a line from the file
|
|
453 |
*
|
|
454 |
* @param line
|
|
455 |
* @param band
|
|
456 |
* @return
|
|
457 |
* @throws InvalidSetViewException
|
|
458 |
* @throws FileNotOpenException
|
|
459 |
* @throws RasterDriverException
|
|
460 |
* @Deprecated This operation is deprecated because is not useful and in the
|
|
461 |
* future it will not be maintained. The abstract operation has dissapear
|
|
462 |
*/
|
|
463 |
public Object readCompleteLine(int line, int band) throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
|
464 |
if (line > this.getHeight() || band > this.getBandCount()) {
|
|
465 |
throw new InvalidSetViewException("Request out of grid");
|
|
466 |
}
|
440 |
467 |
|
441 |
|
try{
|
442 |
|
return file.readCompleteLine(line, band);
|
443 |
|
}catch(GdalException e){
|
444 |
|
throw new RasterDriverException("Error reading data from Gdal library");
|
445 |
|
}
|
446 |
|
}
|
|
468 |
try {
|
|
469 |
return file.readCompleteLine(line, band);
|
|
470 |
} catch (GdalException e) {
|
|
471 |
throw new RasterDriverException("Error reading data from Gdal library");
|
|
472 |
}
|
|
473 |
}
|
447 |
474 |
|
448 |
|
public Object readBlock(int pos, int blockHeight, double scale)
|
449 |
|
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
450 |
|
if(pos < 0)
|
451 |
|
throw new InvalidSetViewException("Request out of grid");
|
|
475 |
public Object readBlock(int pos, int blockHeight, double scale)
|
|
476 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
|
477 |
if (pos < 0) {
|
|
478 |
throw new InvalidSetViewException("Request out of grid");
|
|
479 |
}
|
452 |
480 |
|
453 |
|
if((pos + blockHeight) > getHeight())
|
454 |
|
blockHeight = Math.abs(((int)getHeight()) - pos);
|
455 |
|
try{
|
456 |
|
return file.readBlock(pos, blockHeight, scale);
|
457 |
|
}catch(GdalException e){
|
458 |
|
throw new RasterDriverException("Error reading data from Gdal library");
|
459 |
|
}
|
460 |
|
}
|
|
481 |
if ((pos + blockHeight) > getHeight()) {
|
|
482 |
blockHeight = Math.abs(((int) getHeight()) - pos);
|
|
483 |
}
|
|
484 |
try {
|
|
485 |
return file.readBlock(pos, blockHeight, scale);
|
|
486 |
} catch (GdalException e) {
|
|
487 |
throw new RasterDriverException("Error reading data from Gdal library");
|
|
488 |
}
|
|
489 |
}
|
461 |
490 |
|
462 |
|
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
463 |
|
if(file != null){
|
464 |
|
if(x < 0 || y < 0 || x >= file.width || y >= file.height)
|
465 |
|
throw new InvalidSetViewException("Request out of grid");
|
466 |
|
Object[] data = file.getData(x, y);
|
467 |
|
return data[band];
|
468 |
|
}
|
469 |
|
throw new FileNotOpenException("GdalNative not exist");
|
470 |
|
}
|
|
491 |
public Object getData(int x, int y, int band) throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
|
492 |
if (file != null) {
|
|
493 |
if (x < 0 || y < 0 || x >= file.width || y >= file.height) {
|
|
494 |
throw new InvalidSetViewException("Request out of grid");
|
|
495 |
}
|
|
496 |
Object[] data = file.getData(x, y);
|
|
497 |
return data[band];
|
|
498 |
}
|
|
499 |
throw new FileNotOpenException("GdalNative not exist");
|
|
500 |
}
|
471 |
501 |
|
472 |
|
@Override
|
473 |
|
public void loadBuffer(SpiRasterQuery q)
|
474 |
|
throws ProcessInterruptedException, RasterDriverException {
|
475 |
|
setView(q.getAdjustedRequestBoundingBox());
|
|
502 |
@Override
|
|
503 |
public void loadBuffer(SpiRasterQuery q)
|
|
504 |
throws ProcessInterruptedException, RasterDriverException {
|
|
505 |
setView(q.getAdjustedRequestBoundingBox());
|
476 |
506 |
|
477 |
|
try {
|
478 |
|
file.readWindow(q.getBufferForProviders(),
|
479 |
|
q.getBandList(),
|
480 |
|
q.getAdjustedRequestBoundingBox(),
|
481 |
|
q.getAdjustedRequestPxWindow(),
|
482 |
|
q.getTaskStatus());
|
483 |
|
} catch (GdalException e) {
|
484 |
|
throw new RasterDriverException("Error reading data", e);
|
485 |
|
}
|
|
507 |
try {
|
|
508 |
file.readWindow(q.getBufferForProviders(),
|
|
509 |
q.getBandList(),
|
|
510 |
q.getAdjustedRequestBoundingBox(),
|
|
511 |
q.getAdjustedRequestPxWindow(),
|
|
512 |
q.getTaskStatus());
|
|
513 |
} catch (GdalException e) {
|
|
514 |
throw new RasterDriverException("Error reading data", e);
|
|
515 |
}
|
486 |
516 |
|
487 |
|
}
|
|
517 |
}
|
488 |
518 |
|
489 |
|
public int getBlockSize(){
|
490 |
|
if(file != null)
|
491 |
|
return file.getBlockSize();
|
492 |
|
else
|
493 |
|
return 0;
|
494 |
|
}
|
|
519 |
public int getBlockSize() {
|
|
520 |
if (file != null) {
|
|
521 |
return file.getBlockSize();
|
|
522 |
} else {
|
|
523 |
return 0;
|
|
524 |
}
|
|
525 |
}
|
495 |
526 |
|
496 |
|
public DataStoreMetadata getMetadata() {
|
497 |
|
if(file != null)
|
498 |
|
return file.metadata;
|
499 |
|
else
|
500 |
|
return null;
|
501 |
|
}
|
|
527 |
public DataStoreMetadata getMetadata() {
|
|
528 |
if (file != null) {
|
|
529 |
return file.metadata;
|
|
530 |
} else {
|
|
531 |
return null;
|
|
532 |
}
|
|
533 |
}
|
502 |
534 |
|
503 |
|
public Transparency getTransparency() {
|
504 |
|
return file.fileTransparency;
|
505 |
|
}
|
|
535 |
public Transparency getTransparency() {
|
|
536 |
return file.fileTransparency;
|
|
537 |
}
|
506 |
538 |
|
507 |
|
public boolean isGeoreferenced() {
|
508 |
|
if(file != null)
|
509 |
|
return file.georeferenced;
|
510 |
|
else
|
511 |
|
return false;
|
512 |
|
}
|
|
539 |
public boolean isGeoreferenced() {
|
|
540 |
if (file != null) {
|
|
541 |
return file.georeferenced;
|
|
542 |
} else {
|
|
543 |
return false;
|
|
544 |
}
|
|
545 |
}
|
513 |
546 |
|
514 |
|
/**
|
515 |
|
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar?
|
516 |
|
* el valor de esta variable cada vez que dibuja.
|
517 |
|
* @return true si se ha supersampleado y false si no se ha hecho.
|
518 |
|
*/
|
519 |
|
public boolean isSupersampling() {
|
520 |
|
if(file != null)
|
521 |
|
return file.isSupersampling;
|
522 |
|
else
|
523 |
|
return false;
|
524 |
|
}
|
|
547 |
/**
|
|
548 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el
|
|
549 |
* driver el que colocar? el valor de esta variable cada vez que dibuja.
|
|
550 |
*
|
|
551 |
* @return true si se ha supersampleado y false si no se ha hecho.
|
|
552 |
*/
|
|
553 |
public boolean isSupersampling() {
|
|
554 |
if (file != null) {
|
|
555 |
return file.isSupersampling;
|
|
556 |
} else {
|
|
557 |
return false;
|
|
558 |
}
|
|
559 |
}
|
525 |
560 |
|
526 |
|
protected GdalDataSource getNative(){
|
527 |
|
return file;
|
528 |
|
}
|
|
561 |
protected GdalDataSource getNative() {
|
|
562 |
return file;
|
|
563 |
}
|
529 |
564 |
|
530 |
|
public void setAffineTransform(AffineTransform t){
|
531 |
|
super.setAffineTransform(t);
|
532 |
|
file.setExternalTransform(t);
|
533 |
|
}
|
|
565 |
public void setAffineTransform(AffineTransform t) {
|
|
566 |
super.setAffineTransform(t);
|
|
567 |
file.setExternalTransform(t);
|
|
568 |
}
|
534 |
569 |
|
535 |
|
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException {
|
536 |
|
if(band >= getBandCount())
|
537 |
|
throw new BandAccessException("Wrong band");
|
538 |
|
try {
|
539 |
|
return file.getRasterBand(band + 1).getOverviewCount();
|
540 |
|
} catch (GdalException e) {
|
541 |
|
throw new RasterDriverException("");
|
542 |
|
}
|
543 |
|
}
|
|
570 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException {
|
|
571 |
if (band >= getBandCount()) {
|
|
572 |
throw new BandAccessException("Wrong band");
|
|
573 |
}
|
|
574 |
try {
|
|
575 |
return file.getRasterBand(band + 1).getOverviewCount();
|
|
576 |
} catch (GdalException e) {
|
|
577 |
throw new RasterDriverException("");
|
|
578 |
}
|
|
579 |
}
|
544 |
580 |
|
545 |
|
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException {
|
546 |
|
if (band >= getBandCount())
|
547 |
|
throw new BandAccessException("Wrong band");
|
548 |
|
try {
|
549 |
|
if (overview >= file.getRasterBand(band + 1).getOverviewCount())
|
550 |
|
throw new BandAccessException("Wrong overview count");
|
551 |
|
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandXSize();
|
552 |
|
} catch (GdalException e) {
|
553 |
|
throw new RasterDriverException("");
|
554 |
|
}
|
555 |
|
}
|
|
581 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException {
|
|
582 |
if (band >= getBandCount()) {
|
|
583 |
throw new BandAccessException("Wrong band");
|
|
584 |
}
|
|
585 |
try {
|
|
586 |
if (overview >= file.getRasterBand(band + 1).getOverviewCount()) {
|
|
587 |
throw new BandAccessException("Wrong overview count");
|
|
588 |
}
|
|
589 |
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandXSize();
|
|
590 |
} catch (GdalException e) {
|
|
591 |
throw new RasterDriverException("");
|
|
592 |
}
|
|
593 |
}
|
556 |
594 |
|
557 |
|
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException {
|
558 |
|
if (band >= getBandCount())
|
559 |
|
throw new BandAccessException("Wrong band");
|
560 |
|
try {
|
561 |
|
if (overview >= file.getRasterBand(band + 1).getOverviewCount())
|
562 |
|
throw new BandAccessException("Wrong overview count");
|
563 |
|
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandYSize();
|
564 |
|
} catch (GdalException e) {
|
565 |
|
throw new RasterDriverException("");
|
566 |
|
}
|
567 |
|
}
|
|
595 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException {
|
|
596 |
if (band >= getBandCount()) {
|
|
597 |
throw new BandAccessException("Wrong band");
|
|
598 |
}
|
|
599 |
try {
|
|
600 |
if (overview >= file.getRasterBand(band + 1).getOverviewCount()) {
|
|
601 |
throw new BandAccessException("Wrong overview count");
|
|
602 |
}
|
|
603 |
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandYSize();
|
|
604 |
} catch (GdalException e) {
|
|
605 |
throw new RasterDriverException("");
|
|
606 |
}
|
|
607 |
}
|
568 |
608 |
|
569 |
|
public boolean isOverviewsSupported() {
|
570 |
|
return true;
|
571 |
|
}
|
|
609 |
public boolean isOverviewsSupported() {
|
|
610 |
return true;
|
|
611 |
}
|
572 |
612 |
|
573 |
|
public boolean isReproyectable() {
|
574 |
|
return true;
|
575 |
|
}
|
|
613 |
public boolean isReproyectable() {
|
|
614 |
return true;
|
|
615 |
}
|
576 |
616 |
|
577 |
|
public boolean needEnhanced() {
|
578 |
|
return (getDataType()[0] != Buffer.TYPE_BYTE);
|
|
617 |
public boolean needEnhanced() {
|
|
618 |
return (getDataType()[0] != Buffer.TYPE_BYTE);
|
579 |
619 |
//Desconozco pq raz?n estaba esta condici?n. Quiz?s haya que volver a a?adirla
|
580 |
|
//Eliminada 30/5/2013
|
581 |
|
//|| (getBandCount() == 1 && getDataType()[0] == Buffer.TYPE_BYTE));
|
582 |
|
}
|
|
620 |
//Eliminada 30/5/2013
|
|
621 |
//|| (getBandCount() == 1 && getDataType()[0] == Buffer.TYPE_BYTE));
|
|
622 |
}
|
583 |
623 |
|
584 |
|
public String getProviderName() {
|
585 |
|
return NAME;
|
586 |
|
}
|
|
624 |
public String getProviderName() {
|
|
625 |
return NAME;
|
|
626 |
}
|
587 |
627 |
|
588 |
|
public void setStatus(RasterProvider provider) {
|
589 |
|
if(provider instanceof GdalProvider) {
|
590 |
|
//Not implemented yet
|
591 |
|
}
|
592 |
|
}
|
|
628 |
public void setStatus(RasterProvider provider) {
|
|
629 |
if (provider instanceof GdalProvider) {
|
|
630 |
//Not implemented yet
|
|
631 |
}
|
|
632 |
}
|
593 |
633 |
|
594 |
|
public TileServer getTileServer() {
|
595 |
|
if(tileServer == null) {
|
596 |
|
DefaultRasterStore store = new DefaultRasterStore();
|
597 |
|
store.setProvider(this);
|
598 |
|
tileServer = new FileTileServer(store);
|
|
634 |
public TileServer getTileServer() {
|
|
635 |
if (tileServer == null) {
|
|
636 |
DefaultRasterStore store = new DefaultRasterStore();
|
|
637 |
store.setProvider(this);
|
|
638 |
tileServer = new FileTileServer(store);
|
599 |
639 |
// tileServer.setFileSuffix("rmf");
|
600 |
|
}
|
601 |
|
return tileServer;
|
602 |
|
}
|
|
640 |
}
|
|
641 |
return tileServer;
|
|
642 |
}
|
603 |
643 |
|
604 |
|
public void close() {
|
605 |
|
if(file != null){
|
606 |
|
file.dispose();
|
607 |
|
}
|
608 |
|
try {
|
609 |
|
finalize();
|
610 |
|
} catch (Throwable e) {
|
611 |
|
}
|
612 |
|
}
|
|
644 |
public void close() {
|
|
645 |
if (file != null) {
|
|
646 |
file.dispose();
|
|
647 |
}
|
|
648 |
try {
|
|
649 |
finalize();
|
|
650 |
} catch (Throwable e) {
|
|
651 |
}
|
|
652 |
}
|
613 |
653 |
|
614 |
|
protected void finalize() throws Throwable {
|
615 |
|
file = null;
|
616 |
|
viewRequest = null;
|
617 |
|
if(formatList != null) {
|
618 |
|
for (int i = 0; i < formatList.length; i++) {
|
619 |
|
formatList[i] = null;
|
620 |
|
}
|
621 |
|
formatList = null;
|
622 |
|
}
|
623 |
|
super.finalize();
|
624 |
|
}
|
|
654 |
protected void finalize() throws Throwable {
|
|
655 |
file = null;
|
|
656 |
viewRequest = null;
|
|
657 |
if (formatList != null) {
|
|
658 |
for (int i = 0; i < formatList.length; i++) {
|
|
659 |
formatList[i] = null;
|
|
660 |
}
|
|
661 |
formatList = null;
|
|
662 |
}
|
|
663 |
super.finalize();
|
|
664 |
}
|
625 |
665 |
|
626 |
666 |
public void addFile(File file) throws InvalidSourceException {
|
627 |
667 |
// Do nothing
|
... | ... | |
631 |
671 |
// Do nothing
|
632 |
672 |
}
|
633 |
673 |
|
634 |
|
private File getPrjFile(URI uri){
|
635 |
|
if("file".equalsIgnoreCase(uri.getScheme())){
|
636 |
|
String uriPath = uri.getPath();
|
637 |
|
String prjPath = FilenameUtils.removeExtension(uriPath)+".prj";
|
|
674 |
private File getPrjFile(URI uri) {
|
|
675 |
if ("file".equalsIgnoreCase(uri.getScheme())) {
|
|
676 |
String uriPath = new File(uri).getAbsolutePath();
|
|
677 |
String prjPath = FilenameUtils.removeExtension(uriPath) + ".prj";
|
638 |
678 |
return new File(prjPath);
|
639 |
679 |
}
|
640 |
680 |
return null;
|
641 |
|
};
|
|
681 |
}
|
642 |
682 |
|
643 |
|
private String loadPrj(File prjFile){
|
|
683 |
;
|
|
684 |
|
|
685 |
private String loadPrj(File prjFile) {
|
644 |
686 |
if (prjFile.exists()) {
|
645 |
687 |
try {
|
646 |
688 |
return FileUtils.readFileToString(prjFile);
|
... | ... | |
651 |
693 |
return null;
|
652 |
694 |
}
|
653 |
695 |
|
654 |
|
}
|
|
696 |
}
|