コード例 #1
0
    protected void setInlineIconStyle(
        Style style,
        org.geotools.styling.Style sld,
        IconProperties properties,
        KmlEncodingContext context) {
      final String name = properties.getIconName(sld);

      Map<String, org.geotools.styling.Style> iconStyles = context.getIconStyles();
      if (!iconStyles.containsKey(name)) {
        final org.geotools.styling.Style injectedStyle =
            IconPropertyInjector.injectProperties(sld, properties.getProperties());

        iconStyles.put(name, injectedStyle);
      }
      final Double scale = properties.getScale();
      final String path = "icons/" + name + ".png";

      IconStyle is = style.createAndSetIconStyle();
      if (properties.getHeading() != null) {
        is.setHeading(0.0);
      }
      if (scale != null) {
        is.setScale(scale);
      }

      Icon icon = is.createAndSetIcon();
      icon.setHref(path);
    }
コード例 #2
0
    protected void setLiveIconStyle(
        Style style,
        org.geotools.styling.Style sld,
        IconProperties properties,
        KmlEncodingContext context) {
      final Double opacity = properties.getOpacity();
      final Double scale = properties.getScale();
      final Double heading = properties.getHeading();

      IconStyle is = style.createAndSetIconStyle();

      if (opacity != null) {
        is.setColor(colorToHex(Color.WHITE, opacity));
      }

      if (scale != null) {
        is.setScale(scale);
      }

      if (heading != null) {
        is.setHeading(heading);
      }

      // Get the name of the workspace

      WorkspaceInfo ws = context.getWms().getCatalog().getStyleByName(sld.getName()).getWorkspace();
      String wsName = null;
      if (ws != null) wsName = ws.getName();

      Icon icon = is.createAndSetIcon();
      icon.setHref(
          properties.href(
              context.getMapContent().getRequest().getBaseUrl(), wsName, sld.getName()));
    }
コード例 #3
0
 /** Encodes a KML IconStyle from a point style and symbolizer. */
 protected void setIconStyle(
     Style style,
     org.geotools.styling.Style sld,
     IconProperties properties,
     KmlEncodingContext context) {
   if (context.isLiveIcons() || properties.isExternal()) {
     setLiveIconStyle(style, sld, properties, context);
   } else {
     setInlineIconStyle(style, sld, properties, context);
   }
 }