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