Statistics
| Revision:

svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / org.gvsig.sldsupport / org.gvsig.sldsupport.basic / src / main / java / org / gvsig / sldsupport / basic / sld1_0_0 / FMapSLDDriver.java @ 40754

History | View | Annotate | Download (6.13 KB)

1
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ibáñez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.sldsupport.basic.sld1_0_0;
42

    
43

    
44

    
45
/**
46
 * Implements the driver for Styled Layer Descriptor documents in order
47
 * to allow gvSIG to read or write XML documents of this OGC Standard.
48
 *
49
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
50
 */
51
public class FMapSLDDriver { // implements IFMapLegendDriver{
52

    
53
//        private FLayer layer;
54
//        private String[] fieldNames;
55
//        private int[] fieldTypes;
56
//
57
//        private static String sldReadVersion;
58
//
59
//        public boolean accept(File f) {
60
//                if (f.isDirectory()) return true;
61
//                String fName = f.getAbsolutePath();
62
//                if (fName!=null) {
63
//                        fName = fName.toLowerCase();
64
//                        return fName.endsWith(".sld");
65
//                }
66
//                return false;
67
//        }
68
//
69
//        public String getDescription() {return DESCRIPTION;}
70
//        public String getFileExtension() {return FILE_EXTENSION;}
71
//        /**
72
//         * Obtains the classifying field names that are used in the .sld
73
//         * document
74
//         *
75
//         * @return Array of Strings with the classifying field names
76
//         */
77
//        public String[] getClassifyingFieldNames() { return fieldNames; }
78
//        /**
79
//         * Returns the classifying field types of the classifying field names
80
//         * that are used in the .sld document
81
//         *
82
//         * @return Array of integers with the types
83
//         */
84
//        public int[] getClassifyingFieldTypes() { return fieldTypes; }
85
//
86
//        /**
87
//         * Returns true if any layer contained in the TOC menu of gvSIG has the
88
//         * same name that is passed as an argument. Otherwise,false.
89
//         *
90
//         * @param layer
91
//         * @param name
92
//         *
93
//         * @return boolean
94
//         */
95
//        private boolean checkIsUsableSldLyr(FLayer layer, String name) {
96
//                if (layer instanceof FLayers) {
97
//                        FLayers layers = (FLayers) layer;
98
//                        for (int i = 0; i < layers.getLayersCount(); i++) {
99
//                                if (checkIsUsableSldLyr(layers.getLayer(i), name)) {
100
//                                        return true;
101
//                                }
102
//                        }
103
//                        return false;
104
//                }
105
//                return layer.getName().equals(name);
106
//        }
107
//
108
//        public Hashtable<FLayer, ILegend> read(FLayers layers,FLayer layer, File file) throws LegendDriverException {
109
//                this.layer = layer;
110
//                SLDProtocolHandler my_sld = null;
111
//
112
//                try {
113
//
114
//                        my_sld = SLDProtocolHandlerFactory.createVersionedProtocolHandler(file);
115
//                        sldReadVersion = my_sld.getVersion();
116
//                        ((SLDProtocolHandler) my_sld).parse(file);
117
//
118
//                } catch (LegendDriverException e) {
119
//                        throw new LegendDriverException(e.getType());
120
//                } catch (IOException e) {
121
//                        throw new LegendDriverException(LegendDriverException.READ_DRIVER_EXCEPTION);
122
//                } catch (XmlPullParserException e) {
123
//                        throw new LegendDriverException(LegendDriverException.PARSE_LEGEND_FILE_ERROR);
124
//                } catch (UnsupportedSLDVersionException e) {
125
//                        throw new LegendDriverException(LegendDriverException.UNSUPPORTED_LEGEND_FILE_VERSION);
126
//                }
127
//
128
//                ArrayList<ISLDLayer> sldLayers = my_sld.getLayers();
129
//                Hashtable<FLayer, ILegend> table = new Hashtable<FLayer, ILegend>();
130
//                ArrayList<ISLDLayer> usableLayers = new ArrayList<ISLDLayer>();
131
//
132
//
133
//                for (Iterator<ISLDLayer> iterator = sldLayers.iterator(); iterator.hasNext();) {
134
//                        ISLDLayer aLayer = (ISLDLayer) iterator.next();
135
//                        if (checkIsUsableSldLyr(layers, aLayer.getName())){
136
//                                usableLayers.add(aLayer);
137
//                        }
138
//                }
139
//
140
//
141
//                for (int i = 0; i < usableLayers.size(); i++) {
142
//                        if(usableLayers.get(i).getName().compareTo(layer.getName()) == 0) {
143
//                                try {
144
//                                        ILegend legend = createLegend(usableLayers.get(i));;
145
//                                        if (legend != null) {
146
//                                                table.put(layer, legend);
147
//
148
//                                        }
149
//                                }catch (ReadDriverException e) {
150
//                                        e.printStackTrace();
151
//                                        throw new LegendDriverException(LegendDriverException.READ_DRIVER_EXCEPTION);
152
//                                } catch (NumberFormatException e) {
153
//                                        e.printStackTrace();
154
//                                        throw new LegendDriverException(LegendDriverException.READ_DRIVER_EXCEPTION);
155
//                                }
156
//                        }
157
//                }
158
//
159
//                if (table.isEmpty()) {
160
//                        throw new LegendDriverException(LegendDriverException.LAYER_NAME_NOT_FOUND);
161
//                }
162
//                return table;
163
//
164
//        }
165
//        /**
166
//         * Takes a SLDLayer and with its information, creates a gvSIG legend. Depending
167
//         * on if the layer has filters or not, it will be created a single symbol legend
168
//         * or a filter expression legend
169
//         *
170
//         * @param sldLayer layer contained in a .sld document
171
//         * @return a gvSIG legend
172
//         * @throws ReadDriverException
173
//         * @throws NumberFormatException
174
//         * @throws LegendDriverException
175
//         * @throws UnknownHostException
176
//         */
177
//
178
//        /**
179
//         * Checks if the field names contained in an sld document appear in the information
180
//         * of the layer that we are using. If all the field names are correct the method
181
//         * returns true.Otherwise, false.
182
//         *
183
//         * @param fieldNames
184
//         * @return
185
//         * @throws ReadDriverException
186
//         */
187
//
188
//
189
//
190
//
191
//
192
//
193
//
194
//
195
//
196
//
197
//
198
//
199
//
200
//
201
//        public ArrayList<String> getSupportedVersions() {
202
//                return SLDProtocolHandlerFactory.getSupportedVersions();
203
//        }
204

    
205
}
206