Ticket #1542 (closed feature: fixed)

Opened 5 years ago

Last modified 5 years ago

Format.SLD: add support for TextSymbolizer

Reported by: bartvde Owned by: tschaub
Priority: minor Milestone: 2.7 Release
Component: Format.SLD Version: 2.6
Keywords: Cc:
State: Complete

Description

I'll create a patch to add support for TextSymbolizer.

Attachments

ticket1542.patch Download (2.4 KB) - added by bartvde 5 years ago.
patch implementing write support for TextSymbolizer
text.patch Download (5.5 KB) - added by tschaub 5 years ago.
write text symbolizers with support for label expressions

Change History

Changed 5 years ago by bartvde

  • keywords review added

It does not really make sense to implement read support right now, since vector layers can't render labels as yet.

Write support makes sense IMHO as you can now easily label a WMS layer using SLD.

An example useage is:

    var symbolizer = {};
    symbolizer["Text"] = {property: propertyName, fontFamily: fontFamily,
        fontSize: fontSize, fillColor: color};

Which will create something like (when used in an SLD document):

<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><NamedLayer><Name>AAA64</Name><UserStyle><FeatureTypeStyle><Rule><Name>default</Name><TextSymbolizer><Label><ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">ROUTE</ogc:PropertyName></Label><Font><CssParameter name="font-family">Arial</CssParameter><CssParameter name="font-size">10</CssParameter></Font><Fill><CssParameter name="fill">#FFFF00</CssParameter></Fill></TextSymbolizer></Rule></FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>

Changed 5 years ago by bartvde

patch implementing write support for TextSymbolizer

Changed 5 years ago by bartvde

  • keywords review removed
  • state set to Review

Changed 5 years ago by bartvde

  • milestone set to 2.7 Release

Changed 5 years ago by tschaub

write text symbolizers with support for label expressions

Changed 5 years ago by tschaub

Hey Bart - This is a nice addition. I think we'll eventually want to support more ogc:expressions. With that in mind, I decided a "label" property in the text symbolizer would more closely fit the sld:Label element. This parser has support for limited expression handling, so you can do something like:

var symbolizer = {
    "Text": {
        "label": "There are ${population} people in ${state}.",
        "fontFamily": "Arial" // etc
    }
};

I also added a test to demonstrate it working. Let me know if this works for you.

Changed 5 years ago by ahocevar

  • state changed from Review to Commit
  • type changed from task to feature

Great work Bart and Tim! I can confirm that tests pass in FF2 and IE7, and that the patch does not interfer with existing code. Also, is an important contribution to make SLD read/write support more complete. Tim, please commit.

Changed 5 years ago by tschaub

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [7333]) Adding support for TextSymbolizer writing in the SLD format. Thanks to Bart for the original patch. This provides basic expression handling for text labels. Read support later. r=ahocevar (closes #1542)

Note: See TracTickets for help on using tickets.