Revision 7721 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/fmap/layers/FLyrWFS.java
FLyrWFS.java | ||
---|---|---|
7 | 7 |
import java.net.URL; |
8 | 8 |
import java.util.HashMap; |
9 | 9 |
import java.util.Map; |
10 |
import java.util.Vector; |
|
10 | 11 |
|
11 | 12 |
import javax.swing.ImageIcon; |
12 | 13 |
|
14 |
import org.cresques.cts.IProjection; |
|
15 |
import org.cresques.cts.ProjectionPool; |
|
16 |
import org.cresques.geo.Projection; |
|
13 | 17 |
import org.gvsig.remoteClient.wfs.WFSAttribute; |
14 | 18 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
15 | 19 |
|
20 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
|
16 | 21 |
import com.iver.andami.PluginServices; |
17 | 22 |
import com.iver.cit.gvsig.fmap.DriverException; |
18 | 23 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
... | ... | |
67 | 72 |
* |
68 | 73 |
* $Id$ |
69 | 74 |
* $Log$ |
70 |
* Revision 1.11 2006-09-25 10:22:35 caballero
|
|
71 |
* Projection
|
|
75 |
* Revision 1.12 2006-10-02 09:09:45 jorpiell
|
|
76 |
* Cambios del 10 copiados al head
|
|
72 | 77 |
* |
78 |
* Revision 1.10.2.3 2006/09/29 14:12:53 luisw2 |
|
79 |
* CRSFactory.getCRS substitutes ProjectionPool.get |
|
80 |
* |
|
81 |
* Revision 1.10.2.2 2006/09/28 08:54:01 jorpiell |
|
82 |
* Ya se puede reproyectar |
|
83 |
* |
|
84 |
* Revision 1.10.2.1 2006/09/26 07:36:24 jorpiell |
|
85 |
* El WFS no reproyectaba porque no se le asignaba a la capa un sistema de referencia. Ahora ya se hace. |
|
86 |
* |
|
73 | 87 |
* Revision 1.10 2006/09/05 15:41:52 jorpiell |
74 | 88 |
* A?adida la funcionalidad de cargar WFS desde el cat?logo |
75 | 89 |
* |
... | ... | |
117 | 131 |
private WFSAttribute[] fields = null; |
118 | 132 |
private int numfeatures = 100; |
119 | 133 |
private int timeout = 10000; |
134 |
private String srs = null; |
|
120 | 135 |
private FMapWFSDriver wfsDriver = null; |
121 | 136 |
private VectorialAdapter vectorialAdapter = null; |
122 | 137 |
private WFSLayerNode wfsLayerNode = null; |
123 |
|
|
138 |
|
|
124 | 139 |
/** |
125 | 140 |
* Constructor |
126 | 141 |
*/ |
127 | 142 |
public FLyrWFS(){ |
128 | 143 |
super(); |
129 | 144 |
} |
130 |
|
|
145 |
|
|
131 | 146 |
/** |
132 | 147 |
* Constructor to load a new layer from a catalog |
133 | 148 |
* search |
134 | 149 |
* @param args |
135 | 150 |
* Params to load a new layer |
136 |
* @throws WFSException |
|
137 |
* @throws IOException |
|
138 |
* @throws MalformedURLException |
|
139 |
* @throws ConnectException |
|
140 |
* @throws DriverIOException |
|
151 |
* @throws WFSException
|
|
152 |
* @throws IOException
|
|
153 |
* @throws MalformedURLException
|
|
154 |
* @throws ConnectException
|
|
155 |
* @throws DriverIOException
|
|
141 | 156 |
*/ |
142 | 157 |
public FLyrWFS(Map args) throws WFSException, ConnectException, MalformedURLException, IOException, DriverIOException{ |
143 | 158 |
String[] sLayer = (String[])args.get("layer"); |
144 | 159 |
String user = (String)args.get("user"); |
145 | 160 |
String pwd = (String)args.get("pwd"); |
146 |
String host = (String)args.get("host"); |
|
161 |
String host = (String)args.get("host");
|
|
147 | 162 |
String projection = (String)args.get("projection"); |
148 |
|
|
163 |
|
|
149 | 164 |
FMapWFSDriver driver = FMapWFSDriverFactory.getFMapDriverForURL(new URL(host)); |
150 | 165 |
WFSLayerNode[] layers = driver.getLayerList(); |
151 | 166 |
WFSLayerNode layer = driver.getLayerInfo(sLayer[0]); |
152 |
|
|
167 |
|
|
153 | 168 |
layer.setSelectedFields(layer.getFields()); |
154 |
|
|
169 |
|
|
155 | 170 |
WFSAttribute[] atts = new WFSAttribute[layer.getFields().size()]; |
156 | 171 |
for (int i=0 ; i<atts.length ; i++){ |
157 | 172 |
atts[i] = (WFSAttribute)layer.getFields().get(i); |
158 | 173 |
} |
159 |
|
|
174 |
|
|
160 | 175 |
setHost(host); |
161 | 176 |
setName(sLayer[0]); |
162 | 177 |
setLayerName(sLayer[0]); |
... | ... | |
166 | 181 |
setPassword(pwd); |
167 | 182 |
setNumfeatures(10000); |
168 | 183 |
setTimeout(10000); |
169 |
setWfsDriver(driver); |
|
170 |
setProjection( CRSFactory.getCRS(projection));
|
|
171 |
|
|
172 |
load(); |
|
184 |
setWfsDriver(driver);
|
|
185 |
setProjection(CRSFactory.getCRS(projection)); |
|
186 |
|
|
187 |
load();
|
|
173 | 188 |
} |
189 |
|
|
174 | 190 |
|
175 |
|
|
176 | 191 |
/** |
177 | 192 |
* Loads the features from the server |
178 | 193 |
*/ |
... | ... | |
205 | 220 |
status.setTimeout(getTimeout()); |
206 | 221 |
status.setFields(getFieldNames()); |
207 | 222 |
status.setOnlineResource(getOnlineResource()); |
223 |
status.setSrs(getSrs()); |
|
208 | 224 |
return status; |
209 | 225 |
} |
210 | 226 |
|
... | ... | |
360 | 376 |
*/ |
361 | 377 |
public Rectangle2D getFullExtent() throws DriverException { |
362 | 378 |
try { |
363 |
return wfsDriver.getFullExtent(); |
|
379 |
Rectangle2D extent = wfsDriver.getFullExtent(); |
|
380 |
if (getCoordTrans() != null){ |
|
381 |
return getCoordTrans().convert(extent); |
|
382 |
} |
|
383 |
return extent; |
|
364 | 384 |
} catch (IOException e) { |
365 | 385 |
throw new DriverException(e.toString()); |
366 | 386 |
} |
... | ... | |
386 | 406 |
info.put("layerName", getLayerName()); |
387 | 407 |
info.put("layerText", getLayerText()); |
388 | 408 |
info.put("attributes", getFields()); |
389 |
info.put("host", getHost()); |
|
390 |
info.put("wfsLayerNode", getWfsLayerNode()); |
|
409 |
info.put("host", getHost());
|
|
410 |
info.put("wfsLayerNode", getWfsLayerNode());
|
|
391 | 411 |
WFSStatus status = new WFSStatus(getLayerName()); |
392 | 412 |
status.setBuffer(getNumfeatures()); |
393 | 413 |
status.setTimeout(getTimeout()); |
394 | 414 |
status.setUserName(getUserName()); |
395 | 415 |
status.setPassword(getPassword()); |
396 |
info.put("status",status); |
|
416 |
info.put("status",status);
|
|
397 | 417 |
return info; |
398 | 418 |
|
399 | 419 |
} |
... | ... | |
418 | 438 |
} catch (MalformedURLException e) { |
419 | 439 |
// TODO Auto-generated catch block |
420 | 440 |
e.printStackTrace(); |
421 |
} |
|
441 |
}
|
|
422 | 442 |
} |
423 |
|
|
424 |
public ImageIcon getTocImageIcon() { |
|
443 |
|
|
444 |
public ImageIcon getTocImageIcon() {
|
|
425 | 445 |
return new ImageIcon(PluginServices.getPluginServices("com.iver.cit.gvsig.wfs2").getClassLoader().getResource("images/icoLayer.png")); |
426 | 446 |
} |
427 |
|
|
447 |
|
|
428 | 448 |
/* |
429 | 449 |
* (non-Javadoc) |
430 | 450 |
* @see com.iver.cit.gvsig.fmap.layers.FLyrVect#isPropertiesMenuVisible() |
... | ... | |
432 | 452 |
public boolean isPropertiesMenuVisible(){ |
433 | 453 |
return false; |
434 | 454 |
} |
455 |
|
|
456 |
public String getSrs() { |
|
457 |
return srs; |
|
458 |
} |
|
459 |
|
|
460 |
public void setSrs(String srs) { |
|
461 |
this.srs = srs; |
|
462 |
} |
|
435 | 463 |
} |
Also available in: Unified diff