Package org.geotools.feature.simple

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder


     * the attributeMappings map.
     * @param schema
     * @return
     */
    private SimpleFeatureType remapSchema(SimpleFeatureType schema) {
        SimpleFeatureTypeBuilder builder=new SimpleFeatureTypeBuilder();
        builder.setName(schema.getName());
        for(AttributeDescriptor attDesc : schema.getAttributeDescriptors()) {
            if(attDesc instanceof GeometryDescriptor) {
                GeometryDescriptor geoDesc=(GeometryDescriptor)attDesc;
                builder.add(attributesMapping.get(attDesc.getLocalName()),attDesc.getType().getBinding(),geoDesc.getCoordinateReferenceSystem());           
            } else
                builder.add(attributesMapping.get(attDesc.getLocalName()),attDesc.getType().getBinding());
        }
        return builder.buildFeatureType();
    }
View Full Code Here


            GridCoverage2D coverage, double[] pixelValues, Name coverageName)
            throws SchemaException {
       
        GridSampleDimension[] sampleDimensions = coverage.getSampleDimensions();
       
        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.setName(coverageName);
        final Set<String> bandNames=new HashSet<String>();
        for (int i = 0; i < sampleDimensions.length; i++) {
          String name=sampleDimensions[i].getDescription().toString();
          //GEOS-2518
          if(bandNames.contains(name))
            // it might happen again that the name already exists but it pretty difficult I'd say
            name= new StringBuilder(name).append("_Band").append(i).toString();
          bandNames.add(name);
            builder.add(name, Double.class);
        }
        SimpleFeatureType gridType = builder.buildFeatureType();
       
        Double[] values = new Double[pixelValues.length];
        for (int i = 0; i < values.length; i++) {
            values[i] = new Double(pixelValues[i]);
        }
View Full Code Here

        final String fileName = MockData.PRIMITIVEGEOFEATURE.getLocalPart() + ".properties";
        URL properties = MockData.class.getResource(fileName);
        IOUtils.copy(properties.openStream(), new File(data, fileName));

        // build a feature type with less attributes, extra attributes, type changes
        SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
        ftb.add("description", String.class);
        ftb.add("pointProperty", MultiPoint.class); // poly -> multi-poly
        ftb.add("intProperty", Long.class); // int -> long
        ftb.add("dateTimeProperty", Date.class); // timestamp -> date
        ftb.add("newProperty", String.class); // new property
        ftb.setName(RENAMED); // rename type
        primitive = ftb.buildFeatureType();
       
        PropertyDataStore pds = new PropertyDataStore(data);
        rts = new RetypingDataStore(pds) {
         
          @Override
View Full Code Here

        }
    }
   
    public void testEscapes() throws Exception {
        // build some fake data in memory, the property data store cannot handle newlines in its data
        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.add("geom", Point.class);
        builder.add("label", String.class);
        builder.setName("funnyLabels");
        SimpleFeatureType type = builder.buildFeatureType();
       
        GeometryFactory gf = new GeometryFactory();
        SimpleFeature f1 = SimpleFeatureBuilder.build(type, new Object[]{gf.createPoint(new Coordinate(5, 8)), "A label with \"quotes\""}, null);
        SimpleFeature f2 = SimpleFeatureBuilder.build(type, new Object[]{gf.createPoint(new Coordinate(5, 4)), "A long label\nwith newlines"}, null);
       
View Full Code Here

    for (Entry<String, AttributeDescriptor> entry : this.mapUnionAttributes
        .entrySet()) {

      attrType[i++] = entry.getValue();
    }
    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();

    builder.setName(FEATURE_TYPE_NAME);
    builder.setAbstract(false);
    builder.add(this.unionGeometryAttr);
    builder.addAll(attrType);

    SimpleFeatureType newType = builder.buildFeatureType();
    return newType;
  }
View Full Code Here

        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
       
        int index = 0;
        SimpleFeature f;
        DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName(kml.getName());
        b.setCRS(crs);
        b.add("name", String.class);
        b.add("the_geom", Geometry.class); //$NON-NLS-1$
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

        while( (f = (SimpleFeature) parser.parse()) != null ) {
            Geometry geometry = (Geometry) f.getDefaultGeometry();
            Object nameAttribute = null;
View Full Code Here

        } catch (NoSuchAuthorityCodeException e) {
          logger.error("No such authority code!", e);
        } catch (FactoryException e) {
          logger.error("Error parsing SRID!", e);
        }
        SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
        simpleFeatureTypeBuilder.setName("SimpleFeature");
        simpleFeatureTypeBuilder.setCRS(sourceCRS);
        simpleFeatureTypeBuilder.add("GEOM", binding);
        simpleFeatureTypeBuilder.addAll(featureSchema);
        SimpleFeatureType simpleFeatureTypeWithCRS = simpleFeatureTypeBuilder
            .buildFeatureType();
        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
            simpleFeatureTypeWithCRS);
        featureBuilder.add(JTSGeometry);
View Full Code Here

import java.util.List;

public class OgcGenericFilters
{
    private static SimpleFeatureType reprojectGeometryType(Name geometryAttName) {
        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        AttributeTypeBuilder attBuilder  = new AttributeTypeBuilder();
        attBuilder.crs(DefaultGeographicCRS.WGS84);
        attBuilder.binding(MultiPolygon.class);
        GeometryDescriptor geomDescriptor = attBuilder.buildDescriptor(geometryAttName, attBuilder.buildGeometryType());
        builder.setName("dummy");
        builder.setCRS( DefaultGeographicCRS.WGS84 );
        builder.add(geomDescriptor);
        return builder.buildFeatureType();
    }
View Full Code Here

        return attemptToCreateSpatialIndexFeatureStore(datastore);
    }

    private static FeatureStore<SimpleFeatureType, SimpleFeature> attemptToCreateSpatialIndexFeatureStore(DataStore datastore) throws
            IOException {
        SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
        typeBuilder.setName(_SPATIAL_INDEX_TYPENAME);

        typeBuilder.setCRS(DefaultGeographicCRS.WGS84);
        typeBuilder.add("geom", MultiPolygon.class);

        SimpleFeatureType type = typeBuilder.buildFeatureType();
        datastore.createSchema(type);
        return (FeatureStore<SimpleFeatureType, SimpleFeature>) datastore.getFeatureSource(type.getName());
    }
View Full Code Here

        if (crs != null) {
            ids.forceSchemaCRS(crs);
        }

        if (!file.exists()) {
            SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
            AttributeDescriptor geomDescriptor = new AttributeTypeBuilder().crs(DefaultGeographicCRS.WGS84).binding(MultiPolygon.class).buildDescriptor("the_geom");
            builder.setName(SpatialIndexWriter._SPATIAL_INDEX_TYPENAME);
            builder.add(geomDescriptor);
            builder.add(SpatialIndexWriter._IDS_ATTRIBUTE_NAME, String.class);
            ids.createSchema(builder.buildFeatureType());
        }

        logger.info("NOTE: Using shapefile for spatial index, this can be slow for larger catalogs");
        return ids;
    }
View Full Code Here

TOP

Related Classes of org.geotools.feature.simple.SimpleFeatureTypeBuilder

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.