Package org.geotools.feature

Examples of org.geotools.feature.AttributeTypeBuilder


            // gather the attributes from the first feature collection
            for (AttributeDescriptor descriptor : firstFeatureCollectionSchema
                    .getAttributeDescriptors()) {
                if (!(descriptor.getType() instanceof GeometryTypeImpl)
                        || (!geometryDescriptor.getName().equals(descriptor.getName()))) {
                    AttributeTypeBuilder builder = new AttributeTypeBuilder();
                    builder.setName(this.firstFeatures.features().next().getFeatureType().getName()
                            .getLocalPart()
                            + "_" + descriptor.getName());
                    builder.setNillable(descriptor.isNillable());
                    builder.setBinding(descriptor.getType().getBinding());
                    builder.setMinOccurs(descriptor.getMinOccurs());
                    builder.setMaxOccurs(descriptor.getMaxOccurs());
                    builder.setDefaultValue(descriptor.getDefaultValue());
                    builder.setCRS(this.firstFeatures.features().next().getFeatureType()
                            .getCoordinateReferenceSystem());
                    AttributeDescriptor intersectionDescriptor = builder.buildDescriptor(
                            this.firstFeatures.features().next().getFeatureType().getName()
                                    .getLocalPart()
                                    + "_" + descriptor.getName(), descriptor.getType());
                    tb.add(intersectionDescriptor);
                    tb.addBinding(descriptor.getType());
                } else {
                    tb.add(descriptor);
                }

            }
            // gather the attributes from the second feature collection
            geometryDescriptor = secondFeatureCollectionSchema.getGeometryDescriptor();
            for (AttributeDescriptor descriptor : secondFeatureCollectionSchema
                    .getAttributeDescriptors()) {
                if (!(descriptor.getType() instanceof GeometryTypeImpl)
                        || (!geometryDescriptor.getName().equals(descriptor.getName()))) {
                    AttributeTypeBuilder builder = new AttributeTypeBuilder();
                    builder.setName(this.secondFeatures.features().next().getFeatureType()
                            .getName().getLocalPart()
                            + "_" + descriptor.getName());
                    builder.setNillable(descriptor.isNillable());
                    builder.setBinding(descriptor.getType().getBinding());
                    builder.setMinOccurs(descriptor.getMinOccurs());
                    builder.setMaxOccurs(descriptor.getMaxOccurs());
                    builder.setDefaultValue(descriptor.getDefaultValue());
                    builder.setCRS(this.secondFeatures.features().next().getFeatureType()
                            .getCoordinateReferenceSystem());
                    builder.setNamespaceURI(this.secondFeatures.features().next().getFeatureType()
                            .getName().getNamespaceURI());
                    builder.setDefaultValue(descriptor.getDefaultValue());
                    AttributeDescriptor intersectionDescriptor = builder.buildDescriptor(
                            this.secondFeatures.features().next().getFeatureType().getName()
                                    .getLocalPart()
                                    + "_" + descriptor.getName(), descriptor.getType());
                    tb.addBinding(descriptor.getType());
                    tb.add(intersectionDescriptor);
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

            // Create schema containing the attributes from both the feature collections
            SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
            for (AttributeDescriptor descriptor : delegate.getSchema().getAttributeDescriptors()) {
                if (sameNames(features.getSchema(), descriptor)
                        && !sameTypes(features.getSchema(), descriptor)) {
                    AttributeTypeBuilder builder = new AttributeTypeBuilder();
                    builder.setName(descriptor.getLocalName());
                    builder.setNillable(descriptor.isNillable());
                    builder.setBinding(String.class);
                    builder.setMinOccurs(descriptor.getMinOccurs());
                    builder.setMaxOccurs(descriptor.getMaxOccurs());
                    builder.setDefaultValue(descriptor.getDefaultValue());
                    builder.setCRS(this.delegate.features().next().getFeatureType()
                            .getCoordinateReferenceSystem());
                    AttributeDescriptor attributeDescriptor = builder.buildDescriptor(descriptor
                            .getName(), builder.buildType());
                    tb.add(attributeDescriptor);
                } else {
                    tb.add(descriptor);
                }
            }
View Full Code Here

    }

    private static List<AttributeDescriptor> readAttributes(Integer geometryTypeId, CoordinateReferenceSystem crs, String[] extraPropertyNames) {
        Class<? extends Geometry> geometryClass = SpatialDatabaseService.convertGeometryTypeToJtsClass(geometryTypeId);

        AttributeTypeBuilder build = new AttributeTypeBuilder();
        build.setName(Classes.getShortName(geometryClass));
        build.setNillable(true);
        build.setCRS(crs);
        build.setBinding(geometryClass);

        GeometryType geometryType = build.buildGeometryType();

        List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>();
        attributes.add(build.buildDescriptor(BasicFeatureTypes.GEOMETRY_ATTRIBUTE_NAME, geometryType));

        if (extraPropertyNames != null) {
            Set<String> usedNames = new HashSet<String>();
            // record names in case of duplicates
            usedNames.add(BasicFeatureTypes.GEOMETRY_ATTRIBUTE_NAME);

            for (String propertyName : extraPropertyNames) {
                if (!usedNames.contains(propertyName)) {
                    usedNames.add(propertyName);

                    build.setNillable(true);
                    build.setBinding(String.class);

                    attributes.add(build.buildDescriptor(propertyName));
                }
            }
        }

        return attributes;
View Full Code Here

  public static SimpleFeatureType createTdrivePointDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(TDRIVE_POINT_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Geometry.class).nillable(
        false).buildDescriptor(
        "geometry"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        false).buildDescriptor(
        "taxiid"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        true).buildDescriptor(
        "pointinstance"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Date.class).nillable(
        true).buildDescriptor(
        "Timestamp"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        true).buildDescriptor(
        "Latitude"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        true).buildDescriptor(
        "Longitude"));

    return simpleFeatureTypeBuilder.buildFeatureType();
View Full Code Here

   * @return Simple Feature definition for our demo point feature
   */
  protected SimpleFeatureType createPointFeatureType() {

    final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    final AttributeTypeBuilder ab = new AttributeTypeBuilder();

    // Names should be unique (at least for a given GeoWave namespace) -
    // think about names in the same sense as a full classname
    // The value you set here will also persist through discovery - so when
    // people are looking at a dataset they will see the
    // type names associated with the data.
    builder.setName("Point");

    // The data is persisted in a sparse format, so if data is nullable it
    // will not take up any space if no values are persisted.
    // Data which is included in the primary index (in this example
    // lattitude/longtiude) can not be null
    // Calling out latitude an longitude separately is not strictly needed,
    // as the geometry contains that information. But it's
    // convienent in many use cases to get a text representation without
    // having to handle geometries.
    builder.add(ab.binding(
        Geometry.class).nillable(
            false).buildDescriptor(
                "geometry"));
    builder.add(ab.binding(
        Date.class).nillable(
            true).buildDescriptor(
                "TimeStamp"));
    builder.add(ab.binding(
        Double.class).nillable(
            false).buildDescriptor(
                "Latitude"));
    builder.add(ab.binding(
        Double.class).nillable(
            false).buildDescriptor(
                "Longitude"));
    builder.add(ab.binding(
        String.class).nillable(
            true).buildDescriptor(
                "TrajectoryID"));
    builder.add(ab.binding(
        String.class).nillable(
            true).buildDescriptor(
                "Comment"));

    return builder.buildFeatureType();
View Full Code Here

  public static SimpleFeatureType createGeoLifeTrackDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(GEOLIFE_TRACK_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Geometry.class).nillable(
        true).buildDescriptor(
        "geometry"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Date.class).nillable(
        true).buildDescriptor(
        "StartTimeStamp"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Date.class).nillable(
        true).buildDescriptor(
        "EndTimeStamp"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Long.class).nillable(
        true).buildDescriptor(
        "Duration"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Long.class).nillable(
        true).buildDescriptor(
        "NumberPoints"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "TrackId"));
    return simpleFeatureTypeBuilder.buildFeatureType();
View Full Code Here

  public static SimpleFeatureType createGeoLifePointDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(GEOLIFE_POINT_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Geometry.class).nillable(
        false).buildDescriptor(
        "geometry"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        false).buildDescriptor(
        "trackid"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Integer.class).nillable(
        true).buildDescriptor(
        "pointinstance"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Date.class).nillable(
        true).buildDescriptor(
        "Timestamp"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        true).buildDescriptor(
        "Latitude"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        true).buildDescriptor(
        "Longitude"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Double.class).nillable(
        true).buildDescriptor(
        "Elevation"));

    return simpleFeatureTypeBuilder.buildFeatureType();
