Statistics
| Revision:

svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / streetsmap / core / impl_1_0_0 / SMProtocolHandlerImpl_1_0_0.java @ 26601

History | View | Annotate | Download (4.01 KB)

1
package es.logex.gvsig.streetsmap.core.impl_1_0_0;
2

    
3

    
4
import java.io.File;
5
import java.net.URL;
6
import java.util.ArrayList;
7
import java.util.List;
8

    
9

    
10

    
11
import org.apache.log4j.Logger;
12

    
13
import com.iver.andami.PluginServices;
14
import com.iver.cit.gvsig.fmap.MapContext;
15

    
16
import com.iver.cit.gvsig.project.documents.view.gui.View;
17

    
18

    
19
import es.logex.gvsig.fmap.layers.FLyrWPS;
20
import es.logex.gvsig.fmap.layers.FLyrWPSFactory;
21
import es.logex.gvsig.fmap.layers.SMLayerInfo;
22
import es.logex.gvsig.fmap.layers.SMapLayerInfoImpl_1_0_0;
23
import es.logex.gvsig.streetsmap.core.SMProtocolHandler;
24

    
25

    
26
/**
27
 * @uml.dependency supplier="es.logex.gvsig.streetsmap.core.StreetsMapTocListener"
28
 */
29
public class SMProtocolHandlerImpl_1_0_0 implements
30
                SMProtocolHandler {
31

    
32
        @SuppressWarnings("unused")
33
        private static Logger logger = Logger
34
                        .getLogger(SMProtocolHandlerImpl_1_0_0.class.getName());
35

    
36
        private MapContext mapContext = null;
37
        private List<SMLayerInfo> listLayers = null;
38

    
39
        private URL host = null;
40
        // parámetros obtenidos del servidor de callejeros.
41

    
42
        
43
        private String crsDefault;
44

    
45
        //private FLayers groupLayers = null;
46

    
47
        private boolean attachedToToc;
48

    
49
        public SMProtocolHandlerImpl_1_0_0() {
50
                if(PluginServices.getMDIManager().getActiveWindow() instanceof View)
51
                {
52
                        mapContext = ((View) PluginServices.getMDIManager().getActiveWindow())
53
                                .getMapControl().getMapContext();
54
                }
55
                else
56
                {
57
                        PluginServices.getMainFrame().getStatusBar().setWarningTextTemporal(PluginServices.getText(this, "no_hay_vista_seleccionada"));
58
                }
59
        }
60

    
61
        public void setCrsDefault(String crsDefault) {
62
                this.crsDefault = crsDefault;
63
        }
64
        
65
        public String getCrsDefault() {
66
                return this.crsDefault;
67
        }
68
        
69
        public void attachToToc()
70
        {
71
                if(!attachedToToc)
72
                {
73

    
74
                        attachedToToc = true;
75

    
76
                        listLayers = new ArrayList<SMLayerInfo>();
77
                        
78
                        FLyrWPS flyr = null;
79
                                                
80
                        flyr = prepareLayer("manzanas", "Manzanas", "Manzanas o MASA", "manzanas",
81
                                        1.0, 160000.0, crsDefault, this.host, "MultiPolygon");
82
                        mapContext.getLayers().addLayer(flyr);
83
                        
84
                        flyr = prepareLayer("municipios_geom", "Municipios",
85
                                        "Todos los municipios de la Comunidad Valenciana",
86
                                        "municipios", 1.0, 2000000.0, crsDefault, this.host, "MultiPolygon" );
87
                        
88
                        mapContext.getLayers().addLayer(flyr);
89
                        
90
                        flyr = prepareLayer("numpolicias", "Números de policía",
91
                                        "Los números de policía corregidos y verificados",
92
                                        "numpolicias", 1.0, 2000.0, crsDefault, this.host, "MultiPoint");
93
                        mapContext.getLayers().addLayer(flyr);
94
                        
95
                        flyr = prepareLayer("calles", "Ejes de calles", "Ejes de calles por tramos",
96
                                        "calles", 1.0, 10000.0, crsDefault, this.host, "MultiLine");
97
                        mapContext.getLayers().addLayer(flyr);
98
                        
99
                        flyr = prepareLayer("textos", "Textos", "Textos y toponimía", "textos", 1.0,
100
                                        6000.0, crsDefault, this.host,  "MultiLine");
101
                        mapContext.getLayers().addLayer(flyr);
102

    
103
                }
104
        }
105
        
106
        public void initialize(URL host) {
107
                this.host = host;
108
                this.crsDefault = "EPSG:23030";
109
        }
110

    
111
        private FLyrWPS prepareLayer(String layerId, String layerName,
112
                        String layerAbstract, String defaultLegend, Double minScale,
113
                        Double maxScale, String crsDefault, URL host, String geometryType) {
114

    
115
                SMLayerInfo smlInfo = new SMapLayerInfoImpl_1_0_0(
116
                                layerId, layerName, layerAbstract, defaultLegend, minScale,
117
                                maxScale, crsDefault, host, geometryType);
118
                
119
                String defaultLegendPath = PluginServices
120
                        .getPluginServices(this).getPluginDirectory()
121
                        .getAbsolutePath()
122
                        + File.separator
123
                        + "leyendas"
124
                        + File.separator
125
                        + smlInfo.getId().toLowerCase() + ".gvl";
126
                
127
                FLyrWPS flyr = new FLyrWPSFactory().getFLyrWPS(layerId,layerName,
128
                                crsDefault,host,minScale,maxScale,geometryType,
129
                                defaultLegendPath);
130
                
131
                
132
                flyr.load(this.mapContext.getViewPort().getExtent(),this.mapContext.getViewPort().getProjection(),"SAMPLE");
133
                listLayers.add(smlInfo);
134
                return flyr;
135

    
136
        }
137

    
138
        public List<SMLayerInfo> getStreetsMapLayerInfo() {
139

    
140
                return listLayers;
141
        }
142

    
143
        public String getVersion() {
144
                return "1.0.0";
145
        }
146

    
147
        public URL getHost() {
148
                return this.host;
149
        }
150

    
151
        public void setHost(URL host) {
152
                this.host = host;
153

    
154
        }
155

    
156
}