Package org.geotools.data.simple

Examples of org.geotools.data.simple.SimpleFeatureReader


    public static SimpleFeatureReader simple(final FeatureReader r) {
        if (r instanceof SimpleFeatureReader) {
            return (SimpleFeatureReader) r;
        }
        return new SimpleFeatureReader() {
            @Override
            public SimpleFeatureType getFeatureType() {
                return (SimpleFeatureType) r.getFeatureType();
            }
View Full Code Here


     * @throws IOException
     */
    public SortedFeatureIterator(SimpleFeatureIterator iterator, SimpleFeatureType schema,
            SortBy[] sortBy, int maxFeatures) throws IOException {
        DelegateSimpleFeatureReader reader = new DelegateSimpleFeatureReader(schema, iterator);
        SimpleFeatureReader sorted = new SortedFeatureReader(reader, sortBy, maxFeatures);
        this.delegate = new FeatureReaderFeatureIterator(sorted);
    }
View Full Code Here

        assertTableExists("bugsites");

        //check metadata contents
        assertFeatureEntry(entry);
       
        SimpleFeatureReader re = Features.simple(shp.getFeatureReader());
        SimpleFeatureReader ra = geopkg.reader(entry, null, null);

        while(re.hasNext()) {
            assertTrue(ra.hasNext());
            assertSimilar(re.next(), ra.next());
        }

        re.close();
        ra.close();
    }
View Full Code Here

    }

    @Test
    public void testMemorySort() throws IOException {
        // make it so that we are not going to hit the disk
        SimpleFeatureReader sr = null;
        try {
            sr = new SortedFeatureReader(fr, peopleAsc, 1000);
            assertSortedOnPeopleAsc(sr);
        } finally {
            if (sr != null) {
                sr.close();
            }
        }
    }
View Full Code Here

    }
   
    @Test
    public void testFileSortDate() throws IOException {
        // make it so that we are not going to hit the disk
        SimpleFeatureReader sr = null;
        try {
            sr = new SortedFeatureReader(fr, dateAsc, 100);
            assertSortedOnDateAsc(sr);
        } finally {
            if (sr != null) {
                sr.close();
            }
        }
    }
View Full Code Here

    }

    @Test
    public void testFileSortPeople() throws IOException {
        // make it so that we are not going to hit the disk
        SimpleFeatureReader sr = null;
        try {
            sr = new SortedFeatureReader(fr, peopleAsc, 5);
            assertSortedOnPeopleAsc(sr);
        } finally {
            if (sr != null) {
                sr.close();
            }
        }
    }
View Full Code Here

    }

    @Test
    public void testSortDescending() throws IOException {
        // make it so that we are not going to hit the disk
        SimpleFeatureReader sr = null;
        try {
            sr = new SortedFeatureReader(fr, peopleDesc, 1000);
            double prev = -1;
            while (fr.hasNext()) {
                SimpleFeature f = fr.next();
                double curr = (Double) f.getAttribute("PERSONS");
                if (prev > 0) {
                    assertTrue(curr <= prev);
                }
                prev = curr;
            }
        } finally {
            if (sr != null) {
                sr.close();
            }
        }
    }
View Full Code Here

    }

    @Test
    public void testSortNatural() throws IOException {
        // make it so that we are not going to hit the disk
        SimpleFeatureReader sr = null;
        try {
            sr = new SortedFeatureReader(fr, fidAsc, 1000);
            String prev = null;
            while (fr.hasNext()) {
                SimpleFeature f = fr.next();
                String id = f.getID();
                if (prev != null) {
                    assertTrue(id.compareTo(prev) >= 0);
                }
                prev = id;
            }
        } finally {
            if (sr != null) {
                sr.close();
            }
        }
    }
View Full Code Here

                queue.addSource(fc);
                store.submit(fc);
            }

            // build a reader out of the queue
            SimpleFeatureReader reader = new QueueReader(queue, target);
            return reader;
        } catch (SchemaException e) {
            throw new IOException("Failed to compute target feature type", e);
        }
    }
View Full Code Here

        box = source.getBounds(new Query("bar", CQL.toFilter("baz = 'ten'")));
        assertNotNull(box);
        assertTrue(box.contains(new Coordinate(10,10)));
        assertFalse(box.contains(new Coordinate(20,20)));
       
        SimpleFeatureReader r = (SimpleFeatureReader)
            dataStore.getFeatureReader(new Query("bar"), Transaction.AUTO_COMMIT);
       
        assertNotNull(r);
        assertTrue(r.hasNext());
      
        SimpleFeature f = r.next();
        assertNotNull(f);
        assertTrue(f.getDefaultGeometry() instanceof Point);
        assertTrue(new Coordinate(10,10).equals2D(((Point)f.getDefaultGeometry()).getCoordinate()));
        assertEquals("ten", f.getAttribute("baz"));
       
        assertTrue(r.hasNext());
        f = r.next();
        assertNotNull(f);
        assertTrue(f.getDefaultGeometry() instanceof Point);
        assertTrue(new Coordinate(20,20).equals2D(((Point)f.getDefaultGeometry()).getCoordinate()));
        assertEquals("twenty", f.getAttribute("baz"));
        r.close();
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.simple.SimpleFeatureReader

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.