-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Extract SLD version from SLD (#926)
- Loading branch information
Showing
5 changed files
with
141 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
/build | ||
/browser | ||
|
||
# history | ||
/.history | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
/* eslint camelcase: 0 */ | ||
|
||
import * as fs from 'fs'; | ||
import SldStyleParser from './SldStyleParser'; | ||
import { expect, it, describe } from 'vitest'; | ||
|
||
import point_simplepoint from '../data/styles/point_simplepoint'; | ||
|
||
describe('SldStyleParser implements StyleParser (reading from one version and writing to another version)', () => { | ||
it('can read and write a SLD PointSymbolizer (from 1.0.0 version to 1.1.0 version)', async () => { | ||
const styleParser = new SldStyleParser({sldVersion: '1.1.0'}); | ||
|
||
const sld = fs.readFileSync('./data/slds/1.0/point_simplepoint.sld', 'utf8'); | ||
const { output: geoStylerStyle } = await styleParser.readStyle(sld); | ||
expect(geoStylerStyle).toBeDefined(); | ||
expect(geoStylerStyle).toEqual(point_simplepoint); | ||
|
||
// writing | ||
const { | ||
output: sldString, | ||
errors | ||
} = await styleParser.writeStyle(geoStylerStyle!); | ||
expect(sldString).toBeDefined(); | ||
expect(errors).toBeUndefined(); | ||
|
||
// As string comparison between two XML-Strings is awkward and nonsens | ||
// we read it again and compare the json input with the parser output | ||
const { output: readStyle } = await styleParser.readStyle(sldString!); | ||
expect(readStyle).toEqual(point_simplepoint); | ||
}); | ||
it('can read and write a SLD PointSymbolizer (from 1.1.0 version to 1.0.0 version)', async () => { | ||
const styleParser = new SldStyleParser({sldVersion: '1.0.0'}); | ||
|
||
const sld = fs.readFileSync('./data/slds/1.1/point_simplepoint.sld', 'utf8'); | ||
const { output: geoStylerStyle } = await styleParser.readStyle(sld); | ||
expect(geoStylerStyle).toBeDefined(); | ||
expect(geoStylerStyle).toEqual(point_simplepoint); | ||
|
||
// writing | ||
const { | ||
output: sldString, | ||
errors | ||
} = await styleParser.writeStyle(geoStylerStyle!); | ||
expect(sldString).toBeDefined(); | ||
expect(errors).toBeUndefined(); | ||
|
||
// As string comparison between two XML-Strings is awkward and nonsens | ||
// we read it again and compare the json input with the parser output | ||
const { output: readStyle } = await styleParser.readStyle(sldString!); | ||
expect(readStyle).toEqual(point_simplepoint); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters