root / trunk / extensions / extSymbology / src / org / gvsig / remoteClient / sld / sld1_0_0 / layers / SLDUserLayer1_0_0.java @ 20768
History | View | Annotate | Download (6.46 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.remoteClient.sld.sld1_0_0.layers; |
42 |
|
43 |
import java.io.IOException; |
44 |
import java.net.URL; |
45 |
import java.util.ArrayList; |
46 |
|
47 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
48 |
import org.gvsig.remoteClient.sld.SLDTags; |
49 |
import org.gvsig.remoteClient.sld.filterEncoding.Filter; |
50 |
import org.gvsig.remoteClient.sld.layers.SLDUserLayer; |
51 |
import org.gvsig.remoteClient.sld.sld1_0_0.SLDFeatureTypeStyle1_0_0; |
52 |
import org.gvsig.remoteClient.sld.sld1_0_0.SLDLayerFeatureConstraints1_0_0; |
53 |
import org.gvsig.remoteClient.sld.sld1_0_0.SLDRule1_0_0; |
54 |
import org.gvsig.remoteClient.sld.sld1_0_0.styles.SLDUserStyle1_0_0; |
55 |
import org.xmlpull.v1.XmlPullParserException; |
56 |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException; |
58 |
|
59 |
|
60 |
|
61 |
/**
|
62 |
* Implements the User-Defined Layer element of an SLD implementation specification
|
63 |
* (version 1.0.0).<p>
|
64 |
*
|
65 |
* In addition to using named layers, it is also useful to be able to define custom
|
66 |
* user-defined layers for rendering.<p>
|
67 |
* Since a layer is defined as a collection of potentially mixed-type features, the
|
68 |
* UserLayer element must provide the means to identify the features to be used. All
|
69 |
* features to be rendered are assumed to be fetched from a Web Feature Server (WFS) or a
|
70 |
* Web Coverage Service (WCS, in which case the term �features� is used loosely).
|
71 |
*
|
72 |
* The remote server to be used is identified by RemoteOWS (OGC Web Service) element.
|
73 |
*
|
74 |
* @see SLDLayer
|
75 |
* @see SLDNamedLayer1_0_0
|
76 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188
|
77 |
*
|
78 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
79 |
*/
|
80 |
public class SLDUserLayer1_0_0 extends SLDUserLayer { |
81 |
|
82 |
/**
|
83 |
* Parses the xml data retrieved from the SLD, it will parse the User-Defined Layer
|
84 |
* element</p>
|
85 |
* @throws LegendDriverException
|
86 |
*/
|
87 |
public void parse(XMLSchemaParser parser)throws IOException, XmlPullParserException, LegendDriverException { |
88 |
|
89 |
int currentTag;
|
90 |
boolean end = false; |
91 |
|
92 |
parser.require(XMLSchemaParser.START_TAG, null, SLDTags.USERDEFINEDLAYER);
|
93 |
currentTag = parser.next(); |
94 |
|
95 |
while (!end)
|
96 |
{ |
97 |
switch(currentTag)
|
98 |
{ |
99 |
case XMLSchemaParser.START_TAG:
|
100 |
if (parser.getName().compareTo(SLDTags.NAME)==0) { |
101 |
setName(parser.nextText()); |
102 |
} |
103 |
else if(parser.getName().compareTo(SLDTags.REMOTE_OWS)==0){ |
104 |
parseRemoteOWS(parser); |
105 |
} |
106 |
else if (parser.getName().compareTo(SLDTags.LAYER_FEATURE_CONST)==0) { |
107 |
SLDLayerFeatureConstraints1_0_0 sldLayerFeatCons = new SLDLayerFeatureConstraints1_0_0();
|
108 |
sldLayerFeatCons.parse(parser,currentTag,null);
|
109 |
addLayerFeatureConstraint(sldLayerFeatCons); |
110 |
} |
111 |
else if (parser.getName().compareTo(SLDTags.USERSTYLE)==0) { |
112 |
SLDUserStyle1_0_0 userStyle = new SLDUserStyle1_0_0();
|
113 |
userStyle.parse(parser); |
114 |
addLayerStyle(userStyle); |
115 |
} |
116 |
break;
|
117 |
case XMLSchemaParser.END_TAG:
|
118 |
if (parser.getName().compareTo(SLDTags.USERDEFINEDLAYER) == 0) |
119 |
end = true;
|
120 |
break;
|
121 |
case XMLSchemaParser.TEXT:
|
122 |
break;
|
123 |
} |
124 |
if (!end)
|
125 |
currentTag = parser.next(); |
126 |
} |
127 |
|
128 |
parser.require(XMLSchemaParser.END_TAG, null, SLDTags.USERDEFINEDLAYER);
|
129 |
|
130 |
} |
131 |
|
132 |
|
133 |
/**
|
134 |
* Parses the xml data retrieved from the SLD, it will parse the RemoteOWS
|
135 |
* element which identifies the remote server to be used</p>
|
136 |
*
|
137 |
* @param parser
|
138 |
* @throws IOException
|
139 |
* @throws XmlPullParserException
|
140 |
*/
|
141 |
|
142 |
private void parseRemoteOWS(XMLSchemaParser parser)throws IOException, XmlPullParserException { |
143 |
|
144 |
int currentTag;
|
145 |
boolean end = false; |
146 |
|
147 |
parser.require(XMLSchemaParser.START_TAG, null, SLDTags.REMOTE_OWS);
|
148 |
currentTag = parser.next(); |
149 |
|
150 |
while (!end)
|
151 |
{ |
152 |
switch(currentTag)
|
153 |
{ |
154 |
case XMLSchemaParser.START_TAG:
|
155 |
if (parser.getName().compareTo(SLDTags.SERVICE)==0) { |
156 |
setRemoteOWSService(parser.nextText()); |
157 |
} |
158 |
else if (parser.getName().compareTo(SLDTags.ONLINE_RESOURCE)==0) { |
159 |
for (int i = 0; i < parser.getAttributeCount(); i++) { |
160 |
if (parser.getAttributeName(i).compareTo(SLDTags.XLINK_HREF) == 0) { |
161 |
URL myURL = new URL(parser.getAttributeValue(i)); |
162 |
addRemoteOWSOnlineResource(myURL); |
163 |
} |
164 |
} |
165 |
} |
166 |
break;
|
167 |
case XMLSchemaParser.END_TAG:
|
168 |
if (parser.getName().compareTo(SLDTags.REMOTE_OWS) == 0) |
169 |
end = true;
|
170 |
break;
|
171 |
case XMLSchemaParser.TEXT:
|
172 |
break;
|
173 |
} |
174 |
if (!end)
|
175 |
currentTag = parser.next(); |
176 |
} |
177 |
|
178 |
parser.require(XMLSchemaParser.END_TAG, null, SLDTags.REMOTE_OWS);
|
179 |
|
180 |
} |
181 |
|
182 |
public ArrayList<Filter> getLayerFilters() { |
183 |
ArrayList<Filter> layerFilter = new ArrayList<Filter>(); |
184 |
for (int i = 0; i < this.getLayerStyles().size(); i++) { |
185 |
SLDUserStyle1_0_0 userStyle = (SLDUserStyle1_0_0) this.getLayerStyles().get(i);
|
186 |
for (int j = 0; j < userStyle.getFeatureTypeStyle().size(); j++) { |
187 |
SLDFeatureTypeStyle1_0_0 featTypeStyle = (SLDFeatureTypeStyle1_0_0) userStyle.getFeatureTypeStyle().get(j); |
188 |
for (int k = 0; k < featTypeStyle.getRules().size(); k++) { |
189 |
SLDRule1_0_0 rule = (SLDRule1_0_0) featTypeStyle.getRules().get(k); |
190 |
layerFilter.add(rule.getFilter()); |
191 |
} |
192 |
} |
193 |
} |
194 |
return layerFilter;
|
195 |
} |
196 |
|
197 |
|
198 |
@Override
|
199 |
public String toXML() { |
200 |
// TODO Auto-generated method stub
|
201 |
throw new Error ("Not yet implemented"); |
202 |
} |
203 |
|
204 |
|
205 |
} |