Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Expression


         */
        protected String evaluateDynamicSymbolizer(String strLocation, SimpleFeature feature){
            if (strLocation == null) return null;

            // parse the eventual ${cqlExpression} embedded in the URL
            Expression location;
            try {
                location = ExpressionExtractor.extractCqlExpressions(strLocation);
            } catch(IllegalArgumentException e) {
                // in the unlikely event that a URL is using one of the chars reserved for ${cqlExpression}
                // let's try and use the location as a literal
                if(LOGGER.isLoggable(Level.SEVERE))
                    LOGGER.log(Level.SEVERE, "Could not parse cql expressions out of " + strLocation, e);
                location = ff.literal(strLocation);
            }

            return location.evaluate(feature).toString();
        }
View Full Code Here


            LOGGER.finer(new StringBuffer("applying symbolizer ").append(
                    symbolizers[m]).toString());

            if (symbolizers[m] instanceof TextSymbolizer) {
                TextSymbolizer ts = (TextSymbolizer) symbolizers[m];
                Expression ex = ts.getLabel();
                featureLabel.append((String) ex.evaluate(feature, String.class)); // attach
                // the lable title

                Style2D style = styleFactory.createStyle(feature,
                        symbolizers[m], scaleRange);
                writeStyle(style, feature.getID(), symbolizers[m]);
View Full Code Here

                // TODO: come back and sort out crs transformation
                // CoordinateReferenceSystem crs = findGeometryCS(feature,
                // symbolizers[m]);
                if (symbolizers[m] instanceof TextSymbolizer) {
                    TextSymbolizer ts = (TextSymbolizer) symbolizers[m];
                    Expression ex = ts.getLabel();
                    String value = (String) ex.evaluate(feature, String.class);
                    title.append(value);

                    Style2D style = styleFactory.createStyle(feature,
                            symbolizers[m], scaleRange);
                    writeStyle(style, feature.getID(), symbolizers[m]);
View Full Code Here

     * @param sym
     * @return
     */
    private float getOpacity(final Symbolizer sym) {
        float alpha = 1.0f;
        Expression exp = null;

        if (sym instanceof PolygonSymbolizer) {
            exp = ((PolygonSymbolizer) sym).getFill().getOpacity();
        } else if (sym instanceof LineSymbolizer) {
            exp = ((LineSymbolizer) sym).getStroke().getOpacity();
        } else if (sym instanceof PointSymbolizer) {
            exp = ((PointSymbolizer) sym).getGraphic().getOpacity();
        } else if (sym instanceof TextSymbolizer) {
            exp = ((TextSymbolizer) sym).getFill().getOpacity();
        } else {
            LOGGER.info("Symbolizer not matched; was of class: " + sym);
        }

        if (exp == null) {
            LOGGER.info("Could not determine proper symbolizer opacity.");

            return alpha;
        }

        Float number = (Float) exp.evaluate(null, Float.class);

        if (number == null) {
            return alpha;
        }

View Full Code Here

         * @throws IOException if an error occurs during the process
         */
        protected void processSymbolizer(SimpleFeature ft,Rule rule,Symbolizer symbolizer) throws IOException{
          if(symbolizer instanceof TextSymbolizer) {
            // TODO: any check for label definition needed here?
          Expression e = SLD.textLabel((TextSymbolizer) symbolizer);
          // eval label actual value
                Object object = e.evaluate(ft);
                String value = null;

                if (object instanceof String) {
                    value = (String) object;
                } else {
View Full Code Here

        @Override
        protected void encodePlacemarkDescription(SimpleFeature feature, FeatureTypeStyle[] styles)
                throws IOException {
            // look for a kml text style with the description attribute
            List<TextSymbolizer2> textSymbolizers = getTextSymbolizers2(feature, styles);
            Expression description = null;
            for (TextSymbolizer2 ts : textSymbolizers) {
                if(ts.getFeatureDescription() != null)
                    description = ts.getFeatureDescription();
            }
            if(description == null) {
                // use the freemarker template as a fallback
                super.encodePlacemarkDescription(feature, styles);
                return;
            }
           
            start("description");
            cdata(description.evaluate(feature, String.class));
            end("description");
        }
View Full Code Here

       
        @Override
        protected void encodePlacemarkSnippet(SimpleFeature feature, FeatureTypeStyle[] styles) {
            // look for a kml text style with the abstract attribute
            List<TextSymbolizer2> textSymbolizers = getTextSymbolizers2(feature, styles);
            Expression abxtract = null;
            for (TextSymbolizer2 ts : textSymbolizers) {
                if(ts.getSnippet() != null)
                    abxtract = ts.getSnippet();
            }
            if(abxtract == null) {
                // no snippet then...
                return;
            }
            start("Snippet");
            cdata(abxtract.evaluate(feature, String.class));
            end("Snippet");
        }
View Full Code Here

        @Override
        protected void encodePlacemarkTime(SimpleFeature feature, FeatureTypeStyle[] styles)
                throws IOException {
            // look for a kml text style with the time/startTime/endTime otherText attributes
            List<TextSymbolizer2> textSymbolizers = getTextSymbolizers2(feature, styles);
            Expression abxtract = null;
            Date fromDate = null;
            Date toDate = null;
            Date timestamp = null;
            for (TextSymbolizer2 ts : textSymbolizers) {
                final OtherText ot = ts.getOtherText();
View Full Code Here

        sb.set("FID", "Fid001");
        sb.set("NAME", "Pluto");
        SimpleFeature f = sb.buildFeature("fidxxx");

        String template = "Hello this is ${FID.value} my name is ${NAME.value}";
        Expression freemarker = CQL.toExpression("freemarker('" + template + "')");
        String result = freemarker.evaluate(f, String.class);
        String expected = "Hello this is " + f.getAttribute("FID") + " my name is "
                + f.getAttribute("NAME");
        assertEquals(expected, result);
    }
View Full Code Here

    // 1.0.0.</a>:
    // "Not all systems can support opacity in colormaps. The default
    // opacity is 1.0 (fully opaque)."
    //
    // //
    final Expression opacity = entry.getOpacity();
    Double opacityValue = null;
    if (opacity != null)
      opacityValue = opacity.evaluate(null, Double.class);
    else
      return 1.0;
    if ((opacityValue.doubleValue() - 1) > 0
        || opacityValue.doubleValue() < 0) {
      throw new IllegalArgumentException(Errors.format(
View Full Code Here

TOP

Related Classes of org.opengis.filter.expression.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.