Package org.opengis.feature.simple

Examples of org.opengis.feature.simple.SimpleFeatureType


                                SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
                                b.setName("places");
                                b.setCRS(DefaultGeographicCRS.WGS84);
                                b.add("the_geom", MultiPoint.class);
                                b.add("name", String.class);
                                SimpleFeatureType type = b.buildFeatureType();

                                DefaultFeatureCollection newCollection = new DefaultFeatureCollection();

                                int size = keySet.size();

                                pm.beginTask("Converting geometries of places...", size);
                                int id = 0;
                                for( String name : keySet ) {
                                    Coordinate coordinate = placesMap.get(name);
                                    MultiPoint point = gF.createMultiPoint(new Coordinate[]{coordinate});
                                    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
                                    Object[] values = new Object[]{point, name};
                                    builder.addAll(values);
                                    SimpleFeature feature = builder.buildFeature(type.getTypeName() + "." + id);
                                    id++;
                                    newCollection.add(feature);
                                    pm.worked(1);
                                }
                                pm.done();
View Full Code Here


                    Messages.getString("OperationUtils_warning"), Messages.getString("OperationUtils_nolayer"), MSGTYPE.WARNING); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }
        ILayer toLayer = mapLayers.get(toPosition);

        SimpleFeatureType toSchema = toLayer.getSchema();
        SimpleFeatureType selectedSchema = selectedLayer.getSchema();
        int compare = DataUtilities.compare(toSchema, selectedSchema);
        if (compare != 0) {
            showMessage(display,
                    Messages.getString("OperationUtils_warning"), Messages.getString("OperationUtils_sametypeproblem"), //$NON-NLS-1$ //$NON-NLS-2$
                    MSGTYPE.WARNING);
View Full Code Here

                    FeatureSource.class, null);
            if (featureSource == null) {
                return Filter.INCLUDE;
            }

            SimpleFeatureType schema = layer.getSchema();

            Filter copy;
            if (filter instanceof SpatialOperator)
                copy = localize(schema, (SpatialOperator) filter);
            else
View Full Code Here

        }

    }

    boolean sameFeatureTypes( IStructuredSelection structuredSelection ) {
        SimpleFeatureType type = null;
        for( Iterator iter = structuredSelection.iterator(); iter.hasNext(); ) {
            Object obj = iter.next();
            if (!(obj instanceof SimpleFeature))
                return false;

            SimpleFeature feature = (SimpleFeature) obj;
            if (type == null)
                type = feature.getFeatureType();
            else if (!type.equals(feature.getFeatureType()))
                return false;
        }
        return true;
    }
