From 2f246023ac0abe961c02270bcb45af3772c6da5c Mon Sep 17 00:00:00 2001 From: jansule Date: Mon, 12 Feb 2024 17:11:18 +0100 Subject: [PATCH] fix: omit setting style title for sld 1.1.0 --- data/slds/1.0/multi_simplelineLabel.sld | 2 +- data/slds/1.1/function_filter.sld | 1 - data/slds/1.1/function_markSymbolizer.sld | 1 - data/slds/1.1/function_nested.sld | 1 - data/slds/1.1/multi_simplelineLabel.sld | 2 +- data/slds/1.1/point_simplepoint.sld | 1 - .../1.1/point_simplepoint_displacement.sld | 1 - data/slds/1.1/point_simplepoint_oneline.sld | 2 +- .../1.1/point_styledLabel_elementOrder.sld | 1 - data/slds/1.1/unsupported_properties.sld | 1 - data/styles/geoserver/burg.ts | 2 +- data/styles/geoserver/capitals.ts | 2 +- data/styles/geoserver/default_generic.ts | 2 +- data/styles/geoserver/default_line.ts | 2 +- data/styles/geoserver/default_line2.ts | 2 +- data/styles/geoserver/default_point.ts | 2 +- data/styles/geoserver/default_polygon.ts | 2 +- data/styles/geoserver/dem.ts | 2 +- data/styles/geoserver/giant_polygon.ts | 2 +- data/styles/geoserver/grass_poly.ts | 2 +- data/styles/geoserver/green.ts | 2 +- data/styles/geoserver/poi.ts | 2 +- data/styles/geoserver/pophatch.ts | 2 +- data/styles/geoserver/popshade.ts | 2 +- data/styles/geoserver/rain.ts | 2 +- data/styles/geoserver/raster.ts | 2 +- data/styles/geoserver/restricted.ts | 2 +- data/styles/geoserver/simpleRoads.ts | 2 +- data/styles/geoserver/simple_streams.ts | 2 +- src/SldStyleParser.geoserver.spec.ts | 2 +- src/SldStyleParser.ts | 23 ++++++++++++------- 31 files changed, 38 insertions(+), 38 deletions(-) diff --git a/data/slds/1.0/multi_simplelineLabel.sld b/data/slds/1.0/multi_simplelineLabel.sld index 5f32dc4d..e002d007 100644 --- a/data/slds/1.0/multi_simplelineLabel.sld +++ b/data/slds/1.0/multi_simplelineLabel.sld @@ -8,7 +8,7 @@ Simple Line and Point - Simple Line with label + Simple Line with label diff --git a/data/slds/1.1/function_filter.sld b/data/slds/1.1/function_filter.sld index 5a3c557d..813a971b 100644 --- a/data/slds/1.1/function_filter.sld +++ b/data/slds/1.1/function_filter.sld @@ -12,7 +12,6 @@ Function Property Function Property - Function Property Function Property Rule 0 diff --git a/data/slds/1.1/function_markSymbolizer.sld b/data/slds/1.1/function_markSymbolizer.sld index ffe3be15..75f126ae 100644 --- a/data/slds/1.1/function_markSymbolizer.sld +++ b/data/slds/1.1/function_markSymbolizer.sld @@ -11,7 +11,6 @@ Function MarkSymbolizer - Function MarkSymbolizer Function MarkSymbolizer diff --git a/data/slds/1.1/function_nested.sld b/data/slds/1.1/function_nested.sld index fd163bb5..ea61cba4 100644 --- a/data/slds/1.1/function_nested.sld +++ b/data/slds/1.1/function_nested.sld @@ -12,7 +12,6 @@ OL Style OL Style - OL Style OL Style Rule 0 diff --git a/data/slds/1.1/multi_simplelineLabel.sld b/data/slds/1.1/multi_simplelineLabel.sld index 8246183f..e0952189 100644 --- a/data/slds/1.1/multi_simplelineLabel.sld +++ b/data/slds/1.1/multi_simplelineLabel.sld @@ -1,7 +1,7 @@ - Simple Line with label + Simple Line and Point Simple Line with label diff --git a/data/slds/1.1/point_simplepoint.sld b/data/slds/1.1/point_simplepoint.sld index d3ad84a4..42dff9d3 100644 --- a/data/slds/1.1/point_simplepoint.sld +++ b/data/slds/1.1/point_simplepoint.sld @@ -11,7 +11,6 @@ Simple Point Simple Point - Simple Point diff --git a/data/slds/1.1/point_simplepoint_displacement.sld b/data/slds/1.1/point_simplepoint_displacement.sld index 531ac444..9c54c322 100644 --- a/data/slds/1.1/point_simplepoint_displacement.sld +++ b/data/slds/1.1/point_simplepoint_displacement.sld @@ -11,7 +11,6 @@ Simple Point Simple Point - Simple Point diff --git a/data/slds/1.1/point_simplepoint_oneline.sld b/data/slds/1.1/point_simplepoint_oneline.sld index 65bd0402..7cd081ec 100644 --- a/data/slds/1.1/point_simplepoint_oneline.sld +++ b/data/slds/1.1/point_simplepoint_oneline.sld @@ -1 +1 @@ -Simple PointSimple PointSimple Pointcircle#FF00000.5#0000FF0.76 +Simple PointSimple Pointcircle#FF00000.5#0000FF0.76 diff --git a/data/slds/1.1/point_styledLabel_elementOrder.sld b/data/slds/1.1/point_styledLabel_elementOrder.sld index 698a1d0d..b2c38e8f 100644 --- a/data/slds/1.1/point_styledLabel_elementOrder.sld +++ b/data/slds/1.1/point_styledLabel_elementOrder.sld @@ -4,7 +4,6 @@ Styled Label Styled Label - Styled Label diff --git a/data/slds/1.1/unsupported_properties.sld b/data/slds/1.1/unsupported_properties.sld index 48726430..38cc4a00 100644 --- a/data/slds/1.1/unsupported_properties.sld +++ b/data/slds/1.1/unsupported_properties.sld @@ -4,7 +4,6 @@ OL Style OL Style - OL Style OL Style Rule 0 diff --git a/data/styles/geoserver/burg.ts b/data/styles/geoserver/burg.ts index 29351665..531ed67e 100644 --- a/data/styles/geoserver/burg.ts +++ b/data/styles/geoserver/burg.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const burg: Style = { - name: 'A small red flag', + name: 'burg', rules: [ { name: 'Red flag', diff --git a/data/styles/geoserver/capitals.ts b/data/styles/geoserver/capitals.ts index 36fbb5a2..64bd8664 100644 --- a/data/styles/geoserver/capitals.ts +++ b/data/styles/geoserver/capitals.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Capital cities', + name: 'capitals', rules: [ { name: 'Capitals', diff --git a/data/styles/geoserver/default_generic.ts b/data/styles/geoserver/default_generic.ts index 0f90bc35..218b5d32 100644 --- a/data/styles/geoserver/default_generic.ts +++ b/data/styles/geoserver/default_generic.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Generic', + name: 'generic', rules: [{ name: 'Opaque Raster', filter: ['==', { diff --git a/data/styles/geoserver/default_line.ts b/data/styles/geoserver/default_line.ts index fd5859fd..da655b08 100644 --- a/data/styles/geoserver/default_line.ts +++ b/data/styles/geoserver/default_line.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Blue Line', + name: 'default_line', rules: [ { name: 'Blue Line', diff --git a/data/styles/geoserver/default_line2.ts b/data/styles/geoserver/default_line2.ts index 9d340600..5290b784 100644 --- a/data/styles/geoserver/default_line2.ts +++ b/data/styles/geoserver/default_line2.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Green line', + name: 'Default Line', rules: [ { name: 'Green Line', diff --git a/data/styles/geoserver/default_point.ts b/data/styles/geoserver/default_point.ts index e92db726..c5cf2f86 100644 --- a/data/styles/geoserver/default_point.ts +++ b/data/styles/geoserver/default_point.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Red Square Point', + name: 'default_point', rules: [ { name: 'Red Square Point', diff --git a/data/styles/geoserver/default_polygon.ts b/data/styles/geoserver/default_polygon.ts index 8c11b602..251115fb 100644 --- a/data/styles/geoserver/default_polygon.ts +++ b/data/styles/geoserver/default_polygon.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Default Polygon', + name: 'default_polygon', rules: [ { name: 'Gray Polygon with Black Outline', diff --git a/data/styles/geoserver/dem.ts b/data/styles/geoserver/dem.ts index e35afe32..7c31b10c 100644 --- a/data/styles/geoserver/dem.ts +++ b/data/styles/geoserver/dem.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Simple DEM style', + name: 'dem', rules: [ { name: '', diff --git a/data/styles/geoserver/giant_polygon.ts b/data/styles/geoserver/giant_polygon.ts index 7996f9bb..d3bdfc38 100644 --- a/data/styles/geoserver/giant_polygon.ts +++ b/data/styles/geoserver/giant_polygon.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Border-less gray fill', + name: 'area landmarks', rules: [ { name: '', diff --git a/data/styles/geoserver/grass_poly.ts b/data/styles/geoserver/grass_poly.ts index 5f8326f7..bf2b47cc 100644 --- a/data/styles/geoserver/grass_poly.ts +++ b/data/styles/geoserver/grass_poly.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Grass fill', + name: 'grass', rules: [ { name: 'Grass', diff --git a/data/styles/geoserver/green.ts b/data/styles/geoserver/green.ts index fae475e7..0c81202c 100644 --- a/data/styles/geoserver/green.ts +++ b/data/styles/geoserver/green.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Green polygon', + name: 'green', rules: [ { name: '', diff --git a/data/styles/geoserver/poi.ts b/data/styles/geoserver/poi.ts index e2c53fa4..a2d59d6f 100644 --- a/data/styles/geoserver/poi.ts +++ b/data/styles/geoserver/poi.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Points of interest', + name: 'poi', rules: [ { name: '', diff --git a/data/styles/geoserver/pophatch.ts b/data/styles/geoserver/pophatch.ts index 7ee1530a..6143c973 100644 --- a/data/styles/geoserver/pophatch.ts +++ b/data/styles/geoserver/pophatch.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Population in the United States', + name: 'population', rules: [ { name: '< 2M', diff --git a/data/styles/geoserver/popshade.ts b/data/styles/geoserver/popshade.ts index 63ce8f7e..c5749c22 100644 --- a/data/styles/geoserver/popshade.ts +++ b/data/styles/geoserver/popshade.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Population in the United States', + name: 'population', rules: [ { name: '< 2M', diff --git a/data/styles/geoserver/rain.ts b/data/styles/geoserver/rain.ts index 33e327fd..87d7f0f7 100644 --- a/data/styles/geoserver/rain.ts +++ b/data/styles/geoserver/rain.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Rain distribution', + name: 'rain', rules: [ { name: '', diff --git a/data/styles/geoserver/raster.ts b/data/styles/geoserver/raster.ts index 6977588f..702a95fb 100644 --- a/data/styles/geoserver/raster.ts +++ b/data/styles/geoserver/raster.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Opaque Raster', + name: 'default_raster', rules: [ { name: 'Opaque Raster', diff --git a/data/styles/geoserver/restricted.ts b/data/styles/geoserver/restricted.ts index 6d48fc3b..30673385 100644 --- a/data/styles/geoserver/restricted.ts +++ b/data/styles/geoserver/restricted.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Red, translucent style', + name: 'Restricted areas', rules: [ { name: 'RedFill RedOutline', diff --git a/data/styles/geoserver/simpleRoads.ts b/data/styles/geoserver/simpleRoads.ts index dddb40a0..ce120dca 100644 --- a/data/styles/geoserver/simpleRoads.ts +++ b/data/styles/geoserver/simpleRoads.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Red Line', + name: 'Simple Roads', rules: [ { name: 'Roads', diff --git a/data/styles/geoserver/simple_streams.ts b/data/styles/geoserver/simple_streams.ts index e12f7a31..1b3194e8 100644 --- a/data/styles/geoserver/simple_streams.ts +++ b/data/styles/geoserver/simple_streams.ts @@ -1,7 +1,7 @@ import { Style } from 'geostyler-style'; const style: Style = { - name: 'Streams', + name: 'Simple Streams', rules: [ { name: 'Blue Line', diff --git a/src/SldStyleParser.geoserver.spec.ts b/src/SldStyleParser.geoserver.spec.ts index f9da264d..fe157b7e 100644 --- a/src/SldStyleParser.geoserver.spec.ts +++ b/src/SldStyleParser.geoserver.spec.ts @@ -36,7 +36,7 @@ describe('SldStyleParser implements StyleParser', () => { let styleParser: SldStyleParser; beforeEach(() => { - styleParser = new SldStyleParser(); + styleParser = new SldStyleParser({sldVersion: '1.0.0'}); }); describe('#readStyle', () => { diff --git a/src/SldStyleParser.ts b/src/SldStyleParser.ts index 19809e91..284e03f9 100644 --- a/src/SldStyleParser.ts +++ b/src/SldStyleParser.ts @@ -401,7 +401,7 @@ export class SldStyleParser implements StyleParser { * @return The name to be used for the GeoStyler Style Style */ getStyleNameFromSldObject(sldObject: any): string { - const userStyleTitle = get(sldObject, 'StyledLayerDescriptor.NamedLayer[0].UserStyle.Title.#text'); + const userStyleTitle = get(sldObject, 'StyledLayerDescriptor.NamedLayer[0].UserStyle.Name.#text'); const namedLayerName = get(sldObject, 'StyledLayerDescriptor.NamedLayer.Name.#text'); return userStyleTitle ? userStyleTitle : namedLayerName ? namedLayerName : ''; @@ -1228,6 +1228,19 @@ export class SldStyleParser implements StyleParser { '@_xmlns:se': 'http://www.opengis.net/se' }; + const userStyle = []; + userStyle.push({ + [Name]: [{ '#text': geoStylerStyle.name || '' }] + }); + if (this.sldVersion === '1.0.0') { + userStyle.push({ + [Title]: [{ '#text': geoStylerStyle.name || '' }] + }); + } + userStyle.push({ + [FeatureTypeStyle]: featureTypeStyle + }); + return [{ '?xml': [{ '#text': '' }], ':@': { @@ -1240,13 +1253,7 @@ export class SldStyleParser implements StyleParser { NamedLayer: [{ [Name]: [{ '#text': geoStylerStyle.name || '' }] }, { - UserStyle: [{ - [Name]: [{ '#text': geoStylerStyle.name || '' }] - }, { - [Title]: [{ '#text': geoStylerStyle.name || '' }] - }, { - [FeatureTypeStyle]: featureTypeStyle - }] + UserStyle: userStyle }] }], ':@': attributes