[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
>>
>
>
>
------------------------------------------------------------------------------
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