Skip to content
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

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

pprev94
Copy link
Contributor

@pprev94 pprev94 commented Jun 18, 2024

For reading you can force sldVersion in option but it's not mandatory, it will be guessed, but for writing style, sldVersion is mandatory

Copy link
Contributor

@jansule jansule left a 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:

  1. when reading an SLD always derive the version from the SLD itself (and ignore this._sldVersion)
  2. when writing always use this._sldVersion
  3. keep the default version for this._sldVersion, so passing the version to the constructor will remain optional

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const SLD_VERSIONS = ['1.0.0','1.1.0'] as const;
const SLD_VERSIONS = ['1.0.0', '1.1.0'] as const;


if (this._sldVersion === undefined) {
const version = getAttribute(sldObject[0], 'version');
if (! SLD_VERSIONS.includes(version)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (! SLD_VERSIONS.includes(version)) {
if (!SLD_VERSIONS.includes(version)) {

@pprev94 pprev94 requested a review from jansule June 19, 2024 09:55
Copy link
Contributor

@jansule jansule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@@ -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',
Copy link
Contributor

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.

@@ -935,6 +944,7 @@ describe('SldStyleParser implements StyleParser', () => {
});
it('adds unsupportedProperties to the write output', async () => {
const styleParserOrder = new SldStyleParser({
sldVersion: '1.0.0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

@pprev94 pprev94 requested a review from jansule June 19, 2024 11:52
Copy link
Contributor

@jansule jansule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition. Thanks!

@jansule jansule merged commit 56f231b into master Jun 19, 2024
7 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 21, 2024
## [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)
@jansule
Copy link
Contributor

jansule commented Jun 21, 2024

🎉 This PR is included in version 5.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants