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

Rectangle shape using ol.style.RegularShape do not get correctly parsed from ol style to geoserver style #453

Open
MichaelTang778 opened this issue Dec 1, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@MichaelTang778
Copy link

Bug

Describe the bug

When converting from openlayer style to geoserver style, the rectangle shape fails to parse correctly for ol.style.RegularShape. The reason for this is because the scale doesn't get parsed correctly. For rectangle shapes the scale have an array of two numbers and for shapes that are not of rectangle have a scale with one number stored.

A clear and concise description of what the bug is.

  1. Run the following code
var OlStyleParser = new GeoStylerOpenlayersParser.OlStyleParser(ol);

const rectangleStyle = new ol.style.Style({
          image: new ol.style.RegularShape({
              fill: new ol.style.Fill({ color: 'rgba(0,0,0,1)', width: 1}),
              stroke: new ol.style.Stroke({ color: 'rgba(0,0,0,1)', width: 1}),
              radius: 10 / Math.SQRT2,
              radius2: 10,
              points: 4,
              angle: 0,
              scale: [1, 0.5], // <------- note
              rotation: null
          })
  });

// To geoserver style
const olStyleOriginal = await OlStyleParser.readStyle(rectangleStyle );
const geoserverStyle = olStyleOriginal .output;

// back to ol style
var olStyleParser = await OlStyleParser.writeStyle(geoserverStyle );
const olStyleNew = olStyleParser.output;
  1. Note the the following:

rectangleStyle:
images -> scale_ = [1, 0.5]

olStyleNew
images -> scale_ = 1

Expected behavior
It is expected that the rectangle shape can be parsed correctly from openlayer style to geoserver style.

Screenshots
If applicable, add screenshots to help explain your problem.

Screenshot showing original rectangleStyle
style

Screenshot showing ol style to geoserver style
olToGeoserver

screenshot showing geoserver style converted back to ol style
GeoserverToOl

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: Version 96.0.4664.45 (Official Build) (64-bit)
@MichaelTang778 MichaelTang778 added the bug Something isn't working label Dec 1, 2021
@jansule
Copy link
Contributor

jansule commented Dec 7, 2021

Thanks for the info @MichaelTang778

The openlayers parser does not support rectangular shapes and non-numeric scales, yet. Currently, we support:

  • 'shape://vertline'
  • 'shape://horline'
  • 'shape://slash'
  • 'shape://backslash'
  • 'triangle'
  • 'shape://carrow'
  • 'cross'
  • 'x'
  • 'square'
  • 'star'

Would you like to create a PR that introduces that feature?

@MichaelTang778
Copy link
Author

I would love to, but I'm moving on from my current role in January and will be working on other stuff. Maybe someone else can implement this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants