Package org.opengis.feature.simple

Examples of org.opengis.feature.simple.SimpleFeature


        //add the two geometries to a FeatureCollection
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName( "Test" );
        b.add( "location", Polygon.class );
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeature donutFeature = SimpleFeatureBuilder.build(type, new Object[]{donut}, "fid.1");
        SimpleFeature holeFeature = SimpleFeatureBuilder.build(type, new Object[]{hole}, "fid.2");
        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        fc.add(donutFeature);
        fc.add(holeFeature);
       
        //create iterator for collection
View Full Code Here


        //Testing searching through the layer for the closest point.
        assertEquals(2, editBlackboard.getCoords(30,20).size());

        ILayer editLayer = handler.getEditLayer();
        FeatureSource<SimpleFeatureType, SimpleFeature> source = editLayer.getResource(FeatureSource.class, new NullProgressMonitor());
        SimpleFeature feature = source.getFeatures().features().next();
        Coordinate coord = ((Geometry) feature.getDefaultGeometry()).getCoordinates()[1];
        Coordinate t = JTS.transform(coord, new Coordinate(), editLayer.layerToMapTransform());
        java.awt.Point pointOnScreen = handler.getContext().worldToPixel(t);
        handler.getMouseTracker().setDragStarted(Point.valueOf(30,20));
        event = new MapMouseEvent( DISPLAY, pointOnScreen.x+5,pointOnScreen.y,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
View Full Code Here

            reader.parse(input);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        SimpleFeature feature=collection.features().next();
        ReferencedEnvelope bounds = new ReferencedEnvelope(feature.getBounds());
        bounds=new ReferencedEnvelope( bounds.getMinX()-(bounds.getWidth()/8),
                bounds.getMaxX()+(bounds.getWidth()/8),
                bounds.getMinY()-(bounds.getHeight()/4),
                bounds.getMaxY()+(bounds.getHeight()/4), DefaultGeographicCRS.WGS84 );
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, ScaleUtils.worldToScreenTransform(bounds, new Dimension(100,100)), layerToWorld);
       
        map.setGeometries((Geometry) feature.getDefaultGeometry(), null);
       
        Polygon poly=(Polygon) ((MultiPolygon) feature.getDefaultGeometry()).getGeometryN(0);
       
        PrimitiveShape shell = map.getGeoms().get(0).getShell();
        assertEquals(poly.getExteriorRing().getCoordinates().length, shell.getNumCoords());
        for (int i=0; i<shell.getNumCoords(); i++){
            assertEquals("i="+i, poly.getExteriorRing().getCoordinateN(i), shell.getCoord(i)); //$NON-NLS-1$
View Full Code Here

    public void testRun() throws Exception {
        final TestHandler handler=new TestHandler();
       
        ILayer layer = handler.getContext().getMapLayers().get(0);
        FeatureSource<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureSource.class, null);
        SimpleFeature feature = resource.getFeatures().features().next();
        IEditManager editManager = handler.getContext().getEditManager();
    ((EditManager)editManager).setEditFeature(feature, (Layer) layer);
       
        EditBlackboard editBlackboard = handler.getEditBlackboard();
        PrimitiveShape shell = editBlackboard.getGeoms().get(0).getShell();
        editBlackboard.addPoint(100,100,shell);
        shell.getEditGeom().setShapeType(ShapeType.POINT);
        editBlackboard.newGeom("newone", null); //$NON-NLS-1$
       
        StartEditingBehaviour behav=new StartEditingBehaviour(ShapeType.POLYGON);

        handler.getBehaviours().add(behav);
       
        assertNotNull( editManager.getEditFeature());
       
        handler.setTesting(false);
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
        try{
            PlatformGIS.wait(200, 200, WaitCondition.FALSE_CONDITION, null);
        }catch (Exception e) {
            // its expected
        }
        assertEquals(1, handler.getEditBlackboard().getGeoms().size());
       
        ((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
       
        assertEquals("Is the feature ID equal", feature.getID(), editManager.getEditFeature().getID());       
        assertEquals("Is the feature equal", feature, editManager.getEditFeature());
        assertFalse( handler.isLocked() );
        assertEquals(2, editBlackboard.getGeoms().size());
        assertEquals(ShapeType.POINT, editBlackboard.getGeoms().get(0).getShapeType());
        assertEquals(Point.valueOf(100,100), editBlackboard.getGeoms().get(0).getShell().getPoint(0));
View Full Code Here

    public BufferedImage line( final Rule rule, final int width, final int height ) {
        BufferedImage bI = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

        int[] coords = new int[]{scale(1), scale(14), scale(6), scale(0), scale(11), scale(14),
                scale(15), scale(1)};
        final SimpleFeature feature = java2dDrawing.feature(java2dDrawing.line(coords));
        java2dDrawing.drawDirect(bI, display, feature, rule);
        return bI;
    }
View Full Code Here

            public boolean hasNext() {
                while( feature==null ){
                    if ( !iter.hasNext() )
                        return false;
                    SimpleFeature next = iter.next();
                    if( next==null )
                        continue;
                    Geometry geometry=(Geometry) next.getAttribute(typeToUseAsGeometry.getName());
                    geometry = toCollection(geometry);
                    if (geometry != null) {
                        try {
                            geometry = JTS.transform(geometry, mt);
                        } catch (TransformException e) {
                            throw (RuntimeException) new RuntimeException(
                                    Messages.ReprojectingFeatureCollection_transformationError
                                            + next.getID()).initCause(e);
                        }
                    }
                    feature = new FeatureWrapper(next, schema, new Geometry[]{geometry},
                                new String[]{ schema.getGeometryDescriptor().getName().getLocalPart()});
                }
               
                return feature!=null;
            }

            public SimpleFeature next() {
                SimpleFeature tmp = feature;
                feature=null;
                monitor.worked(1);
                return tmp;
            }
View Full Code Here

        FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
        IViewportModel viewPort = ApplicationGIS.getActiveMap().getViewportModel();
        List<AbstractDrawCommand> commands = new ArrayList<AbstractDrawCommand>();
        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
            Geometry fGeom = (Geometry) feature.getDefaultGeometry();
            if (!crsEqual) {
                fGeom = JTS.transform(fGeom, mathTransform);
            }
            Coordinate[] coords = fGeom.getCoordinates();
            java.awt.Point start = viewPort.worldToPixel(coords[0]);
View Full Code Here

        SimpleFeatureIterator featureIterator = featureCollection.features();
        EditCommandFactory cmdFactory = EditCommandFactory.getInstance();
        List<UndoableMapCommand> cmdList = new LinkedList<UndoableMapCommand>();
        count = 0;
        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            Geometry newGeometry = geometry.reverse();
            UndoableMapCommand setGeometryCmd = cmdFactory.createSetGeomteryCommand(feature, selectedLayer, newGeometry);
            cmdList.add(setGeometryCmd);
            count++;
        }
View Full Code Here

            if (info.getMimeType() == null) {
                getDetails().showPage(information);
            } else if (info.getMimeType().startsWith(LayerPointInfo.GML)) {
                getDetails().showPage(featureDisplay.getControl());
                try {
                    SimpleFeature feature = (SimpleFeature) info.acquireValue();
                    FeaturePropertySource src = new FeaturePropertySource(feature);
                    StructuredSelection sel = new StructuredSelection(src);
                    featureDisplay.selectionChanged(null, sel);
                } catch(IOException ex) {
                    InfoPlugin.log("GML value could not be acquired.", ex); //$NON-NLS-1$
View Full Code Here

                TreeItem removedItem = null;
                for( int i = 0; i < treeItems.length; i++ ) {
                    TreeItem item = treeItems[i];

                    if (item.getData() instanceof SimpleFeature) {
                        SimpleFeature feature = (SimpleFeature) item.getData();
                        Filter id = createFidFiler(feature.getID());
                        if (!isFeatureOnStore(id)) {
                            // this feature was removed, so remove from tree.
                            removedItem = treeItems[i];
                            break;
                        }
View Full Code Here

TOP

Related Classes of org.opengis.feature.simple.SimpleFeature

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.