Package org.opengis.feature.type

Examples of org.opengis.feature.type.AttributeDescriptor


    List<AttributeDescriptor> attributes = prototype.getAttributeDescriptors();
    GeometryDescriptor defaultGeometry = prototype.getGeometryDescriptor();

    for (int i = 0; i < attributes.size(); i++) {

      AttributeDescriptor att = attributes.get(i);

      if (att == defaultGeometry) {
        if (att.getType().getBinding() != MultiPolygon.class && att.getType().getBinding() != Polygon.class) {

          Class<?> targetGeomType = Polygon.class;
          final Class<?> sourceGeomClass = defaultGeometry.getType().getBinding();
          if (GeometryCollection.class.isAssignableFrom(sourceGeomClass)) {

            targetGeomType = MultiPolygon.class;
          }
          final String geomTypeName = att.getLocalName();
          CoordinateReferenceSystem crs = defaultGeometry.getCoordinateReferenceSystem();

          AttributeTypeBuilder build = new AttributeTypeBuilder();
          build.setName(geomTypeName);
          build.setBinding(targetGeomType);
          build.setNillable(true);
          build.setCRS(crs);

          GeometryType type = build.buildGeometryType();
          att = build.buildDescriptor(geomTypeName, type);

        }
        builder.add(att);
        builder.setDefaultGeometry(att.getLocalName());
      } else {
        builder.add(att);
      }
    }
    return builder;
View Full Code Here


    assert defaultGeomAttr != null : "default geometry was expected"; //$NON-NLS-1$

    // adds all attributes without default geometry
    for (int i = 0; i < attributes.size(); i++) {
      AttributeDescriptor att = attributes.get(i);
      if (att != defaultGeomAttr) {
        builder.add(att);
      }
    }
    // create the default geometry with Geometry Class value
View Full Code Here

    AttributeTypeBuilder build = new AttributeTypeBuilder();
    build.setName(attributeName);
    build.setNillable(true);
    build.setBinding(clazz);

    AttributeDescriptor att = build.buildDescriptor(attributeName);

    builder.add(att);

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

                return new FeaturePropertySource((SimpleFeature) feature.getAttribute(i), true);
            }
        }
        if (id instanceof Integer) {
            Integer i = (Integer) id;
            AttributeDescriptor attrType = attrs.get(i.intValue());
            if ( attrType instanceof GeometryDescriptor )
                return getGeomProperty((Geometry) feature.getAttribute(i.intValue()));
            if (Collection.class.isAssignableFrom(attrType.getType().getBinding()))
                return getAttrProperty(attrType, feature.getAttribute(i.intValue()));
            // return feature.getAttribute(i.intValue()).toString();
            Object attr = feature.getAttribute(i.intValue());

            if (!(attr instanceof Boolean) && !(attr instanceof CodeList)) {
View Full Code Here

      StyleLayer selectedLayer) {
    SimpleFeatureType featureType = selectedLayer.getSchema();
   
    if (featureType != null) {
        for (int i = 0; i < featureType.getAttributeCount(); i++) {
            AttributeDescriptor attributeType = featureType.getDescriptor(i);
            if (!(attributeType instanceof GeometryDescriptor)) { //don't include the geometry
                attributeCombo.add(attributeType.getName().getLocalPart());
                if (isNumber(attributeType)) {
                    numericAttr.add(attributeType.getName().getLocalPart());
                }
            }
        }
        //select the first numeric attribute that isn't ID
        int index = -1;
View Full Code Here

    }
       
    private AttributeDescriptor getAttributeType(String attributeTypeName) {
        SimpleFeatureType featureType = getSelectedLayer().getSchema();
        for (int i = 0; i < featureType.getAttributeCount(); i++) {
            AttributeDescriptor attributeType = featureType.getDescriptor(i);
            //if (attributeType.getName().equals(attributeTypeName)) return attributeType;
            if (attributeType.getName().getLocalPart().equals(attributeTypeName)) return attributeType;
        }
        return null;
    }
View Full Code Here

                PropertyType property = (PropertyType) prop.next();

                //check that valus that are non-nillable exist
                if (property.getValue() == null) {
                    String propertyName = property.getName().getLocalPart();
                    AttributeDescriptor attributeType = null;
                    PropertyDescriptor pd = featureType.getDescriptor(propertyName);
                    if(pd instanceof AttributeDescriptor) {
                        attributeType = (AttributeDescriptor) pd;
                    }
                    if ((attributeType != null) && (attributeType.getMinOccurs() > 0)) {
                        String msg = "Property '" + attributeType.getLocalName()
                            + "' is mandatory but no value specified.";
                        throw new WFSException(msg, "MissingParameterValue");
                    }
                }
               
View Full Code Here

            HSSFCell cell;
           
            cell = header.createCell(0);
            cell.setCellValue(new HSSFRichTextString("FID"));
            for ( int i = 0; i < ft.getAttributeCount(); i++ ) {
                AttributeDescriptor ad = ft.getDescriptor(i);
               
                cell = header.createCell(i+1);
                cell.setCellValue(new HSSFRichTextString(ad.getLocalName()));
            }
           
            // write out the features
            FeatureIterator<SimpleFeature> i = fc.features();
            int r = 0; // row index
View Full Code Here

    static SimpleFeature retype(SimpleFeature source, SimpleFeatureBuilder builder)
            throws IllegalAttributeException {
        SimpleFeatureType target = builder.getFeatureType();
        for (int i = 0; i < target.getAttributeCount(); i++) {
            AttributeDescriptor attributeType = target.getDescriptor(i);
            Object value = null;

            if (source.getFeatureType().getDescriptor(attributeType.getName()) != null) {
                value = source.getAttribute(attributeType.getName());
            }

            builder.add(value);
        }
View Full Code Here

        public void write() throws IOException {
            try {
                SimpleFeatureType target = getFeatureType();
                for (int i = 0; i < target.getAttributeCount(); i++) {
                    AttributeDescriptor at = target.getDescriptor(i);
                    Object value = retyped.getAttribute(i);
                    current.setAttribute(at.getLocalName(), value);
                }
                delegate.write();
            } catch (IllegalAttributeException e) {
                throw (IOException) new IOException("Error occurred while retyping feature")
                        .initCause(e);
View Full Code Here

TOP

Related Classes of org.opengis.feature.type.AttributeDescriptor

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.