Package org.geoserver.wfs.request

Examples of org.geoserver.wfs.request.FeatureCollectionResponse


    public void write(Object value, OutputStream output, Operation operation)
        throws IOException, ServiceException {
        WFSInfo wfs = getInfo();
       
        FeatureCollectionResponse featureCollection = (FeatureCollectionResponse) value;
       
        //create a new feautre collcetion type with just the numbers
        FeatureCollectionResponse hits = featureCollection.create();
        if (GML3OutputFormat.isComplexFeature(featureCollection)) {
            // we have to count the number of features here manually because complex feature
            // collection size() now returns 0. In order to count the number of features,
            // we have to build the features to count them and this has great performance
            // impact. Unless we introduce joins in our fetching of
            // data, we will have to count the number of features manually when needed. In
            // GML3Outputformat I use xslt to populate numberOfFeatures attribute.
            hits.setNumberOfFeatures(countFeature(featureCollection));
        } else {
            hits.setNumberOfFeatures(featureCollection.getNumberOfFeatures());
        }
       
        hits.setTotalNumberOfFeatures(featureCollection.getTotalNumberOfFeatures());
        hits.setNext(featureCollection.getNext());
        hits.setPrevious(featureCollection.getPrevious());
        hits.setTimeStamp(featureCollection.getTimeStamp());

        encode(hits, output, wfs);
    }
View Full Code Here


     * Allows subclasses to alter the result generation
     */
    protected FeatureCollectionResponse buildResults(GetFeatureRequest request, int offset, int maxFeatures,
        int count, int total, List results, String lockId) {

        FeatureCollectionResponse result = request.createResponse();
        result.setNumberOfFeatures(BigInteger.valueOf(count));
        result.setTotalNumberOfFeatures(BigInteger.valueOf(total));
        result.setTimeStamp(Calendar.getInstance());
        result.setLockId(lockId);
        result.getFeature().addAll(results);

        if (offset > 0 || count < Integer.MAX_VALUE) {
            //paged request, set the values of previous and next

            //get the Request thread local since we need to know about the request, whether it is
            // GET or POST some kvp information if the former
            Request req = Dispatcher.REQUEST.get();
           
            //grab the original kvp params if this is a GET request
            //for POST, do nothing, make the client post the same content
            //TODO: try to encode the request as best we can in a GET request, only issue should
            // be the filter and encoding it property... especially for joins that might be
            // tricky, and it also may cause the request to be too large for a get request
            //TODO: figure out what the spec says about this...
            Map<String,String> kvp = null;
            if (req.isGet()) {
                kvp = new KvpMap(req.getRawKvp());
            }
            else {
                //generate kvp map from request object
                kvp = buildKvpFromRequest(request);
            }

            if (offset > 0) {
                //previous
               
                //previous offset calculated as the current offset - maxFeatures, or 0 if this is a
                // negative value
                int prevOffset = Math.max(offset - maxFeatures, 0);
                kvp.put("startIndex", String.valueOf(prevOffset));
               
                //previous count should be current offset - previousOffset
                kvp.put("count", String.valueOf(offset - prevOffset));
                result.setPrevious(buildURL(request.getBaseUrl(), "wfs", kvp, URLType.SERVICE));
            }

            if (count > 0 && offset > -1) {
                //next

                //calculate the count of the next result set
                int nextCount = total - (offset + count);
                if (nextCount > 0) {
                    kvp.put("startIndex", String.valueOf(offset > 0 ? offset + count : count));
                    //kvp.put("count", String.valueOf(nextCount));
                    kvp.put("count", String.valueOf(maxFeatures));
                    result.setNext(buildURL(request.getBaseUrl(), "wfs", kvp, URLType.SERVICE));
                }
            }
        }

        return result;
View Full Code Here

    }
   
    @Override
    public String getAttachmentFileName(Object value, Operation operation) {     
        try {
            FeatureCollectionResponse featureCollections = (FeatureCollectionResponse) value;
            TransformInfo info = locateTransformation(featureCollections, operation);
           
            // concatenate all feature types requested
            StringBuilder sb = new StringBuilder();
            for (FeatureCollection<FeatureType, Feature> fc : featureCollections.getFeatures()) {
                sb.append(fc.getSchema().getName().getLocalPart());
                sb.append("_");
            }
            sb.setLength(sb.length() - 1);
           
View Full Code Here

        op = new Operation("GetFeature", getServiceDescriptor10(), null, new Object[] { gft });
    }
   
    @Test
    public void testGetFeatureOneType () throws IOException {
        FeatureCollectionResponse fct =
            FeatureCollectionResponse.adapt(WfsFactory.eINSTANCE.createFeatureCollectionType());
       
        FeatureSource<? extends FeatureType, ? extends Feature> fs = getFeatureSource(SystemTestData.BASIC_POLYGONS);;
        fct.getFeature().add(fs.getFeatures());
       
        testGetFeature(fct);
    }
View Full Code Here

        testGetFeature(fct);
    }
   
    @Test
    public void testGetFeatureTwoTypes () throws IOException {
        FeatureCollectionResponse fct =
            FeatureCollectionResponse.adapt(WfsFactory.eINSTANCE.createFeatureCollectionType());
       
        FeatureSource<? extends FeatureType, ? extends Feature> fs = getFeatureSource(SystemTestData.SEVEN);;
        fct.getFeature().add(fs.getFeatures());
       
        fs = getFeatureSource(SystemTestData.FIFTEEN);;
        fct.getFeature().add(fs.getFeatures());
               
        testGetFeature(fct);
    }
