NieuwlandGeo/SLDReader

GraphicStroke / Windows display scale settings

calinarens opened this issue · 6 comments

If a user's Windows display scale settings is not 100%, the graphics in graphicstroke are drawn at an offset (e.g. at 125% the marks are drawn on the right side of the line). I know I coded this myself, but do you have any idea on how to fix this?

I noticed that the pixelRatio_ property on the render object is correctly at 1.25 (when the scale setting in Windows is at 125%), but it seems not be used in:
render.drawPoint(new geom.Point([point[0], point[1]]));

If I change the code to:
render.drawPoint(new geom.Point([point[0]/1.25, point[1]/1.25]));
it works.

Any idea on a general solution?

image

I figured out some more by debugging into OpenLayers. Somehow OpenLayers expects a different set of coordinates, because it actually multiplies the coordinates with 1.25 to create what OpenLayers thinks are pixelCoordinates.

I can solve it now to ignore the pixel ratio when creating the render context in
function getGraphicStrokeRenderer(linesymbolizer)
by adding pixelRatio=1 as an option to:
var render$1 = render.toContext(renderState.context, { pixelRatio: 1.0});

Is it possible for you to add this change?

I don't think using a pixelRatio of 1 for the render context is the right solution. This means that graphic stroke marks become really tiny on mobile devices that typically have a pixelRatio of 3 or higher.

I think that it's better to scale the calculated stroke mark coördinates (and the gaps between the marks) with the pixelRatio. I will make a pull request that fixes this.

Thanks for the quick fix! :-)

Hi Arjen, when do you think you can create a release? I have a customer that is really happy with the new graphicstroke capabilities, and is eager to get the fixed version.

I will probably create a new release this week.

I have just released v0.2.6 which fixes this bug.