Package org.geotools.data.simple

Examples of org.geotools.data.simple.SimpleFeatureIterator


       
        // check size
        assertEquals(1, features.size());
       
        // check actual iteration
        SimpleFeatureIterator it = features.features();
        try {
            assertTrue(it.hasNext());
            SimpleFeature f = it.next();
            ReferencedEnvelope fe = ReferencedEnvelope.reference(f.getBounds());
            assertEquals(1, ((Number) f.getAttribute(aname("intProperty"))).intValue());
            assertFalse(it.hasNext());
            //assertEquals(fe, features.getBounds());
            assertTrue(areReferencedEnvelopesEuqal(fe, features.getBounds()));
        } finally {
            it.close();
        }
    }
View Full Code Here


    }
   
    public void testNaturalSortingAsc() throws Exception {
        Query q = new Query(featureSource.getSchema().getTypeName());
        q.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER});
        SimpleFeatureIterator features = featureSource.getFeatures(q).features();
        String prevId = null;
        while(features.hasNext()) {
            String currId = features.next().getID();
            if(prevId != null)
                assertTrue(prevId.compareTo(currId) <= 0);
            prevId = currId;
        }
        features.close();
    }
View Full Code Here

    }
   
    public void testNaturalSortingdesc() throws Exception {
        Query q = new Query(featureSource.getSchema().getTypeName());
        q.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER});
        SimpleFeatureIterator features = featureSource.getFeatures(q).features();
        String prevId = null;
        while(features.hasNext()) {
            String currId = features.next().getID();
            if(prevId != null)
                assertTrue(prevId.compareTo(currId) >= 0);
            prevId = currId;
        }
        features.close();
    }
View Full Code Here

        }
        features.close();
    }
   
    public void testFeatureIteratorNextContract() throws Exception {
        SimpleFeatureIterator features = featureSource.getFeatures().features();
       
        try {
            // 1) non empty iterator, calling next() should just return the feature
            SimpleFeature f = features.next();
            assertNotNull(f);
        } finally {       
            features.close();
        }
    }
