Revision 10626 trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/layers/FLyrWCS.java
FLyrWCS.java | ||
---|---|---|
73 | 73 |
import org.gvsig.remoteClient.wcs.WCSStatus; |
74 | 74 |
import org.gvsig.remoteClient.wms.ICancellable; |
75 | 75 |
|
76 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
76 | 77 |
import com.iver.andami.PluginServices; |
78 |
import com.iver.cit.gvsig.exceptions.layers.ConnectionErrorLayerException; |
|
79 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
|
80 |
import com.iver.cit.gvsig.exceptions.layers.UnsupportedVersionLayerException; |
|
81 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
77 | 82 |
import com.iver.cit.gvsig.fmap.ConnectionErrorExceptionType; |
78 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
79 | 83 |
import com.iver.cit.gvsig.fmap.UnknownResponseFormatExceptionType; |
80 | 84 |
import com.iver.cit.gvsig.fmap.UnsuportedProtocolVersionExceptionType; |
81 | 85 |
import com.iver.cit.gvsig.fmap.ViewPort; |
82 | 86 |
import com.iver.cit.gvsig.fmap.WCSDriverExceptionType; |
83 | 87 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
84 |
import com.iver.cit.gvsig.fmap.drivers.UnsupportedVersionException; |
|
85 | 88 |
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver; |
86 | 89 |
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriverFactory; |
87 |
import com.iver.cit.gvsig.fmap.drivers.wcs.WCSException; |
|
90 |
import com.iver.cit.gvsig.fmap.drivers.wcs.WCSDriverException;
|
|
88 | 91 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
89 | 92 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.StringXMLItem; |
90 | 93 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem; |
... | ... | |
429 | 432 |
* @deprecated |
430 | 433 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo |
431 | 434 |
*/ |
432 |
public String queryByPoint(Point p) throws DriverException { |
|
435 |
public String queryByPoint(Point p) throws ReadDriverException {
|
|
433 | 436 |
String data = "<file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n"; |
434 | 437 |
ArrayList attr = this.getAttributes(); |
435 | 438 |
data += " <raster\n"; |
... | ... | |
455 | 458 |
/** |
456 | 459 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo |
457 | 460 |
*/ |
458 |
public XMLItem[] getInfo(Point point, double tolerance, Cancellable cancel ) throws DriverException {
|
|
461 |
public XMLItem[] getInfo(Point point, double tolerance, Cancellable cancel ) throws ReadDriverException, VisitorException {
|
|
459 | 462 |
String data = "<file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n"; |
460 | 463 |
|
461 | 464 |
Point2D pReal = getMapContext().getViewPort().toMapPoint(point); |
... | ... | |
537 | 540 |
* (non-Javadoc) |
538 | 541 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable, double) |
539 | 542 |
*/ |
540 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws DriverException { |
|
543 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws ReadDriverException {
|
|
541 | 544 |
|
542 | 545 |
if (isWithinScale(scale)){ |
543 | 546 |
Point2D p = viewPort.getOffset(); |
... | ... | |
556 | 559 |
visualStatus.rasterMaxX = 0; |
557 | 560 |
visualStatus.rasterMaxY = 0; |
558 | 561 |
visualStatus.fileNames = new String[1]; |
559 |
|
|
562 |
try { |
|
560 | 563 |
if(mustTileDraw){ |
561 | 564 |
if(viewPort.getImageWidth()<= maxTileDrawWidth && viewPort.getImageHeight()<=maxTileDrawHeight) |
562 | 565 |
drawTile(g, viewPort, cancel, 0); |
... | ... | |
577 | 580 |
} |
578 | 581 |
}else |
579 | 582 |
drawTile(g, viewPort, cancel, 0); |
583 |
}catch (ConnectionErrorLayerException e) { |
|
584 |
e.printStackTrace(); |
|
585 |
}catch (UnsupportedVersionLayerException e) { |
|
586 |
e.printStackTrace(); |
|
587 |
}catch (LoadLayerException e) { |
|
588 |
e.printStackTrace(); |
|
589 |
} |
|
580 | 590 |
} |
581 | 591 |
Runtime r = Runtime.getRuntime(); |
582 | 592 |
long mem = r.totalMemory() - r.freeMemory(); |
... | ... | |
587 | 597 |
* This is the method used to draw a tile in a WMS mosaic layer. |
588 | 598 |
* @param tile Tile number to draw |
589 | 599 |
*/ |
590 |
private void drawTile(Graphics2D g, ViewPort vp, Cancellable cancel, int tile) throws DriverException {
|
|
600 |
private void drawTile(Graphics2D g, ViewPort vp, Cancellable cancel, int tile) throws LoadLayerException {
|
|
591 | 601 |
|
592 | 602 |
// Compute the query geometry |
593 | 603 |
// 1. Check if it is within borders |
... | ... | |
645 | 655 |
visualStatus.fileNames[tile] = f.getAbsolutePath(); |
646 | 656 |
rasterProcess(g, vpData, f); |
647 | 657 |
|
648 |
} catch (ValidationException e) { |
|
649 |
UnknownResponseFormatExceptionType type = |
|
650 |
new UnknownResponseFormatExceptionType(); |
|
651 |
type.setLayerName(getName()); |
|
652 |
try { |
|
653 |
type.setDriverName(getDriver().getName()); |
|
654 |
} catch (Exception e1) { |
|
655 |
e1.printStackTrace(); |
|
656 |
} |
|
657 |
type.setFormat(format); |
|
658 |
type.setHost(host); |
|
659 |
type.setProtocol("WCS"); |
|
660 |
DriverException exception = new DriverException("unknown_response_format", type);
|
|
661 |
throw exception; |
|
658 |
// } catch (ValidationException e) {
|
|
659 |
// UnknownResponseFormatExceptionType type =
|
|
660 |
// new UnknownResponseFormatExceptionType();
|
|
661 |
// type.setLayerName(getName());
|
|
662 |
// try {
|
|
663 |
// type.setDriverName(getDriver().getName());
|
|
664 |
// } catch (Exception e1) {
|
|
665 |
// e1.printStackTrace();
|
|
666 |
// }
|
|
667 |
// type.setFormat(format);
|
|
668 |
// type.setHost(host);
|
|
669 |
// type.setProtocol("WCS");
|
|
670 |
// ReadDriverException exception = new ReadDriverException("unknown_response_format",type);
|
|
671 |
// throw exception;
|
|
662 | 672 |
// azabala throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e); |
663 |
} |
|
664 |
catch (UnsupportedVersionException e) {
|
|
665 |
UnsuportedProtocolVersionExceptionType type = |
|
666 |
new UnsuportedProtocolVersionExceptionType(); |
|
667 |
type.setLayerName(getName()); |
|
668 |
try { |
|
669 |
type.setDriverName(getDriver().getName()); |
|
670 |
} catch (Exception ex){ |
|
671 |
} |
|
672 |
type.setUrl(host); |
|
673 |
throw new DriverException(PluginServices.getText(this, "version_conflict"), e, type);
|
|
673 |
// }
|
|
674 |
// catch (UnsupportedVersionLayerException e) {
|
|
675 |
// UnsuportedProtocolVersionExceptionType type =
|
|
676 |
// new UnsuportedProtocolVersionExceptionType();
|
|
677 |
// type.setLayerName(getName());
|
|
678 |
// try {
|
|
679 |
// type.setDriverName(getDriver().getName());
|
|
680 |
// } catch (Exception ex){
|
|
681 |
// }
|
|
682 |
// type.setUrl(host);
|
|
683 |
// throw new ReadDriverException(PluginServices.getText(this, "version_conflict"), e, type);
|
|
674 | 684 |
|
675 | 685 |
// azabala throw new DriverException(PluginServices.getText(this, "version_conflict"), e); |
676 | 686 |
} catch (IOException e) { |
677 |
ConnectionErrorExceptionType type = new ConnectionErrorExceptionType(); |
|
678 |
type.setLayerName(getName()); |
|
679 |
try { |
|
680 |
type.setDriverName(getDriver().getName()); |
|
681 |
} catch (Exception e1) { |
|
682 |
} |
|
683 |
type.setHost(host); |
|
684 |
throw new DriverException(PluginServices. |
|
685 |
getText(this, "connect_error"), e, type); |
|
686 |
} catch (WCSException e) { |
|
687 |
//azabala: la capturamos y la convertimos en DriverException |
|
688 |
WCSDriverExceptionType type = new WCSDriverExceptionType(); |
|
689 |
type.setLayerName(getName()); |
|
690 |
try { |
|
691 |
type.setDriverName(getDriver().getName()); |
|
692 |
} catch (Exception e1) { |
|
693 |
} |
|
694 |
type.setWcsStatus(wcsStatus); |
|
695 |
this.setVisible(false); |
|
696 |
throw new DriverException("Error WCS", e, type); |
|
697 |
|
|
698 |
// JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage()); |
|
699 |
|
|
700 |
}//catch |
|
687 |
// ConnectionErrorExceptionType type = new ConnectionErrorExceptionType(); |
|
688 |
// type.setLayerName(getName()); |
|
689 |
// try { |
|
690 |
// type.setDriverName(getDriver().getName()); |
|
691 |
// } catch (Exception e1) { |
|
692 |
// } |
|
693 |
// type.setHost(host); |
|
694 |
throw new ConnectionErrorLayerException(getName(),e); |
|
695 |
} |
|
696 |
// catch (WCSLayerException e) { |
|
697 |
////azabala: la capturamos y la convertimos en DriverException |
|
698 |
// WCSDriverExceptionType type = new WCSDriverExceptionType(); |
|
699 |
// type.setLayerName(getName()); |
|
700 |
// try { |
|
701 |
// type.setDriverName(getDriver().getName()); |
|
702 |
// } catch (Exception e1) { |
|
703 |
// } |
|
704 |
// type.setWcsStatus(wcsStatus); |
|
705 |
// this.setVisible(false); |
|
706 |
// throw new WDriverException("Error WCS", e, type); |
|
707 |
// |
|
708 |
//// JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage()); |
|
709 |
// |
|
710 |
// }// |
|
711 |
catch (WCSDriverException e) { |
|
712 |
throw new LoadLayerException(getName(),e); |
|
713 |
} catch (IllegalStateException e) { |
|
714 |
throw new LoadLayerException(getName(),e); |
|
715 |
} |
|
701 | 716 |
} |
702 | 717 |
|
703 | 718 |
/** |
... | ... | |
707 | 722 |
* |
708 | 723 |
* @throws IllegalStateException |
709 | 724 |
* @throws ValidationException |
710 |
* @throws UnsupportedVersionException |
|
725 |
* @throws UnsupportedVersionLayerException
|
|
711 | 726 |
* @throws IOException |
712 | 727 |
*/ |
713 |
private FMapWCSDriver getDriver() throws IllegalStateException, ValidationException, UnsupportedVersionException, IOException {
|
|
728 |
private FMapWCSDriver getDriver() throws IllegalStateException, IOException { |
|
714 | 729 |
if (wcs == null) { |
715 | 730 |
wcs = FMapWCSDriverFactory.getFMapDriverForURL(host); |
716 | 731 |
} |
... | ... | |
798 | 813 |
rasterFile.close(); |
799 | 814 |
} |
800 | 815 |
|
801 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws DriverException { |
|
816 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws ReadDriverException {
|
|
802 | 817 |
draw(null, g, viewPort, cancel, scale); |
803 | 818 |
} |
804 | 819 |
|
Also available in: Unified diff