-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Extract SLD version from SLD #696 and #925 #926
Conversation
cbbece1
to
0d33e10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! Thanks.
I would propose following slightly different approach:
- when reading an SLD always derive the version from the SLD itself (and ignore
this._sldVersion
) - when writing always use
this._sldVersion
- keep the default version for
this._sldVersion
, so passing the version to the constructor will remain optional
src/SldStyleParser.ts
Outdated
@@ -56,11 +56,14 @@ import { | |||
numberExpression | |||
} from './Util/SldUtil'; | |||
|
|||
export type SldVersion = '1.0.0' | '1.1.0'; | |||
const SLD_VERSIONS = ['1.0.0','1.1.0'] as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SLD_VERSIONS = ['1.0.0','1.1.0'] as const; | |
const SLD_VERSIONS = ['1.0.0', '1.1.0'] as const; |
src/SldStyleParser.ts
Outdated
|
||
if (this._sldVersion === undefined) { | ||
const version = getAttribute(sldObject[0], 'version'); | ||
if (! SLD_VERSIONS.includes(version)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (! SLD_VERSIONS.includes(version)) { | |
if (!SLD_VERSIONS.includes(version)) { |
… sld string (xml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
src/SldStyleParser.v1.0.spec.ts
Outdated
@@ -924,6 +932,7 @@ describe('SldStyleParser implements StyleParser', () => { | |||
|
|||
it('creates the correct order in a text symbolizer', async () => { | |||
const styleParserOrder = new SldStyleParser({ | |||
sldVersion: '1.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can probably be omitted, as version 1.0.0 is set as default.
src/SldStyleParser.v1.0.spec.ts
Outdated
@@ -935,6 +944,7 @@ describe('SldStyleParser implements StyleParser', () => { | |||
}); | |||
it('adds unsupportedProperties to the write output', async () => { | |||
const styleParserOrder = new SldStyleParser({ | |||
sldVersion: '1.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition. Thanks!
## [5.4.0](v5.3.1...v5.4.0) (2024-06-21) ### Features * Extract SLD version from SLD ([#926](#926)) ([56f231b](56f231b)) * implement i18n for error messages [#923](#923) [#924](#924) ([#928](#928)) ([e01c8c8](e01c8c8)) ### Bug Fixes * offset Y for Textsymbolizer ([#932](#932)) ([398ce0c](398ce0c)), closes [#566](#566)
🎉 This PR is included in version 5.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
For reading you can force sldVersion in option but it's not mandatory, it will be guessed, but for writing style, sldVersion is mandatory