Skip to content

Offset property is being ignored on MarkSymbolizer #799

@florentsuc

Description

@florentsuc

Bug

Describe the bug
Converting from SLD to OpenLayers style, offsets on MarkSymbolizer are no longer handled, even though the SLD uses displacement. Displacement is transformed to undefined.

To Reproduce
Steps to reproduce the behavior:

  • Create an SLD with a Mark style and Displacement.
  • Convert the style to geostyler and then to OpenLayers
  • Style a vector layer with the OL style.

Example:

<Rule>
	<Name>selected property</Name>
	<PointSymbolizer>
		<Graphic>
			<Mark>
				<WellKnownName>circle</WellKnownName>
				<Fill>
					<CssParameter name="fill">#FFFFFF</CssParameter>
				</Fill>
			</Mark>
			<Size>45.0</Size>
			<Displacement>
				<DisplacementX>1</DisplacementX>
				<DisplacementY>1</DisplacementY>
			</Displacement>
		</Graphic>
	</PointSymbolizer>
</Rule>

Expected behavior
offset property should not be undefined

Desktop (please complete the following information):
OS: Mac OS
Browser: Chrome
Version: 122.0

Additional context
The bug has been introduced here:

displacement: typeof(markSymbolizer.offset) === 'number' ? markSymbolizer.offset : undefined

Proposed solution

  • offset is not a number, it is an array, so we could check Array.isArray(offset)
  • we should update the unit tests and introduce an offset + displacement into the mocked data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions