Replies: 2 comments 5 replies
-
|
Hi, thank you for the interesting write-up! We're currently working (or trying to work) on supporting OpenLayers flat style conversion. For now we are excluding support for units but it could definitely be done using flat style expressions (and the 96 DPI value you mention). Do you see support for this in the OpenLayers parser as interesting? Would you be interested in helping? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I was just asking on the discord server if there was a reason why the sld parser wasn't currently handling the units. The timing is perfect ! 😄 On my side, it is quite the same: basically, we're aiming at being able to display QGIS-styled maps in the browser, and so the real-world units are important for us too. I'm new to geostyler, and more a programmer than a GIS expert, but here is my answers to your open question @hebersgit: First open question Second open question |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For us, the units for size-specifications such as line-widths or font-sizes are important in the process of converting QML to other formats (focus on SLD). Therefore, I plan to submit two larger pull requests that correctly take these into account for QML and SLD. Until now, this has not been implemented at all or only in isolated cases. Before doing so, I would of course like to hear the community's opinion on this!
Interpretation of “DistanceUnit”
In style.ts, enum
DistanceUnitis defined and can take the valuespxandm. Some properties that deal with size also have a size-unit-property (e.g.,strokeWidthUnit). This seems to be well modeled to me.Open question: Does
pxmean that the size refers to a layout-size (fixed output size on the screen, e.g., always 5 pixels), whereasmdefines a ground-unit (size that scales when zooming, e.g., covering a width of 500m on the earth's surface)?If this assessment is correct, it would have the following consequences:
line_width_unit=RenderMetersInMapUnits(QGIS: Unit=Meters on Earth) is mapped toDistanceUnit = 'm'.px, whereby the value may need to be converted (more on this below).uom-attribute on the symbolizers. ADistanceUnit = 'm'would be mapped touom="http://www.opengeospatial.org/se/units/metre"when writing; when reading, such an attribute leads toDistanceUnit = 'm'being set.Mapbox only offers pixel sizes. Writing
DistanceUnit = 'm'could only be achieved through tricks.Conversion of units
The
DistanceUnitonly allows the above-mentioned values “m” and “px”. In my opinion, this means that values in other units (e.g., “pt,” “mm,” “inch,” ‘cm’) must be converted to pixels and theDistanceUnitmust be set to'px'(or omitted if this is the default value according to the documentation).Open question: How should the units be converted? The conversion from pixels to mm normally depends on the resolution of the output device. This would be completely impractical for our purposes. W3.org always defines a pixel in terms of 96 DPI (W3C Length Units ), which results in
1 inch = 96 pixels = 25.4 mm = 72 pt. Unfortunately, to my knowledge, there is no more specific conversion for the GIS sector, so this should be used.This would be a significant change, especially with regard to the QML parser, because size specifications often come into play in QML. There are tests that I believe are incorrect.
Example: “can read a QML FillSymbolizer with a PointPatternFill”: polygon_point_pattern_fill.qml contains
which means that the symbol has an outline width of 0.2 mm. Currently, this is simply transferred unchanged. Together with the note in the documentation that the default unit is pixels, this results in 2 pixels. However, the correct value would be (according to the conversion suggested above)
0.2 mm * 3.78 (pixels/mm) = 3.756 px. Such tests should be adapted.I am excited to hear your thoughts on this topic!
Beta Was this translation helpful? Give feedback.
All reactions