svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / streetsmap / core / impl_1_0_0 / SMProtocolHandlerImpl_1_0_0.java @ 26551
History | View | Annotate | Download (6.3 KB)
1 |
package es.logex.gvsig.streetsmap.core.impl_1_0_0; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.geom.Point2D; |
5 |
import java.awt.geom.Rectangle2D; |
6 |
import java.io.File; |
7 |
import java.io.IOException; |
8 |
import java.net.ConnectException; |
9 |
import java.net.MalformedURLException; |
10 |
import java.net.URL; |
11 |
import java.util.ArrayList; |
12 |
import java.util.Iterator; |
13 |
import java.util.List; |
14 |
|
15 |
import javax.swing.JOptionPane; |
16 |
|
17 |
import org.apache.log4j.Logger; |
18 |
import org.cresques.cts.IProjection; |
19 |
import org.cresques.cts.ICoordTrans; |
20 |
|
21 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
22 |
import com.iver.andami.PluginServices; |
23 |
import com.iver.cit.gvsig.ProjectExtension; |
24 |
import com.iver.cit.gvsig.fmap.ColorEvent; |
25 |
import com.iver.cit.gvsig.fmap.DriverException; |
26 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
27 |
import com.iver.cit.gvsig.fmap.MapContext; |
28 |
import com.iver.cit.gvsig.fmap.MapControl; |
29 |
import com.iver.cit.gvsig.fmap.ProjectionEvent; |
30 |
import com.iver.cit.gvsig.fmap.ViewPort; |
31 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
32 |
import com.iver.cit.gvsig.fmap.MapContext.LayerEventListener; |
33 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
34 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
35 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
36 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
37 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
38 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
39 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent; |
40 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionListener; |
41 |
import com.iver.cit.gvsig.fmap.layers.LayerPositionEvent; |
42 |
import com.iver.cit.gvsig.fmap.layers.LegendListener; |
43 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
44 |
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory; |
45 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
46 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
47 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC; |
48 |
|
49 |
import es.logex.gvsig.fmap.drivers.WPSException; |
50 |
import es.logex.gvsig.fmap.drivers.wps.FMapWPSDriver; |
51 |
import es.logex.gvsig.fmap.drivers.wps.FMapWPSDriverFactory; |
52 |
import es.logex.gvsig.fmap.layers.FLyrWPS; |
53 |
import es.logex.gvsig.fmap.layers.FLyrWPSFactory; |
54 |
import es.logex.gvsig.streetsmap.core.SMLayerInfo; |
55 |
import es.logex.gvsig.streetsmap.core.SMProtocolHandler; |
56 |
import es.logex.gvsig.wps.client.WPSClient; |
57 |
|
58 |
import es.logex.xml.utils.LegendManager; |
59 |
|
60 |
/**
|
61 |
* @uml.dependency supplier="es.logex.gvsig.streetsmap.core.StreetsMapTocListener"
|
62 |
*/
|
63 |
public class SMProtocolHandlerImpl_1_0_0 implements |
64 |
SMProtocolHandler { |
65 |
|
66 |
private static Logger logger = Logger |
67 |
.getLogger(SMProtocolHandlerImpl_1_0_0.class.getName()); |
68 |
|
69 |
private ViewPort v = null; |
70 |
private MapContext mapContext = null; |
71 |
private List<SMLayerInfo> listLayers = null; |
72 |
|
73 |
private URL host = null; |
74 |
// parámetros obtenidos del servidor de callejeros.
|
75 |
private Rectangle2D maxExtent; |
76 |
private String crsDefault; |
77 |
|
78 |
//private FLayers groupLayers = null;
|
79 |
|
80 |
private boolean attachedToToc; |
81 |
|
82 |
public SMProtocolHandlerImpl_1_0_0() {
|
83 |
mapContext = ((View) PluginServices.getMDIManager().getActiveWindow())
|
84 |
.getMapControl().getMapContext(); |
85 |
} |
86 |
|
87 |
|
88 |
private Rectangle2D getProjectedExtent(Rectangle2D extent) { |
89 |
IProjection defaultServerProjection = CRSFactory |
90 |
.getCRS(this.crsDefault);
|
91 |
IProjection viewProjection = ((View) PluginServices.getMDIManager()
|
92 |
.getActiveWindow()).getProjection(); |
93 |
Rectangle2D projectedExtent = null; |
94 |
|
95 |
projectedExtent = extent; |
96 |
if (defaultServerProjection != viewProjection) {
|
97 |
// projectar.
|
98 |
ICoordTrans ct = defaultServerProjection.getCT(viewProjection); |
99 |
projectedExtent = ct.convert(this.maxExtent);
|
100 |
} |
101 |
|
102 |
return projectedExtent;
|
103 |
} |
104 |
public void attachToToc() |
105 |
{ |
106 |
if(!attachedToToc)
|
107 |
{ |
108 |
|
109 |
attachedToToc = true;
|
110 |
|
111 |
// groupLayers = new FLayers(mapContext, mapContext.getLayers());
|
112 |
// groupLayers.setName("Callejero");
|
113 |
//mapContext.getLayers().addLayer(groupLayers);
|
114 |
|
115 |
this.crsDefault = "EPSG:23030"; |
116 |
|
117 |
// (626673.9375 4191040,815708.0625 4519371) = maxExtent de los
|
118 |
// municipios.
|
119 |
/*
|
120 |
* Double minX = 626673.9375; Double minY = 4191040.0; Double maxX =
|
121 |
* 815708.0625; Double maxY = 4519371.0;
|
122 |
* Point2D ll = new Point2D.Double(minX, minY);
|
123 |
* Point2D lm = new Point2D.Double(maxX, minY);
|
124 |
* Double w = ll.distance(lm);
|
125 |
*
|
126 |
* ll = new Point2D.Double(minX, minY);
|
127 |
* lm = new Point2D.Double(minX,maxY);
|
128 |
* Double h = ll.distance(lm);
|
129 |
*
|
130 |
* this.maxExtent = new Rectangle2D.Double(minX, minY, w, h);
|
131 |
*/
|
132 |
|
133 |
listLayers = new ArrayList<SMLayerInfo>(); |
134 |
|
135 |
FLyrWPS flyr = null;
|
136 |
flyr = prepareLayer("municipios_geom", "Municipios", |
137 |
"Todos los municipios de la Comunidad Valenciana",
|
138 |
"municipios", 1.0, 600000.0, crsDefault, this.host); |
139 |
|
140 |
mapContext.getLayers().addLayer(flyr); |
141 |
|
142 |
flyr = prepareLayer("manzanas", "Manzanas", "Manzanas o MASA", "manzanas", |
143 |
1.0, 100000.0, crsDefault, this.host); |
144 |
mapContext.getLayers().addLayer(flyr); |
145 |
|
146 |
flyr = prepareLayer("numpolicias", "Números de policía", |
147 |
"Los números de policía corregidos y verificados",
|
148 |
"numpolicias", 1.0, 4000.0, crsDefault, this.host); |
149 |
mapContext.getLayers().addLayer(flyr); |
150 |
|
151 |
flyr = prepareLayer("calles", "Ejes de calles", "Ejes de calles por tramos", |
152 |
"calles", 1.0, 10000.0, crsDefault, this.host); |
153 |
mapContext.getLayers().addLayer(flyr); |
154 |
|
155 |
flyr = prepareLayer("textos", "Textos", "Textos y toponimía", "textos", 1.0, |
156 |
6000.0, crsDefault, this.host); |
157 |
mapContext.getLayers().addLayer(flyr); |
158 |
|
159 |
//mapContext.getLayers().addLayer(groupLayers);
|
160 |
} |
161 |
} |
162 |
public void initialize(URL host) { |
163 |
this.host = host;
|
164 |
} |
165 |
|
166 |
private FLyrWPS prepareLayer(String layerId, String layerName, |
167 |
String layerAbstract, String defaultLegend, Double minScale, |
168 |
Double maxScale, String crsDefault, URL host) { |
169 |
|
170 |
SMLayerInfo smlInfo = new SMapLayerInfoImpl_1_0_0(
|
171 |
layerId, layerName, layerAbstract, defaultLegend, minScale, |
172 |
maxScale, crsDefault, host); |
173 |
|
174 |
|
175 |
|
176 |
FLyrWPS flyr = new FLyrWPSFactory().getFLyrWPS(smlInfo, false, false); |
177 |
flyr.load(this.mapContext.getViewPort().getExtent(),this.mapContext.getViewPort().getProjection()); |
178 |
listLayers.add(smlInfo); |
179 |
return flyr;
|
180 |
|
181 |
} |
182 |
|
183 |
public List<SMLayerInfo> getStreetsMapLayerInfo() { |
184 |
|
185 |
return listLayers;
|
186 |
} |
187 |
|
188 |
public String getVersion() { |
189 |
return "1.0.0"; |
190 |
} |
191 |
|
192 |
public URL getHost() { |
193 |
return this.host; |
194 |
} |
195 |
|
196 |
public void setHost(URL host) { |
197 |
this.host = host;
|
198 |
|
199 |
} |
200 |
|
201 |
} |