Revision 4180 org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/layer/FLyrWCS.java
FLyrWCS.java | ||
---|---|---|
50 | 50 |
import java.awt.geom.Rectangle2D; |
51 | 51 |
import java.awt.image.BufferedImage; |
52 | 52 |
import java.io.IOException; |
53 |
import java.net.URI; |
|
54 |
import java.net.URISyntaxException; |
|
53 | 55 |
import java.util.HashMap; |
54 | 56 |
import java.util.List; |
55 | 57 |
|
56 | 58 |
import javax.print.attribute.PrintRequestAttributeSet; |
57 | 59 |
|
58 | 60 |
import org.cresques.cts.IProjection; |
61 |
|
|
59 | 62 |
import org.gvsig.compat.net.ICancellable; |
60 | 63 |
import org.gvsig.fmap.dal.DALLocator; |
61 | 64 |
import org.gvsig.fmap.dal.DataManager; |
... | ... | |
107 | 110 |
import org.gvsig.tools.task.Cancellable; |
108 | 111 |
import org.gvsig.tools.task.SimpleTaskStatus; |
109 | 112 |
import org.gvsig.tools.task.TaskStatusManager; |
113 |
|
|
110 | 114 |
import org.slf4j.Logger; |
111 | 115 |
import org.slf4j.LoggerFactory; |
112 | 116 |
|
... | ... | |
188 | 192 |
this(); |
189 | 193 |
//Create the explorer and connect |
190 | 194 |
DataManager dataManager = DALLocator.getDataManager(); |
191 |
WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters)
|
|
195 |
WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters) |
|
192 | 196 |
dataManager.createServerExplorerParameters(WCSProvider.NAME); |
193 | 197 |
explorerParams.setHost((String)dataStoreParameters.getDynValue("uri")); |
194 |
WCSServerExplorer wmsServerExplorer =
|
|
198 |
WCSServerExplorer wmsServerExplorer = |
|
195 | 199 |
(WCSServerExplorer) dataManager.openServerExplorer(WCSProvider.NAME, explorerParams); |
196 | 200 |
wmsServerExplorer.connect(null); |
197 | 201 |
wmsServerExplorer.getCoverageList(); |
198 |
|
|
202 |
|
|
199 | 203 |
//Set the parameters |
200 | 204 |
setParameters((WCSDataParameters)dataStoreParameters); |
201 | 205 |
setExplorer(wmsServerExplorer); |
... | ... | |
211 | 215 |
} catch (ProviderNotRegisteredException e) { |
212 | 216 |
return null; |
213 | 217 |
} |
214 |
params.setURI(host); |
|
218 |
URI uriHost; |
|
219 |
try { |
|
220 |
uriHost = new URI(host); |
|
221 |
} catch (URISyntaxException e1) { |
|
222 |
throw new InitializeException(e1); |
|
223 |
} |
|
224 |
params.setURI(uriHost); |
|
215 | 225 |
params.setSRS(srs); |
216 | 226 |
|
217 | 227 |
try { |
... | ... | |
255 | 265 |
firstLoad = true; |
256 | 266 |
} |
257 | 267 |
|
258 |
callCount = 0;
|
|
268 |
callCount = 0; |
|
259 | 269 |
|
260 | 270 |
enableStopped(); |
261 |
|
|
271 |
|
|
262 | 272 |
if(recalcLevel) { |
263 | 273 |
double pixelSize = viewPort.getEnvelope().getLength(0) / (double)viewPort.getImageWidth(); |
264 | 274 |
zoomLevel = dataStore.getNearestLevel(pixelSize); |
... | ... | |
343 | 353 |
//Rectangle2D.intersect(vpExtent, bBox, extent); |
344 | 354 |
|
345 | 355 |
Extent ex = rManager.getDataStructFactory().createExtent( |
346 |
vp.getAdjustedEnvelope().getMinimum(0),
|
|
347 |
vp.getAdjustedEnvelope().getMaximum(1),
|
|
348 |
vp.getAdjustedEnvelope().getMaximum(0),
|
|
356 |
vp.getAdjustedEnvelope().getMinimum(0), |
|
357 |
vp.getAdjustedEnvelope().getMaximum(1), |
|
358 |
vp.getAdjustedEnvelope().getMaximum(0), |
|
349 | 359 |
vp.getAdjustedEnvelope().getMinimum(1)); |
350 | 360 |
ViewPortData vpData = rManager.getDataStructFactory().createViewPortData(vp.getProjection(), ex, sz ); |
351 | 361 |
vpData.setMat(vp.getAffineTransform()); |
352 | 362 |
vpData.setDPI((int)vp.getDPI()); |
353 |
|
|
363 |
|
|
354 | 364 |
try { |
355 | 365 |
getParameters().setExtent(bBox); |
356 | 366 |
getParameters().setWidth(wImg); |
... | ... | |
376 | 386 |
} catch (QueryException e) { |
377 | 387 |
throw new RemoteServiceException("Problems drawing this layer: " + e.getMessage(), e); |
378 | 388 |
} finally { |
379 |
taskStatus.terminate();
|
|
389 |
taskStatus.terminate(); |
|
380 | 390 |
} |
381 | 391 |
|
382 | 392 |
} catch (RemoteServiceException e) { |
... | ... | |
430 | 440 |
.getLength(0), env.getLength(1)); |
431 | 441 |
} |
432 | 442 |
|
433 |
|
|
443 |
|
|
434 | 444 |
/** |
435 | 445 |
* Gets the explorer |
436 | 446 |
* @return |
... | ... | |
445 | 455 |
} |
446 | 456 |
return null; |
447 | 457 |
} |
448 |
|
|
458 |
|
|
449 | 459 |
/** |
450 | 460 |
* Calcula el contenido del fichero de georreferenciaci?n de una imagen. |
451 | 461 |
* @param bBox Tama?o y posici?n de la imagen (en coordenadas de usuario) |
... | ... | |
575 | 585 |
public boolean isTiled() { |
576 | 586 |
return mustTileDraw; |
577 | 587 |
} |
578 |
|
|
588 |
|
|
579 | 589 |
public boolean isRemote() { |
580 | 590 |
return true; |
581 | 591 |
} |
... | ... | |
619 | 629 |
} |
620 | 630 |
return new DynObjectSetWCSInfo(fInfo, DynObjectSetWCSInfo.TYPE_TEXT); |
621 | 631 |
} |
622 |
|
|
632 |
|
|
623 | 633 |
@Override |
624 | 634 |
public String getFileFormat() { |
625 | 635 |
return "WCS"; |
... | ... | |
679 | 689 |
}*/ |
680 | 690 |
return getWCSParameters(getDataStore().getParameters()); |
681 | 691 |
} |
682 |
|
|
692 |
|
|
683 | 693 |
/** |
684 | 694 |
* Gets <code>WCSDataParameters</code> |
685 | 695 |
* @param parameters |
... | ... | |
690 | 700 |
if(parameters instanceof WCSDataParameters) { |
691 | 701 |
params = (WCSDataParameters) parameters; |
692 | 702 |
} |
693 |
|
|
703 |
|
|
694 | 704 |
if(parameters instanceof TileDataParameters) { |
695 | 705 |
DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
696 | 706 |
if(p instanceof WCSDataParameters) { |
... | ... | |
708 | 718 |
if(getDataStore() != null) |
709 | 719 |
getDataStore().setExplorer(explorer); |
710 | 720 |
} |
711 |
|
|
721 |
|
|
712 | 722 |
/** |
713 | 723 |
* Assigns the flag to delete this layer from the cache |
714 | 724 |
* @param selected |
... | ... | |
726 | 736 |
if(params instanceof TileDataParameters) { |
727 | 737 |
((TileDataParameters)params).deleteCache(deleteCache); |
728 | 738 |
} |
729 |
|
|
739 |
|
|
730 | 740 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
731 | 741 |
try { |
732 | 742 |
DataStore dStore = dataman.openStore(params.getDataStoreName(), params); |
... | ... | |
735 | 745 |
if(params instanceof WCSDataParameters) { |
736 | 746 |
this.setName((String)((WCSDataParameters)params).getURI()); |
737 | 747 |
} |
738 |
|
|
748 |
|
|
739 | 749 |
if(params instanceof TileDataParameters) { |
740 | 750 |
DataParameters p = ((TileDataParameters) params).getDataParameters(); |
741 | 751 |
if(p instanceof WCSDataParameters) { |
... | ... | |
750 | 760 |
throw new InitializeException(e); |
751 | 761 |
} |
752 | 762 |
} |
753 |
|
|
763 |
|
|
754 | 764 |
/*@Override |
755 | 765 |
public void loadFromState(PersistentState state) |
756 | 766 |
throws PersistenceException { |
757 | 767 |
String host = state.getString("host"); |
758 |
|
|
768 |
|
|
759 | 769 |
getParameters(); |
760 | 770 |
((WCSServerExplorerParameters)explorer.getParameters()).setHost(host); |
761 |
|
|
771 |
|
|
762 | 772 |
if(!explorer.isHostReachable()) { |
763 | 773 |
loadDataStore = false; |
764 | 774 |
super.loadFromState(state); |
765 | 775 |
return; |
766 | 776 |
} |
767 |
|
|
777 |
|
|
768 | 778 |
try { |
769 | 779 |
explorer.connect(new CancelTaskImpl()); |
770 | 780 |
explorer.getCoverageList(); |
... | ... | |
773 | 783 |
super.loadFromState(state); |
774 | 784 |
return; |
775 | 785 |
} |
776 |
|
|
786 |
|
|
777 | 787 |
loadDataStore = true; |
778 | 788 |
|
779 | 789 |
super.loadFromState(state); |
... | ... | |
795 | 805 |
state.set("host", getParameters().getURI()); |
796 | 806 |
state.set("name", getName()); |
797 | 807 |
}*/ |
798 |
|
|
808 |
|
|
799 | 809 |
/*public static void registerPersistent() { |
800 | 810 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
801 | 811 |
DynStruct definition = manager.getDefinition(PERSISTENT_NAME); |
... | ... | |
808 | 818 |
FLyrWCS.class, |
809 | 819 |
PERSISTENT_NAME, |
810 | 820 |
PERSISTENT_DESCRIPTION, |
811 |
null,
|
|
821 |
null, |
|
812 | 822 |
null |
813 | 823 |
); |
814 |
|
|
824 |
|
|
815 | 825 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, "FLyrDefault"); |
816 | 826 |
} |
817 | 827 |
|
... | ... | |
820 | 830 |
definition.addDynFieldString("host").setMandatory(false); |
821 | 831 |
definition.addDynFieldString("name").setMandatory(false); |
822 | 832 |
}*/ |
823 |
|
|
833 |
|
|
824 | 834 |
public static void registerPersistent() { |
825 | 835 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
826 | 836 |
DynStruct definition = manager.getDefinition("FLyrWCS_Persistent"); |
... | ... | |
833 | 843 |
FLyrWCS.class, |
834 | 844 |
"FLyrWCS_Persistent", |
835 | 845 |
"FLyrWCS Persistent Definition", |
836 |
null,
|
|
846 |
null, |
|
837 | 847 |
null |
838 | 848 |
); |
839 |
|
|
849 |
|
|
840 | 850 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, DefaultFLyrRaster.PERSISTENT_NAME); |
841 | 851 |
} |
842 | 852 |
|
Also available in: Unified diff