View Full Code Here

        testGetFeature(fct);
    }
   
    @Test
    public void testGetFeatureWithFilter () throws IOException {
        FeatureCollectionResponse fct =
            FeatureCollectionResponse.adapt(WfsFactory.eINSTANCE.createFeatureCollectionType());
       
        FeatureSource<? extends FeatureType, ? extends Feature> fs = getFeatureSource(SystemTestData.SEVEN);;
        fct.getFeature().add(fs.getFeatures());
       
        fs = getFeatureSource(SystemTestData.STREAMS);
        FeatureCollection coll = fs.getFeatures(ff.equals(ff.property("NAME"), ff.literal("Cam Stream")));
        assertEquals(1, coll.size());
       
        fct.getFeature().add(coll);               
        testGetFeature(fct);
    }
View Full Code Here

               query.setFilter(filter);
              
               GetFeatureType getFeature = Wfs20Factory.eINSTANCE.createGetFeatureType();
               getFeature.getAbstractQueryExpression().add(query);

               FeatureCollectionResponse fc = getFeatureDelegate.run(GetFeatureRequest.adapt(getFeature));
              
               for (FeatureCollection collection: fc.getFeatures()) {                  
                   if (! (collection instanceof SimpleFeatureCollection)) {
                       throw new ServiceException("GeoPackage OutputFormat does not support Complex Features.");
                   }
                  
                   FeatureEntry e = new FeatureEntry();
View Full Code Here

    @Test
    public void testSingle() throws Exception {
        FeatureSource<? extends FeatureType, ? extends Feature> source = getFeatureSource(MockData.SEVEN);
        FeatureCollection<? extends FeatureType, ? extends Feature> features = source.getFeatures();

        FeatureCollectionResponse fcType =
            FeatureCollectionResponse.adapt(WfsFactory.eINSTANCE.createFeatureCollectionType());

        fcType.getFeature().add(features);

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        producer().write(fcType, output, request(MockData.SEVEN) );

        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
View Full Code Here

    }

    @Test
    public void testMultipleSameNamespace() throws Exception {
        FeatureCollectionResponse fcType = FeatureCollectionResponse.adapt(WfsFactory.eINSTANCE
                .createFeatureCollectionType());
        fcType.getFeature().add(
               getFeatureSource(MockData.SEVEN).getFeatures());
        fcType.getFeature().add(getFeatureSource(MockData.FIFTEEN).getFeatures());

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        producer().write(fcType, output, request(MockData.SEVEN, MockData.FIFTEEN));

        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
View Full Code Here

                + document.getElementsByTagName("cdf:Fifteen").getLength());
    }

    @Test
    public void testMultipleDifferentNamespace() throws Exception {
        FeatureCollectionResponse fcType = FeatureCollectionResponse.adapt(WfsFactory.eINSTANCE
                .createFeatureCollectionType());
        fcType.getFeature().add(getFeatureSource(MockData.SEVEN).getFeatures());
        fcType.getFeature().add(getFeatureSource(MockData.POLYGONS).getFeatures());
       
        int npolys = getFeatureSource(MockData.POLYGONS).getFeatures().size();

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        producer().write(fcType, output, request(MockData.SEVEN, MockData.POLYGONS));
View Full Code Here

TOP

Related Classes of org.geoserver.wfs.request.FeatureCollectionResponse

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.