gvsig-catalog / trunk / extCatalog / src / org / gvsig / catalog / loaders / WMSLayerLoader.java @ 6
History | View | Annotate | Download (4 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.catalog.loaders; |
42 |
|
43 |
|
44 |
import java.util.HashMap; |
45 |
import java.util.Map; |
46 |
|
47 |
import org.gvsig.andami.PluginServices; |
48 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
49 |
import org.gvsig.catalog.schemas.Resource; |
50 |
import org.gvsig.fmap.dal.DataStoreParameters; |
51 |
import org.gvsig.fmap.dal.exception.InitializeException; |
52 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
53 |
import org.gvsig.i18n.Messages; |
54 |
|
55 |
|
56 |
/**
|
57 |
* This class is used to load a WMS layer in gvSIG
|
58 |
*
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 |
*/
|
61 |
public class WMSLayerLoader extends GvSigLayerLoader{ |
62 |
private static final String FIELD_NAME = "name"; |
63 |
private static final String FIELD_SRSSTR = "srsstr"; |
64 |
private static final String FIELD_FORMAT = "format"; |
65 |
private static final String FIELD_TRANSPARENCY = "transparency"; |
66 |
private static final String FIELD_LAYERQUERY = "layer_query"; |
67 |
private static final String FIELD_URI = "uri"; |
68 |
private static final String FIELD_ONLINERESOURC = "onlineresources"; |
69 |
|
70 |
public WMSLayerLoader(Resource resource) {
|
71 |
super(resource);
|
72 |
} |
73 |
|
74 |
protected boolean hasSpecificLayer() { |
75 |
return true; |
76 |
} |
77 |
|
78 |
protected String getLayerName() { |
79 |
return getResource().getName();
|
80 |
} |
81 |
|
82 |
protected DataStoreParameters createDataStoreParameters()
|
83 |
throws InitializeException, ProviderNotRegisteredException {
|
84 |
DataStoreParameters dataStoreParameters = DATA_MANAGER.createStoreParameters("Wms Store");
|
85 |
dataStoreParameters.setDynValue(FIELD_URI, getResource().getLinkage()); |
86 |
dataStoreParameters.setDynValue(FIELD_FORMAT, "image/png");
|
87 |
dataStoreParameters.setDynValue(FIELD_LAYERQUERY, getResource().getName()); |
88 |
AbstractViewPanel activeView = |
89 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
90 |
dataStoreParameters.setDynValue(FIELD_SRSSTR, activeView.getProjection().getAbrev()); |
91 |
dataStoreParameters.setDynValue(FIELD_TRANSPARENCY, Boolean.TRUE);
|
92 |
dataStoreParameters.setDynValue(FIELD_NAME, getLayerName()); |
93 |
dataStoreParameters.setDynValue(FIELD_ONLINERESOURC, createOnlineResources()); |
94 |
return dataStoreParameters;
|
95 |
} |
96 |
|
97 |
protected Map createOnlineResources() { |
98 |
Map args = new HashMap(); |
99 |
args.put("GepMap", getResource().getLinkage());
|
100 |
return args;
|
101 |
} |
102 |
|
103 |
protected String extensionPointName() { |
104 |
return "OGC:WMS"; |
105 |
} |
106 |
|
107 |
protected String getErrorMessage() { |
108 |
return Messages.getText("wmsError") + ".\n" + |
109 |
Messages.getText("server") + ": " + |
110 |
getResource().getLinkage() + "\n" +
|
111 |
Messages.getText("layer") + ": " + |
112 |
getResource().getName(); |
113 |
} |
114 |
|
115 |
protected String getWindowMessage() { |
116 |
return Messages.getText("loadWMS"); |
117 |
} |
118 |
} |