@Override public String getPreferredDisposition(Object value, Operation operation) { GetFeatureRequest request = GetFeatureRequest.adapt(operation.getParameters()[0]); String outputFormat = request.getOutputFormat(); Format format = formats.get(outputFormat); List<Query> queries = request.getQueries(); if (format == null) { throw new WFSException("Unknown output format " + outputFormat); } else if (format.getType() == OutputType.BINARY || queries.size() > 1) { return DISPOSITION_ATTACH; } else { return DISPOSITION_INLINE; } }
Map<String, String> kvp) { if (request.isResultTypeHits() && (request.getVersion() == null || request.getVersion().startsWith("2"))) { kvp = new KvpMap(kvp); kvp.put("RESULTTYPE", "results"); if (offset > 0 && !(request.isResultTypeHits() && request.getVersion().startsWith("2"))) { result.setPrevious(buildURL(request.getBaseUrl(), "wfs", kvp, URLType.SERVICE)); if (request.isResultTypeHits() && request.getVersion().startsWith("2")) { result.setNext(buildURL(request.getBaseUrl(), "wfs", kvp, URLType.SERVICE)); } else if (count > 0 && offset > -1 && maxFeatures <= count) { kvp.put("startIndex", String.valueOf(offset > 0 ? offset + count : count)); kvp.put("count", String.valueOf(maxFeatures)); result.setNext(buildURL(request.getBaseUrl(), "wfs", kvp, URLType.SERVICE));
/** * Looks up the charset parameter, either in the GetFeature request or as a global parameter * * @param getFeature * @return the found charset, or the platform's default one if none was specified */ private Charset getShapefileCharset(Operation getFeature) { Charset result = null; GetFeatureRequest gft = GetFeatureRequest.adapt(getFeature.getParameters()[0]); if (gft.getFormatOptions() != null && gft.getFormatOptions().get("CHARSET") != null) { result = (Charset) gft.getFormatOptions().get("CHARSET"); } else { final String charsetName = GeoServerExtensions.getProperty(GS_SHAPEFILE_CHARSET, applicationContext); if (charsetName != null) result = Charset.forName(charsetName); } // if not specified let's use the shapefile default one return result != null ? result : Charset.forName("ISO-8859-1"); }
protected List<Query> getQueries(EObject eObject) { return GetFeatureRequest.adapt(eObject).getQueries(); }
/** * Gets current request extension (dxf or zip). * * @param operation * @return */ public String getDxfExtension(Operation operation) { GetFeatureRequest request = GetFeatureRequest.adapt(operation .getParameters()[0]); String outputFormat = request.getOutputFormat().toUpperCase(); // DXF if (outputFormat.equals("DXF")) return "dxf"; // DXF-ZIP return "zip"; }
public FeatureCollectionResponse run(GetFeatureRequest request) throws WFSException { List<Query> queries = request.getQueries(); if (WFSInfo.Version.V_20.compareTo(request.getVersion()) >= 0 && request.isLockRequest() && request.isResultTypeHits()) { throw new WFSException( "GetFeatureWithLock cannot be used with result type 'hits'", queries = request.getQueries(); if (request.isQueryTypeNamesUnset()) { expandTypeNames(request, queries, getFeatureById, getCatalog()); if (request.isLockRequest()) { LockFeatureRequest lockRequest = request.createLockRequest(); lockRequest.setExpiry(request.getExpiry()); lockRequest.setHandle(request.getHandle()); if (request.isLockActionSome()) { lockRequest.setLockActionSome(); } else { if (request.isLockActionSome()) { Filter lockedFeatureFilter = toFeatureIdFilter(response.getLockedFeatures()); for (Query query : queries) { BigInteger bi = request.getMaxFeatures(); if (bi == null) { request.setMaxFeatures(BigInteger.valueOf(Integer.MAX_VALUE));
GetFeatureRequest request = GetFeatureRequest.adapt(operation .getParameters()[0]); if (request.getHandle() != null) { LOGGER.log(Level.FINE, "Using handle for file name: " + request.getHandle()); return request.getHandle(); for (Query query : request.getQueries()) { addLayerNames(names, query, false);
GetFeatureRequest req = GetFeatureRequest.adapt(request); if (kvp.containsKey("format_options")) { req.getFormatOptions().putAll((Map) kvp.get("format_options")); if (req.getViewParams() == null) { req.setViewParams(new ArrayList<Map<String, String>>()); (List<Map<String, String>>) kvp.get("viewParams"); if (viewParams.size() > 0) { int layerCount = req.getQueries().size(); req.setViewParams(viewParams);
boolean forcedDecimal = getForcedDecimal(featureCollections, geoServer, catalog); GetFeatureRequest request = GetFeatureRequest.adapt(getFeature.getParameters()[0]); for (int fcIndex = 0; fcIndex < featureCollections.size(); fcIndex++) { if (request != null) { List<Query> queries = request.getQueries(); Query queryType = queries.get(fcIndex); encoder.setSchemaLocation( getWfsNamespace(), buildSchemaURL(request.getBaseURL(), getRelativeWfsSchemaLocation())); "WFS", "version", request.getVersion(), "request", "DescribeFeatureType"); buildURL(request.getBaseURL(), "wfs", params, URLType.SERVICE); LOGGER.finer( "Unable to find user-defined schema location for: "
GetFeatureRequest gft = GetFeatureRequest.adapt(operation.getParameters()[0]); String version = (String) gft.getFormatOptions().get("VERSION"); String blocks = (String) gft.getFormatOptions().get("ASBLOCKS"); String colors = (String) gft.getFormatOptions().get("COLORS"); String ltypes = (String) gft.getFormatOptions().get("LTYPES"); String layerNames = (String) gft.getFormatOptions().get("LAYERS"); String writeAttributes = (String) gft.getFormatOptions().get("WITHATTRIBUTES"); LOGGER.log(Level.FINE,"Format options: "+version+"; "+blocks+"; "+colors+"; "+ltypes+"; "+layerNames+"; "+writeAttributes); layers=layerNames.toUpperCase().split(","); else layers=getLayerNames(gft.getQueries()); LOGGER.log(Level.FINE,"Layers names: "+StringUtils.join(layers,",")); dxfWriter.setOption("layers", layers);
kvp.put("VERSION", request.getVersion()); kvp.put("OUTPUTFORMAT", request.getOutputFormat()); kvp.put( "RESULTTYPE", request.isResultTypeHits() ? ResultTypeType.HITS.name() : ResultTypeType.RESULTS.name()); List<Query> queries = request.getQueries(); Query q = queries.get(0); if (q.getSrsName() != null) {
templateSupport.getTemplate(referenceFeatureType, "getfeature-footer.ftl"); GetFeatureRequest request = GetFeatureRequest.adapt(getFeature.getParameters()[0]); Map<String, Object> model = new HashMap<>(); model.put("baseURL", request.getBaseURL()); model.put("response", response); AbstractHTMLResponse.addServiceLinkFunctions(response, getFeature, model); request.getVersion() != null && request.getVersion().startsWith("3."); for (int i = 0; i < collections.size(); i++) { FeatureCollection fc = collections.get(i);
GetFeatureRequest req = GetFeatureRequest.adapt(request); List query = req.getAdaptedQueries(); query.add(req.createQuery().getAdaptee()); query.add(EMFUtils.clone(q, req.getFactory()));
protected Encoder createEncoder( Configuration configuration, Map<String, Set<ResourceInfo>> resources, Object request) { // reuse the WFS configuration feature builder, otherwise build a new one FeatureTypeSchemaBuilder schemaBuilder; if (configuration instanceof WFSConfiguration) { schemaBuilder = ((WFSConfiguration) configuration).getSchemaBuilder(); } else { schemaBuilder = new FeatureTypeSchemaBuilder.GML3(geoServer); } // create this request specific schema ApplicationSchemaXSD1 schema = new ApplicationSchemaXSD1(schemaBuilder); schema.setBaseURL(GetFeatureRequest.adapt(request).getBaseURL()); schema.setResources(resources); if (schema.getFeatureTypes().isEmpty()) { // no feature types so let's use the base WFS schema return new Encoder(configuration, configuration.schema()); } try { // let's just instantiate the encoder return new Encoder(configuration, schema.getSchema()); } catch (IOException exception) { throw new RuntimeException( "Error generating the XSD schema during the encoder instantiation.", exception); } }
GetFeatureRequest gft = GetFeatureRequest.adapt(getFeature.getParameters()[0]); null, catalog, gft.getBaseUrl(), org.geotools.wfs.v1_0.WFS.getInstance(), featureTypes); buildSchemaURL(gft.getBaseUrl(), "wfs/1.0.0/WFS-basic.xsd")); namespaceURI, buildURL(gft.getBaseUrl(), "wfs", params, URLType.RESOURCE));
protected void buildStoredQueries(EObject request, List<URI> storedQueryIds, Map kvp) { GetFeatureRequest req = GetFeatureRequest.adapt(request); Wfs20Factory factory = (Wfs20Factory) req.getFactory(); StoredQueryType storedQuery = factory.createStoredQueryType(); storedQuery.setId(storedQueryId.toString()); req.getAdaptedQueries().add(storedQuery);
/** * Ensures that the operation being executed is a GetFeature operation. * * <p>Subclasses may implement */ public boolean canHandle(Operation operation) { // GetFeature operation? if ("GetFeature".equalsIgnoreCase(operation.getId()) || "GetFeatureWithLock".equalsIgnoreCase(operation.getId())) { // also check that the resultType is "results" GetFeatureRequest req = GetFeatureRequest.adapt(operation.getParameters()[0]); if (req.isResultTypeResults()) { // call subclass hook return canHandleInternal(operation); } } return false; }
/** @see WFSGetFeatureOutputFormat#write(Object, OutputStream, Operation) */ public void write( List<SimpleFeatureCollection> collections, Charset charset, OutputStream output, final GetFeatureRequest request) throws IOException, ServiceException { // We might get multiple featurecollections in our response (multiple queries?) so we need // to // write out multiple shapefile sets, one for each query response. final File tempDir = IOUtils.createTempDirectory("shpziptemp"); ShapefileDumper dumper = new ShapefileDumper(tempDir) { @Override protected String getShapeName(SimpleFeatureType schema, String geometryType) { FeatureTypeInfo ftInfo = getFeatureTypeInfo(schema); String fileName = new FileNameSource(getClass()).getShapeName(ftInfo, geometryType); return fileName; } @Override protected void shapefileDumped( String fileName, SimpleFeatureType remappedSchema) throws IOException { try { changeWKTFormatIfFileFormatIsESRI( tempDir, request, fileName, remappedSchema); } catch (FactoryException e) { throw new IOException("Failed to write out the ESRI style prj file", e);
geoServer.getGlobal(), (FeatureTypeInfo) meta, request.getBaseUrl()); ftNamespaces.put(uri, location); Query query = request.getQueries().get(i); try { String srsName = query.getSrsName() != null ? query.getSrsName().toString() : null; transformer.addSchemaLocation(WFS.NAMESPACE, wfsCanonicalSchemaLocation()); } else { String wfsSchemaloc = wfsSchemaLocation(request.getBaseUrl()); transformer.addSchemaLocation(WFS.NAMESPACE, wfsSchemaloc);
private FeatureTypeInfo getFeatureType(GetFeatureRequest request) { // a WFS3 always has a collection reference, so one query Query query = request.getQueries().get(0); QName typeName = query.getTypeNames().get(0); return gs.getCatalog() .getFeatureTypeByName( new NameImpl(typeName.getNamespaceURI(), typeName.getLocalPart())); }