The usual way to set a point size based on the scale denominator is to use the <MinScaleDenominator>
and <MaxScaleDenominator>
elements across multiple rules. So, to take your example you would need to do something like:
<Rule>
<Name>Local Company A - Large</Name>
<Title>Local Company A</Title>
<MaxScaleDenominator>100000</MaxScaleDenominator>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>company</ogc:PropertyName>
<ogc:Literal>A</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#000080</CssParameter>
</Fill>
</Mark>
<Size>12</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Local Company A - Medium</Name>
<Title>Local Company A</Title>
<MinScaleDenominator>100000</MinScaleDenominator>
<MaxScaleDenominator>500000</MaxScaleDenominator>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>company</ogc:PropertyName>
<ogc:Literal>A</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#000080</CssParameter>
</Fill>
</Mark>
<Size>8</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Local Company A - Small</Name>
<Title>Local Company A</Title>
<MinScaleDenominator>500000</MinScaleDenominator>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>company</ogc:PropertyName>
<ogc:Literal>A</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#000080</CssParameter>
</Fill>
</Mark>
<Size>4</Size>
</Graphic>
</PointSymbolizer>
</Rule>
So the above three rules will set the size of the point for company A based on the current scale denominator in relation to ranges. The three rules in this case are:
Rule 1: <= 1:100000 point size = 12
Rule 2: 1:100000 to 1:500000 point size = 8
Rule 3: >= 1:500000 point size = 4
So the point size gets progressively smaller the more the user zooms out. These three rules would then need to be repeated for Company B to give you the different coloured points based on company name.
GeoServer does also contain the ability to get properties from the request and then use these within the SLD. There may be potential to use this, as an environment variable that GeoServer provides for all WMS requests is wms_scale_denominator
. It might be possible to set the point size dynamically using this, for example by doing something with the number you get.
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#000080</CssParameter>
</Mark>
<Size>
<ogc:Function name="env">
<ogc:Literal>wms_scale_denominator</ogc:Literal>
</ogc:Function>
</Size>
</Graphic>
</PointSymbolizer>
This is a poor example because the value returned will be huge and so the point would be huge, or it will kill GeoServer. Much more likely would be to do something with that number so as it changes the point size changes in a more appropriate way. You could use <ogc:Div>
for example to divide the number by something (map resolution maybe) to get a sensible point size.
Best Answer
Check out the SLD Cookbook for examples of this. Despite it being on the GeoServer site it is nearly all applicable to all SLD implementations (and the bits that are GeoServer extensions are clearly marked)