Package org.geotools.styling

Examples of org.geotools.styling.StyleAttributeExtractor


  private FeatureCollection<SimpleFeatureType, SimpleFeature> createCollection(List<InternalFeature> features,
      VectorLayer layer, CoordinateReferenceSystem mapCrs, Style style) {
    SimpleFeatureType type = createFeatureType(layer, mapCrs);
    ListFeatureCollection result = new ListFeatureCollection(type);
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    StyleAttributeExtractor extractor = new StyleAttributeExtractor();
    style.accept(extractor);
    Set<String> styleAttributeNames = extractor.getAttributeNameSet();
    FeatureInfo featureInfo = layer.getLayerInfo().getFeatureInfo();
    for (InternalFeature internalFeature : features) {
      // 2 more attributes : geometry + style attribute
      Object[] values = new Object[internalFeature.getAttributes().size() + 2];
      int i = 0;
View Full Code Here


            // symbolizer?
            return;
        }

        // extract attributes used in the style
        StyleAttributeExtractor sae = new StyleAttributeExtractor();
        sae.visit(style);
        String[] styleAttributes = sae.getAttributeNames();

        // see if we can collect any attribute out of the provided layer
        Set attributes = new HashSet();
        if (mapLayerInfo.getType() == MapLayerInfo.TYPE_VECTOR
                || mapLayerInfo.getType() == MapLayerInfo.TYPE_REMOTE_VECTOR) {
View Full Code Here

     * @return the minimum set of attribute names needed to render
     *         <code>layer</code>
     */
    private List<PropertyName> findStyleAttributes(LiteFeatureTypeStyle[] styles,
            FeatureType schema) {
        final StyleAttributeExtractor sae = new StyleAttributeExtractor();

        LiteFeatureTypeStyle lfts;
        Rule[] rules;
        int rulesLength;
        final int length = styles.length;
        for (int t = 0; t < length; t++) {
            lfts = styles[t];
            rules = lfts.elseRules;
            rulesLength = rules.length;
            for (int j = 0; j < rulesLength; j++) {
                sae.visit(rules[j]);
            }
            rules = lfts.ruleList;
            rulesLength = rules.length;
            for (int j = 0; j < rulesLength; j++) {
                sae.visit(rules[j]);
            }
        }

        if(sae.isUsingDynamincProperties()) {
            return null;
        }
        Set<PropertyName> attributes = sae.getAttributes();
        Set<String> attributeNames = sae.getAttributeNameSet();

        /*
         * DJB: this is an old comment - erase it soon (see geos-469 and below) -
         * we only add the default geometry if it was used.
         *
         * GR: if as result of sae.getAttributeNames() ftsAttributes already
         * contains geometry attribute names, they gets duplicated, which produces
         * an error in AbstracDatastore when trying to create a derivate
         * SimpleFeatureType. So I'll add the default geometry only if it is not
         * already present, but: should all the geometric attributes be added by
         * default? I will add them, but don't really know what's the expected
         * behavior
         */
        List<PropertyName> atts = new ArrayList<PropertyName>(attributes);
        Collection<PropertyDescriptor> attTypes = schema.getDescriptors();
        Name attName;
       
        for (PropertyDescriptor pd : attTypes) {
            //attName = pd.getName().getLocalPart();
            attName = pd.getName();

            // DJB: This geometry check was commented out. I think it should
            // actually be back in or
            // you get ALL the attributes back, which isn't what you want.
            // ALX: For rasters I need even the "grid" attribute.

            // DJB:geos-469, we do not grab all the geometry columns.
            // for symbolizers, if a geometry is required it is either
            // explicitly named
            // ("<Geometry><PropertyName>the_geom</PropertyName></Geometry>")
            // or the default geometry is assumed (no <Geometry> element).
            // I've modified the style attribute extractor so it tracks if the
            // default geometry is used. So, we no longer add EVERY geometry
            // column to the query!!

            if ((attName.getLocalPart().equalsIgnoreCase("grid"))
                    && !attributeNames.contains(attName.getLocalPart())
                    || (attName.getLocalPart().equalsIgnoreCase("params"))
                    && !attributeNames.contains(attName.getLocalPart())
                    ) {  
                atts.add(filterFactory.property (attName));
                if (LOGGER.isLoggable(Level.FINE))
                    LOGGER.fine("added attribute " + attName);
            }
        }

        try {
            // DJB:geos-469 if the default geometry was used in the style, we
            // need to grab it.
            if (sae.getDefaultGeometryUsed()
                    && (!attributeNames.contains(schema.getGeometryDescriptor().getName().toString()))
                    ) {
                atts.add(filterFactory.property ( schema.getGeometryDescriptor().getName() ));
            }
        } catch (Exception e) {
View Full Code Here

        // check if there is any conflicting geometry transformation.
        // No geometry transformations -> we can modify geometries in place
        // Just one geometry transformation over an attribute -> we can modify geometries in place
        // Two tx over the same attribute, or straight usage and a tx -> we have to preserve the
        // original geometry as well, thus we need cloning
        StyleAttributeExtractor extractor = new StyleAttributeExtractor();
        FeatureType featureType = layer.getFeatureSource().getSchema();
        Set<String> plainGeometries = new java.util.HashSet<String>();
        Set<String> txGeometries = new java.util.HashSet<String>();
        for (LiteFeatureTypeStyle lft : lfts) {
            for(Rule r: lft.ruleList) {
                for(Symbolizer s: r.symbolizers()) {
                    if(s.getGeometry() == null) {
                        String attribute = featureType.getGeometryDescriptor().getName().getLocalPart();
                        if(txGeometries.contains(attribute))
                            return true;
                        plainGeometries.add(attribute);
                    } else if(s.getGeometry() instanceof PropertyName) {
                        String attribute = ((PropertyName) s.getGeometry()).getPropertyName();
                        if(txGeometries.contains(attribute))
                            return true;
                        plainGeometries.add(attribute);
                    } else {
                        Expression g = s.getGeometry();
                        extractor.clear();
                        g.accept(extractor, null);
                        Set<String> attributes = extractor.getAttributeNameSet();
                        for (String attribute : attributes) {
                            if(plainGeometries.contains(attribute))
                                return true;
                            if(txGeometries.contains(attribute))
                                return true;
View Full Code Here

            if(geometry instanceof PropertyName) {
                return getAttributeCRS((PropertyName) geometry, schema);
            } else if(geometry == null) {
                return getAttributeCRS(null, schema);
            } else {
                StyleAttributeExtractor attExtractor = new StyleAttributeExtractor();
                geometry.accept(attExtractor, null);
                for(PropertyName name : attExtractor.getAttributes()) {
                    if(name.evaluate(schema) instanceof GeometryDescriptor) {
                        return getAttributeCRS(name, schema);
                    }
                }
            }
View Full Code Here

            // symbolizer?
            return;
        }

        // extract attributes used in the style
        StyleAttributeExtractor sae = new StyleAttributeExtractor();
        sae.visit(style);
        String[] styleAttributes = sae.getAttributeNames();

        // see if we can collect any attribute out of the provided layer
        Set attributes = new HashSet();
        if (mapLayerInfo.getType() == MapLayerInfo.TYPE_VECTOR
                || mapLayerInfo.getType() == MapLayerInfo.TYPE_REMOTE_VECTOR) {
View Full Code Here

            return Math.max(dynamicBuffer / 2, estimatedRadius);
        }
    }

    private String[] getDynamicProperties(List<Rule> dynamicRules) {
        StyleAttributeExtractor extractor = new StyleAttributeExtractor();
        for (Rule rule : dynamicRules) {
            rule.accept(extractor);
        }
       
        return extractor.getAttributeNames();
    }
View Full Code Here

        // if a rendering transform is present don't check the attributes, since they may be changed
        if (hasTransformation(style))
            return

        // extract attributes used in the style
        StyleAttributeExtractor sae = new StyleAttributeExtractor();
        sae.visit(style);
        Set<PropertyName> styleAttributes = sae.getAttributes();

        // see if we can collect any attribute out of the provided layer
       // Set attributes = new HashSet();
        FeatureType type = null;
        if (mapLayerInfo.getType() == MapLayerInfo.TYPE_VECTOR
View Full Code Here

     *
     * @throws WmsException DOCUMENT ME!
     */
    private void checkStyle(Style style, FeatureType fType)
        throws WmsException {
        StyleAttributeExtractor sae = new StyleAttributeExtractor();
        sae.visit(style);

        String[] styleAttributes = sae.getAttributeNames();

        for (int i = 0; i < styleAttributes.length; i++) {
            String attName = styleAttributes[i];

            if (fType.getAttributeType(attName) == null) {
View Full Code Here

TOP

Related Classes of org.geotools.styling.StyleAttributeExtractor

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.