[Geoserver-devel] New Labeling Options - Priority, group, and spaceAround

The labeler is *much* better now - you can actually control it quite
well.

I've added 3 things:
1. Priority (Expression) - features with higher priority are
rendered first
2. group (VendorOption "group" -> yes/no) - group labels (ie.
for roads)
3. spaceAround (VendorOption "spaceAround" -> int) - do not put other
labels near this one

See the below SLD Rule for what these options look like. See the
attached images for the effects of "spaceAround". The 1st image has
value "0" and the 2nd has value "10" - notice that the 2nd image does
not have other labels "near" the bolded labels.

Currently, these values default to:
a) Priority 1000
b) group "yes"
c) spaceAround "0"

These are the old default behaviors so noone should see these changes
until you actually try to use them. I'd like to change the default for
"group" to be "no".

Implemenation
-------------
I split the implementation into two parts - (a) Priority because its an
Expression (ie. changes for each feature) and (b) VendorOption Map
because they are the same for all features processed for that
symbolizer.

The SLD parser was modified so it will handle <Priority> tags and create
the VendorOptions map.

I changed the labeler so it has two stores - the HashTable (for grouped
items) and a List (for the non-grouped items).

When the system is ready to actually label (ie. in "end()"), it will put
all the labels together (grouped and non-grouped) and sort on Priority.
It then starts labeling from the highest priority to the lowest.

spaceAround is simple - I just changed (a) the overlaps check and (b)
the record-label-bounds so it was actually using a larger bounds.

---------------
The geoserver capabilities/validation have been updated so it allows
these extensions.

  <xsd:element name="TextSymbolizer" substitutionGroup="sld:Symbolizer">
    <xsd:annotation>
      <xsd:documentation>
        A "TextSymbolizer" is used to render text labels according to
        various graphical parameters.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="sld:SymbolizerType">
          <xsd:sequence>
            <xsd:element ref="sld:Geometry" minOccurs="0"/>
            <xsd:element ref="sld:Label" minOccurs="0"/>
            <xsd:element ref="sld:Font" minOccurs="0"/>
            <xsd:element ref="sld:LabelPlacement" minOccurs="0"/>
            <xsd:element ref="sld:Halo" minOccurs="0"/>
            <xsd:element ref="sld:Fill" minOccurs="0"/>
            <xsd:element ref="sld:Priority" minOccurs="0"/>
            <xsd:element ref="sld:VendorOption" minOccurs="0"
maxOccurs="unbounded" />
          </xsd:sequence>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

<xsd:element name="VendorOption">
  <xsd:complexType mixed="true">
      <xsd:simpleContent>
          <xsd:extension base="xsd:string">
             <xsd:attribute name="name" type="xsd:string" />
          </xsd:extension>
      </xsd:simpleContent>
  </xsd:complexType>
</xsd:element>

<xsd:element name="Priority" type="sld:ParameterValueType">
</xsd:element>

---------------

<Rule>
  <ogc:Filter>
  <ogc:PropertyIsLessThan>
  <ogc:PropertyName>POP_2000</ogc:PropertyName>
  <ogc:Literal>500000</ogc:Literal>
  </ogc:PropertyIsLessThan>
  </ogc:Filter>
     <TextSymbolizer>

        <Label>
      <ogc:PropertyName>NAME</ogc:PropertyName>
        </Label>

        <Font>
      <CssParameter name="font-family">Times New Roman</CssParameter>
      <CssParameter name="font-style">Normal</CssParameter>
      <CssParameter name="font-size">12</CssParameter>

        </Font>

        <LabelPlacement>
      <PointPlacement>
      <Displacement>
        <DisplacementX>6
        </DisplacementX>
        <DisplacementY>0
        </DisplacementY>
        </Displacement>

      </PointPlacement>
        </LabelPlacement>
        <Fill>
      <CssParameter name="fill">#000000</CssParameter>
        </Fill>

        <Priority>
              <ogc:PropertyName>POP_2000</ogc:PropertyName>
        </Priority>

        <VendorOption name="group">no</VendorOption>
        <VendorOption name="spaceAround">10</VendorOption>

  </TextSymbolizer>
</Rule>

----------------------------------------------------------
This mail sent through IMP: https://webmail.limegroup.com/

(attachments)

space0.gif
space10.gif