Skip to content

Commit

Permalink
fix: omit setting style title for sld 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jansule committed Feb 12, 2024
1 parent f58d53d commit 2f24602
Show file tree
Hide file tree
Showing 31 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion data/slds/1.0/multi_simplelineLabel.sld
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NamedLayer>
<Name>Simple Line and Point</Name>
<UserStyle>
<Title>Simple Line with label</Title>
<Name>Simple Line with label</Name>
<FeatureTypeStyle>
<Rule>
<LineSymbolizer>
Expand Down
1 change: 0 additions & 1 deletion data/slds/1.1/function_filter.sld
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<se:Name>Function Property</se:Name>
<UserStyle>
<se:Name>Function Property</se:Name>
<se:Title>Function Property</se:Title>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>Function Property Rule 0</se:Name>
Expand Down
1 change: 0 additions & 1 deletion data/slds/1.1/function_markSymbolizer.sld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<NamedLayer>
<se:Name>Function MarkSymbolizer</se:Name>
<UserStyle>
<se:Title>Function MarkSymbolizer</se:Title>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>Function MarkSymbolizer</se:Name>
Expand Down
1 change: 0 additions & 1 deletion data/slds/1.1/function_nested.sld
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<se:Name>OL Style</se:Name>
<UserStyle>
<se:Name>OL Style</se:Name>
<se:Title>OL Style</se:Title>
<FeatureTypeStyle>
<se:Rule>
<se:Name>OL Style Rule 0</se:Name>
Expand Down
2 changes: 1 addition & 1 deletion data/slds/1.1/multi_simplelineLabel.sld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<se:Name>Simple Line with label</se:Name>
<se:Name>Simple Line and Point</se:Name>
<UserStyle>
<se:Name>Simple Line with label</se:Name>
<se:FeatureTypeStyle>
Expand Down
1 change: 0 additions & 1 deletion data/slds/1.1/point_simplepoint.sld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<se:Name>Simple Point</se:Name>
<UserStyle>
<se:Name>Simple Point</se:Name>
<se:Title>Simple Point</se:Title>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name />
Expand Down
1 change: 0 additions & 1 deletion data/slds/1.1/point_simplepoint_displacement.sld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<se:Name>Simple Point</se:Name>
<UserStyle>
<se:Name>Simple Point</se:Name>
<se:Title>Simple Point</se:Title>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name />
Expand Down
2 changes: 1 addition & 1 deletion data/slds/1.1/point_simplepoint_oneline.sld
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><StyledLayerDescriptor version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se"><NamedLayer><se:Name>Simple Point</se:Name><UserStyle><se:Name>Simple Point</se:Name><se:Title>Simple Point</se:Title><se:FeatureTypeStyle><se:Rule><se:PointSymbolizer><se:Graphic><se:Mark><se:WellKnownName>circle</se:WellKnownName><se:Fill><se:SvgParameter name="fill">#FF0000</se:SvgParameter><se:SvgParameter name="fill-opacity">0.5</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#0000FF</se:SvgParameter><se:SvgParameter name="stroke-opacity">0.7</se:SvgParameter></se:Stroke></se:Mark><se:Size>6</se:Size></se:Graphic></se:PointSymbolizer></se:Rule></se:FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><StyledLayerDescriptor version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se"><NamedLayer><se:Name>Simple Point</se:Name><UserStyle><se:Name>Simple Point</se:Name><se:FeatureTypeStyle><se:Rule><se:PointSymbolizer><se:Graphic><se:Mark><se:WellKnownName>circle</se:WellKnownName><se:Fill><se:SvgParameter name="fill">#FF0000</se:SvgParameter><se:SvgParameter name="fill-opacity">0.5</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#0000FF</se:SvgParameter><se:SvgParameter name="stroke-opacity">0.7</se:SvgParameter></se:Stroke></se:Mark><se:Size>6</se:Size></se:Graphic></se:PointSymbolizer></se:Rule></se:FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>
1 change: 0 additions & 1 deletion data/slds/1.1/point_styledLabel_elementOrder.sld
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<se:Name>Styled Label</se:Name>
<UserStyle>
<se:Name>Styled Label</se:Name>
<se:Title>Styled Label</se:Title>
<se:FeatureTypeStyle>
<se:Rule>
<se:TextSymbolizer>
Expand Down
1 change: 0 additions & 1 deletion data/slds/1.1/unsupported_properties.sld
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<se:Name>OL Style</se:Name>
<UserStyle>
<se:Name>OL Style</se:Name>
<se:Title>OL Style</se:Title>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>OL Style Rule 0</se:Name>
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/burg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const burg: Style = {
name: 'A small red flag',
name: 'burg',
rules: [
{
name: 'Red flag',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/capitals.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Capital cities',
name: 'capitals',
rules: [
{
name: 'Capitals',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/default_generic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Generic',
name: 'generic',
rules: [{
name: 'Opaque Raster',
filter: ['==', {
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/default_line.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Blue Line',
name: 'default_line',
rules: [
{
name: 'Blue Line',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/default_line2.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Green line',
name: 'Default Line',
rules: [
{
name: 'Green Line',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/default_point.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Red Square Point',
name: 'default_point',
rules: [
{
name: 'Red Square Point',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/default_polygon.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/dem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Simple DEM style',
name: 'dem',
rules: [
{
name: '',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/giant_polygon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Border-less gray fill',
name: 'area landmarks',
rules: [
{
name: '',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/grass_poly.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Grass fill',
name: 'grass',
rules: [
{
name: 'Grass',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/green.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Green polygon',
name: 'green',
rules: [
{
name: '',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/poi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Points of interest',
name: 'poi',
rules: [
{
name: '',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/pophatch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Population in the United States',
name: 'population',
rules: [
{
name: '< 2M',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/popshade.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Population in the United States',
name: 'population',
rules: [
{
name: '< 2M',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/rain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Rain distribution',
name: 'rain',
rules: [
{
name: '',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/raster.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Opaque Raster',
name: 'default_raster',
rules: [
{
name: 'Opaque Raster',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/restricted.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Red, translucent style',
name: 'Restricted areas',
rules: [
{
name: 'RedFill RedOutline',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/simpleRoads.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Red Line',
name: 'Simple Roads',
rules: [
{
name: 'Roads',
Expand Down
2 changes: 1 addition & 1 deletion data/styles/geoserver/simple_streams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Style } from 'geostyler-style';

const style: Style = {
name: 'Streams',
name: 'Simple Streams',
rules: [
{
name: 'Blue Line',
Expand Down
2 changes: 1 addition & 1 deletion src/SldStyleParser.geoserver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('SldStyleParser implements StyleParser', () => {
let styleParser: SldStyleParser;

beforeEach(() => {
styleParser = new SldStyleParser();
styleParser = new SldStyleParser({sldVersion: '1.0.0'});
});

describe('#readStyle', () => {
Expand Down
23 changes: 15 additions & 8 deletions src/SldStyleParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class SldStyleParser implements StyleParser<string> {
* @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 : '';
Expand Down Expand Up @@ -1228,6 +1228,19 @@ export class SldStyleParser implements StyleParser<string> {
'@_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': '' }],
':@': {
Expand All @@ -1240,13 +1253,7 @@ export class SldStyleParser implements StyleParser<string> {
NamedLayer: [{
[Name]: [{ '#text': geoStylerStyle.name || '' }]
}, {
UserStyle: [{
[Name]: [{ '#text': geoStylerStyle.name || '' }]
}, {
[Title]: [{ '#text': geoStylerStyle.name || '' }]
}, {
[FeatureTypeStyle]: featureTypeStyle
}]
UserStyle: userStyle
}]
}],
':@': attributes
Expand Down

0 comments on commit 2f24602

Please sign in to comment.