GeoTools : TextTestSLD

Example of text in different size according to different rules

<!--
 Automatically generated on Wed Nov 21 14:40:01 EST 2001 
-->
<StyledLayerDescriptor version="0.7.1">
    <NamedLayer name="GEONAMES:cgns">
        <UserStyle name="Filter by scale">
            <Title>Filter by scale</Title>
            <IsDefault>1</IsDefault>
            <Rule>
                <Title>City - All Scales</Title>
                <Filter>
                    <SqlExpression>concise_code='CITY'</SqlExpression>
                </Filter>
                <TextSymbol>
                    <Font>
                        <Size>18.0</Size>
                    </Font>
                    <Fill>
                        <Color>#000000</Color>
                    </Fill>
                </TextSymbol>
            </Rule>
            <Rule>
                <Title>Town - 500K and less</Title>
                <Filter>
                    <SqlExpression>concise_code in ('TOWN','MUN1','IR','VILG')</SqlExpression>
                </Filter>
                <MaxScale>500001</MaxScale>
                <TextSymbol>
                    <Font>
                        <Size>14.0</Size>
                    </Font>
                    <Fill>
                        <Color>#FF0000</Color>
                    </Fill>
                </TextSymbol>
            </Rule>
            <Rule>
                <Title>Water - 250K and less</Title>
                <Filter>
                    <SqlExpression> concise_code in ('LAKE','RIV','RAP','FALL','RIVF','SEA','SEAF','SHL','SPRG')</SqlExpression>
                </Filter>
                <MaxScale>250001</MaxScale>
                <TextSymbol>
                    <Font>
                        <Size>12.0</Size>
                    </Font>
                    <Fill>
                        <Color>#0000FF</Color>
                    </Fill>
                </TextSymbol>
            </Rule>
            <Rule>
                <Title>All Other Features - 50K and less</Title>
                <Filter>
                    <SqlExpression> concise_code not in('CITY','TOWN','MUN1','IR','VILG','LAKE','FALL','RAP','RIV','RIVF','SEA','SEAF','SHL','SPRG')</SqlExpression>
                </Filter>
                <MaxScale>50001.0</MaxScale>
                <TextSymbol>
                    <Font>
                        <Size>10.0</Size>
                    </Font>
                    <Fill>
                        <Color>#00AA00</Color>
                    </Fill>
                </TextSymbol>
            </Rule>
           <rule>
             <TextSymbolizer>
                <Label><PropertyName>name</PropertyName></Label>
                <Font>
                    <CssParameter name="font-family">Times New Roman</CssParameter>
                    <CssParameter name="font-Size">
                        <literal>10</literal>
                    </CssParameter>
                </Font>
                <Font>
                    <CssParameter name="font-family">Arial</CssParameter>
                    <CssParameter name="font-Size">
                        <literal>10</literal>
                    </CssParameter>
                </Font>
                <LabelPlacement>
                    <PointPlacement>
                        <AnchorPoint>
                            <AnchorPointX><PropertyName>X</PropertyName> </AnchorPointX>
                            <AnchorPointY><PropertyName>Y</PropertyName> </AnchorPointY>
                        </AnchorPoint>
                    </PointPlacement>
                </LabelPlacement>
                <Fill>
                    <CssParameter name="fill">#000000</CssParameter>
                </Fill>
                <Halo/>
            </TextSymbolizer>
        </rule>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>


Comments:

It should be noted that SqlExpression is not part of the current SLD specification. Whilst the above can be achived without it the result would be very verbose indeed.

Does the above code actualy work with all datastores? including non sql based ones?

Posted by jmacgill at Jan 31, 2005 12:09

is the <LabelPlacement> support the <LinePlacement> node ?
there are not a lot of informations 'bout <LabelPacement> ...

Posted by at Apr 20, 2005 11:58