View Full Code Here

        return list;
    }
   
    public static List<SimpleFeature> info2( ILayer layer, ReferencedEnvelope bbox, IProgressMonitor monitor ) throws Exception{
        FeatureSource<SimpleFeatureType, SimpleFeature> source = layer.getResource( FeatureSource.class, null );
        SimpleFeatureType type = source.getSchema();
        CoordinateReferenceSystem crs = layer.getCRS();
       
        if( !bbox.getCoordinateReferenceSystem().equals( crs )) {
            bbox = bbox.transform(crs, true);
        }
        FilterFactory2 factory = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Geometry geom = new GeometryFactory().toGeometry(bbox);
        Intersects filter = factory.intersects(factory.property(type.getGeometryDescriptor().getName()), factory.literal(geom));
       
        layer.getQuery(false);
        final FeatureCollection<SimpleFeatureType, SimpleFeature>  results = source.getFeatures( filter );
//        if( results.getCount() == 0 ) {
//            return null; // no content!
View Full Code Here

                try {
                    FeatureCollection<SimpleFeatureType, SimpleFeature> csvFileFeatureCollection = csvFileToFeatureCollection(
                            csvFile, crs, fieldsAndTypesIndex, separator, pm);

                    SimpleFeatureType featureType = csvFileFeatureCollection.getSchema();
                    JGrassCatalogUtilities.removeMemoryServiceByTypeName(featureType.getTypeName());
                    IGeoResource resource = CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource(featureType);

                    SimpleFeatureStore resolve = (SimpleFeatureStore) resource.resolve(FeatureStore.class, pm);
                    resolve.addFeatures(csvFileFeatureCollection);
                    ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(), Collections.singletonList(resource), -1);
View Full Code Here

            } else {
                Class<?> class1 = typesMap.get(typesArray[typeIndex]);
                b.add(fieldName, class1);
            }
        }
        SimpleFeatureType featureType = b.buildFeatureType();

        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
        Collection<Integer> orderedTypeIndexes = fieldsAndTypesIndex.values();
        Integer[] orderedTypeIndexesArray = (Integer[]) orderedTypeIndexes.toArray(new Integer[orderedTypeIndexes.size()]);

        BufferedReader bR = null;
        try {
            bR = new BufferedReader(new FileReader(csvFile));
            String line = null;
            int featureId = 0;
            pm.beginTask("Importing raw data", -1);
            while( (line = bR.readLine()) != null ) {
                pm.worked(1);
                line = line.trim();
                if (line.length() == 0) {
                    continue;
                }
                if (line.startsWith("#")) {
                    continue;
                }

                SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
                Object[] values = new Object[fieldNames.size() - 1];

                String[] lineSplit = line.split(separator);
                double x = Double.parseDouble(lineSplit[xIndex]);
                double y = Double.parseDouble(lineSplit[yIndex]);
                Point point = gf.createPoint(new Coordinate(x, y));
                values[0] = point;

                int objIndex = 1;
                for( int i = 0; i < lineSplit.length; i++ ) {
                    if (i == xIndex || i == yIndex) {
                        continue;
                    }

                    String value = lineSplit[i];
                    int typeIndex = orderedTypeIndexesArray[i];
                    String typeName = typesArray[typeIndex];
                    if (typeName.equals(typesArray[3])) {
                        values[objIndex] = value;
                    } else if (typeName.equals(typesArray[4])) {
                        values[objIndex] = new Double(value);
                    } else if (typeName.equals(typesArray[5])) {
                        values[objIndex] = new Integer(value);
                    } else {
                        throw new IllegalArgumentException("An undefined value type was found");
                    }
                    objIndex++;
                }
                builder.addAll(values);

                SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + featureId);
                featureId++;
                newCollection.add(feature);
            }
        } finally {
            if (bR != null)
View Full Code Here

        try {
            SimpleFeatureCollection collection = source.getFeatures();
            SimpleFeatureCollection output = process.executeList(collection, transform);

           
            final SimpleFeatureType featureType = output.getSchema();
           
            IGeoResource scratch = CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource( featureType );
            final SimpleFeatureStore store = scratch.resolve(SimpleFeatureStore.class, SubMonitor.convert(monitor,Messages.ReshapeOperation_createTempSpaceTask, 10));
           
            store.setTransaction( transaction );
View Full Code Here

    @Test
    public void testRun() throws Exception {
        GeometryFactory factory = new GeometryFactory();
        MultiPolygon mp=factory.createMultiPolygon(new Polygon[]{createPolygon(factory, 0), createPolygon(factory, 10)});
       
        SimpleFeatureType schema = handler.getEditLayer().getSchema();
        SimpleFeature feature = SimpleFeatureBuilder.build(schema, new Object[]{mp, "test"}, "test"); //$NON-NLS-1$ //$NON-NLS-2$
        SelectFeatureCommand command=new SelectFeatureCommand(handler, feature, null);
       
        assertEquals(1, bb.getGeoms().size());
        handler.getContext().sendSyncCommand(command);
View Full Code Here

                return;
            }
            MathTransform mt = createMathTransform(sourceLayer, targetLayer);
            FeatureCollection<SimpleFeatureType, SimpleFeature> features = source
                    .getFeatures(query);
            SimpleFeatureType schema = targetLayer.getSchema();

           
            CopyFeatureCollection c = new CopyFeatureCollection(schema, features, monitor, worked,
                    mt, attributeMap, targetLayer.layerToMapTransform());
            Envelope env = c.env;
View Full Code Here

TOP

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

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.