Package org.geotools.data

Examples of org.geotools.data.FeatureReader


        FilterFactory fFac = FilterFactory.createFilterFactory();

        for (int i = 0; i < nLayers; i++) {
            MapLayer layer = layers[i];
            FeatureReader featureReader = null;
            FeatureSource fSource = layer.getFeatureSource();
            FeatureType schema = fSource.getSchema();

            try {
                Expression bboxExpression = fFac.createBBoxExpression(mapContext
                        .getAreaOfInterest());
                GeometryFilter bboxFilter = fFac.createGeometryFilter(FilterType.GEOMETRY_INTERSECTS);
                bboxFilter.addLeftGeometry(bboxExpression);
                bboxFilter.addRightGeometry(fFac.createAttributeExpression(
                        schema, schema.getDefaultGeometry().getName()));

                Query bboxQuery = new DefaultQuery(schema.getTypeName(),
                        bboxFilter);

                LOGGER.fine("obtaining FeatureReader for "
                    + schema.getTypeName());
                featureReader = fSource.getFeatures(bboxQuery).reader();
                LOGGER.fine("got FeatureReader, now writing");

                String groupId = null;
                String styleName = null;

                groupId = schema.getTypeName();

                styleName = layer.getStyle().getName();

                writer.write("<g id=\"" + groupId + "\"");

                if (!styleName.startsWith("#")) {
                    writer.write(" class=\"" + styleName + "\"");
                }

                writer.write(">\n");

                writeDefs(schema);

                writer.writeFeatures(featureReader, styleName);
                writer.write("</g>\n");
            } catch (IOException ex) {
                throw ex;
            } catch (AbortedException ae) {
                LOGGER.info("process aborted: " + ae.getMessage());
                throw ae;
            } catch (Throwable t) {
                LOGGER.warning("UNCAUGHT exception: " + t.getMessage());

                IOException ioe = new IOException("UNCAUGHT exception: "
                        + t.getMessage());
                ioe.setStackTrace(t.getStackTrace());
                throw ioe;
            } finally {
                if (featureReader != null) {
                    featureReader.close();
                }
            }
        }
    }
View Full Code Here


      String typeRef = (String) entry.getKey();
      FeatureSource featureSource =(FeatureSource) entry.getValue();
      String dataStoreId = typeRef.split(":")[0];
      try {
        LOGGER.finer(dataStoreId + ": feature validation, "+featureSource );
        FeatureReader reader = featureSource.getFeatures().reader();
        try {
          validator.featureValidation( dataStoreId, reader , results);
        }
        finally {
          reader.close();
        }       
      } catch (Exception e1) {
        e1.printStackTrace();
      }
     
View Full Code Here

TOP

Related Classes of org.geotools.data.FeatureReader

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.