getFeature.setService("WFS"); getFeature.setVersion(getVersion()); getFeature.setOutputFormat(outputFormat); getFeature.setHandle(query.getHandle()); getFeature.setMaxFeatures(BigInteger.valueOf(maxFeatures.intValue())); getFeature.setResultType( RESULTS == resultType ? ResultTypeType.RESULTS_LITERAL getFeature.getQuery().add(wfsQuery);
map.put("VERSION", "1.1.0"); map.put("REQUEST", "GetFeature"); map.put("OUTPUTFORMAT", request.getOutputFormat()); if (request.getMaxFeatures() != null) { map.put("MAXFEATURES", String.valueOf(request.getMaxFeatures())); final QueryType query = (QueryType) request.getQuery().get(0); final String typeName = (String) query.getTypeName().get(0); map.put("TYPENAME", typeName);
@Override public String getAttachmentFileName(Object value, Operation operation) { GetFeatureType request = (GetFeatureType) OwsUtils.parameter(operation.getParameters(), GetFeatureType.class); OgrFormat format = formats.get(request.getOutputFormat()); if (format == null) { throw new WFSException("Unknown output format " + request.getOutputFormat()); } else if (!format.singleFile || request.getQuery().size() > 1) { String outputFileName = ((QName) ((QueryType) request.getQuery().get(0)).getTypeName() .get(0)).getLocalPart(); return outputFileName + ".zip"; } else { return null; } }
getFeature.getQuery().addAll(node.getChildValues(QueryType.class)); Object rt = node.getAttributeValue("resultType"); if ("results".equals(rt)) { getFeature.setResultType(ResultTypeType.RESULTS_LITERAL); } else if ("hits".equals(rt)) { getFeature.setResultType(ResultTypeType.HITS_LITERAL); } else { getFeature.setResultType((ResultTypeType) rt); getFeature.setOutputFormat((String) node .getAttributeValue("outputFormat")); getFeature.setMaxFeatures((BigInteger) node .getAttributeValue("maxFeatures")); getFeature.setTraverseXlinkDepth((String) node .getAttributeValue("traverseXlinkDepth")); getFeature.setTraverseXlinkExpiry((BigInteger) node .getAttributeValue("traverseXlinkExpiry"));
/** * Turns a GetLogType objects into an almost equivalent GetFeatureType object s * that the superclass can do its work * @param featureCollection * @param request * @return */ private GetFeatureType toGetFeatureType(FeatureCollectionType featureCollection, GetLogType request) { FeatureCollection features = (FeatureCollection) featureCollection.getFeature().get(0); FeatureType featureType = features.getSchema(); GetFeatureType ftRequest = WfsFactory.eINSTANCE.createGetFeatureType(); QueryType query = WfsFactory.eINSTANCE.createQueryType(); query.setTypeName(Collections.singletonList(featureType.getTypeName())); ftRequest.getQuery().add(query); ftRequest.setBaseUrl(request.getBaseUrl()); ftRequest.setHandle(request.getHandle()); ftRequest.setMaxFeatures(request.getMaxFeatures()); ftRequest.setOutputFormat(request.getOutputFormat()); ftRequest.setResultType(ResultTypeType.RESULTS_LITERAL); return ftRequest; }
public void testCanHandle() { gft.setOutputFormat("OGR-KML"); assertTrue(ogr.canHandle(op)); gft.setOutputFormat("OGR-CSV"); assertTrue(ogr.canHandle(op)); gft.setOutputFormat("RANDOM_FORMAT"); assertTrue(ogr.canHandle(op)); }
/** * Build a GetFeature operation to request the named types. * * @param names type names for which queries are present in the returned request * @return GetFeature operation to request the named types */ Operation request(QName... names) { Service service = getServiceDescriptor10(); GetFeatureType type = WfsFactory.eINSTANCE.createGetFeatureType(); type.setBaseUrl("http://localhost:8080/geoserver"); for (QName name : names) { QueryType queryType = WfsFactory.eINSTANCE.createQueryType(); queryType.setTypeName(Collections.singletonList(name)); type.getQuery().add(queryType); } Operation request = new Operation("wfs", service, null, new Object[] {type}); return request; }
/** * Ionic uses {@code urn:opengis:def:crs:ogc::83} instead of {@code EPSG:4269}. If that's the * case, the query srsName is replaced by the kown "EPSG:4269" code */ @Override public RequestComponents createGetFeatureRequest(WFSProtocol wfs, GetFeature query) throws IOException { RequestComponents req = super.createGetFeatureRequest(wfs, query); GetFeatureType getFeature = req.getServerRequest(); QueryType queryType = (QueryType) getFeature.getQuery().get(0); URI srsNameUri = queryType.getSrsName(); final String overrideSrs = "urn:opengis:def:crs:ogc::83"; if (srsNameUri != null && srsNameUri.toString().equalsIgnoreCase(overrideSrs)) { try { queryType.setSrsName(new URI("EPSG:4269")); } catch (URISyntaxException e) { throw new RuntimeException("shouln't happen: " + e.getMessage()); } Map<String, String> kvpParameters = req.getKvpParameters(); kvpParameters.put("SRSNAME", "EPSG:4269"); } return req; }
getFeature.setHandle((String) node.getAttributeValue("handle")); getFeature.setMaxFeatures(WFSBindingUtils.asBigInteger(number)); getFeature.setStartIndex(startIndex); getFeature.getQuery().addAll(node.getChildValues(QueryType.class));
/** * Checks if this factory can create a parser for the potential responses of the given WFS * request. * <p> * For instance, this factory can create a parser as long as the request is a * {@link GetFeatureType GetFeature} request and the request output format matches {@code * "text/xml; subtype=gml/3.1.1"}. * </p> * * @see WFSResponseParserFactory#canProcess(WFSOperationType, String) */ public boolean canProcess(EObject request) { if (!(request instanceof GetFeatureType)) { return false; } String outputFormat = ((GetFeatureType) request).getOutputFormat(); boolean matches = isSupportedOutputFormat(outputFormat); return matches; }
/** * Addresses the following issues with the CubeWerx WFS server: * <p> * <ul> * <li>The request fails if the {@code resultType} parameter is set, either if the value is hits * or results, so it sets {@link GetFeatureType#setResultType(net.opengis.wfs.ResultTypeType)} * to {@code null} * * <li>CubeWerx does not support filtering logical filters containing mixed geometry filters * (eg, AND(BBOX, Intersects)), no matter what the capabilities doc says * </ul> * </p> */ @SuppressWarnings("nls") @Override public RequestComponents createGetFeatureRequest(WFSProtocol wfs, GetFeature query) throws IOException { RequestComponents parts = super.createGetFeatureRequest(wfs, query); GetFeatureType serverRequest = parts.getServerRequest(); serverRequest.setResultType(null); parts.setServerRequest(serverRequest); GetFeatureType nonResultTypeRequest = new CubeWerxGetFeatureType(); EMFUtils.copy(serverRequest, nonResultTypeRequest); // CubeWerx fails if the _mandatory_ resultType attribute is sent nonResultTypeRequest.setResultType(null); parts.setServerRequest(nonResultTypeRequest); parts.getKvpParameters().remove("RESULTTYPE"); return parts; }
getFeature.getQuery().addAll(node.getChildValues(QueryType.class)); getFeature.setResultType((ResultTypeType) node.getAttributeValue("resultType")); getFeature.setOutputFormat((String) node.getAttributeValue("outputFormat")); getFeature.setMaxFeatures((BigInteger) node.getAttributeValue("maxFeatures")); getFeature.setStartIndex( Converters.convert(node.getAttributeValue("startIndex"), BigInteger.class)); getFeature.setTraverseXlinkDepth((String) node.getAttributeValue("traverseXlinkDepth")); getFeature.setTraverseXlinkExpiry( (BigInteger) node.getAttributeValue("traverseXlinkExpiry"));
public void testContentTypeZip() { gft.setOutputFormat("OGR-SHP"); assertEquals("application/zip", ogr.getMimeType(null, op)); }
gfreq.setBaseUrl(fInfoReq.getBaseUrl()); gfreq.getQuery().add(qt);
/** * @return a {@link GetFeatureParser} to stream the contents of the GML 3.1 response */ public Object parse(WFS_1_1_0_DataStore wfs, WFSResponse response) throws IOException { GetFeatureType request = (GetFeatureType) response.getOriginatingRequest(); QueryType queryType = (QueryType) request.getQuery().get(0); String prefixedTypeName = (String) queryType.getTypeName().get(0); SimpleFeatureType schema = wfs.getSchema(prefixedTypeName); List<String> propertyNames = queryType.getPropertyName(); if (propertyNames.size() > 0) { // the expected schema may contain less properties than the full schema. Let's say it to // the parser so it does not parse unnecessary attributes in case the WFS returns more // than requested String[] properties = propertyNames.toArray(new String[propertyNames.size()]); try { schema = DataUtilities.createSubType(schema, properties); } catch (SchemaException e) { throw (RuntimeException) new RuntimeException().initCause(e); } } QName featureName = wfs.getFeatureTypeName(prefixedTypeName); InputStream in = response.getInputStream(); GetFeatureParser featureReader = new XmlSimpleFeatureParser(in, schema, featureName, wfs.getAxisOrderForOutput()); return featureReader; } }
/** * @see WFSGetFeatureOutputFormat#getMimeType(Object, Operation) */ public String getMimeType(Object value, Operation operation) throws ServiceException { GetFeatureType request = (GetFeatureType) OwsUtils.parameter(operation.getParameters(), GetFeatureType.class); OgrFormat format = formats.get(request.getOutputFormat()); if (format == null) { throw new WFSException("Unknown output format " + request.getOutputFormat()); } else if (format.singleFile && request.getQuery().size() <= 1) { if(format.mimeType != null) { return format.mimeType; } else { // use a default binary blob return "application/octet-stream"; } } else { return "application/zip"; } }
protected void write(FeatureCollectionType featureCollection, OutputStream output, Operation getFeature) throws IOException, ServiceException { GetLogType request = (GetLogType) getFeature.getParameters()[0]; GetFeatureType ftRequest = toGetFeatureType(featureCollection, request); prepare(ftRequest.getOutputFormat(), featureCollection, ftRequest); encode(output, featureCollection, ftRequest); }
getFeature.setService("WFS"); getFeature.setVersion(wfs.getServiceVersion().toString()); getFeature.setOutputFormat(query.getOutputFormat()); getFeature.setHandle("GeoTools " + GeoTools.getVersion() + " WFS DataStore"); Integer maxFeatures = query.getMaxFeatures(); if (maxFeatures != null) { getFeature.setMaxFeatures(BigInteger.valueOf(maxFeatures.intValue())); getFeature.setResultType(RESULTS == resultType ? RESULTS_LITERAL : HITS_LITERAL); getFeature.getQuery().add(wfsQuery);
public void testContentTypeKml() { gft.setOutputFormat("OGR-KML"); assertEquals("application/vnd.google-earth.kml", ogr.getMimeType(null, op)); }
gfreq.setBaseUrl(fInfoReq.getBaseUrl()); gfreq.getQuery().add(qt);