Package org.geotools.data.collection

Examples of org.geotools.data.collection.ListFeatureCollection


            if (raf == null) {
                // simple case, we managed to keep everything in memory, sort and return a
                // reader based on the collection contents
                Collections.sort(features, comparator);

                SimpleFeatureIterator fi = new ListFeatureCollection(schema, features).features();
                return new DelegateSimpleFeatureReader(schema, fi);
            } else {
                // go merge-sort
                cleanFile = false;
                return new MergeSortReader(schema, raf, file, readers, comparator);
View Full Code Here


        tb.add("geom", geometry.getClass(), crs);
        SimpleFeatureType schema = tb.buildFeatureType();

        // build the feature
        SimpleFeature sf = SimpleFeatureBuilder.build(schema, new Object[] { geometry }, null);
        ListFeatureCollection result = new ListFeatureCollection(schema);
        result.add(sf);
        return result;
    }
View Full Code Here

        } else {
            generator = new MetricGenerator(center, quadrantSegments, UnitConverter.IDENTITY);
        }

        // we don't expect million of directions, so we use a simple in memory collection
        ListFeatureCollection result = new ListFeatureCollection(schema);
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema);
        for (int i = 0; i < distances.length; i++) {
            fb.add(generator.getBuffer(distances[i]));
            fb.add(distances[i]);
            result.add(fb.buildFeature("buffers." + (i + 1)));
        }

        return result;
    }
View Full Code Here

            final FeatureCollection<SimpleFeatureType, SimpleFeature> collection) {
        if (collection == null) {
            throw new NullPointerException("No content provided");
        }
        if (collection instanceof ListFeatureCollection) {
            ListFeatureCollection list = (ListFeatureCollection) collection;
            CollectionFeatureSource source = new CollectionFeatureSource(list);

            return source;
        }
        if (collection instanceof SpatialIndexFeatureCollection) {
View Full Code Here

        tb.add("buffer", Double.class);

        GeometryFactory gf = new GeometryFactory();
        SimpleFeatureBuilder b = new SimpleFeatureBuilder(tb.buildFeatureType());

        ListFeatureCollection features = new ListFeatureCollection(b.getFeatureType());
        for (int numFeatures = 0; numFeatures < 5; numFeatures++) {
            Coordinate array[] = new Coordinate[4];
            int j = 0;
            for (int i = 0 + numFeatures; i < 3 + numFeatures; i++) {
                array[j] = new Coordinate(i, i);
                j++;
            }
            array[3] = new Coordinate(numFeatures, numFeatures);
            LinearRing shell = new LinearRing(array, new PrecisionModel(), 0);
            b.add(gf.createPolygon(shell, null));
            b.add(0);
            b.add(numFeatures + 1);
            features.add(b.buildFeature(numFeatures + ""));
        }

        BufferFeatureCollection process = new BufferFeatureCollection();
        SimpleFeatureCollection output = process.execute(features, null, "buffer");
        assertEquals(5, output.size());
View Full Code Here

    }
    }
   
    public void testNearest() throws Exception {
        SimpleFeatureType type = DataUtilities.createType("nearestTest","name:String,size:int,flow:double,event:java.util.Date,data:java.io.File");
        ListFeatureCollection fc = new ListFeatureCollection(type);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd", Locale.ENGLISH);
        df.setTimeZone(TimeZone.getTimeZone("GMT"));
        fc.add(SimpleFeatureBuilder.build(type, new Object[] {"abc", 10, 10.5, df.parse("2014-12-10"), new File("/tmp/test.txt")}, null));
        fc.add(SimpleFeatureBuilder.build(type, new Object[] {"ade", 5, 3.5, df.parse("2012-11-10"), new File("/tmp/abc.txt")}, null));
        fc.add(SimpleFeatureBuilder.build(type, new Object[] {"zaa", 2, 50.4, df.parse("2010-11-10"), new File("/tmp/zaa.txt")}, null));

        // test on integer
        testNearest(fc, "size", 5, 5); // exact match
        testNearest(fc, "size", 1, 2); // below min
        testNearest(fc, "size", 3, 2); // mid
View Full Code Here

        tb.add("value", features.getSchema().getDescriptor(attIndex).getType().getBinding());
        tb.setName("UniqueValue");
        SimpleFeatureType ft = tb.buildFeatureType();
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(ft);

        ListFeatureCollection result = new ListFeatureCollection(ft);
        for (Object value : uniqueValues) {
            fb.add(value);
            result.add(fb.buildFeature(null));
        }
        return result;
    }
