7.3.0 • Published 5 months ago

geostyler-sld-parser v7.3.0

Weekly downloads
473
License
BSD-2-Clause
Repository
github
Last release
5 months ago

geostyler-sld-parser

Coverage Status License npm version

GeoStyler Style Parser implementation for Styled Layer Descriptor (SLD)

How to use

ES6:

import SLDParser from 'geostyler-sld-parser';
import { Style } from 'geostyler-style';

const pointSimplePoint = {
  name: 'My Style',
  rules: [
    {
      name: 'My Rule',
      symbolizers: [
        {
          kind: 'Mark',
          wellKnownName: 'circle',
          color: '#FF0000',
          radius: 6
        }
      ]
    }
  ]
};

const parser = new SLDParser();

parser
  .writeStyle(pointSimplePoint)
  .then(({output: sld}) => console.log(sld))
  .catch(error => console.log(error));


// Read style from string
let sldString = '<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0"> <sld:NamedLayer> <sld:Name>Default Styler</sld:Name> <sld:UserStyle> <sld:Name>Default Styler</sld:Name> <sld:Title>Gravel_Program_2016</sld:Title> <sld:FeatureTypeStyle> <sld:Name>name</sld:Name> <sld:Rule> <sld:MinScaleDenominator>1.0</sld:MinScaleDenominator> <sld:MaxScaleDenominator>1.0E7</sld:MaxScaleDenominator> <sld:LineSymbolizer> <sld:Stroke> <sld:CssParameter name="stroke">#8000FF</sld:CssParameter> <sld:CssParameter name="stroke-width">3.000</sld:CssParameter> </sld:Stroke> </sld:LineSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor>';

parser
  .readStyle(sldString)
  .then(({output: sldObject}) => console.log(sldObject))
  .catch(error => console.log(error));

Browser:

const pointSimplePoint = {
  name: "My Style",
  rules: [
    {
      name: "My Rule",
      symbolizers: [
        {
          kind: "Mark",
          wellKnownName: "Circle",
          color: "#FF0000",
          radius: 6
        }
      ]
    }
  ]
};
var parser = new GeoStylerSLDParser.SldStyleParser();
parser
  .writeStyle(pointSimplePoint)
  .then(({output: sld}) => console.log(sld))
  .catch(error => console.log(error));

// Read style from string
var sldString = '<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0"> <sld:NamedLayer> <sld:Name>Default Styler</sld:Name> <sld:UserStyle> <sld:Name>Default Styler</sld:Name> <sld:Title>Gravel_Program_2016</sld:Title> <sld:FeatureTypeStyle> <sld:Name>name</sld:Name> <sld:Rule> <sld:MinScaleDenominator>1.0</sld:MinScaleDenominator> <sld:MaxScaleDenominator>1.0E7</sld:MaxScaleDenominator> <sld:LineSymbolizer> <sld:Stroke> <sld:CssParameter name="stroke">#8000FF</sld:CssParameter> <sld:CssParameter name="stroke-width">3.000</sld:CssParameter> </sld:Stroke> </sld:LineSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor>';


parser
  .readStyle(sldString)
  .then(({output: sldObject}) => console.log(sldObject))
  .catch(error => console.log(error));

Funding & financial sponsorship

Maintenance and further development of this code can be funded through the GeoStyler Open Collective. All contributions and expenses can transparently be reviewed by anyone; you see what we use the donated money for. Thank you for any financial support you give the GeoStyler project 💞

7.3.0

5 months ago

7.2.1

6 months ago

7.1.0

6 months ago

6.1.2

11 months ago

7.0.0

9 months ago

6.1.0

1 year ago

6.1.1

1 year ago

6.0.0-next.8

1 year ago

5.4.0

1 year ago

6.0.0

1 year ago

6.0.0-next.1

1 year ago

6.0.0-next.2

1 year ago

6.0.0-next.3

1 year ago

6.0.0-next.4

1 year ago

6.0.0-next.5

1 year ago

6.0.0-next.6

1 year ago

6.0.0-next.7

1 year ago

5.3.1

1 year ago

5.3.0

1 year ago

5.2.0

2 years ago

5.1.0

2 years ago

5.0.1

2 years ago

5.0.0-beta.0

3 years ago

5.0.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.0-beta.0

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.1

4 years ago

2.2.2

4 years ago

2.2.0

4 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.18.2

6 years ago

0.18.1

6 years ago

0.18.0

7 years ago

0.17.4

7 years ago

0.17.3

7 years ago

0.17.2

7 years ago

0.17.1

7 years ago

0.17.0

7 years ago

0.16.0

7 years ago

0.15.1

7 years ago

0.15.0

7 years ago

0.14.0

7 years ago

0.13.0

7 years ago

0.12.0

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago