@@ -5,6 +5,7 @@ import QGISParser from 'geostyler-qgis-parser';
5
5
import MapfileParser from 'geostyler-mapfile-parser' ;
6
6
import MapboxParser from 'geostyler-mapbox-parser' ;
7
7
import LyrxParser from 'geostyler-lyrx-parser' ;
8
+ import { MapnikStyleParser } from '@koordinates/geostyler-mapnik-parser' ;
8
9
9
10
import {
10
11
existsSync ,
@@ -49,6 +50,22 @@ const getParserFromFormat = (inputString: string): StyleParser | undefined => {
49
50
case 'qgis' :
50
51
case 'qml' :
51
52
return new QGISParser ( ) ;
53
+ case 'mapnik' :
54
+ return new MapnikStyleParser ( {
55
+ output : {
56
+ includeMap : false ,
57
+ wellKnownBasePath : 'icons' ,
58
+ style : {
59
+ name : 'style' ,
60
+ } ,
61
+ symbolizers : {
62
+ MarkersSymbolizer : {
63
+ 'allow-overlap' : 'true' ,
64
+ } ,
65
+ } ,
66
+ } ,
67
+ } ) as StyleParser < any > ;
68
+
52
69
case 'geostyler' :
53
70
return undefined ;
54
71
default:
@@ -65,7 +82,7 @@ const getFormatFromFilename = (fileName: string): string | undefined => {
65
82
return undefined ;
66
83
}
67
84
fileEnding = fileEnding . toLowerCase ( ) ;
68
- if ( [ 'lyrx' , 'mapbox' , 'map' , 'sld' , 'qml' , 'geostyler' ] . includes ( fileEnding ) ) {
85
+ if ( [ 'lyrx' , 'mapbox' , 'map' , 'sld' , 'qml' , 'mapnik' , ' geostyler'] . includes ( fileEnding ) ) {
69
86
return fileEnding ;
70
87
}
71
88
return undefined ;
@@ -88,7 +105,7 @@ const getExtensionFromFormat = (format: string): string => {
88
105
} ;
89
106
90
107
const tryRemoveExtension = ( fileName : string ) : string => {
91
- const possibleExtensions = [ 'js' , 'ts' , 'mapbox' , 'map' , 'sld' , 'qml' , 'lyrx' ] ;
108
+ const possibleExtensions = [ 'js' , 'ts' , 'mapbox' , 'map' , 'sld' , 'qml' , 'lyrx' , 'mapnik' ] ;
92
109
const splittedFileName = fileName . split ( '.' ) ;
93
110
const sourceFileExtension = splittedFileName . pop ( ) ;
94
111
if ( sourceFileExtension && possibleExtensions . includes ( sourceFileExtension . toLowerCase ( ) ) ) {
@@ -154,6 +171,11 @@ function collectPaths(basePath: string, isFile: boolean): string[] {
154
171
}
155
172
156
173
function handleResult ( result : ReadStyleResult | WriteStyleResult , parser : StyleParser , stage : 'Source' | 'Target' ) {
174
+ if ( parser instanceof MapnikStyleParser ) {
175
+ // MapnikStyleParser uses an older StyleParser interface, I haven't brought it up to date.
176
+ return result ;
177
+ }
178
+
157
179
const { output, errors, warnings, unsupportedProperties } = result ;
158
180
if ( errors && errors . length > 0 ) {
159
181
throw errors ;
0 commit comments