GeoPubby  Version 0.1.0.0
SLDParser Class Reference
Inheritance diagram for SLDParser:
Collaboration diagram for SLDParser:

Public Member Functions

 SLDParser ()
 
void startElement (String uri, String localName, String qName, Attributes attributes) throws SAXException
 
void characters (char[] ch, int start, int length) throws SAXException
 
void endElement (String uri, String localName, String qName) throws SAXException
 

Static Public Member Functions

static void main (String[] args) throws SAXException, IOException, ParserConfigurationException
 

Package Attributes

OntModel model
 
Boolean featureTypeStyle =false
 
Boolean filter =false
 
Boolean rule =false
 
Boolean polygon =false
 
Boolean linestring =false
 
Boolean point =false
 
Boolean name =false
 
Boolean and =false
 
Boolean or =false
 
Boolean condition =false
 
Boolean svgParameter =false
 
Map< String, String > svgInstance =new HashMap<String,String>()
 
List< StyleObjectstyles =new LinkedList<StyleObject>()
 
String svgParamName
 
String ruleName
 
String conditionName
 
StyleObject currentStyle
 
Condition currentCondition
 
List< Conditioncurcondlist
 
boolean literal
 
boolean gmlgeometry
 
Map< String, String > wellKnownNameToSVG =new TreeMap<>()
 

Private Attributes

boolean propertyName
 
boolean userstyle
 
String styleId
 

Constructor & Destructor Documentation

◆ SLDParser()

SLDParser ( )
53  {
54  this.model=ModelFactory.createOntologyModel();
55  this.wellKnownNameToSVG.put("circle", "");
56  this.wellKnownNameToSVG.put("square", "");
57  this.wellKnownNameToSVG.put("triangle", "");
58  this.wellKnownNameToSVG.put("star", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"255\" height=\"240\" viewBox=\"0 0 51 48\">\r\n"
59  + "<title>Five Pointed Star</title>\r\n"
60  + "<path fill=\"none\" stroke=\"#000\" d=\"m25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z\"/>\r\n"
61  + "</svg>");
62  this.wellKnownNameToSVG.put("cross", "");
63  this.wellKnownNameToSVG.put("x", "");
64  this.wellKnownNameToSVG.put("vertline", "");
65  this.wellKnownNameToSVG.put("horline", "");
66  this.wellKnownNameToSVG.put("slash", "");
67  this.wellKnownNameToSVG.put("backslash", "");
68  this.wellKnownNameToSVG.put("dot", "");
69  this.wellKnownNameToSVG.put("plus", "");
70  this.wellKnownNameToSVG.put("times", "");
71  this.wellKnownNameToSVG.put("oarrow", "");
72  this.wellKnownNameToSVG.put("carrow", "");
73 
74  }
Map< String, String > wellKnownNameToSVG
Definition: SLDParser.java:47
OntModel model
Definition: SLDParser.java:25

Referenced by SLDParser.main().

Member Function Documentation

◆ characters()

void characters ( char[]  ch,
int  start,
int  length 
) throws SAXException
224  {
225  if(svgParameter) {
226  this.svgInstance.put(this.svgParamName, new String(ch,start,length));
227  }
228  if(this.name && this.userstyle && !this.rule) {
229  System.out.println(new String(ch,start,length).replace(" ", "_"));
230  this.styleId=new String(ch,start,length).replace(" ", "_");
231  }
232  if(this.name)
233  System.out.println("CHaracters: "+new String(ch,start,length)+" "+this.userstyle+" "+this.rule);
234  if(this.name && this.userstyle && this.rule) {
235  this.ruleName=new String(ch,start,length);
236  System.out.println(new String(ch,start,length));
237  this.currentStyle.styleName=new String(ch,start,length);
238  this.currentStyle.styleId=this.styleId;
239  }
240  if(this.propertyName) {
241  this.currentCondition.property=new String(ch,start,length);
242  }
243  if(this.literal) {
244  this.currentCondition.value=new String(ch,start,length);
245  }
246  }
String value
Definition: Condition.java:7
String property
Definition: Condition.java:5
Boolean rule
Definition: SLDParser.java:29
boolean literal
Definition: SLDParser.java:45
String ruleName
Definition: SLDParser.java:37
Condition currentCondition
Definition: SLDParser.java:41
String styleId
Definition: SLDParser.java:51
Boolean svgParameter
Definition: SLDParser.java:31
Map< String, String > svgInstance
Definition: SLDParser.java:33
StyleObject currentStyle
Definition: SLDParser.java:39
String svgParamName
Definition: SLDParser.java:37
boolean propertyName
Definition: SLDParser.java:45
Boolean name
Definition: SLDParser.java:29
boolean userstyle
Definition: SLDParser.java:49
String styleId
Definition: StyleObject.java:75
String styleName
An identifier of a given style.
Definition: StyleObject.java:73

