Skip to content

koordinates/geostyler-mapnik-parser

 
 

Repository files navigation

geostyler-mapnik-parser

GeoStyler Style Parser implementation for Mapnik XML

How to use

Converting SLD to Mapnk XML

CLI

npm install

npm run build

node dist/bin/sld2mapnik.js input.sld > output.mapnik.xml

Programmatically

import SLDParser from 'geostyler-sld-parser'
import { MapnikStyleParser } from './geostyler-mapnik-parser'

export async function sld2mapnik(sldString: string) {
  const sldParser = new SLDParser()
  const mapnikParser = new MapnikStyleParser({
    output: {
      includeMap: true,
      wellKnownBasePath: 'icons',
      map: {
        srs: '+init=epsg:3857',
      },
      style: {
        name: 'style',
      },
      symbolizers: {
        MarkersSymbolizer: {
          'allow-overlap': 'true',
          'avoid-edges': 'true',
        },
      },
    },
  })

  const style = await sldParser.readStyle(sldString)
  const xml = await mapnikParser.writeStyle(style)

  return xml
}

About

GeoStyler-Style-Parser implementation for Mapnik

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scheme 54.5%
  • TypeScript 44.7%
  • JavaScript 0.8%