Package org.opengis.feature.type

Examples of org.opengis.feature.type.AttributeDescriptor


    /** Today is used as a default; unless the attribute descriptor has a better idea */
    protected void doLoadDefault() {
        if (dateTime != null && getFeature() != null ) {
            SimpleFeatureType schema = getFeature().getFeatureType();
            AttributeDescriptor descriptor = schema.getDescriptor( getAttributeName());           
            Object value =  descriptor.getDefaultValue();      
            Date date = Converters.convert(value, Date.class );
           
            if( date == null ){
                date = new Date(); // today!
            }
View Full Code Here


    }

    @Override
    protected void doStore() {
        SimpleFeatureType schema = getFeature().getFeatureType();
        AttributeDescriptor descriptor = schema.getDescriptor( getAttributeName())
        int year = dateTime.getYear();
        int day = dateTime.getDay();
        int month = dateTime.getMonth(); // from 0=Jan
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day);
       
        Date date = cal.getTime();
       
        Object value = Converters.convert( date, descriptor.getType().getBinding() );       
        getFeature().setAttribute( getAttributeName(), value );
    }
View Full Code Here

                public void runWithEvent( Event event ) {
                    SimpleFeatureType ft = (SimpleFeatureType) viewer.getInput();
                    SimpleFeatureTypeBuilder ftB = builderFromFeatureType(ft);
                    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                    for( Iterator<AttributeDescriptor> iter = selection.iterator(); iter.hasNext(); ) {
                        AttributeDescriptor element = iter.next();
                        ftB.remove(element.getLocalName());
                    }
                    featureType = ftB.buildFeatureType();
                    viewer.setInput(featureType);
                }
            };
View Full Code Here

     * type schema and sets it to the check box.
     */
    protected void doLoadDefault() {
        if (checkBox != null) {
            SimpleFeatureType schema = getFeature().getFeatureType();
            AttributeDescriptor descriptor = schema.getDescriptor(getAttributeName());
            Object value = descriptor.getDefaultValue();
           
            Boolean check = toBoolean(value);
           
            checkBox.setSelection(check);
            wasSelected = check;
View Full Code Here

    /*
     * (non-Javadoc) Method declared on AttributeField.
     */
    protected void doStore() {
        SimpleFeatureType schema = getFeature().getFeatureType();
        AttributeDescriptor descriptor = schema.getDescriptor(getAttributeName());
        Class< ? > binding = descriptor.getType().getBinding();
       
        boolean check = checkBox.getSelection();
       
        Object checkValue = check ? YES : NO;
        Object value = Converters.convert(checkValue, binding);
View Full Code Here

     *
     * @see org.eclipse.jface.preference.AttributeField#doLoadDefault()
     */
    protected void doLoadDefault() {
        SimpleFeatureType schema = getFeature().getFeatureType();
        AttributeDescriptor descriptor = schema.getDescriptor(getAttributeName());
        Object value = descriptor.getDefaultValue();
        ISelection selection = new StructuredSelection(value);
        viewer.removeSelectionChangedListener(listener);
        viewer.setSelection(selection, true);
        viewer.addSelectionChangedListener(listener);
    }
View Full Code Here

       
        // Need to get all available labels
        //check if this layer has a feature
        Layer currLayer = getLayer();
        List<AttributeDescriptor> attributeList = null;
        AttributeDescriptor defaultGeom = null;
        if (currLayer.hasResource(FeatureSource.class)) {
            SimpleFeatureType ft = currLayer.getSchema();
            attributeList = ft.getAttributeDescriptors();
            defaultGeom=ft.getGeometryDescriptor();
        }
        labelCombo.removeAll();
        if (attributeList != null) {
            for( int i = 0; i < attributeList.size(); i++ ) {
                AttributeDescriptor attributeDescriptor = attributeList.get(i);
        if( attributeDescriptor != defaultGeom )
                    labelCombo.add(attributeDescriptor.getName().getLocalPart());
                if( label != null && attributeDescriptor != null &&
                        attributeDescriptor.getName().equals(label.toString()) ) {
                    //Set the correct initial label
                    labelCombo.select(i);
                } else if( i == 0 ) {
                    labelCombo.select(i);
                }
View Full Code Here

            // we will not use it.
            crs = null;
        }

        for( int i = 0; i < schema.getAttributeCount(); i++ ) {
            AttributeDescriptor attribute = schema.getDescriptor(i);
            if (!(attribute instanceof GeometryDescriptor)) {
                builder.add(attribute);
            } else {
                GeometryDescriptor geom = schema.getGeometryDescriptor();
                builder.crs(crs).defaultValue(null).restrictions(geom.getType().getRestrictions())
View Full Code Here

   
    for (String property : propertiesList) {

      assert source.getAttribute(property) != null : "propery should be in the source feature"; //$NON-NLS-1$
     
      AttributeDescriptor propDescriptor = target.getFeatureType().getDescriptor(property);
      if(propDescriptor != null){
       
        target = copyAttributeValue(property, source, target);
      }
    }
View Full Code Here

      final String attrName,
      final SimpleFeature source,
      SimpleFeature target ) {
   
    // if the attributes are compatible (equals name and type) then does the copy
    AttributeDescriptor sourceAttrDescriptor = source.getType().getDescriptor(attrName);
    if(sourceAttrDescriptor != null){
     
      AttributeDescriptor targetAttrDescriptor = target.getType().getDescriptor(attrName);
      if(targetAttrDescriptor != null){
       
        Class<?> sourceClass = sourceAttrDescriptor.getType().getBinding();
        Class<?> targetClass = targetAttrDescriptor.getType().getBinding();
        if(sourceClass.isAssignableFrom(targetClass) ){

          Object value =source.getAttribute(attrName);
          target.setAttribute(attrName, value);
        }
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.