References SLDParser.name, Condition.property, SLDParser.rule, SLDParser.styleId, StyleObject.styleId, StyleObject.styleName, SLDParser.svgParameter, and Condition.value.

◆ endElement()

void endElement ( String  uri,
String  localName,
String  qName 
) throws SAXException
249  {
250  switch(qName) {
251  case "se:SvgParameter":
252  this.svgParameter=false;
253  break;
254  case "se:CssParameter":
255  this.svgParameter=false;
256  break;
257  case "ogc:Filter":
258  filter=false;
259  this.curcondlist.add(currentCondition);
260  System.out.println(currentCondition.toSHACL());
261  break;
262  case "se:PolygonSymbolizer":
263  polygon=false;
265  break;
266  case "se:LineSymbolizer":
267  linestring=false;
269  break;
270  case "se:PointSymbolizer":
271  point=false;
273  break;
274  case "se:Rule":
275  this.rule=false;
277  this.styles.add(currentStyle);
278  break;
279  case "se:Name":
280  this.name=false;
281  break;
282  case "UserStyle":
283  this.userstyle=false;
284  break;
285  case "ogc:PropertyName":
286  this.propertyName=false;
287  break;
288  case "ogc:Literal":
289  this.literal=false;
290  break;
291  case "ogc:PropertyIsEqualTo":
292  this.condition=false;
293  break;
294  case "ogc:PropertyIsNotEqualTo":
295  this.condition=false;
296  break;
297  case "ogc:PropertyIsLessThan":
298  this.condition=false;
299  break;
300  case "ogc:PropertyIsLessThanOrEqualTo":
301  this.condition=false;
302  break;
303  case "ogc:PropertyIsGreaterThan":
304  this.condition=false;
305  break;
306  case "ogc:PropertyIsGreaterThanOrEqualTo":
307  this.condition=false;
308  break;
309  case "ogc:PropertyIsLike":
310  this.condition=false;
311  break;
312  case "ogc:PropertyIsNull":
313  this.condition=false;
314  break;
315  case "ogc:PropertyIsBetween":
316  this.condition=false;
317  break;
318  case "ogc:Intersects":
319  this.condition=false;
320  break;
321  case "ogc:Equals":
322  this.condition=false;
323  break;
324  case "ogc:Disjoint":
325  this.condition=false;
326  break;
327  case "ogc:Touches":
328  this.condition=false;
329  break;
330  case "ogc:Within":
331  this.condition=false;
332  break;
333  case "ogc:Overlaps":
334  this.condition=false;
335  break;
336  case "ogc:Crosses":
337  this.condition=false;
338  break;
339  case "ogc:Contains":
340  this.condition=false;
341  break;
342  case "ogc:DWithin":
343  this.condition=false;
344  break;
345  case "ogc:Beyond":
346  this.condition=false;
347  break;
348  case "ogc:BBOX":
349  this.condition=false;
350  break;
351  }
352  }
String toSHACL()
Definition: Condition.java:11
Boolean linestring
Definition: SLDParser.java:29
Boolean point
Definition: SLDParser.java:29
Boolean filter
Definition: SLDParser.java:29
List< Condition > curcondlist
Definition: SLDParser.java:43
Boolean condition
Definition: SLDParser.java:29
Boolean polygon
Definition: SLDParser.java:29
List< StyleObject > styles
Definition: SLDParser.java:35
String polygonStyle
A Polygon style definition in CSS.
Definition: StyleObject.java:46
String mapToCSS(Map< String, String > map)
Definition: StyleObject.java:254
String pointStyle
A point style definition in CSS.
Definition: StyleObject.java:26
String lineStringStyle
A hatch definition in CSS.
Definition: StyleObject.java:36
List< Condition > conditions
Definition: StyleObject.java:92

