8 |
8 |
import java.io.File;
|
9 |
9 |
import java.io.IOException;
|
10 |
10 |
import java.net.URL;
|
|
11 |
import java.util.ArrayList;
|
11 |
12 |
import java.util.Hashtable;
|
12 |
13 |
|
|
14 |
import org.apache.commons.lang3.StringUtils;
|
|
15 |
import org.cresques.cts.IProjection;
|
13 |
16 |
import org.gvsig.fmap.dal.DALLocator;
|
14 |
17 |
import org.gvsig.fmap.dal.DataStore;
|
15 |
18 |
import org.gvsig.fmap.dal.DataStoreParameters;
|
... | ... | |
63 |
66 |
public static String NAME = "Wcs Store";
|
64 |
67 |
public static String DESCRIPTION = "Wcs Raster file";
|
65 |
68 |
public static final String METADATA_DEFINITION_NAME = "WcsStore";
|
66 |
|
|
|
69 |
|
67 |
70 |
private Extent viewRequest = null;
|
68 |
71 |
private static Hashtable<URL, WCSConnector>
|
69 |
|
drivers = new Hashtable<URL, WCSConnector> ();
|
|
72 |
drivers = new Hashtable<URL, WCSConnector> ();
|
70 |
73 |
private boolean open = false;
|
71 |
74 |
private DataStoreTransparency fileTransparency = null;
|
72 |
75 |
private File lastRequest = null;
|
73 |
76 |
private AbstractRasterProvider lastRequestProvider = null;
|
74 |
|
|
|
77 |
|
75 |
78 |
public static void register() {
|
76 |
79 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
|
77 |
80 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
|
... | ... | |
84 |
87 |
}
|
85 |
88 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
|
86 |
89 |
}
|
87 |
|
|
|
90 |
|
88 |
91 |
public WCSProvider() throws NotSupportedExtensionException {
|
89 |
92 |
super();
|
90 |
93 |
}
|
91 |
|
|
|
94 |
|
92 |
95 |
/**
|
93 |
96 |
* Constructor. Abre el dataset.
|
94 |
97 |
* @param proj Proyecci?n
|
... | ... | |
107 |
110 |
init(p, null);
|
108 |
111 |
}
|
109 |
112 |
}
|
110 |
|
|
|
113 |
|
111 |
114 |
public WCSProvider(WCSDataParametersImpl params,
|
112 |
115 |
DataStoreProviderServices storeServices) throws InitializeException {
|
113 |
116 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
... | ... | |
116 |
119 |
DataStore.METADATA_DEFINITION_NAME)));
|
117 |
120 |
init(params, storeServices);
|
118 |
121 |
}
|
119 |
|
|
|
122 |
|
120 |
123 |
/**
|
121 |
124 |
* Gets the connector from the URL
|
122 |
125 |
* @return
|
... | ... | |
136 |
139 |
throw new RemoteServiceException("Error getting the connector",e);
|
137 |
140 |
}
|
138 |
141 |
}
|
139 |
|
|
|
142 |
|
140 |
143 |
/**
|
141 |
144 |
* Crea las referencias al fichero y carga
|
142 |
145 |
* las estructuras con la informaci?n y los metadatos.
|
... | ... | |
154 |
157 |
} catch (RasterDriverException e) {
|
155 |
158 |
throw new InitializeException(e.getMessage(), e);
|
156 |
159 |
}
|
157 |
|
|
|
160 |
|
158 |
161 |
stats = new RemoteDataStoreStatistics(this);
|
159 |
162 |
}
|
160 |
|
|
|
163 |
|
161 |
164 |
public static final WCSConnector getConnectorFromURL(URL url) throws IOException {
|
162 |
165 |
WCSConnector drv = (WCSConnector) drivers.get(url);
|
163 |
166 |
if (drv == null) {
|
... | ... | |
166 |
169 |
}
|
167 |
170 |
return drv;
|
168 |
171 |
}
|
169 |
|
|
|
172 |
|
170 |
173 |
/**
|
171 |
174 |
* Obtiene el objeto que contiene que contiene la interpretaci?n de
|
172 |
175 |
* color por banda
|
... | ... | |
187 |
190 |
}
|
188 |
191 |
return super.getColorInterpretation();
|
189 |
192 |
}
|
190 |
|
|
|
193 |
|
191 |
194 |
/**
|
192 |
195 |
* Gets WCS parameters
|
193 |
196 |
* @return
|
... | ... | |
195 |
198 |
public WCSDataParameters getParameters() {
|
196 |
199 |
return (WCSDataParameters)parameters;
|
197 |
200 |
}
|
198 |
|
|
|
201 |
|
199 |
202 |
public AffineTransform getAffineTransform() {
|
200 |
203 |
Extent e = getExtent();
|
201 |
204 |
double resolutionX = e.width() / getWidth();
|
... | ... | |
210 |
213 |
externalTransformation = (AffineTransform) ownTransformation.clone();
|
211 |
214 |
return ownTransformation;
|
212 |
215 |
}
|
213 |
|
|
|
216 |
|
214 |
217 |
/**
|
215 |
218 |
* Calcula el extent en coordenadas del mundo real
|
216 |
219 |
* @return Extent
|
... | ... | |
218 |
221 |
public Extent getExtent() {
|
219 |
222 |
WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
|
220 |
223 |
try {
|
|
224 |
p.setFormat("image/tiff");
|
|
225 |
if(p.getSRSCode() == null){
|
|
226 |
WCSConnector connector = WCSProvider.getConnectorFromURL(new URL(p.getURI()));
|
|
227 |
ArrayList srs = connector.getSRSs(p.getCoverageName());
|
|
228 |
if(!srs.isEmpty() && !StringUtils.isBlank((String)srs.get(0))){
|
|
229 |
p.setSRSID((String) srs.get(0));
|
|
230 |
}else{
|
|
231 |
return null;
|
|
232 |
}
|
|
233 |
}
|
221 |
234 |
Rectangle2D r = getConnector().getFullExtent(p.getCoverageName(), p.getSRSCode());
|
222 |
235 |
if(r == null)
|
223 |
236 |
return null;
|
... | ... | |
237 |
250 |
public RasterProvider load() {
|
238 |
251 |
return this;
|
239 |
252 |
}
|
240 |
|
|
|
253 |
|
241 |
254 |
public boolean isOpen() {
|
242 |
255 |
return open;
|
243 |
256 |
}
|
... | ... | |
245 |
258 |
public void close() {
|
246 |
259 |
open = false;
|
247 |
260 |
}
|
248 |
|
|
|
261 |
|
249 |
262 |
public Transparency getTransparency() {
|
250 |
263 |
if(fileTransparency == null)
|
251 |
264 |
fileTransparency = new DataStoreTransparency(getColorInterpretation());
|
... | ... | |
263 |
276 |
public Extent getView() {
|
264 |
277 |
return viewRequest;
|
265 |
278 |
}
|
266 |
|
|
|
279 |
|
267 |
280 |
public double getWidth() {
|
268 |
281 |
WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
|
269 |
282 |
try {
|
... | ... | |
285 |
298 |
}
|
286 |
299 |
|
287 |
300 |
public Object readCompleteLine(int line, int band)
|
288 |
|
throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
|
301 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
289 |
302 |
return null;
|
290 |
303 |
}
|
291 |
|
|
|
304 |
|
292 |
305 |
/**
|
293 |
306 |
* When the remote layer has fixed size this method downloads the file and return its reference.
|
294 |
307 |
* File layer has in the long side FIXED_SIZE pixels and the bounding box is complete. This file could be
|
... | ... | |
300 |
313 |
Extent e = getExtent();
|
301 |
314 |
Rectangle2D bBox = new Rectangle2D.Double(e.getULX(), e.getLRY(), e.width(), e.height());
|
302 |
315 |
WCSStatus wcsStatus = loadWCSStatus(bBox);
|
303 |
|
|
|
316 |
|
304 |
317 |
return downloadFile(wcsStatus, e, (int)getWidth(), (int)getHeight());
|
305 |
318 |
}
|
306 |
319 |
|
... | ... | |
318 |
331 |
* @throws RasterDriverException
|
319 |
332 |
*/
|
320 |
333 |
public Object readBlock(int pos, int blockHeight, double scale)
|
321 |
|
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
|
334 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
322 |
335 |
File lastFile = getFileLayer();
|
323 |
336 |
BandList bandList = new BandListImpl();
|
324 |
337 |
for (int i = 0; i < 3; i++) {
|
... | ... | |
338 |
351 |
throw new RasterDriverException("Error building GdalDriver", exc);
|
339 |
352 |
}
|
340 |
353 |
}
|
341 |
|
|
|
354 |
|
342 |
355 |
public double getLastRequestHeight() throws RasterDriverException {
|
343 |
356 |
if(lastRequestProvider == null) {
|
344 |
357 |
try {
|
... | ... | |
351 |
364 |
}
|
352 |
365 |
return lastRequestProvider.getHeight();
|
353 |
366 |
}
|
354 |
|
|
|
367 |
|
355 |
368 |
public double getLastRequestWidth() throws RasterDriverException {
|
356 |
369 |
if(lastRequestProvider == null) {
|
357 |
370 |
try {
|
... | ... | |
364 |
377 |
}
|
365 |
378 |
return lastRequestProvider.getWidth();
|
366 |
379 |
}
|
367 |
|
|
|
380 |
|
368 |
381 |
public File getLastRequest() {
|
369 |
382 |
return lastRequest;
|
370 |
383 |
}
|
371 |
|
|
|
384 |
|
372 |
385 |
public Buffer getBufferLastRequest() throws ProcessInterruptedException, RasterDriverException {
|
373 |
386 |
try {
|
374 |
387 |
lastRequestProvider = openLastRequest();
|
375 |
|
|
|
388 |
|
376 |
389 |
/*BandList bandList = new BandListImpl();
|
377 |
390 |
for (int i = 0; i < lastRequestProvider.getBandCount(); i++) {
|
378 |
391 |
try {
|
... | ... | |
381 |
394 |
}
|
382 |
395 |
}
|
383 |
396 |
bandList.setDrawableBands(new int[]{0, 1, 2});*/
|
384 |
|
|
|
397 |
|
385 |
398 |
RasterQuery q = RasterLocator.getManager().createQuery();
|
386 |
399 |
q.setAreaOfInterest(lastRequestProvider.getExtent(),
|
387 |
400 |
(int)lastRequestProvider.getWidth(),
|
388 |
401 |
(int)lastRequestProvider.getHeight());
|
389 |
402 |
q.setAllDrawableBands();
|
390 |
403 |
q.setAdjustToExtent(true);
|
391 |
|
|
|
404 |
|
392 |
405 |
DefaultRasterStore store = new DefaultRasterStore();
|
393 |
406 |
store.setProvider(lastRequestProvider);
|
394 |
407 |
return store.query(q);
|
... | ... | |
400 |
413 |
throw new RasterDriverException("Error reading data", e);
|
401 |
414 |
}
|
402 |
415 |
}
|
403 |
|
|
|
416 |
|
404 |
417 |
/**
|
405 |
418 |
* Opens the last request downloaded
|
406 |
419 |
* @return
|
... | ... | |
417 |
430 |
}
|
418 |
431 |
|
419 |
432 |
public Object getData(int x, int y, int band)
|
420 |
|
throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
|
433 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
421 |
434 |
int w = 25;
|
422 |
435 |
int h = 25;
|
423 |
|
|
|
436 |
|
424 |
437 |
Point2D p1 = rasterToWorld(new Point2D.Double(x, y));
|
425 |
438 |
Point2D p2 = rasterToWorld(new Point2D.Double(x + w, y + h));
|
426 |
439 |
Rectangle2D bBox = new Rectangle2D.Double(p1.getX(), p1.getY(), Math.abs(p1.getX() - p2.getX()), Math.abs(p1.getY() - p2.getY()));
|
427 |
|
|
|
440 |
|
428 |
441 |
WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
|
429 |
442 |
WCSStatus wcsStatus = new WCSStatus();
|
430 |
443 |
wcsStatus.setCoveraName(p.getCoverageName());
|
... | ... | |
437 |
450 |
wcsStatus.setDepth(p.getDepth());
|
438 |
451 |
wcsStatus.setParameters(p.getParameter());
|
439 |
452 |
wcsStatus.setTime(p.getTime());
|
440 |
|
|
|
453 |
|
441 |
454 |
lastRequest = downloadFile(wcsStatus, p1.getX(), p1.getY(), p2.getX(), p2.getY(), w, h);
|
442 |
|
|
|
455 |
|
443 |
456 |
AbstractRasterProvider driver = null;
|
444 |
457 |
try {
|
445 |
458 |
driver = DefaultProviderServices.loadProvider(new File(lastRequest.getPath()));
|
... | ... | |
454 |
467 |
}
|
455 |
468 |
}
|
456 |
469 |
bandList.setDrawableBands(drawable);*/
|
457 |
|
|
|
470 |
|
458 |
471 |
RasterQuery q = RasterLocator.getManager().createQuery();
|
459 |
472 |
Rectangle r = new Rectangle(0, 0, 25, 25);
|
460 |
473 |
q.setAreaOfInterest(r);
|
461 |
474 |
q.setAllDrawableBands();
|
462 |
475 |
DefaultRasterStore store = new DefaultRasterStore();
|
463 |
476 |
store.setProvider(driver);
|
464 |
|
|
|
477 |
|
465 |
478 |
Buffer buf = store.query(q);
|
466 |
479 |
driver.close();
|
467 |
480 |
if(buf.getDataType() == Buffer.TYPE_BYTE) {
|
... | ... | |
489 |
502 |
}
|
490 |
503 |
return null;
|
491 |
504 |
}
|
492 |
|
|
|
505 |
|
493 |
506 |
/**
|
494 |
507 |
* Gets the georeferencing file name form a raster file
|
495 |
508 |
* @param file
|
... | ... | |
507 |
520 |
}
|
508 |
521 |
return worldFile;
|
509 |
522 |
}
|
510 |
|
|
|
523 |
|
511 |
524 |
/**
|
512 |
525 |
* Obtiene la extensi?n del fichero de georreferenciaci?n
|
513 |
526 |
* @return String con la extensi?n del fichero de georreferenciaci?n dependiendo
|
... | ... | |
521 |
534 |
}
|
522 |
535 |
return extWorldFile;
|
523 |
536 |
}
|
524 |
|
|
|
537 |
|
525 |
538 |
private WCSStatus loadWCSStatus(Rectangle2D bBox) {
|
526 |
539 |
WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
|
527 |
540 |
WCSStatus wcsStatus = new WCSStatus();
|
... | ... | |
537 |
550 |
wcsStatus.setTime(p.getTime());
|
538 |
551 |
return wcsStatus;
|
539 |
552 |
}
|
540 |
|
|
|
553 |
|
541 |
554 |
public boolean needEnhanced() {
|
542 |
555 |
return (getDataType()[0] != Buffer.TYPE_BYTE ||
|
543 |
556 |
(getBandCount() == 1 && getDataType()[0] == Buffer.TYPE_BYTE));
|
544 |
557 |
}
|
545 |
|
|
|
558 |
|
546 |
559 |
/**
|
547 |
560 |
* This function downloads the file and creates the georeferencing file
|
548 |
561 |
* @param wcsStatus
|
... | ... | |
559 |
572 |
Extent extent = new ExtentImpl(ulx, uly, lrx, lry);
|
560 |
573 |
return downloadFile(wcsStatus, extent, w, h);
|
561 |
574 |
}
|
562 |
|
|
|
575 |
|
563 |
576 |
/**
|
564 |
577 |
* This function downloads the file and creates the georeferencing file
|
565 |
578 |
* @param wcsStatus
|
... | ... | |
578 |
591 |
} catch (RemoteServiceException e) {
|
579 |
592 |
throw new RasterDriverException(e.getMessage(), e);
|
580 |
593 |
}
|
581 |
|
|
|
594 |
|
582 |
595 |
String nameWorldFile = getWorldFile(lastRequest.getPath());
|
583 |
596 |
try {
|
584 |
597 |
fileUtil.createWorldFile(nameWorldFile, extent, w, h);
|
... | ... | |
588 |
601 |
|
589 |
602 |
return lastRequest;
|
590 |
603 |
}
|
591 |
|
|
|
604 |
|
592 |
605 |
/**
|
593 |
606 |
* Assigns the list of bands RGB and read a window of data
|
594 |
607 |
* @param rasterBuf
|
... | ... | |
610 |
623 |
for (int i = 0; i < bandList.getBandCount(); i++) {
|
611 |
624 |
bandList.getBand(i).setFileName(lastFile.getPath());
|
612 |
625 |
}*/
|
613 |
|
|
|
626 |
|
614 |
627 |
AbstractRasterProvider driver = DefaultProviderServices.loadProvider(new File(lastFile.getPath()));
|
615 |
|
|
|
628 |
|
616 |
629 |
RasterQuery q = RasterLocator.getManager().createQuery();
|
617 |
630 |
q.setAreaOfInterest(new ExtentImpl(ulx, uly, lrx, lry));
|
618 |
631 |
q.setDrawableBands(bandList.getDrawableBands());
|
619 |
632 |
DefaultRasterStore store = new DefaultRasterStore();
|
620 |
633 |
store.setProvider(driver);
|
621 |
634 |
Buffer buf = store.query(q);
|
622 |
|
|
|
635 |
|
623 |
636 |
/*for (int i = 0; i < bandList.getBandCount(); i++) {
|
624 |
637 |
bandList.getBand(i).setFileName(serverName);
|
625 |
638 |
}*/
|
626 |
|
|
|
639 |
|
627 |
640 |
return buf;
|
628 |
641 |
} catch (ProviderNotRegisteredException e) {
|
629 |
642 |
throw new RasterDriverException("Error building GdalDriver", e);
|
... | ... | |
633 |
646 |
throw new RasterDriverException("Error reading data", e);
|
634 |
647 |
}
|
635 |
648 |
}
|
636 |
|
|
|
649 |
|
637 |
650 |
@Override
|
638 |
651 |
public void loadBuffer(SpiRasterQuery query)
|
639 |
652 |
throws ProcessInterruptedException, RasterDriverException {
|
640 |
653 |
Extent ex = query.getAdjustedRequestBoundingBox();
|
641 |
654 |
WCSStatus wcsStatus = loadWCSStatus(ex.toRectangle2D());
|
642 |
|
|
|
655 |
|
643 |
656 |
lastRequest = downloadFile(
|
644 |
657 |
wcsStatus,
|
645 |
658 |
ex,
|
646 |
659 |
query.getAdjustedBufWidth(),
|
647 |
660 |
query.getAdjustedBufHeight());
|
648 |
|
|
|
661 |
|
649 |
662 |
if (lastRequest == null) {
|
650 |
663 |
return;
|
651 |
664 |
}
|
652 |
|
|
|
665 |
|
653 |
666 |
try {
|
654 |
667 |
AbstractRasterProvider driver = DefaultProviderServices.loadProvider(new File(lastRequest.getPath()));
|
655 |
668 |
DefaultRasterStore store = new DefaultRasterStore();
|
... | ... | |
663 |
676 |
} catch (QueryException e) {
|
664 |
677 |
throw new RasterDriverException("Error reading data", e);
|
665 |
678 |
}
|
666 |
|
|
|
679 |
|
667 |
680 |
}
|
668 |
|
|
|
681 |
|
669 |
682 |
/**
|
670 |
683 |
* When a WCS provider is opened the information of data type and number of bands is not
|
671 |
684 |
* available. Only after the first time a raster has been downloaded it can be know.
|
... | ... | |
678 |
691 |
private void loadInitialInfo() throws RasterDriverException {
|
679 |
692 |
WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
|
680 |
693 |
Extent ext = getExtent();
|
681 |
|
Rectangle2D bBox = ext.toRectangle2D();
|
682 |
|
int w = 0;
|
683 |
|
int h = 0;
|
684 |
|
if(ext.width() > ext.height()) {
|
685 |
|
w = 200;
|
686 |
|
h = (int)((ext.height() * w) / ext.width());
|
687 |
|
} else {
|
688 |
|
h = 200;
|
689 |
|
w = (int)((ext.width() * h) / ext.height());
|
|
694 |
if(ext != null){
|
|
695 |
Rectangle2D bBox = ext.toRectangle2D();
|
|
696 |
int w = 0;
|
|
697 |
int h = 0;
|
|
698 |
if(ext.width() > ext.height()) {
|
|
699 |
w = 200;
|
|
700 |
h = (int)((ext.height() * w) / ext.width());
|
|
701 |
} else {
|
|
702 |
h = 200;
|
|
703 |
w = (int)((ext.width() * h) / ext.height());
|
|
704 |
}
|
|
705 |
p.setWidth(w);
|
|
706 |
p.setHeight(h);
|
|
707 |
p.setExtent(bBox);
|
|
708 |
WCSStatus wcsStatus = loadWCSStatus(bBox);
|
|
709 |
|
|
710 |
lastRequest = downloadFile(wcsStatus, ext.getULX(), ext.getULY(), ext.getLRX(), ext.getLRY(), w, h);
|
|
711 |
AbstractRasterProvider driver;
|
|
712 |
try {
|
|
713 |
driver = DefaultProviderServices.loadProvider(lastRequest);
|
|
714 |
setDataType(driver.getDataType());
|
|
715 |
bandCount = driver.getBandCount();
|
|
716 |
driver.close();
|
|
717 |
} catch (ProviderNotRegisteredException e) {
|
|
718 |
throw new RasterDriverException("", e);
|
|
719 |
} catch (InitializeException e) {
|
|
720 |
throw new RasterDriverException("", e);
|
|
721 |
}
|
690 |
722 |
}
|
691 |
|
p.setWidth(w);
|
692 |
|
p.setHeight(h);
|
693 |
|
p.setExtent(bBox);
|
694 |
|
WCSStatus wcsStatus = loadWCSStatus(bBox);
|
695 |
|
|
696 |
|
lastRequest = downloadFile(wcsStatus, ext.getULX(), ext.getULY(), ext.getLRX(), ext.getLRY(), w, h);
|
697 |
|
AbstractRasterProvider driver;
|
698 |
|
try {
|
699 |
|
driver = DefaultProviderServices.loadProvider(lastRequest);
|
700 |
|
setDataType(driver.getDataType());
|
701 |
|
bandCount = driver.getBandCount();
|
702 |
|
driver.close();
|
703 |
|
} catch (ProviderNotRegisteredException e) {
|
704 |
|
throw new RasterDriverException("", e);
|
705 |
|
} catch (InitializeException e) {
|
706 |
|
throw new RasterDriverException("", e);
|
707 |
|
}
|
708 |
723 |
}
|
709 |
|
|
|
724 |
|
710 |
725 |
/**
|
711 |
726 |
* When a WCS provider is opened the information of data type and number of bands is not
|
712 |
727 |
* available. Only after the first time a raster has been downloaded it can be know.
|
... | ... | |
722 |
737 |
buf.free();
|
723 |
738 |
} else
|
724 |
739 |
return buf;
|
725 |
|
|
|
740 |
|
726 |
741 |
bandList.clear();
|
727 |
742 |
for(int i = 0; i < getBandCount(); i++)
|
728 |
743 |
try {
|
... | ... | |
741 |
756 |
Point2D p2 = rasterToWorld(new Point2D.Double(x + w, y + h));
|
742 |
757 |
Rectangle2D bBox = new Rectangle2D.Double(p1.getX(), p1.getY(), Math.abs(p1.getX() - p2.getX()), Math.abs(p1.getY() - p2.getY()));
|
743 |
758 |
WCSStatus wcsStatus = loadWCSStatus(bBox);
|
744 |
|
|
|
759 |
|
745 |
760 |
lastRequest = downloadFile(wcsStatus, p1.getX(), p1.getY(), p2.getX(), p2.getY(), rasterBuf.getWidth(), rasterBuf.getHeight());
|
746 |
|
|
|
761 |
|
747 |
762 |
if (lastRequest == null) {
|
748 |
763 |
return rasterBuf;
|
749 |
764 |
}
|
... | ... | |
751 |
766 |
AbstractRasterProvider driver = null;
|
752 |
767 |
try {
|
753 |
768 |
driver = DefaultProviderServices.loadProvider(new File(lastRequest.getPath()));
|
754 |
|
|
|
769 |
|
755 |
770 |
//El nombre de fichero que ha puesto en el bandList es el del servidor y no el del fichero en disco
|
756 |
771 |
String serverName = bandList.getBand(0).getFileName();
|
757 |
772 |
for (int i = 0; i < bandList.getBandCount(); i++) {
|
758 |
773 |
bandList.getBand(i).setFileName(lastRequest.getPath());
|
759 |
774 |
}
|
760 |
|
|
|
775 |
|
761 |
776 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
|
762 |
777 |
q.setAreaOfInterest(0, 0, w, h);
|
763 |
778 |
q.setBandList(bandList);
|
... | ... | |
781 |
796 |
}
|
782 |
797 |
|
783 |
798 |
public void setAffineTransform(AffineTransform t){
|
784 |
|
|
|
799 |
|
785 |
800 |
}
|
786 |
801 |
|
787 |
802 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException {
|
... | ... | |
808 |
823 |
return NAME;
|
809 |
824 |
}
|
810 |
825 |
|
811 |
|
public String getName() {
|
812 |
|
return this.getParameters().getCoverageName();
|
813 |
|
}
|
|
826 |
public String getName() {
|
|
827 |
return this.getParameters().getCoverageName();
|
|
828 |
}
|
814 |
829 |
|
815 |
830 |
/**
|
816 |
831 |
* Convierte un punto desde coordenadas pixel a coordenadas del mundo.
|
... | ... | |
837 |
852 |
}
|
838 |
853 |
return p;
|
839 |
854 |
}
|
840 |
|
|
|
855 |
|
841 |
856 |
public void setStatus(RasterProvider provider) {
|
842 |
857 |
if(provider instanceof WCSProvider) {
|
843 |
858 |
}
|
844 |
859 |
}
|
845 |
|
|
|
860 |
|
846 |
861 |
/**
|
847 |
862 |
* ASigna el par?metro de inicializaci?n del driver.
|
848 |
863 |
*/
|
... | ... | |
851 |
866 |
this.uri = ((WCSDataParametersImpl)param).getURI();
|
852 |
867 |
this.param = param;
|
853 |
868 |
}
|
854 |
|
|
|
869 |
|
855 |
870 |
/**
|
856 |
871 |
* Gets the suffix of the downloaded image
|
857 |
872 |
* @return
|
... | ... | |
863 |
878 |
return "xml";
|
864 |
879 |
}
|
865 |
880 |
if (format.indexOf("png") >= 0){
|
866 |
|
return "png";
|
|
881 |
return "png";
|
867 |
882 |
}
|
868 |
|
if (format.indexOf("xml") >= 0){
|
869 |
|
return "xml";
|
870 |
|
}
|
871 |
|
if (format.indexOf("gif") >= 0){
|
872 |
|
return "gif";
|
873 |
|
}
|
874 |
|
if (format.indexOf("tif") >= 0){
|
875 |
|
return "tif";
|
876 |
|
}
|
877 |
|
if (format.indexOf("bmp") >= 0){
|
878 |
|
return "bmp";
|
879 |
|
}
|
880 |
|
if (format.indexOf("jpg") >= 0
|
881 |
|
|| format.indexOf("jpeg") >= 0){
|
882 |
|
return "jpg";
|
883 |
|
}
|
|
883 |
if (format.indexOf("xml") >= 0){
|
|
884 |
return "xml";
|
|
885 |
}
|
|
886 |
if (format.indexOf("gif") >= 0){
|
|
887 |
return "gif";
|
|
888 |
}
|
|
889 |
if (format.indexOf("tif") >= 0){
|
|
890 |
return "tif";
|
|
891 |
}
|
|
892 |
if (format.indexOf("bmp") >= 0){
|
|
893 |
return "bmp";
|
|
894 |
}
|
|
895 |
if (format.indexOf("jpg") >= 0
|
|
896 |
|| format.indexOf("jpeg") >= 0){
|
|
897 |
return "jpg";
|
|
898 |
}
|
884 |
899 |
return "xml";
|
885 |
900 |
}
|
886 |
|
|
|
901 |
|
887 |
902 |
public TileServer getTileServer() {
|
888 |
903 |
if(tileServer == null) {
|
889 |
904 |
DefaultRasterStore store = new DefaultRasterStore();
|
... | ... | |
892 |
907 |
}
|
893 |
908 |
return tileServer;
|
894 |
909 |
}
|
895 |
|
|
|
910 |
|
896 |
911 |
public boolean isRasterEnclosed() {
|
897 |
912 |
return true;
|
898 |
913 |
}
|
899 |
|
|
|
914 |
|
900 |
915 |
public String getRMFFile() {
|
901 |
916 |
if(lastRequest != null)
|
902 |
917 |
return fileUtil.getNameWithoutExtension(lastRequest.getAbsolutePath()) + ".rmf";
|
903 |
918 |
return null;
|
904 |
919 |
}
|
905 |
|
|
|
920 |
|
906 |
921 |
public HistogramComputer getHistogramComputer() {
|
907 |
922 |
if (histogram == null)
|
908 |
923 |
histogram = new RemoteStoreHistogram(this);
|