View Full Code Here

  public static SimpleFeatureType createGPXTrackDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(GPX_TRACK_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Geometry.class).nillable(
        true).buildDescriptor(
        "geometry"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Name"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Date.class).nillable(
        true).buildDescriptor(
        "StartTimeStamp"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Date.class).nillable(
        true).buildDescriptor(
        "EndTimeStamp"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Long.class).nillable(
        true).buildDescriptor(
        "Duration"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Long.class).nillable(
        true).buildDescriptor(
        "NumberPoints"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "TrackId"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Long.class).nillable(
        true).buildDescriptor(
        "UserId"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "User"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Description"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Tags"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Source"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Comment"));

    return simpleFeatureTypeBuilder.buildFeatureType();
View Full Code Here

  public static SimpleFeatureType createGPXRouteDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(GPX_ROUTE_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Geometry.class).nillable(
        true).buildDescriptor(
        "geometry"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Name"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        Long.class).nillable(
        true).buildDescriptor(
        "NumberPoints"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "TrackId"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Symbol"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "User"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Description"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Source"));
    simpleFeatureTypeBuilder.add(attributeTypeBuilder.binding(
        String.class).nillable(
        true).buildDescriptor(
        "Comment"));

    return simpleFeatureTypeBuilder.buildFeatureType();
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.