@Override public Response responseDispatched( Request request, Operation operation, Object result, Response response) { // is this a feature response we are about to encode? if (result instanceof FeatureCollectionResponse) { HttpServletResponse httpResponse = request.getHttpResponse(); FeatureCollectionResponse fcr = (FeatureCollectionResponse) result; String contentType = response.getMimeType(result, operation); if (fcr.getPrevious() != null) { addLink(httpResponse, "prev", contentType, fcr.getPrevious()); } if (fcr.getNext() != null) { addLink(httpResponse, "next", contentType, fcr.getNext()); } } return response; }
/** * Writes WFS3 compliant paging links * * @param response * @param operation * @param jw */ protected void writePagingLinks( FeatureCollectionResponse response, Operation operation, GeoJSONBuilder jw) { if (response.getPrevious() != null || response.getNext() != null) { jw.key("links"); jw.array(); String mimeType = getMimeType(response, operation); writeLink(jw, "previous page", mimeType, "previous", response.getPrevious()); writeLink(jw, "next page", mimeType, "next", response.getNext()); jw.endArray(); } }
if (response.getPrevious() != null) { writeLink(jw, "Previous page", MIME, "prev", response.getPrevious());
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); }