Examples of SimpleFeatureTypeBuilder


Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

                if (ft.getDescriptor(index) == editElement)
                    break;
            }
            if (index == ft.getAttributeCount())
                return;
            SimpleFeatureTypeBuilder builder = builderFromFeatureType(ft);
            builder.remove(ft.getDescriptor(index).getLocalName());
            builder.add(index, newAttr);
            featureType = builder.buildFeatureType();
            viewer.setInput(featureType);
        }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

        }
    }

  private AttributeDescriptor getAttributeDescriptor(int index) {
        TreeViewer testingGetViewer = editor.testingGetViewer();
    SimpleFeatureTypeBuilder newFeatureTypeBuilder = (SimpleFeatureTypeBuilder) testingGetViewer.getInput();
        SimpleFeatureType type = newFeatureTypeBuilder.buildFeatureType();
        AttributeDescriptor attributeType = type.getDescriptor(index);
    return attributeType;
  }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

    @Ignore
    @Test
    public void testSetFeatureType() throws Exception {
        editor.setFeatureType(null);

        SimpleFeatureTypeBuilder builder = (SimpleFeatureTypeBuilder) editor.testingGetViewer().getInput();
        assertEquals(2, builder.buildFeatureType().getAttributeCount());
        assertEquals(Messages.FeatureTypeEditor_newFeatureTypeName, builder.getName());
        assertEquals(String.class, getAttributeDescriptor(0).getType().getBinding());
        assertEquals(Messages.FeatureTypeEditor_defaultNameAttributeName, getAttributeDescriptor(0).getName());
        assertEquals(LineString.class, getAttributeDescriptor(1).getType().getBinding());
        assertEquals(Messages.FeatureTypeEditor_defaultGeometryName, getAttributeDescriptor(1).getName());
        assertEquals(Messages.FeatureTypeEditor_newFeatureTypeName, editor.testingGetNameText().getText() );
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

       
        TreeViewer viewer = editor.testingGetViewer();
        viewer.setSelection(new StructuredSelection(featureType.getDescriptor(0)));
        action.runWithEvent(new Event());

        SimpleFeatureTypeBuilder builder = (SimpleFeatureTypeBuilder) editor.testingGetViewer().getInput();
        assertEquals(1, builder.buildFeatureType().getAttributeCount());
        assertEquals(String.class, builder.buildFeatureType().getDescriptor(0).getType().getBinding());
        assertEquals("name", builder.buildFeatureType().getDescriptor(0).getName()); //$NON-NLS-1$

        IAction create = editor.getCreateAttributeAction();
        create.runWithEvent(new Event());
        create.runWithEvent(new Event());

        assertEquals(3, builder.buildFeatureType().getAttributeCount());

        List<AttributeDescriptor> attrs = new ArrayList<AttributeDescriptor>(2);
        attrs.add(builder.buildFeatureType().getDescriptor(1));
        attrs.add(builder.buildFeatureType().getDescriptor(2));
        viewer.setSelection(new StructuredSelection(attrs));

        action.runWithEvent(new Event());

        assertEquals(1, builder.buildFeatureType().getAttributeCount());
        assertEquals(String.class, builder.buildFeatureType().getDescriptor(0).getType().getBinding());
        assertEquals("name", builder.buildFeatureType().getDescriptor(0).getName()); //$NON-NLS-1$

    }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

    }
   
    @Ignore
    @Test
    public void testCreateLabel() throws Exception {
        SimpleFeatureTypeBuilder builder = (SimpleFeatureTypeBuilder) editor.testingGetViewer().getInput();
       
        Text text=editor.testingGetNameText();
        text.setText("newName"); //$NON-NLS-1$
        Event event = new Event();
        event.character=SWT.Selection;
        text.notifyListeners(SWT.KeyDown, event);

        assertEquals("newName", builder.getName()); //$NON-NLS-1$
       
        text.setText("newName"); //$NON-NLS-1$
        event = new Event();
        event.character=SWT.ESC;
        text.notifyListeners(SWT.KeyDown, event);
       
        assertEquals("newName", builder.getName()); //$NON-NLS-1$
       
        text.setSelection(0,0);
        event = new Event();
        text.notifyListeners(SWT.FocusIn, event);
        assertEquals(new Point(0,text.getText().length()), text.getSelection());
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

      attributeValue = new String[1];
    }
    if (crs == null) {
        crs = DefaultGeographicCRS.WGS84;
    }
    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName("test");
    builder.crs(crs).add("geom", Geometry.class);
    builder.setCRS(crs);
    builder.add("name", String.class);
    SimpleFeatureType ft = builder.buildFeatureType();
    int size = Math.max(geom.length, attributeValue.length);
    SimpleFeature[] features = new SimpleFeature[size];
    for (int i = 0; i < size; i++) {
      Geometry geometry;
      if (i >= geom.length)
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

                ds.updateSchema(localPart, featureType);
            } catch (Exception e) {
                // some datastores do not support schema update, try a name change
                // create the feature type
                String name = checkSameName(typeNamesList, localPart);
                SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
                b.setName(name);
                b.setCRS(featureType.getCoordinateReferenceSystem());
                List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
                b.addAll(attributeDescriptors);
                featureType = b.buildFeatureType();
                ds.createSchema(featureType);
            }
        } else {
            ds.createSchema(featureType);
        }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

        FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
       
        String attributeName = "string";
        PropertyIsEqualTo filter = fac.equals(fac.property(attributeName), fac.literal("Value"));
       
        SimpleFeatureTypeBuilder builder=new SimpleFeatureTypeBuilder();
        builder.setName("test");
        builder.restriction(filter).add(attributeName, String.class);
       
        SimpleFeatureType featureType = builder.buildFeatureType();
       
        AttributeValidator validator=new AttributeValidator(featureType.getDescriptor(attributeName), featureType);
       
        String valid = validator.isValid("Value");
        assertNull( "Valid", valid );
       
        assertNotNull( "Should not allow 'IllegalValue'", validator.isValid("IllegalValue") );
       
        assertNotNull( "Should not allow 3", validator.isValid(3) );
       
        builder.length(5).nillable(true).add(attributeName,String.class);
        featureType = builder.buildFeatureType();

        validator=new AttributeValidator(featureType.getDescriptor(attributeName), featureType);
       
        assertNull( validator.isValid("name") );
        assertNotNull( validator.isValid("IllegalValue") );
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

     *
     * @param parent the composite that will be used as the TreeViewer's parent.
     * @param layoutData the layout data to use to layout the editor. If null GridData(Fill_Both)
     */
    public void createTable( Composite parent, Object layoutData, SimpleFeatureType type ) {
      SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
      builder.setName(type.getName());
        builder.init(type);
        createTable(parent, layoutData, builder.buildFeatureType(), true);
    }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureTypeBuilder

    private DialogCellEditor createCRSEditor( Tree tree ) {
        return new CRSDialogCellEditor(tree);
    }
   
    public SimpleFeatureTypeBuilder builderFromFeatureType( SimpleFeatureType ft ) {
        SimpleFeatureTypeBuilder ftB;
        ftB = new SimpleFeatureTypeBuilder();
        ftB.init(ft);
        ftB.setName(ft.getName());
        return ftB;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.