[Geoserver-users] proper use of sld to display wms layer

Hello!
I have a raster layer that displays surface currents. Everything works great, but there are some details that I wish to get rid of but dont know how to.
Below, the two pictures show what the layer looks like at a different zoom level. The first one is zoomed out compared to the second one. As you can see, the arrows are smaller on the second one. I wish it wasnt like this. I’m trying to make it so that the arrows stay the same size.
I’ve tried to play around with the wms_scale_denominator property in my sld, but it doesnt seem to do the trick.

image.png

image.png

Here is my SLD:

<?xml version="1.0" encoding="ISO-8859-1"?>



currents

currents data interpolation InterpolationBilinear Heading extshape://narrow u u v v #e0e2e6 0.514 #96ade4 1.03 #376AE2 1.542 #249D53 2.056 #F98308 2.57 #F91A08 u u v v 0 0.001 1 1000 0F u u v v 13 0.514 13 1.03 16 1.542 19 2.056 22 2.57 25 u v

Thanks a lot for your help!

···

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne

Hi Julien (je suis aussi du Québec) !

Have you tried using a fixed value for the Size attribute ?

ex: 8

As I can see in your sld, the size is modified using the Categorize function.

Hope this helps. Good Luck!

Olivier

image.jpg

image.jpg

···

Envoyé à partir d’Outlook


De : Julien Robitaille robitaillej@anonymised.com
Envoyé : 6 septembre 2022 08:53
À : geoserver-users@lists.sourceforge.net geoserver-users@anonymised.coms.sourceforge.net
Objet : [Geoserver-users] proper use of sld to display wms layer

Hello!
I have a raster layer that displays surface currents. Everything works great, but there are some details that I wish to get rid of but dont know how to.
Below, the two pictures show what the layer looks like at a different zoom level. The first one is zoomed out compared to the second one. As you can see, the arrows are smaller on the second one. I wish it wasnt like this. I’m trying to make it so that the arrows stay the same size.
I’ve tried to play around with the wms_scale_denominator property in my sld, but it doesnt seem to do the trick.

image.png

image.png

Here is my SLD:

<?xml version="1.0" encoding="ISO-8859-1"?>



currents

currents data interpolation InterpolationBilinear Heading extshape://narrow u u v v #e0e2e6 0.514 #96ade4 1.03 #376AE2 1.542 #249D53 2.056 #F98308 2.57 #F91A08 u u v v 0 0.001 1 1000 0F u u v v 13 0.514 13 1.03 16 1.542 19 2.056 22 2.57 25 u v

Thanks a lot for your help!

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne

Hello!
I found out that the difference in size from one zoom level to another one comes from openlayers.

But in any cases, what I would like to do is to increase the sizes of the arrows, so it is easier to see. The problem is that the display of those arrows depends a lot on whether the user uses a computer or a smartphone.
Here is an example. The first picture is from my computer, and the second one is from my phone.
As you can see, the resolution of the arrows is not the same, even at the approximate same zoom level.
image.png

image.png

As you can see, increasing the size of the arrows would make the app unreadable on the phone.
Does anyone know how to address this problem? Is it something that can be fixed by geoserver, or is it more of an openlayers’ problem?

Thanks a lot for your help!
Julien

image.jpg

image.jpg

···

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne

The challenge faced here is not particular to geoserver - it is a design challenge on how you wish to adapt your map to different environments.

You can supply GeoServer with the dpi of the display used (have openlayers pass this information in as a format option) . GeoSerer will adjust the sizes appropriately. Much of the other information is available as env variables for use when styling.

Reference:

···


Jody Garnett

It could be a DPI problem - I think some phones will ask openlayers to request WMS tiles/images at a higher DPI, so you end up with smaller arrows as there are more pixels per unit length. You could try adding format_option=dpi:96 to stop that - see https://docs.geoserver.org/latest/en/user/services/wms/vendor.html#format-options for more details.

Ian

···

Ian Turton

aside: Your messages are being held because of the attached images; here is my reply.

The challenge faced here is not particular to geoserver - it is a design challenge on how you wish to adapt your map to different environments.

You can supply GeoServer with the dpi of the display used (have openlayers pass this information in as a format option) . GeoSerer will adjust the sizes appropriately. Much of the other information is available as env variables for use when styling.

Reference:

···


Jody Garnett

Please remember to include the user list (so others can answer you) and yeah sorry it does not support pictures.

Where is the resolution of your raster determined?

Jody

···


Jody Garnett