View Full Code Here

      boolean r = true;
     
        SimpleFeatureSource fsLine = (SimpleFeatureSource) layers.get(getLineTypeRef());
       
        SimpleFeatureCollection fcLine = fsLine.getFeatures();
        SimpleFeatureIterator fLine = fcLine.features();
       
        SimpleFeatureSource fsPoly = (SimpleFeatureSource) layers.get(getRestrictedPolygonTypeRef());
        
        ListFeatureCollection fcPoly = new ListFeatureCollection( fsPoly.getFeatures() );
               
        while(fLine.hasNext()){
          SimpleFeature line = fLine.next();
            SimpleFeatureIterator fPoly = fcPoly.features();
            Geometry lineGeom = (Geometry) line.getDefaultGeometry();
            if(envelope.contains(lineGeom.getEnvelopeInternal())){
              //   check for valid comparison
              if(LineString.class.isAssignableFrom(lineGeom.getClass())){
                while(fPoly.hasNext()){
                  SimpleFeature poly = fPoly.next();
                  Geometry polyGeom = (Geometry) poly.getDefaultGeometry();
                        if(envelope.contains(polyGeom.getEnvelopeInternal())){
                          if(Polygon.class.isAssignableFrom(polyGeom.getClass())){
                            Geometry polyGeomBoundary = polyGeom.getBoundary();
                            if(!polyGeomBoundary.contains(lineGeom)){
View Full Code Here

     
      LineStringGraphGenerator lgb = new LineStringGraphGenerator();
      SimpleFeatureSource fs = (SimpleFeatureSource) layers.get(typeName);
      SimpleFeatureCollection fr = fs.getFeatures();
      SimpleFeatureCollection fc = fr;
      SimpleFeatureIterator f = fc.features();

      while (f.hasNext()) {
          SimpleFeature ft = f.next();

          if (envelope.contains(ft.getBounds())) {
              //lgb.add(ft);
            lgb.add(ft.getDefaultGeometry());
          }
View Full Code Here

    }
   
    public void testFeatureIteratorEmptyContract() throws Exception {
        FilterFactory ff = dataStore.getFilterFactory();
        PropertyIsEqualTo filter = ff.equals(ff.property(aname("stringProperty")), ff.literal("not_there"));
        SimpleFeatureIterator features = featureSource.getFeatures(filter).features();
       
       
        try {
            // 1) non empty iterator, calling next() should just return the feature
            SimpleFeature f = features.next();
            assertNotNull(f);
        } catch(NoSuchElementException e) {
            // ok
        } finally {       
            features.close();
        }
    }
View Full Code Here

        // so just assert that something is returned
        assertTrue(featureSource.getCount(new Query(null, filter)) > 0);
    }

    SimpleFeature getFirstFeature(SimpleFeatureCollection fc) {
        SimpleFeatureIterator fi = null;
        try {
            fi = fc.features();
            if(!fi.hasNext()) {
                return null;
            } else {
                return fi.next();
            }
        } finally {
            if(fi != null) {
                fi.close();
            }
        }
    }
View Full Code Here

        SimpleFeatureCollection featureCollection;
        featureCollection = (SimpleFeatureCollection) featureCollections.get(0);
        assertEquals(5, featureCollection.size());
        assertNotNull(featureCollection.getBounds().getCoordinateReferenceSystem());

        SimpleFeatureIterator features = featureCollection.features();

        try {
            assertTrue(features.hasNext());

            SimpleFeature f = features.next();

            assertEquals("PrimitiveGeoFeature.f001", f.getID());
            assertNull(f.getDefaultGeometry());

            assertNotNull(f.getAttribute("pointProperty"));
            Point p = (Point) f.getAttribute("pointProperty");

            assertEquals(39.73245, p.getX(), 0.1);
            assertEquals(2.00342, p.getY(), 0.1);

            Object intProperty = f.getAttribute("intProperty");
            assertNotNull(intProperty);
            assertTrue(intProperty.getClass().getName(), intProperty instanceof BigInteger);
           
            assertEquals(BigInteger.valueOf(155), intProperty);
            assertEquals(new URI("http://www.opengeospatial.org/"), f.getAttribute("uriProperty"));
            assertEquals(new Float(12765.0), f.getAttribute("measurand"));
            assertTrue(f.getAttribute("dateProperty") instanceof Date);
            assertEquals(BigDecimal.valueOf(5.03), f.getAttribute("decimalProperty"));
        } finally {
            if( features != null ){
                features.close();
            }
        }
    }
View Full Code Here

     
        SimpleFeatureSource fsLine = (SimpleFeatureSource) layers.get(getLineTypeRef());
        if(fsLine == null)
          return true;
        SimpleFeatureCollection fcLine = fsLine.getFeatures();
        SimpleFeatureIterator fLine = fcLine.features();
       
        SimpleFeatureSource fsPoly = (SimpleFeatureSource) layers.get(getRestrictedPolygonTypeRef());
        if(fsPoly == null)
          return true;
        ListFeatureCollection fcPoly = new ListFeatureCollection( fsPoly.getFeatures() );
               
        while(fLine.hasNext()){
          SimpleFeature line = fLine.next();
          SimpleFeatureIterator fPoly = fcPoly.features();
          Geometry lineGeom = (Geometry) line.getDefaultGeometry();
          if(envelope.contains(lineGeom.getEnvelopeInternal())){
            //   check for valid comparison
            if(LineString.class.isAssignableFrom(lineGeom.getClass())){
              while(fPoly.hasNext()){
                SimpleFeature poly = fPoly.next();
                Geometry polyGeom = (Geometry) poly.getDefaultGeometry();
                if(envelope.contains(polyGeom.getEnvelopeInternal())){
                  if(Polygon.class.isAssignableFrom(polyGeom.getClass())){
                    Polygon p = (Polygon)polyGeom;
                    for(int i=0;i<p.getNumInteriorRing();i++){
View Full Code Here

TOP

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

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.