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