Package org.geotools.feature

Examples of org.geotools.feature.AttributeTypeBuilder


           
            //add attributes in order
            for( AttributeDescriptor descriptor : original.getAttributeDescriptors() ){
                if( descriptor instanceof GeometryDescriptor ){
                    GeometryDescriptor geometryDescriptor = (GeometryDescriptor) descriptor;
                    AttributeTypeBuilder adjust = new AttributeTypeBuilder( b.factory );
                    adjust.init( geometryDescriptor );
                    adjust.setCRS( crs );
                    b.add( adjust.buildDescriptor( geometryDescriptor.getLocalName() ));
                    continue;
                }
                b.add( descriptor);
            }           
            return b.buildFeatureType();
View Full Code Here


            //clear attributes
            b.attributes().clear();
           
            //add attributes in order
            for( AttributeDescriptor descriptor : original.getAttributeDescriptors() ){
                AttributeTypeBuilder ab = new AttributeTypeBuilder( b.factory );
                ab.init( descriptor );
                b.add( ab.buildDescriptor( descriptor.getLocalName() ));
            }           
            return b.buildFeatureType();
        }
View Full Code Here

        // Why would the fileList already contain a null?
        //      if(!fileList.contains(null)){
        CoordinateReferenceSystem crs = getCoverage().getLibrary().getCoordinateReferenceSystem();
        if(crs != null){
            descriptor = new AttributeTypeBuilder().binding( Geometry.class )
                .nillable(true).length(-1).crs(crs).buildDescriptor("GEOMETRY");
        }else{
            descriptor = new AttributeTypeBuilder().binding( Geometry.class )
                .nillable(true).buildDescriptor("GEOMETRY");
        }
        VPFColumn result = null; // how to construct
        columns.add(result);
        setGeometryFactory(table);
View Full Code Here

        this.keyType = keyType;
        this.colDesc = colDesc;
        this.valDescTableName = valDescTableName;
        this.thematicIdx = thematicIdx;
        this.narrTable = narrTable;
        descriptor = new AttributeTypeBuilder().length(getColumnSize()).binding(getColumnClass())
                .nillable(true).buildDescriptor(name);
        descriptor.getUserData().put("column", this);
    }
View Full Code Here

        if(ad != null) {
            return ad;
        }
       
        // build it from the sample then
        AttributeTypeBuilder ab = new AttributeTypeBuilder();
        Object result = expression.evaluate(originalFeature);
        Class computedBinding = null;
        if (result != null) {
            computedBinding = result.getClass();
        }

        CoordinateReferenceSystem computedCRS = crs;
        if (Geometry.class.isAssignableFrom(computedBinding) && computedCRS == null) {
            computedCRS = evaluateCRS(originalFeature);
        }

        ab.setBinding(computedBinding);
        ab.setName(name);
        if (computedCRS != null) {
            ab.setCRS(computedCRS);
        }

        return ab.buildDescriptor(name);
    }
View Full Code Here

     *
     * @param originalFeature
     * @return
     */
    public AttributeDescriptor getAttributeDescriptor(SimpleFeatureType originalSchema) {
        AttributeTypeBuilder ab = new AttributeTypeBuilder();
        ExpressionTypeEvaluator typeEvaluator = new ExpressionTypeEvaluator(originalSchema);

        if (binding != null) {

            ab.setBinding(binding);
            ab.setName(name);
            if (crs != null) {
                ab.setCRS(crs);
            } else {
                // try to get it from the expression operands, under the assumption that
                // the geometry crs are not getting modified by the filter functions
                expression.accept(typeEvaluator, null);
                ab.setCRS(typeEvaluator.getCoordinateReferenceSystem());
            }

            return ab.buildDescriptor(name);
        } else {
            // in case no evaluation succeeds
            Class computedBinding = Object.class;

            // see if we are just passing a property trough
            if (expression instanceof PropertyName) {
                PropertyName pn = (PropertyName) expression;
                AttributeDescriptor descriptor = originalSchema.getDescriptor(pn.getPropertyName());

                if (descriptor == null) {
                    throw new IllegalArgumentException(
                            "Original feature type does not have a property named " + name);
                } else {
                    ab.init(descriptor);
                    ab.setName(name);
                    return ab.buildDescriptor(name);
                }
            } else {
                // try static analysis
                computedBinding = (Class) expression.accept(typeEvaluator, null);
                if(computedBinding == null) {
                    return null;
                }

                CoordinateReferenceSystem computedCRS = crs;
                if (Geometry.class.isAssignableFrom(computedBinding) && computedCRS == null) {
                    computedCRS = evaluateCRS(originalSchema);
                }

                ab.setBinding(computedBinding);
                ab.setName(name);
                if (computedCRS != null) {
                    ab.setCRS(computedCRS);
                }

                return ab.buildDescriptor(name);
            }
        }
    }