References SLDParser.condition, StyleObject.conditions, SLDParser.curcondlist, SLDParser.currentCondition, SLDParser.currentStyle, SLDParser.filter, SLDParser.linestring, StyleObject.lineStringStyle, StyleObject.mapToCSS(), SLDParser.name, SLDParser.point, StyleObject.pointStyle, SLDParser.polygon, StyleObject.polygonStyle, SLDParser.rule, and Condition.toSHACL().

◆ main()

static void main ( String[]  args) throws SAXException, IOException, ParserConfigurationException
static
355  {
356  SLDParser parser=new SLDParser();
357  SAXParserFactory.newInstance().newSAXParser().parse("test.sld", parser);
358  System.out.println(parser.styles);
359  System.out.println(parser.styles.size());
360  StringBuilder builder=new StringBuilder();
361  for(StyleObject stl:parser.styles) {
362  builder.append(stl.toRDF());
363  }
364  FileWriter writer=new FileWriter(new File("rules.ttl"));
365  writer.write(builder.toString());
366  writer.close();
367 }
SLDParser()
Definition: SLDParser.java:53

References SLDParser.SLDParser(), SLDParser.styles, and StyleObject.toRDF().

◆ startElement()

void startElement ( String  uri,
String  localName,
String  qName,
Attributes  attributes 
) throws SAXException
77  {
78  switch(qName) {
79  case "se:PolygonSymbolizer":
80  polygon=true;
81  break;
82  case "se:LineSymbolizer":
83  linestring=true;
84  break;
85  case "ogc:Filter":
86  filter=true;
87  this.currentCondition=new Condition();
88  break;
89  case "se:PointSymbolizer":
90  point=true;
91  break;
92  case "se:SvgParameter":
93  this.svgParameter=true;
94  this.svgParamName=attributes.getValue("name");
95  break;
96  case "se:CssParameter":
97  this.svgParameter=true;
98  this.svgParamName=attributes.getValue("name");
99  break;
100  case "se:Rule":
101  this.rule=true;
102  this.currentStyle=new StyleObject();
103  this.curcondlist=new LinkedList<>();
104  break;
105  case "UserStyle":
106  this.userstyle=true;
107  break;
108  case "se:Name":
109  this.name=true;
110  break;
111  case "ogc:PropertyName":
112  this.propertyName=true;
113  break;
114  case "ogc:Point":
115  this.literal=true;
116  break;
117  case "ogc:Literal":
118  this.literal=true;
119  break;
120  case "ogc:PropertyIsEqualTo":
121  this.condition=true;
122  this.gmlgeometry=true;
123  this.currentCondition.operator="PropertyIsEqualTo";
124  break;
125  case "ogc:PropertyIsNotEqualTo":
126  this.condition=true;
127  this.gmlgeometry=true;
128  this.currentCondition.operator="PropertyIsNotEqualTo";
129  break;
130  case "ogc:PropertyIsLessThan":
131  this.condition=true;
132  this.gmlgeometry=true;
133  this.currentCondition.operator="PropertyIsLessThan";
134  break;
135  case "ogc:PropertyIsLessThanOrEqualTo":
136  this.condition=true;
137  this.gmlgeometry=true;
138  this.currentCondition.operator="PropertyIsLessThanOrEqualTo";
139  break;
140  case "ogc:PropertyIsGreaterThan":
141  this.condition=true;
142  this.gmlgeometry=true;
143  this.currentCondition.operator="PropertyIsGreaterThan";
144  break;
145  case "ogc:PropertyIsGreaterThanOrEqualTo":
146  this.condition=true;
147  this.gmlgeometry=true;
148  this.currentCondition.operator="PropertyIsGreaterThanOrEqualTo";
149  break;
150  case "ogc:PropertyIsLike":
151  this.condition=true;
152  this.gmlgeometry=true;
153  this.currentCondition.operator="PropertyIsLike";
154  break;
155  case "ogc:PropertyIsNull":
156  this.condition=true;
157  this.gmlgeometry=true;
158  this.currentCondition.operator="PropertyIsNull";
159  break;
160  case "ogc:PropertyIsBetween":
161  this.condition=true;
162  this.gmlgeometry=true;
163  this.currentCondition.operator="PropertyIsBetween";
164  break;
165  case "ogc:Intersects":
166  this.condition=true;
167  this.gmlgeometry=true;
168  this.currentCondition.operator="Intersects";
169  break;
170  case "ogc:Equals":
171  this.gmlgeometry=true;
172  this.condition=true;
173  this.currentCondition.operator="Equals";
174  break;
175  case "ogc:Disjoint":
176  this.condition=true;
177  this.gmlgeometry=true;
178  this.currentCondition.operator="Disjoint";
179  break;
180  case "ogc:Touches":
181  this.condition=true;
182  this.gmlgeometry=true;
183  this.currentCondition.operator="Touches";
184  break;
185  case "ogc:Within":
186  this.condition=true;
187  this.gmlgeometry=true;
188  this.currentCondition.operator="Within";
189  break;
190  case "ogc:Overlaps":
191  this.condition=true;
192  this.gmlgeometry=true;
193  this.currentCondition.operator="Overlaps";
194  break;
195  case "ogc:Crosses":
196  this.condition=true;
197  this.gmlgeometry=true;
198  this.currentCondition.operator="Crosses";
199  break;
200  case "ogc:Contains":
201  this.condition=true;
202  this.gmlgeometry=true;
203  this.currentCondition.operator="Contains";
204  break;
205  case "ogc:DWithin":
206  this.condition=true;
207  this.gmlgeometry=true;
208  this.currentCondition.operator="DWithin";
209  break;
210  case "ogc:Beyond":
211  this.condition=true;
212  this.gmlgeometry=true;
213  this.currentCondition.operator="Beyond";
214  break;
215  case "ogc:BBOX":
216  this.condition=true;
217  this.gmlgeometry=true;
218  this.currentCondition.operator="BBOX";
219  break;
220  }
221  }
String operator
Definition: Condition.java:9
boolean gmlgeometry
Definition: SLDParser.java:45

