svn-gvsig-desktop / trunk / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / loaders / ARCIMSLayerLoader.java @ 10626
History | View | Annotate | Download (4.91 KB)
1 |
package es.gva.cit.gvsig.catalogClient.loaders; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.net.MalformedURLException; |
5 |
import java.net.ProtocolException; |
6 |
import java.util.HashMap; |
7 |
import java.util.Map; |
8 |
|
9 |
import org.exolab.castor.xml.ValidationException; |
10 |
import org.gvsig.i18n.Messages; |
11 |
|
12 |
import com.iver.andami.PluginServices; |
13 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
14 |
import com.iver.cit.gvsig.exceptions.layers.UnsupportedVersionLayerException; |
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
16 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
17 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
18 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
19 |
|
20 |
import es.gva.cit.catalogClient.schemas.discoverer.Resource; |
21 |
|
22 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
23 |
*
|
24 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
25 |
*
|
26 |
* This program is free software; you can redistribute it and/or
|
27 |
* modify it under the terms of the GNU General Public License
|
28 |
* as published by the Free Software Foundation; either version 2
|
29 |
* of the License, or (at your option) any later version.
|
30 |
*
|
31 |
* This program is distributed in the hope that it will be useful,
|
32 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
33 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
34 |
* GNU General Public License for more details.
|
35 |
*
|
36 |
* You should have received a copy of the GNU General Public License
|
37 |
* along with this program; if not, write to the Free Software
|
38 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
39 |
*
|
40 |
* For more information, contact:
|
41 |
*
|
42 |
* Generalitat Valenciana
|
43 |
* Conselleria d'Infraestructures i Transport
|
44 |
* Av. Blasco Ib??ez, 50
|
45 |
* 46010 VALENCIA
|
46 |
* SPAIN
|
47 |
*
|
48 |
* +34 963862235
|
49 |
* gvsig@gva.es
|
50 |
* www.gvsig.gva.es
|
51 |
*
|
52 |
* or
|
53 |
*
|
54 |
* IVER T.I. S.A
|
55 |
* Salamanca 50
|
56 |
* 46005 Valencia
|
57 |
* Spain
|
58 |
*
|
59 |
* +34 963163400
|
60 |
* dac@iver.es
|
61 |
*/
|
62 |
/* CVS MESSAGES:
|
63 |
*
|
64 |
* $Id: ARCIMSLayerLoader.java 10626 2007-03-06 16:55:54Z caballero $
|
65 |
* $Log$
|
66 |
* Revision 1.3 2007-03-06 16:41:28 caballero
|
67 |
* Exceptions
|
68 |
*
|
69 |
* Revision 1.2 2006/10/02 08:29:06 jorpiell
|
70 |
* Modificados los cambios del Branch 10 al head
|
71 |
*
|
72 |
* Revision 1.1.2.1 2006/09/20 12:01:36 jorpiell
|
73 |
* Se ha cambiado la versi?n de la jzkit, se ha incorporado la funcionalidad de cargar arcims
|
74 |
*
|
75 |
* Revision 1.1 2006/09/20 11:23:50 jorpiell
|
76 |
* Se ha cambiado la versi?n de la librer?a jzkit de la 1 a la 2.0. Adem?s se ha modificado lo del document
|
77 |
*
|
78 |
*
|
79 |
*/
|
80 |
/**
|
81 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
82 |
*/
|
83 |
public class ARCIMSLayerLoader extends LayerLoader { |
84 |
|
85 |
public ARCIMSLayerLoader(Resource resource) {
|
86 |
super(resource);
|
87 |
} |
88 |
|
89 |
/**
|
90 |
* This function loads a ArcIms resource
|
91 |
* @param host
|
92 |
* URL where the server is located
|
93 |
* @param sLayer
|
94 |
* Layer name
|
95 |
* @param crs
|
96 |
* Coordenates System
|
97 |
* @throws LayerLoaderException
|
98 |
*/
|
99 |
|
100 |
public void loadLayer() throws LoadLayerException { |
101 |
String host = getResource().getLinkage();
|
102 |
String sLayer = getResource().getName();
|
103 |
String protocol = getResource().getProtocol();
|
104 |
View activeView =
|
105 |
(View) PluginServices.getMDIManager().getActiveWindow();
|
106 |
String srs = activeView.getProjection().getAbrev();
|
107 |
FLayer flayer = null;
|
108 |
|
109 |
Map args = new HashMap(); |
110 |
args.put("host",host);
|
111 |
args.put("service_name",sLayer);
|
112 |
args.put("layer_name",sLayer);
|
113 |
args.put("srs",srs);
|
114 |
|
115 |
if (protocol.toUpperCase().indexOf(Resource.ARCIMS_IMAGE) >= 0){ |
116 |
flayer = createArcImsImageLayer(args); |
117 |
}else if (protocol.toUpperCase().indexOf(Resource.ARCIMS_VECTORIAL) >= 0){ |
118 |
flayer = createArcImsVectorialLayer(args); |
119 |
} |
120 |
|
121 |
try {
|
122 |
addLayerToView(flayer); |
123 |
} catch (Exception e) { |
124 |
throw new LoadLayerException(sLayer,e); |
125 |
} |
126 |
|
127 |
} |
128 |
|
129 |
private FLayer createArcImsImageLayer(Map args) throws LoadLayerException{ |
130 |
ExtensionPoint extensionPoint = (ExtensionPoint)ExtensionPointsSingleton.getInstance().get("CatalogLayers");
|
131 |
String sLayer = getResource().getName();
|
132 |
try {
|
133 |
return (FLayer)extensionPoint.create("arcims_raster", args ); |
134 |
} catch(Exception e) { |
135 |
throw new LoadLayerException(sLayer,e); |
136 |
} |
137 |
} |
138 |
|
139 |
private FLayer createArcImsVectorialLayer(Map args) throws LoadLayerException{ |
140 |
ExtensionPoint extensionPoint = (ExtensionPoint)ExtensionPointsSingleton.getInstance().get("CatalogLayers");
|
141 |
String sLayer = getResource().getName();
|
142 |
try {
|
143 |
return (FLayer)extensionPoint.create("arcims_vectorial", args); |
144 |
} catch(Exception e) { |
145 |
throw new LoadLayerException(sLayer,e); |
146 |
} |
147 |
} |
148 |
|
149 |
/*
|
150 |
* (non-Javadoc)
|
151 |
* @see es.gva.cit.gvsig.catalogClient.loaders.LayerLoader#getErrorMessage()
|
152 |
*/
|
153 |
protected String getErrorMessage() { |
154 |
return Messages.getText("arcims_server_error") + ".\n" + |
155 |
Messages.getText("server") + ": " + |
156 |
getResource().getLinkage() + "\n" +
|
157 |
Messages.getText("layer") + ": " + |
158 |
getResource().getName(); |
159 |
} |
160 |
|
161 |
/*
|
162 |
* (non-Javadoc)
|
163 |
* @see es.gva.cit.gvsig.catalogClient.loaders.LayerLoader#getWindowMessage()
|
164 |
*/
|
165 |
protected String getWindowMessage() { |
166 |
return Messages.getText("arcims_load"); |
167 |
} |
168 |
} |
169 |
|