Package net.opengis.wfs

Examples of net.opengis.wfs.FeatureCollectionType


        return (request != null) && (request.getResultType() == ResultTypeType.HITS_LITERAL);
    }

    public void write(Object value, OutputStream output, Operation operation)
        throws IOException, ServiceException {
        FeatureCollectionType featureCollection = (FeatureCollectionType) value;

        //create a new feautre collcetion type with just the numbers
        FeatureCollectionType hits = WfsFactory.eINSTANCE.createFeatureCollectionType();
        hits.setNumberOfFeatures(featureCollection.getNumberOfFeatures());
        hits.setTimeStamp(featureCollection.getTimeStamp());

        Encoder encoder = new Encoder(configuration, configuration.schema());
        encoder.setEncoding(Charset.forName( wfs.getGeoServer().getGlobal().getCharset()) );
        encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
            ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/1.1.0/wfs.xsd"));
View Full Code Here


    public void writeTo(final OutputStream out) throws ServiceException, IOException {
        final GetFeatureInfoRequest fInfoReq = getRequest();
        final WMS wmsConfig = fInfoReq.getWMS();

        //the 'response' object we'll pass to our OutputFormat
        FeatureCollectionType features = WfsFactory.eINSTANCE.createFeatureCollectionType();
       
        //the 'request' object we'll pass to our OutputFormat
        GetFeatureType gfreq = WfsFactory.eINSTANCE.createGetFeatureType();
        gfreq.setBaseUrl(fInfoReq.getBaseUrl());

        for (Iterator i = results.iterator(); i.hasNext();) {
            FeatureCollection<SimpleFeatureType, SimpleFeature> fc = (FeatureCollection)i.next();
            features.getFeature().add(fc);
           
            QueryType qt = WfsFactory.eINSTANCE.createQueryType();
            String crs = GML2EncodingUtils.epsgCode(fc.getSchema().getCoordinateReferenceSystem());
            if (crs != null) {
                final String srsName = "EPSG:" + crs;
View Full Code Here

        return null;
    }
   
    @Override
    public Object decode(Object input) throws Exception {
        FeatureCollectionType fc = (FeatureCollectionType) input;
        return fc.getFeature().get( 0 );
    }
View Full Code Here

    @Override
    public void encode(Object object, ContentHandler handler) throws Exception {
        FeatureCollection features = (FeatureCollection) object;
        SimpleFeatureType featureType = (SimpleFeatureType) features.getSchema();
       
        FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType();
        fc.getFeature().add( features );
       
        Encoder e = new Encoder( new WFSConfiguration() );
        e.getNamespaces().declarePrefix( "feature", featureType.getName().getNamespaceURI() );
        e.encode( fc, WFS.FeatureCollection, handler );
    }
View Full Code Here

    public Object getProperty(Object object, QName name)
        throws Exception {
        //check for feature collection memebers
        if (GML.featureMembers.equals(name)) {
            FeatureCollectionType featureCollection = (FeatureCollectionType) object;

            if (!featureCollection.getFeature().isEmpty()) {
                if (featureCollection.getFeature().size() > 1) {
                    //wrap in a single
                    return new CompositeFeatureCollection(featureCollection.getFeature());
                }

                //just return the single
                return featureCollection.getFeature().iterator().next();
            }
        } else if(GML.boundedBy.equals(name) && generateBounds) {
            FeatureCollectionType featureCollection = (FeatureCollectionType) object;

            ReferencedEnvelope env = null;
            for (Iterator it = featureCollection.getFeature().iterator(); it.hasNext();) {
                FeatureCollection fc = (FeatureCollection) it.next();
                if(env == null) {
                    env = fc.getBounds();
                }
                else {
View Full Code Here

     * @param lockId
     * @return
     */
    protected FeatureCollectionType buildResults(int count, List results,
            String lockId) {
        FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType();
        result.setNumberOfFeatures(BigInteger.valueOf(count));
        result.setTimeStamp(Calendar.getInstance());
        result.setLockId(lockId);
        result.getFeature().addAll(results);
        return result;
    }
View Full Code Here

        return false;
    }

    public void write(Object value, OutputStream output, Operation operation)
        throws IOException, ServiceException {
        FeatureCollectionType fct = (FeatureCollectionType) value;
        FeatureCollection<SimpleFeatureType, SimpleFeature> fc = (FeatureCollection) fct.getFeature().get(0);

        // setup template subsystem
        GeoServerTemplateLoader templateLoader = new GeoServerTemplateLoader(getClass());
        templateLoader.setFeatureType(fc.getSchema());
View Full Code Here

    public void testCharset() throws Exception {
        FeatureSource<? extends FeatureType, ? extends Feature> fs;
        fs = getFeatureSource(MockData.BASIC_POLYGONS);
        ShapeZipOutputFormat zip = new ShapeZipOutputFormat();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        FeatureCollectionType fct = WfsFactory.eINSTANCE.createFeatureCollectionType();
        fct.getFeature().add(fs.getFeatures());
       
        // add the charset
        Map options = new HashMap();
        options.put("CHARSET", Charset.forName("ISO-8859-15"));
        gft.setFormatOptions(options);
View Full Code Here

     * output as a byte array
     */
    byte[] writeOut(FeatureCollection fc) throws IOException {
        ShapeZipOutputFormat zip = new ShapeZipOutputFormat();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        FeatureCollectionType fct = WfsFactory.eINSTANCE.createFeatureCollectionType();
        fct.getFeature().add(fc);
        zip.write(fct, bos, op);
        return bos.toByteArray();
    }
View Full Code Here

        if (EMFUtils.isUnset(queries, "typeName")) {
            String msg = "No feature types specified";
            throw new WFSException(msg);
        }

        FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType();
        int residual = request.getMaxFeatures() != null ? request.getMaxFeatures().intValue() : Integer.MAX_VALUE;

        // for each difference query check the feature type is versioned, and
        // gather bounds
        try {
            for (int i = 0; i < queries.size() && residual > 0; i++) {
                DifferenceQueryType query = (DifferenceQueryType) queries.get(i);
                FeatureTypeInfo meta = featureTypeInfo((QName) query.getTypeName());
                FeatureSource<? extends FeatureType, ? extends Feature> source = meta.getFeatureSource(null,null);

                if (!(source instanceof VersioningFeatureSource)) {
                    throw new WFSException("Feature type" + query.getTypeName()
                        + " is not versioned");
                }

                Filter filter = (Filter) query.getFilter();

                //  make sure filters are sane
                if (filter != null) {
                    final FeatureType featureType = source.getSchema();
                    ExpressionVisitor visitor = new AbstractExpressionVisitor() {
                            public Object visit(PropertyName name, Object data) {
                                // case of multiple geometries being returned
                                if (name.evaluate(featureType) == null) {
                                    // we want to throw wfs exception, but cant
                                    throw new WFSException("Illegal property name: "
                                        + name.getPropertyName(), "InvalidParameterValue");
                                }

                                return name;
                            }
                            ;
                        };

                    filter.accept(new AbstractFilterVisitor(visitor), null);
                }

                // extract collection
                VersioningFeatureSource store = (VersioningFeatureSource) source;
                FeatureCollection<SimpleFeatureType, SimpleFeature> logs = store.getLog(query
                        .getFromFeatureVersion(), query.getToFeatureVersion(), filter, null,
                        residual);
                residual -= logs.size();

                // TODO: handle logs reprojection in another CRS
                result.getFeature().add(logs);
            }
        } catch (IOException e) {
            throw new WFSException("Error occurred getting features", e, request.getHandle());
        }

        result.setNumberOfFeatures(BigInteger.valueOf(residual));
        result.setTimeStamp(Calendar.getInstance());

        return result;
    }
View Full Code Here

TOP

Related Classes of net.opengis.wfs.FeatureCollectionType

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.