References SLDParser.condition, SLDParser.filter, SLDParser.linestring, SLDParser.name, Condition.operator, SLDParser.point, SLDParser.polygon, and SLDParser.rule.

Member Data Documentation

◆ and

Boolean and =false
package

◆ condition

Boolean condition =false
package

◆ conditionName

String conditionName
package

◆ curcondlist

List<Condition> curcondlist
package

Referenced by SLDParser.endElement().

◆ currentCondition

Condition currentCondition
package

Referenced by SLDParser.endElement().

◆ currentStyle

StyleObject currentStyle
package

Referenced by SLDParser.endElement().

◆ featureTypeStyle

Boolean featureTypeStyle =false
package

◆ filter

Boolean filter =false
package

◆ gmlgeometry

boolean gmlgeometry
package

◆ linestring

Boolean linestring =false
package

◆ literal

boolean literal
package

◆ model

OntModel model
package

◆ name

Boolean name =false
package

◆ or

Boolean or =false
package

◆ point

Boolean point =false
package

◆ polygon

Boolean polygon =false
package

◆ propertyName

boolean propertyName
private

◆ rule

Boolean rule =false
package

◆ ruleName

String ruleName
package

◆ styleId

String styleId
private

Referenced by SLDParser.characters().

◆ styles

List<StyleObject> styles =new LinkedList<StyleObject>()
package

Referenced by SLDParser.main().

◆ svgInstance

Map<String,String> svgInstance =new HashMap<String,String>()
package

◆ svgParameter

Boolean svgParameter =false
package

Referenced by SLDParser.characters().

◆ svgParamName

String svgParamName
package

◆ userstyle

boolean userstyle
private

◆ wellKnownNameToSVG

Map<String,String> wellKnownNameToSVG =new TreeMap<>()
package