You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bd4c47e
Browse filesBrowse the repository at this point in the historyBrowse files
This page is currently in a draft form. It may also require features
6
+
only available in the `main` MapServer branch, and not yet released in a stable version.
7
+
8
+
## Overview
9
+
10
+
[GeoStyler](https://geostyler.org/) is *an open-source React library that enables developers to build flexible and powerful graphical user interfaces for map-styling in the browser*.
11
+
12
+
It has many different parsers that allow conversion of one style format to another. In this example, we will use the [SLD parser](https://geostyler.org/docs/usage/parsers/sld/)
13
+
to convert SLD created by MapServer styles into GeoStyler JSON format, which can then be used to style vector layers in OpenLayers.
Symbols are added to the Mapfile using `INCLUDE` directives, which allows them to be loaded into the
26
+
demo web application. The symbol `NAME` matches the `LAYER` name.
27
+
28
+
### Symbol Resolution
29
+
30
+
[RESOLUTION](https://mapserver.org/mapfile/map.html#mapfile-map-resolution) and [DEFRESOLUTION](https://mapserver.org/mapfile/map.html#mapfile-map-defresolution)
31
+
are used to control the scaling of symbols in MapServer.
32
+
33
+
When a WMS source has `serverType: 'mapserver', OpenLayers requests HiDPI images by adding
34
+
`MAP_RESOLUTION` = 90 × device pixel ratio to the request (when the ratio isn't 1).
35
+
The 90 value is [hard-coded in OpenLayers](https://github.com/openlayers/openlayers/blob/69e07d8ad933c3081cc10b8bb4a64023917661aa/src/ol/source/wms.js#L99)
36
+
and based on the OGC standard rendering pixel size of 0.28 mm (25.4 mm per inch ÷ 0.28 mm per pixel = 90.71 pixels per inch).
37
+
38
+
The device pixel ratio is a property of the browser, and can be different on different devices.
39
+
To find your browser pixel device ratio, open the developer tools and check the `window.devicePixelRatio` value.
40
+
41
+
For example, if this is `1.5`, then the `MAP_RESOLUTION` parameter sent by OpenLayers to MapServer as part of the WMS request
42
+
will be `90 * 1.5 = 135`. The image is requested at 1.5 times the size of the map. When this parameter is sent
43
+
by a client, it overrides the `RESOLUTION` value set in the Mapfile for that request.
44
+
45
+
MapServer scales symbol sizes by `RESOLUTION / DEFRESOLUTION`. Setting both to 90 keeps symbols
46
+
at the same visual size on any screen, matching the SLD sizes used for client-side styling.
47
+
When `MAP_RESOLUTION` is 135, symbols are scaled by 1.5 in an image that the browser displays 1.5 times smaller.
48
+
49
+
With MapServer's defaults of 72, symbols would instead be scaled by `135 / 72 = 1.875`
50
+
in the image, so they appear 1.25 times too large on HiDPI screens.
51
+
52
+
53
+
```scala
54
+
RESOLUTION90#if no MAP_RESOLUTION is provided in a request, MapServer uses this value
55
+
DEFRESOLUTION90# set to matchOpenLayers default. MapServer default is 72
- OpenLayers and SLD viewer: <http://localhost:7001/geostyler.html>
67
+
- Direct `GetStyles` request: <http://localhost:7000/?map=/etc/mapserver/geostyler.map&REQUEST=GetStyles&SERVICE=WMS&VERSION=1.3.0&LAYERS=notched-rect>
68
+
69
+
??? JavaScript "geostyler.js"
70
+
71
+
``` js
72
+
--8<-- "geostyler.js"
73
+
```
74
+
75
+
??? Mapfile "geostyler.map"
76
+
77
+
``` scala
78
+
--8<-- "geostyler.map"
79
+
```
80
+
81
+
82
+
## Exercises
83
+
84
+
1. Play around with the `RESOLUTION` and `DEFRESOLUTION` values in the Mapfile and see how it affects the symbol sizes.
0 commit comments