public String getKMLStyle(String label, Folder folder) { if (kmlStyles.containsKey(label)) return (String) kmlStyles.get(label); int pushpingLinkCounter = kmlStylesCounter % kmlPushPings.length; int colorCounter = kmlStylesCounter % kmlColors.length; Style style = folder.createAndAddStyle().withId( String.valueOf(kmlStylesCounter)); style.createAndSetIconStyle() .withScale(1.399999976158142) .withIcon( new Icon().withHref(kmlPushPings[pushpingLinkCounter])); style.createAndSetLineStyle().withColor(kmlColors[colorCounter]) .withWidth(2); style.createAndSetPolyStyle().withColor(kmlColors[colorCounter]); kmlStyles.put(label, String.valueOf(kmlStylesCounter)); kmlStylesCounter++; return String.valueOf(kmlStylesCounter - 1); } private String getKMLLabel(SimpleFeature feature) {
/** * Encodes a KML IconStyle + PolyStyle from a polygon style and symbolizer. */ protected void setPolygonStyle(Style style, SimpleFeature feature, PolygonSymbolizer symbolizer, boolean forceOutline) { // if stroke specified add line style as well (it has to be before the fill, otherwise // we'll get a white filling...) if (symbolizer.getStroke() != null) { setLineStyle(style, feature, symbolizer.getStroke()); } // fill PolyStyle ps = style.createAndSetPolyStyle(); Fill fill = symbolizer.getFill(); if (fill != null) { // get opacity Double opacity = fill.getOpacity().evaluate(feature, Double.class); if (opacity == null || Double.isNaN(opacity)) { opacity = 1.0; } Color color = (Color) fill.getColor().evaluate(feature, Color.class); ps.setColor(colorToHex(color, opacity)); } else { // make it transparent ps.setColor("00aaaaaa"); } // outline if (symbolizer.getStroke() != null || forceOutline) { ps.setOutline(true); } }