View Full Code Here

        Collection<StackedPoint> stackedPts = stackPoints(data, crsTransform, cellSizeSrc,
                outputEnv.getMinX(), outputEnv.getMinY());

        SimpleFeatureType schema = createType(srcCRS, normalize);
        ListFeatureCollection result = new ListFeatureCollection(schema);
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema);

        GeometryFactory factory = new GeometryFactory(new PackedCoordinateSequenceFactory());

        double[] srcPt = new double[2];
        double[] dstPt = new double[2];

        // Find maxima of the point stacks if needed.
        int maxCount = 0;
        int maxCountUnique = 0;
        if(normalize){
            for (StackedPoint sp : stackedPts) {
                if(maxCount<sp.getCount()) maxCount = sp.getCount();
                if(maxCountUnique<sp.getCount()) maxCountUnique = sp.getCountUnique();
            }
        }

        for (StackedPoint sp : stackedPts) {
            // create feature for stacked point
            Coordinate pt = getStackedPointLocation(preserveLocation, sp);
           
            // transform back to src CRS, since RT rendering expects the output to be in the same CRS
            srcPt[0] = pt.x;
            srcPt[1] = pt.y;
            invTransform.transform(srcPt, 0, dstPt, 0, 1);
            Coordinate psrc = new Coordinate(dstPt[0], dstPt[1]);

            Geometry point = factory.createPoint(psrc);
            fb.add(point);
            fb.add(sp.getCount());
            fb.add(sp.getCountUnique());
            if(normalize){
                fb.add(((double)sp.getCount())/maxCount);
                fb.add(((double)sp.getCountUnique())/maxCountUnique);
            }
           
            result.add(fb.buildFeature(null));
        }
        return result;
    }
View Full Code Here

    WKTReader2 wkt = new WKTReader2();
    List<SimpleFeature> collection = new LinkedList<SimpleFeature>();
    collection.add(SimpleFeatureBuilder.build(TYPE, new Object[] { wkt.read("POINT (1 2)"), "name1" }, null));
    collection.add(SimpleFeatureBuilder.build(TYPE, new Object[] { wkt.read("POINT (4 4)"), "name2" }, null));

    SimpleFeatureCollection featureCollection = new ListFeatureCollection(TYPE, collection);
 
    FeatureTransformer transform = new FeatureTransformer();
    transform.setEncoding(Charset.defaultCharset());
    transform.setIndentation(4);
    transform.setGmlPrefixing(true);
     
    // define feature information
    final SimpleFeatureType schema = featureCollection.getSchema();
    String prefix = (String) schema.getUserData().get("prefix");
    String namespace = schema.getName().getNamespaceURI();
    transform.getFeatureTypeNamespaces().declareDefaultNamespace(prefix, namespace);
    transform.addSchemaLocation(prefix, namespace);
   
View Full Code Here

        tbuilder.add("j", Long.class);
        tbuilder.add("k", BigDecimal.class);
        tbuilder.add("l", BigInteger.class);
        SimpleFeatureType type = tbuilder.buildFeatureType();
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
        ListFeatureCollection features = new ListFeatureCollection(type);
        for (int i = 0, ii = 20; i < ii; i++) {
            features.add(fb.buildFeature(null, new Object[] {
                    new GeometryFactory().createPoint(new Coordinate(1, -1)), new Byte((byte) i),
                    new Short((short) i), new Double(i), new Float(i), new String(i + " "),
                    new Date(i), new Boolean(true), new Integer(22),
                    new Long(1234567890123456789L),
                    new BigDecimal(new BigInteger("12345678901234567890123456789"), 2),
View Full Code Here

TOP

Related Classes of org.geotools.data.collection.ListFeatureCollection

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.