View Full Code Here

    }

    @Override
    protected SimpleFeatureType buildFeatureType() throws IOException {
        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        AttributeTypeBuilder ab = new AttributeTypeBuilder();
        tb.setName(entry.getName());
        SolrLayerConfiguration layerConfiguration = getDataStore().getSolrConfigurations().get(
                entry.getTypeName());
        String pkField = null;
        if (layerConfiguration != null) {
            String defaultGeometryName = null;
            for (SolrAttribute attribute : layerConfiguration.getAttributes()) {
                if (attribute.isUse()) {
                    AttributeDescriptor att = null;
                    if (attribute.isPk()) {
                        pkField = attribute.getName();
                    }
                    if (Geometry.class.isAssignableFrom(attribute.getType())) {
                        // add the attribute as a geometry
                        Integer srid = attribute.getSrid();
                        try {
                            if (srid != null) {
                                ab.setCRS(CRS.decode("EPSG:" + srid));
                                ab.setName(attribute.getName());
                                ab.setBinding(attribute.getType());
                                att = ab.buildDescriptor(attribute.getName(),
                                        ab.buildGeometryType());
                                if (attribute.isDefaultGeometry() != null
                                        && attribute.isDefaultGeometry()) {
                                    defaultGeometryName = attribute.getName();
                                }
                            }
                        } catch (Exception e) {
                            String msg = "Error occured determing srid for " + attribute.getName();
                            getDataStore().getLogger().log(Level.WARNING, msg, e);
                        }

                    } else {
                        ab.setName(attribute.getName());
                        ab.setBinding(attribute.getType());
                        att = ab.buildDescriptor(attribute.getName(), ab.buildType());
                    }
                    tb.add(att);
                }
            }
            if (defaultGeometryName != null) {
View Full Code Here

            for (AttributeDescriptor descriptor : delegate.getSchema().getAttributeDescriptors()) {
                if (!(descriptor.getType() instanceof GeometryTypeImpl)
                        || (!delegate.getSchema().getGeometryDescriptor().equals(descriptor))) {
                    tb.add(descriptor);
                } else {
                    AttributeTypeBuilder builder = new AttributeTypeBuilder();
                    builder.setBinding(MultiPolygon.class);
                    AttributeDescriptor attributeDescriptor = builder.buildDescriptor(descriptor
                            .getLocalName(), builder.buildType());
                    tb.add(attributeDescriptor);
                    if(tb.getDefaultGeometry() == null) {
                        tb.setDefaultGeometry(descriptor.getLocalName());
                    }
                }
View Full Code Here

            CoordinateReferenceSystem crs, SimpleFeatureTypeBuilder factory,
            GeometryDescriptor defaultGeometryType, AttributeDescriptor attributeType) {
        GeometryDescriptor geometryType = (GeometryDescriptor) attributeType;
        GeometryDescriptor geometry;

        AttributeTypeBuilder builder = new AttributeTypeBuilder();
        builder.setName(geometryType.getLocalName());
        builder.setBinding(geometryType.getType().getBinding());
        builder.setNillable(geometryType.isNillable());

        // builder.setDefaultValue(defaultValue);
        builder.setCRS(crs);

        geometry = builder
                .buildDescriptor(geometryType.getLocalName(), builder.buildGeometryType());

        if (defaultGeometryType == null || geometryType == schema.getGeometryDescriptor()) {
            defaultGeometryType = geometry;
        }
        factory.add(geometry);
View Full Code Here

        } else {
            // we can't be more precise than this
            binding = Geometry.class;
        }

        AttributeTypeBuilder builder = new AttributeTypeBuilder();
        builder.setName("the_geom");
        builder.setBinding(binding);
        builder.setCRS(first.features().next().getFeatureType().getCoordinateReferenceSystem());
        AttributeDescriptor descriptor = builder.buildDescriptor("the_geom");
        return descriptor;
    }
View Full Code Here

TOP

Related Classes of org.geotools.feature.AttributeTypeBuilder

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.