Thank you Ian,
That's the style I get and indeed it looks right:

======================================
      <sld:PointSymbolizer>
        <sld:Geometry>
          <ogc:PropertyName>the_geom</ogc:PropertyName>
        </sld:Geometry>
        <sld:Graphic>
          <sld:Mark>
            <sld:WellKnownName>Circle</sld:WellKnownName>
            <sld:Fill>
              <sld:CssParameter name="fill">
                <ogc:Function name="Categorize">
                  <ogc:PropertyName>value</ogc:PropertyName>
                  <ogc:Literal>30.0</ogc:Literal>
                  <ogc:Literal>#00FF00</ogc:Literal>
                  <ogc:Literal>100.0</ogc:Literal>
                  <ogc:Literal>#FF0000</ogc:Literal>
                  <ogc:Literal>preceding</ogc:Literal>
                </ogc:Function>
              </sld:CssParameter>
              <sld:CssParameter name="fill-opacity">1.0</sld:CssParameter>
            </sld:Fill>
            <sld:Stroke/>
          </sld:Mark>
        </sld:Graphic>
      </sld:PointSymbolizer>
======================================

Still I get empty circles when wrapping this symbolizer into a style.. U_U
I am applying no filters to the wrapping rule.

Anyone ever managed to apply one of these functions to a feature?

-Piero


On 3 May 2016 at 21:27, Ian Turton <[email protected]> wrote:

> I got as far as the following code:
>
> List<Expression> categories = new ArrayList<>();
>     categories.add(ff.property("value"));
>
>     for (int i = 0; i < colors.length; ++i) {
>       categories.add(ff.literal(thresholds[i]));
>       categories.add(
>           ff.literal(String.format("#%02X%02X%02X", colors[i].getRed(),
> colors[i].getGreen(), colors[i].getBlue())));
>     }
>    categories.add(ff.literal("preceding"));
>     Function ctgFun =ff.function("Categorize",categories.toArray(new
> Expression[] {}));
>     //Function ctgFun = new CategorizeFunction(categories,
> ff.literal("#0000FF"));
>     mark.setFill(sf.createFill(ctgFun, ff.literal(1.0)));
>
>     graphic.graphicalSymbols().clear();
>     graphic.graphicalSymbols().add(mark);
>
>     PointSymbolizer ps = sf.createPointSymbolizer(graphic, "the_geom");
>
> which generates the following SLD:
>
>                  <sld:Graphic>
>                     <sld:Mark>
>                         <sld:WellKnownName>Circle</sld:WellKnownName>
>                         <sld:Fill>
>                             <sld:CssParameter name="fill">
>                                 <ogc:Function name="Categorize">
>
> <ogc:PropertyName>Attribute</ogc:PropertyName>
>
> <ogc:PropertyName>value</ogc:PropertyName>
>                                     <ogc:Literal>30.0</ogc:Literal>
>                                     <ogc:Literal>#00FF00</ogc:Literal>
>                                     <ogc:Literal>100.0</ogc:Literal>
>                                     <ogc:Literal>#FF0000</ogc:Literal>
>                                     <ogc:Literal>preceding</ogc:Literal>
>                                 </ogc:Function>
>                             </sld:CssParameter>
>                         </sld:Fill>
>                         <sld:Stroke/>
>                     </sld:Mark>
>                 </sld:Graphic>
>             </sld:PointSymbolizer>
>
> Which looks promising, to be honest I can't see if the preceding or
> succeeding  flags are required (the default seems to be succeeding).
>
> Ian
>
> On 3 May 2016 at 12:49, Piero Campalani <[email protected]> wrote:
>
>> ​​
>> [Sorry, I prematurely hit "Send"]
>>
>> Thanks Ian, that's of great help. !
>>
>> So far, looking at the SLD examples you posted, I crafted a categorized
>> style this way:
>>
>> ================================================
>>
>>     double[] thresholds = new double[] { 30, 100 };
>>     Color[] colors = new Color[] { Color.GREEN, Color.RED };
>>
>>     StyleFactory sf =
>> CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
>>     FilterFactory2 ff =
>> CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
>>
>>     Graphic graphic = sf.getDefaultGraphic();
>>     Mark mark = sf.getCircleMark();
>>
>>     List<Expression> categories = new ArrayList<>();
>>     categories.add(ff.property("value"));
>>
>>     for (int i = 0; i < colors.length; ++i) {
>>         categories.add(ff.literal(thresholds[i]));
>>         categories.add(ff.literal(
>>             String.format("#%02X%02X%02X", colors[i].getRed(),
>> colors[i].getGreen(), colors[i].getBlue());)));
>>     }
>>
>>         Function ctgFun = new CategorizeFunction(categories,
>> ff.literal("#0000FF"));
>>         mark.setFill(sf.createFill(ctgFun, ff.literal(1.0)));
>>
>>         graphic.graphicalSymbols().clear();
>>         graphic.graphicalSymbols().add(mark);
>>
>>         PointSymbolizer ps = sf.createPointSymbolizer(graphic,
>> GEOM_PROPERTY);
>> ​================================================​
>>
>> On the other side, my feature has the "value" attribute set.
>> However I can only see the default black-border circles: color categories
>> are not applied seemingly.
>>
>> Any hint?
>> Any wrong step in the above procedure?
>>
>> On 3 May 2016 at 13:42, Piero Campalani <[email protected]> wrote:
>>
>>> Thanks Ian, that's of great help. !
>>>
>>> So far, I crafted a categorized style this way:
>>>
>>> ================================================
>>>
>>>     Graphic graphic = sf.getDefaultGraphic();
>>>     Mark mark = sf.getCircleMark();
>>>
>>>     List<Expression> categories = new ArrayList<>();
>>>     categories.add(ff.property("value"));
>>>
>>>     for (int i = 0; i < colors.length; ++i) {
>>>         categories.add(ff.literal(thresholds[i]));
>>>
>>> categories.add(ff.literal(FormatUtils.colorToHashedHexs(colors[i])));
>>>     }
>>>
>>>         Function ctgFun = new CategorizeFunction(categories,
>>> ff.literal("#0000FF")); // FIXME remove fallback
>>>         mark.setFill(sf.createFill(ctgFun, ff.literal(fillOpacity)));
>>> //        mark.setStroke(sf.createStroke(
>>> //                ff.literal(color), ff.literal(strokeOpacity)));
>>>         graphic.graphicalSymbols().clear();
>>>         graphic.graphicalSymbols().add(mark);
>>>
>>>         PointSymbolizer ps = sf.createPointSymbolizer(graphic,
>>> GEOM_PROPERTY);
>>> ​================================================​
>>>
>>>
>>> On 2 May 2016 at 12:52, Ian Turton <[email protected]> wrote:
>>>
>>>> What you want can probably be achieved by using a categorize function -
>>>> see
>>>> http://docs.geoserver.org/latest/en/user/styling/sld-tipstricks/transformation-func.html
>>>> for more details of how it works.
>>>>
>>>> Ian
>>>>
>>>
>>>
>>>
>>
>
>
> --
> Ian Turton
>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to