Revision 9462 org.gvsig.online/trunk/org.gvsig.online/org.gvsig.online.swing/org.gvsig.online.swing.impl/src/main/java/org/gvsig/online/swing/impl/WMSUtils.java
WMSUtils.java | ||
---|---|---|
3 | 3 |
import java.net.URL; |
4 | 4 |
import org.gvsig.fmap.dal.DALLocator; |
5 | 5 |
import org.gvsig.fmap.dal.DataManager; |
6 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
6 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
7 |
import org.gvsig.fmap.dal.DataServerExplorer_v2; |
|
8 |
import org.gvsig.fmap.dal.DataStore; |
|
9 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
7 | 10 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
8 | 11 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
9 | 12 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
10 |
import org.gvsig.raster.wms.io.WMSDataParameters; |
|
11 |
import org.gvsig.raster.wms.io.WMSServerExplorer; |
|
12 |
import org.gvsig.raster.wms.io.WMSServerExplorerParameters; |
|
13 | 13 |
import org.slf4j.Logger; |
14 | 14 |
import org.slf4j.LoggerFactory; |
15 | 15 |
|
16 |
/* |
|
17 |
* To change this license header, choose License Headers in Project Properties. |
|
18 |
* To change this template file, choose Tools | Templates |
|
19 |
* and open the template in the editor. |
|
20 |
*/ |
|
21 |
|
|
22 | 16 |
/** |
23 | 17 |
* |
24 | 18 |
* @author jjdelcerro |
25 | 19 |
*/ |
26 | 20 |
@SuppressWarnings("UseSpecificCatch") |
27 | 21 |
public class WMSUtils { |
22 |
private static final String WMS_PROVIDER_NAME = "Wms Store"; |
|
23 |
|
|
24 |
private static final String FIELD_XYAXISORDER = "xyaxisorder"; |
|
25 |
private static final String FIELD_HOST = "host"; |
|
26 |
|
|
27 |
private static final String FIELD_FORMAT = "format"; |
|
28 |
private static final String FIELD_INFOFORMAT = "infoformat"; |
|
29 |
private static final String FIELD_LAYERQUERY = "layer_query"; |
|
30 |
private static final String FIELD_NAME = "name"; |
|
31 |
private static final String FIELD_SRSSTR = "srsstr"; |
|
32 |
private static final String FIELD_TRANSPARENCY = "transparency"; |
|
33 |
private static final String FIELD_INFOLAYERQUERY = "infolayerquery"; |
|
34 |
private static final String FIELD_QUERYABLE = "queryable"; |
|
35 |
private static final String FIELD_OVERRIDE = "override"; |
|
36 |
private static final String FIELD_STYLES = "styles"; |
|
37 |
private static final String FIELD_DIMENSIONS = "dimensions"; |
|
38 |
private static final String FIELD_ONLINERESOURC = "onlineresources"; |
|
39 |
private static final String FIELD_FIXEDSIZE = "fixedsize"; |
|
40 |
private static final String FIELD_EXTENT = "extent"; |
|
41 |
private static final String FIELD_WIDTH = "width"; |
|
42 |
private static final String FIELD_HEIGHT = "height"; |
|
43 |
private static final String FIELD_DELETECACHE = "deletecache"; |
|
44 |
private static final String FIELD_ASSUMEXYAXISORDER = "assumeXY"; |
|
28 | 45 |
|
29 | 46 |
private static final Logger LOGGER = LoggerFactory.getLogger(WMSUtils.class); |
30 | 47 |
|
31 | 48 |
public static FLayer createWMSLayer(String name, URL host, String layers, String srs) { |
32 |
// name = "Preview"; |
|
33 |
// layers = "jjdc_soportes,jjdc_placas,jjdc_manzanas,jjdc_aceras"; |
|
34 |
// srs = "EPSG:25830"; |
|
35 | 49 |
try { |
36 | 50 |
DataManager datamanager = DALLocator.getDataManager(); |
37 |
String providerName = WMSServerExplorer.NAME;
|
|
38 |
WMSServerExplorerParameters explorerParams = (WMSServerExplorerParameters) datamanager.createServerExplorerParameters(providerName);
|
|
39 |
explorerParams.setXyAxisOrder(false);
|
|
51 |
String providerName = WMS_PROVIDER_NAME;
|
|
52 |
DataServerExplorerParameters explorerParams = datamanager.createServerExplorerParameters(providerName);
|
|
53 |
explorerParams.setDynValue(FIELD_XYAXISORDER, false);
|
|
40 | 54 |
|
41 |
explorerParams.setHost(host.toString()); |
|
42 |
WMSServerExplorer explorer = (WMSServerExplorer) datamanager.openServerExplorer(providerName,explorerParams); |
|
43 |
explorer.connect(null); |
|
44 |
WMSDataParameters par = (WMSDataParameters)explorer.getStoredParameters(); |
|
55 |
explorerParams.setDynValue(FIELD_HOST, host.toString()); |
|
56 |
DataServerExplorer_v2 explorer = (DataServerExplorer_v2) datamanager.openServerExplorer(providerName,explorerParams); |
|
57 |
explorer.open(); |
|
45 | 58 |
|
46 |
par.setFormat("image/png"); |
|
47 |
par.setInfoFormat("text/plain"); |
|
48 |
par.setLayerQuery(layers); |
|
49 |
par.setInfoLayerQuery(null); //"jjdc_aceras,jjdc_manzanas,jjdc_placas,jjdc_soportes"); |
|
50 |
par.setSRS(srs); |
|
51 |
par.setWmsTransparency(true); |
|
52 |
par.setStyles(null); // ???? |
|
53 |
par.setDimensions(null); |
|
54 |
par.setOnlineResources(explorer.getOnlineResources()); |
|
55 |
par.setFixedSize(null); |
|
56 |
par.setQueryable(false); //explorer.isQueryable()); |
|
57 |
par.setName(name); |
|
58 |
par.setXyAxisOrder(false); |
|
59 |
DataStoreParameters par = explorer.get(layers); |
|
59 | 60 |
|
60 |
RasterDataStore store = (RasterDataStore) datamanager.openStore(providerName, par); |
|
61 |
store.setExplorer(explorer); |
|
61 |
par.setDynValue(FIELD_FORMAT, "image/png"); |
|
62 |
par.setDynValue(FIELD_INFOFORMAT, "text/plain"); |
|
63 |
par.setDynValue(FIELD_INFOLAYERQUERY, null); |
|
64 |
par.setDynValue(FIELD_SRSSTR, srs); |
|
65 |
par.setDynValue(FIELD_TRANSPARENCY, true); |
|
66 |
par.setDynValue(FIELD_STYLES, null); // ???? |
|
67 |
par.setDynValue(FIELD_DIMENSIONS, null); |
|
68 |
par.setDynValue(FIELD_ONLINERESOURC, explorer.getProperty("OnlineResources")); |
|
69 |
par.setDynValue(FIELD_FIXEDSIZE, null); |
|
70 |
par.setDynValue(FIELD_QUERYABLE, false); |
|
71 |
par.setDynValue(FIELD_NAME, name); |
|
72 |
par.setDynValue(FIELD_XYAXISORDER, false); |
|
62 | 73 |
|
74 |
DataStore store = explorer.open(par); |
|
75 |
|
|
63 | 76 |
MapContextManager mapContextManager = MapContextLocator.getMapContextManager(); |
64 | 77 |
FLayer layer = mapContextManager.createLayer(name, store); |
65 | 78 |
return layer; |
66 |
} catch (Exception ex) {
|
|
79 |
} catch (Throwable ex) {
|
|
67 | 80 |
LOGGER.warn("Can't create WMS layer", ex); |
68 | 81 |
return null; |
69 | 82 |
} |
Also available in: Unified diff