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