By resolution, do you mean the dpi resolution? Or maybe the “resolution” of my raster layer (size of georeferenced cells)? The best way to play with the concentration of arrows that I found was to play with the wms_scale_denominator. So I thought I could make two different sld styles, one for computers, and another one for smartphones, with different values of wms_scale_denominator. And depending on the screen size and/or resolution of screen of the user, one of the two styles would be applied to the layer.
Thanks again,
Julien

···

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne

I am no expert in OpenLayers but could the OpenLayers option;

OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;

help? Can it force the DPI to be the same no matter what the Device DPI is.

···

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne

Thanks for your input. I’ve looked at the DOTS_PER_INCH, but I dont think it is still a valid parameter in openlayers (at least since the version 6).
But I found out that the arrow density seems to depend on the devicePixelRatio of the window. As a matter of fact, if I increase the devicePixelRatio of my browser (to a value similar to the one of my phone) by zooming it in, I get the same arrow density as the layer displayed on a smartphone.
So with that information I will be able to create two different sld styles, one for higher devicePixelRatio (usually smartphones), and one for lower devicePixelRatio (usually computers).
Thanks everyone for your help!
Julien

···

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne

Julien:

For everyone following this list at home can you share your resulting SLD with the group? I am sure others will run into similar challenges and search the email list.

···


Jody Garnett

Hello!
Indeed, this is a great idea!
The issue I faced was that different devices have different pixel ratios (in javascript, you can access this property with the variable window.devicePixelRatio).
So I ended up having two different styles, depending on the pixel ratio of the device.
For a pixel ratio of under 2.3 (usually laptops), here is the SLD:

<?xml version="1.0" encoding="ISO-8859-1"?>



currents

currents data interpolation InterpolationBilinear scale wms_scale_denominator 0.015 500000 0.02 Heading extshape://narrow eccc_winds_tif@anonymised.com 0 #2e4bcb

ogc:Literal2.57222</ogc:Literal>
ogc:Literal#309dcc</ogc:Literal>

ogc:Literal5.14444</ogc:Literal>
ogc:Literal#31d2cd</ogc:Literal>

ogc:Literal7.71667</ogc:Literal>
ogc:Literal#37d384</ogc:Literal>

ogc:Literal10.2889</ogc:Literal>
ogc:Literal#98da42</ogc:Literal>

ogc:Literal12.8611</ogc:Literal>
ogc:Literal#fde144</ogc:Literal>

ogc:Literal15.4333</ogc:Literal>
ogc:Literal#df8a32</ogc:Literal>

ogc:Literal18.0056</ogc:Literal>
ogc:Literal#bf2a1f</ogc:Literal>

ogc:Literal20.5778</ogc:Literal>
ogc:Literal#df2bbd</ogc:Literal>

ogc:Literalcolor</ogc:Literal>
</ogc:Function>




<ogc:Function name=“Categorize”>
ogc:PropertyNameeccc_winds_tif@anonymised.com</ogc:PropertyName>
ogc:Literal15</ogc:Literal>
ogc:Literal1</ogc:Literal>
ogc:Literal16</ogc:Literal>
ogc:Literal2</ogc:Literal>
ogc:Literal17</ogc:Literal>
ogc:Literal3</ogc:Literal>
ogc:Literal18</ogc:Literal>
ogc:Literal4</ogc:Literal>
ogc:Literal19</ogc:Literal>
ogc:Literal5</ogc:Literal>
ogc:Literal21</ogc:Literal>
ogc:Literal6</ogc:Literal>
ogc:Literal23</ogc:Literal>
ogc:Literal7</ogc:Literal>
ogc:Literal25</ogc:Literal>
</ogc:Function>


ogc:Add
ogc:PropertyNameeccc_winds_tif@anonymised.com</ogc:PropertyName>
<ogc:Function name=“if_then_else”>
<ogc:Function name=“between”>
ogc:PropertyNameeccc_winds_tif@anonymised.com</ogc:PropertyName>
ogc:Literal0</ogc:Literal>
ogc:Literal180</ogc:Literal>
</ogc:Function>
ogc:Literal180</ogc:Literal>
ogc:Literal-180</ogc:Literal>
</ogc:Function>
</ogc:Add>







I have underlined in orange the part that has to be changed for a different pixel ratio. In my case, for generally smartphones, this orange part is replaced in my SLD by:
ogc:Literal0.01</ogc:Literal>
ogc:Literal500000</ogc:Literal>
ogc:Literal0.012</ogc:Literal>

Hope this can help someone in the future!
Julien

···

OGSL Logo
Julien Robitaille
Scientifique de données
Data scientist
En télétravail - Working from home

Facebook LogoTwitter LogoLinkedIn Logo

Visitez notre site web pour en savoir plus sur notre campagne de communication en cours!
Visit our website to learn more about our ongoing communication campaign!
signature-campagne