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 |
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.StreetsMapLayerInfo; |
55 |
import es.logex.gvsig.streetsmap.core.StreetsMapProtocolHandler; |
56 |
|
57 |
import es.logex.xml.utils.LegendManager; |
58 |
|
59 |
/**
|
60 |
* @uml.dependency supplier="es.logex.gvsig.streetsmap.core.StreetsMapTocListener"
|
61 |
*/
|
62 |
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 |
|
68 |
private ViewPortListener viewPortListener;
|
69 |
|
70 |
private List<StreetsMapLayerInfo> listLayers = null; |
71 |
|
72 |
private boolean lazy = true; |
73 |
private boolean redrawing = false; |
74 |
ViewPort v = null;
|
75 |
MapContext mapContext = null;
|
76 |
|
77 |
private boolean connectoToViewPort = false; |
78 |
private URL host = null; |
79 |
// parámetros obtenidos del servidor de callejeros.
|
80 |
private Rectangle2D maxExtent; |
81 |
private String crsDefault; |
82 |
|
83 |
private FLayers groupLayers = null; |
84 |
|
85 |
public StreetsMapProtocolHandlerImpl_1_0_0() {
|
86 |
mapContext = ((View) PluginServices.getMDIManager().getActiveWindow())
|
87 |
.getMapControl().getMapContext(); |
88 |
} |
89 |
|
90 |
public void connectToViewPort(ViewPort v) { |
91 |
|
92 |
mapContext = ((View) PluginServices.getMDIManager().getActiveWindow())
|
93 |
.getMapControl().getMapContext(); |
94 |
|
95 |
if (lazy) {
|
96 |
lazyInitialize(); |
97 |
} |
98 |
|
99 |
this.connectoToViewPort = true; |
100 |
} |
101 |
|
102 |
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 |
|
109 |
projectedExtent = extent; |
110 |
if (defaultServerProjection != viewProjection) {
|
111 |
// projectar.
|
112 |
ICoordTrans ct = defaultServerProjection.getCT(viewProjection); |
113 |
projectedExtent = ct.convert(this.maxExtent);
|
114 |
} |
115 |
|
116 |
return projectedExtent;
|
117 |
} |
118 |
|
119 |
private void lazyInitialize() { |
120 |
|
121 |
groupLayers = new FLayers(mapContext, mapContext.getLayers());
|
122 |
groupLayers.setName("Callejero");
|
123 |
mapContext.getLayers().addLayer(groupLayers); |
124 |
|
125 |
this.crsDefault = "EPSG:23030"; |
126 |
|
127 |
// (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 |
|
137 |
ll = new Point2D.Double(minX, minY);
|
138 |
lm = new Point2D.Double(minX, maxY);
|
139 |
Double h = ll.distance(lm);
|
140 |
|
141 |
this.maxExtent = new Rectangle2D.Double(minX, minY, w, h);*/
|
142 |
|
143 |
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 |
} |
161 |
|
162 |
private void prepareLayer(String layerId, String layerName, String layerAbstract, |
163 |
String defaultLegend, Double minScale, Double maxScale, String crsDefault, URL host) { |
164 |
|
165 |
StreetsMapLayerInfo smlInfo = new StreetsMapLayerInfoImpl_1_0_0(layerId,
|
166 |
layerName, |
167 |
layerAbstract, |
168 |
defaultLegend, minScale, maxScale, crsDefault, host); |
169 |
|
170 |
listLayers.add(smlInfo); |
171 |
|
172 |
FLyrWPS flyr = new FLyrWPSFactory().getFLyrWPS(smlInfo, false, false); |
173 |
|
174 |
groupLayers.addLayer(flyr); |
175 |
|
176 |
} |
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 |
} |