diff --git a/data/slds/geoserver/Lakes.sld b/data/slds/geoserver/Lakes.sld new file mode 100644 index 00000000..91c069ca --- /dev/null +++ b/data/slds/geoserver/Lakes.sld @@ -0,0 +1,48 @@ + + + + Blue lake + + + Blue lake + A blue fill, solid black outline style + + + name + + + + #4040C0 + + + 1.0 + + + + + #000000 + + + butt + + + miter + + + 1 + + + 1 + + + 0 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/NamedPlaces.sld b/data/slds/geoserver/NamedPlaces.sld new file mode 100644 index 00000000..0f052b6d --- /dev/null +++ b/data/slds/geoserver/NamedPlaces.sld @@ -0,0 +1,61 @@ + + + Default Styler + + + Default Styler + + + Feature + + ashton + Ashton + + + NAME + Ashton + + + + + + #AAAAAA + + + + + #000000 + + + + + + goose_island + Goose Island + + + NAME + Goose Island + + + + + + #FFFFFF + + + + + #000000 + + + + + + + + diff --git a/data/slds/geoserver/burg.sld b/data/slds/geoserver/burg.sld new file mode 100644 index 00000000..51846aa8 --- /dev/null +++ b/data/slds/geoserver/burg.sld @@ -0,0 +1,30 @@ + + + + redflag + + burg + A small red flag + A sample of how to use an SVG based symbolizer + + + + Red flag + + + + + image/svg+xml + + + 20 + + + + + + + + diff --git a/data/slds/geoserver/capitals.sld b/data/slds/geoserver/capitals.sld new file mode 100644 index 00000000..30f525fa --- /dev/null +++ b/data/slds/geoserver/capitals.sld @@ -0,0 +1,43 @@ + + + + capitals + + capitals + Capital cities + + + Capitals + + + + circle + + + #FFFFFF + + + + + #000000 + + + 2 + + + + + 1.0 + + + 6 + + + + + + + + diff --git a/data/slds/geoserver/default_generic.sld b/data/slds/geoserver/default_generic.sld new file mode 100644 index 00000000..734b336b --- /dev/null +++ b/data/slds/geoserver/default_generic.sld @@ -0,0 +1,86 @@ + + + + generic + + Generic + Generic style + + + raster + Opaque Raster + + + + true + + + + 1.0 + + + + Polygon + Grey Polygon + + + + + + 2 + + + + + #AAAAAA + + + #000000 + 1 + + + + + Line + Blue Line + + + + + + 1 + + + + + #0000FF + 1 + + + + + point + Red Square Point + + + + + square + + #FF0000 + + + 6 + + + + first + + + + diff --git a/data/slds/geoserver/default_line.sld b/data/slds/geoserver/default_line.sld new file mode 100644 index 00000000..f80d632d --- /dev/null +++ b/data/slds/geoserver/default_line.sld @@ -0,0 +1,32 @@ + + + + + default_line + + + Blue Line + A sample style that draws a line + + + + + rule1 + Blue Line + A solid blue line with a 1 pixel width + + + #0000FF + + + + + + + + diff --git a/data/slds/geoserver/default_line2.sld b/data/slds/geoserver/default_line2.sld new file mode 100644 index 00000000..de59a9ea --- /dev/null +++ b/data/slds/geoserver/default_line2.sld @@ -0,0 +1,40 @@ + + + + + + Default Line + + + + Green line + A sample style that just prints out a green line + + + + + + + Rule 1 + Green Line + A green line with a 2 pixel width + + + + + #319738 + 2 + + + + + + + + + diff --git a/data/slds/geoserver/default_point.sld b/data/slds/geoserver/default_point.sld new file mode 100644 index 00000000..b8ba3210 --- /dev/null +++ b/data/slds/geoserver/default_point.sld @@ -0,0 +1,38 @@ + + + + + default_point + + + Red Square Point + A sample style that draws a red square point + + + + + rule1 + Red Square Point + A 6 pixel square with a red fill and no stroke + + + + square + + #FF0000 + + + 6 + + + + + + + + diff --git a/data/slds/geoserver/default_polygon.sld b/data/slds/geoserver/default_polygon.sld new file mode 100644 index 00000000..531ef9fc --- /dev/null +++ b/data/slds/geoserver/default_polygon.sld @@ -0,0 +1,35 @@ + + + + + default_polygon + + + Default Polygon + A sample style that draws a polygon + + + + + rule1 + Gray Polygon with Black Outline + A polygon with a gray fill and a 1 pixel black outline + + + #AAAAAA + + + #000000 + 1 + + + + + + + diff --git a/data/slds/geoserver/dem.sld b/data/slds/geoserver/dem.sld new file mode 100644 index 00000000..9b61775e --- /dev/null +++ b/data/slds/geoserver/dem.sld @@ -0,0 +1,28 @@ + + + + gtopo + + dem + Simple DEM style + Classic elevation color progression + + + + 1.0 + + + + + + + + + + + + + + diff --git a/data/slds/geoserver/giant_polygon.sld b/data/slds/geoserver/giant_polygon.sld new file mode 100644 index 00000000..8235f137 --- /dev/null +++ b/data/slds/geoserver/giant_polygon.sld @@ -0,0 +1,26 @@ + + + + area landmarks + + Border-less gray fill + Light gray polygon fill without a border + + + + + + #DDDDDD + + + 1.0 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/grass_poly.sld b/data/slds/geoserver/grass_poly.sld new file mode 100644 index 00000000..2dd39218 --- /dev/null +++ b/data/slds/geoserver/grass_poly.sld @@ -0,0 +1,42 @@ + + + + + Grass + + + grass + Grass fill + A style filling polygons with a grass theme coming from a PNG file + + + Grass + Grass style that uses a texture + + + + + + + image/png + + + 1.0 + + + + + + + #FF0000 + 1 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/green.sld b/data/slds/geoserver/green.sld new file mode 100644 index 00000000..a1118998 --- /dev/null +++ b/data/slds/geoserver/green.sld @@ -0,0 +1,23 @@ + + + + green + + green + Green polygon + Green fill with black outline + + + + + #66FF66 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/poi.sld b/data/slds/geoserver/poi.sld new file mode 100644 index 00000000..d062ed46 --- /dev/null +++ b/data/slds/geoserver/poi.sld @@ -0,0 +1,77 @@ + + + + poi + + poi + Points of interest + Manhattan points of interest + + + + + + circle + + #FF0000 + 1.0 + + + 11 + + + + + + circle + + #EDE513 + 1.0 + + + 7 + + + + + 32000 + + + + Arial + Bold + 14 + + + + + 0.5 + 0.5 + + + 0 + -15 + + + + + + 2 + + + #FFFFFF + + + + #000000 + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/poly_landmarks.sld b/data/slds/geoserver/poly_landmarks.sld new file mode 100644 index 00000000..6dbec344 --- /dev/null +++ b/data/slds/geoserver/poly_landmarks.sld @@ -0,0 +1,205 @@ + + + + area landmarks + + + + + Feature + + + + + + + + + + CFCC + D82 + + + CFCC + D83 + + + + CFCC + D84 + + + + CFCC + D85 + + + + + + + + #B4DFB4 + + + 1.0 + + + + + #88B588 + + + + + + + + + + + + + CFCC + H11 + + + CFCC + H31 + + + + CFCC + H41 + + + + CFCC + H51 + + + + + + + + #8AA9D1 + + + 1.0 + + + + + #436C91 + + + + + + + + + + + + + + + + + CFCC + D31 + + + CFCC + D43 + + + + CFCC + D64 + + + + CFCC + D65 + + + + CFCC + D90 + + + + CFCC + E23 + + + + + + + + #A5A5A5 + + + 1.0 + + + + + #6E6E6E + + + + + + + + + + + + + + Times New Roman + Normal + 14 + bold + + + + + 0.5 + 0.5 + + + + + + 2 + + + #FDE5A5 + 0.75 + + + + + #000000 + + true + 100 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/pophatch.sld b/data/slds/geoserver/pophatch.sld new file mode 100644 index 00000000..bdd987a4 --- /dev/null +++ b/data/slds/geoserver/pophatch.sld @@ -0,0 +1,127 @@ + + + + USA states population + + population + Population in the United States + A sample filter that filters the United States into three + categories of population, drawn in different colors + + + < 2M + + + PERSONS + 2000000 + + + + + + + + shape://slash + + 0xAAAAAA + + + 16 + + + + + + + 2M - 4M + + + PERSONS + + 2000000 + + + 4000000 + + + + + + + + + shape://slash + + 0xAAAAAA + + + 8 + + + + + + + > 4M + + + + PERSONS + 4000000 + + + + + + + + shape://slash + + 0xAAAAAA + + + 4 + + + + + + + Boundary + + + + + + + Times New Roman + Normal + 14 + + + + + 0.5 + 0.5 + + + + + 2 + + 0xFFFFFF + + + + + + + + diff --git a/data/slds/geoserver/popshade.sld b/data/slds/geoserver/popshade.sld new file mode 100644 index 00000000..ada67303 --- /dev/null +++ b/data/slds/geoserver/popshade.sld @@ -0,0 +1,96 @@ + + + + USA states population + + population + Population in the United States + A sample filter that filters the United States into three + categories of population, drawn in different colors + + + < 2M + + + PERSONS + 2000000 + + + + + + #4DFF4D + 0.7 + + + + + 2M - 4M + + + PERSONS + + 2000000 + + + 4000000 + + + + + + + #FF4D4D + 0.7 + + + + + > 4M + + + + PERSONS + 4000000 + + + + + + #4D4DFF + 0.7 + + + + + Boundary + + + 0.2 + + + + + + Times New Roman + Normal + 14 + + + + + 0.5 + 0.5 + + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/rain.sld b/data/slds/geoserver/rain.sld new file mode 100644 index 00000000..1d04a5fd --- /dev/null +++ b/data/slds/geoserver/rain.sld @@ -0,0 +1,25 @@ + + + + rain + + rain + Rain distribution + + + + 1.0 + + + + + + + + + + + + diff --git a/data/slds/geoserver/raster.sld b/data/slds/geoserver/raster.sld new file mode 100644 index 00000000..a2dcf3b9 --- /dev/null +++ b/data/slds/geoserver/raster.sld @@ -0,0 +1,29 @@ + + + + + default_raster + + + Opaque Raster + A sample style that draws a raster, good for displaying imagery + + + + + rule1 + Opaque Raster + A raster with 100% opacity + + 1.0 + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/restricted.sld b/data/slds/geoserver/restricted.sld new file mode 100644 index 00000000..a0fd1b52 --- /dev/null +++ b/data/slds/geoserver/restricted.sld @@ -0,0 +1,33 @@ + + + + Restricted areas + + Red, translucent style + A sample style that just prints out a transparent red interior with a red outline + + + + + RedFill RedOutline + 70% opaque red fill with a darker 1px red outline + + + + + #FF0000 + 0.7 + + + #AA0000 + 1 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/simpleRoads.sld b/data/slds/geoserver/simpleRoads.sld new file mode 100644 index 00000000..1b30ccc9 --- /dev/null +++ b/data/slds/geoserver/simpleRoads.sld @@ -0,0 +1,28 @@ + + + + Simple Roads + + + Red Line + Light red line, 2px wide + + + Roads + + + + #AA3333 + + + 2 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/simple_streams.sld b/data/slds/geoserver/simple_streams.sld new file mode 100644 index 00000000..522fde2a --- /dev/null +++ b/data/slds/geoserver/simple_streams.sld @@ -0,0 +1,29 @@ + + + + Simple Streams + + + Streams + Blue lines, 2px wide + + Feature + + Blue Line + + + + #003EBA + + + 2 + + + + + + + + \ No newline at end of file diff --git a/data/slds/geoserver/tiger_roads.sld b/data/slds/geoserver/tiger_roads.sld new file mode 100644 index 00000000..87f30bee --- /dev/null +++ b/data/slds/geoserver/tiger_roads.sld @@ -0,0 +1,95 @@ + + + area landmarks + + + Feature + + 32000 + + + + #666666 + + + 2 + + + + + + + 32000 + + + + #666666 + + + 7 + + + + + + + Feature + + 32000 + + + + #FFFFFF + + + 4 + + + + + + + 32000 + + + + + Times New Roman + Normal + 14 + bold + + + + + + + + + 2 + + + #FFFFFF + 0.85 + + + + + #000000 + + + true + + + + + + + + diff --git a/data/styles/geoserver/burg.ts b/data/styles/geoserver/burg.ts new file mode 100644 index 00000000..1a3f0400 --- /dev/null +++ b/data/styles/geoserver/burg.ts @@ -0,0 +1,18 @@ +import { Style } from 'geostyler-style'; + +const burg: Style = { + 'name': 'A small red flag', + 'rules': [ + { + 'name': 'Red flag', + 'symbolizers': [ + { + 'kind': 'Icon', + 'image': 'burg02.svg' + } + ] + } + ] +}; + +export default burg; diff --git a/data/styles/geoserver/capitals.ts b/data/styles/geoserver/capitals.ts new file mode 100644 index 00000000..34ce7f77 --- /dev/null +++ b/data/styles/geoserver/capitals.ts @@ -0,0 +1,21 @@ +import { Style } from 'geostyler-style'; + +const style: Style = { + 'name': 'Capital cities', + 'rules': [ + { + 'name': 'Capitals', + 'symbolizers': [ + { + 'kind': 'Mark', + 'wellKnownName': 'circle', + 'color': '#FFFFFF', + 'strokeColor':'#000000', + 'strokeWidth': 2 + } + ] + } + ] +}; + +export default style; diff --git a/data/styles/geoserver/pophatch.ts b/data/styles/geoserver/pophatch.ts new file mode 100644 index 00000000..6136a77f --- /dev/null +++ b/data/styles/geoserver/pophatch.ts @@ -0,0 +1,91 @@ +import { Style } from 'geostyler-style'; + +const style: Style = { + 'name': 'Population in the United States', + 'rules': [ + { + 'name': '< 2M', + 'filter': [ + '<', + 'PERSONS', + '2000000' + ], + 'symbolizers': [ + { + 'kind': 'Fill', + 'graphicFill': { + 'kind': 'Mark', + 'wellKnownName': 'shape://slash', + 'radius': 8, + 'strokeColor': '0xAAAAAA' + }, + 'opacity': 0 + } + ] + }, + { + 'name': '2M - 4M', + 'filter': [ + '<=x<=', + 'PERSONS', + 2000000, + 4000000 + ], + 'symbolizers': [ + { + 'kind': 'Fill', + 'graphicFill': { + 'kind': 'Mark', + 'wellKnownName': 'shape://slash', + 'radius': 4, + 'strokeColor': '0xAAAAAA' + }, + 'opacity': 0 + } + ] + }, + { + 'name': '> 4M', + 'filter': [ + '>', + 'PERSONS', + '4000000' + ], + 'symbolizers': [ + { + 'kind': 'Fill', + 'graphicFill': { + 'kind': 'Mark', + 'wellKnownName': 'shape://slash', + 'radius': 2, + 'strokeColor': '0xAAAAAA' + }, + 'opacity': 0 + } + ] + }, + { + 'name': 'Boundary', + 'symbolizers': [ + { + 'kind': 'Line' + }, + { + 'kind': 'Text', + 'label': '{{STATE_ABBR}}', + 'color': '#000000', + 'opacity': 1, + 'haloWidth': 2, + 'haloColor': '0xFFFFFF', + 'font': [ + 'Times New Roman' + ], + 'fontStyle': 'normal', + 'size': 14 + } + ] + } + ] +}; + +export default style; diff --git a/src/SldStyleParser.geoserver.spec.ts b/src/SldStyleParser.geoserver.spec.ts new file mode 100644 index 00000000..dfbf5cb2 --- /dev/null +++ b/src/SldStyleParser.geoserver.spec.ts @@ -0,0 +1,65 @@ +/* eslint camelcase: 0 */ +import fs from 'fs'; +import SldStyleParser from './SldStyleParser'; + +import burg from '../data/styles/geoserver/burg'; +import capitals from '../data/styles/geoserver/capitals'; +import pophatch from '../data/styles/geoserver/pophatch'; + +it('SldStyleParser is defined', () => { + expect(SldStyleParser).toBeDefined(); +}); + +describe('SldStyleParser implements StyleParser', () => { + let styleParser: SldStyleParser; + + beforeEach(() => { + styleParser = new SldStyleParser(); + }); + + describe('#readStyle', () => { + it('can read the geoserver burg.sld', async () => { + const sld = fs.readFileSync('./data/slds/geoserver/burg.sld', 'utf8'); + const { output: geoStylerStyle} = await styleParser.readStyle(sld); + expect(geoStylerStyle).toBeDefined(); + expect(geoStylerStyle).toEqual(burg); + }); + // it('can read the geoserver captials.sld', async () => { + // const sld = fs.readFileSync('./data/slds/geoserver/capitals.sld', 'utf8'); + // const { output: geoStylerStyle} = await styleParser.readStyle(sld); + // expect(geoStylerStyle).toBeDefined(); + // expect(geoStylerStyle).toEqual(capitals); + // }); + it('can read the geoserver pophatch.sld', async () => { + const sld = fs.readFileSync('./data/slds/geoserver/pophatch.sld', 'utf8'); + const { output: geoStylerStyle } = await styleParser.readStyle(sld); + expect(geoStylerStyle).toBeDefined(); + expect(geoStylerStyle).toEqual(pophatch); + }); + }); + + // describe('#writeStyle', () => { + // it('is defined', () => { + // expect(styleParser.writeStyle).toBeDefined(); + // }); + + // it('can write a SLD PointSymbolizer', async () => { + // const { + // output: sldString, + // errors, + // warnings, + // unsupportedProperties + // } = await styleParser.writeStyle(burg); + // expect(sldString).toBeDefined(); + // expect(errors).toBeUndefined(); + // expect(warnings).toBeUndefined(); + // expect(unsupportedProperties).toBeUndefined(); + // // As string comparison between two XML-Strings is awkward and nonsens + // // we read it again and compare the json input with the parser output + // const { output: readStyle} = await styleParser.readStyle(sldString); + // expect(readStyle).toEqual(burg); + // }); + + // }); + +});