GeoCat / bridge-style

Cartography library making style format conversions as easy as using Python.
MIT License
45 stars 14 forks source link

Feature request: support labelling along lines #33

Open tomchadwin opened 4 years ago

tomchadwin commented 4 years ago

I can't work out where to find the Geostyler style vocab/syntax, or I could start to look at this myself.

volaya commented 4 years ago

Looks like goestyler text symbolizer is mostly designed for point labels, as can be seen in here:

https://github.com/geostyler/geostyler-style/blob/master/index.d.ts

However, we are extending it when needed. For instance, I am using a "perpendicularOffset" parameter is this symbolizer, for the case of line labels. In general, I have tried to mimic SLD structure and terminology when doing this. Eventually, I would like to create a PR to formally submit those improvements to the GeosTyler repo

Which components of the line labeling in QGIS do you think are more important and should be supported first?

tomchadwin commented 4 years ago

The main one would be QgsPalLayerSettings::Placement:

https://qgis.org/api/classQgsPalLayerSettings.html#a5d449d8e9cb89e5d453c6e33fe1c66cc

Specifically handling the value Line. We could probably leave it at that, but I guess the next one to look at might be QgsPalLayerSettings::repeatDistance:

https://qgis.org/api/classQgsPalLayerSettings.html#a53c13e5f8d6074351308a7a6b65b5aad

What I'm after is the most likely use-case, which is street-labelling, and how to achieve that with the minimum development.

pvgenuchten commented 4 years ago

GeoServer SLD has a vendor parameter for this:

        <TextSymbolizer>
         <Label>
           <ogc:PropertyName>name</ogc:PropertyName>
         </Label>
         <LabelPlacement>
           <LinePlacement />
         </LabelPlacement>
         <Fill>
           <CssParameter name="fill">#000000</CssParameter>
         </Fill>
         <VendorOption name="followLine">true</VendorOption>
       </TextSymbolizer>

some other vendor params here

<VendorOption name="maxAngleDelta">90</VendorOption>
<VendorOption name="maxDisplacement">400</VendorOption>
<VendorOption name="repeat">150</VendorOption>
volaya commented 4 years ago

I added the support for SLD, but haven't been able to find how that's done in mapboxgl.

@tomchadwin Feel free to complete that if you know how to do it

tomchadwin commented 4 years ago

Thanks! For MBGLJS, it can't be done on the same line layer itself - you have to create another layer for the labels. Can't remember if the lib already does this for any other labels.