wfsQuery.setTypeName(Collections.singletonList(typeName)); wfsQuery.setFilter(supportedFilter); wfsQuery.setSrsName(new URI(srsName)); } catch (URISyntaxException e) { throw new RuntimeException("Can't create a URI from the query CRS: " + srsName, e); boolean retrieveAllProperties = propertyNames == null; if (!retrieveAllProperties) { List<String> propertyName = wfsQuery.getPropertyName(); for (String propName : propertyNames) { propertyName.add(propName); if (sortByList != null) { for (SortBy sortBy : sortByList) { wfsQuery.getSortBy().add(sortBy);
@Override protected void setProperty(EObject eObject, String property, Object value, boolean lax) { if ("typeName".equals(property)) { QueryType query = (QueryType) eObject; if (query.getTypeName() == null) { query.setTypeName(new ArrayList()); } } super.setProperty(eObject, property, value, lax); } }
if ("typeName".equals(name.getLocalPart())) { QueryType query = (QueryType) object; List typeName = query.getTypeName(); StringBuilder typeNameList = new StringBuilder(); if (typeName != null) { } else if ("SortBy".equals(name.getLocalPart())) { QueryType query = (QueryType) object; List sortBy = query.getSortBy(); if (sortBy != null && sortBy.size() == 0) { return null;
else propertyName = (String) ((PropertyName) property).getPropertyName(); query.getPropertyName().add(propertyName); query.getFunction().add(node.getChildValues("Function")); query.setFilter((Filter) node.getChildValue(Filter.class)); SortBy[] sortBy = (SortBy[]) node.getChildValue(SortBy[].class); for (int i = 0; i < sortBy.length; i++) query.getSortBy().add(sortBy[i]); query.setHandle((String) node.getAttributeValue("handle")); query.setTypeName((List) node.getAttributeValue("typeName")); query.setFeatureVersion((String) node.getAttributeValue("featureVersion")); query.setSrsName((URI) node.getAttributeValue("srsName")); query.getXlinkPropertyName().addAll(node.getChildValues("XlinkPropertyName"));
queryType.getPropertyName().add(propertyName.getPropertyName()); queryType.setFilter(filter); queryType.setHandle((String) node.getAttributeValue("handle")); queryType.setTypeName(typeNameList); queryType.setFeatureVersion((String) node.getAttributeValue("featureVersion")); queryType.setSrsName(new URI((String) node.getAttributeValue("srsName")));
@Test public void testWFSGetFeature() throws Exception { GetFeatureType gf = WfsFactory.eINSTANCE.createGetFeatureType(); org.opengis.filter.Filter f1 = parseFilter("BBOX(the_geom, 40, -90, 45, -60)"); org.opengis.filter.Filter f2 = parseFilter("BBOX(the_geom, 5988504.35,851278.90, 7585113.55,1950872.01)"); QueryType q = WfsFactory.eINSTANCE.createQueryType(); q.setTypeName(Arrays.asList(new QName("http://acme.org", "foo", "acme"))); q.setFilter(f1); gf.getQuery().add(q); q = WfsFactory.eINSTANCE.createQueryType(); q.setTypeName(Arrays.asList(new QName("http://acme.org", "bar", "acme"))); gf.getQuery().add(q);getClass(); q.setFilter(f2); Operation op = op("GetFeature", "WFS", "1.0.0", gf); callback.operationDispatched(new Request(), op); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); BoundingBox expected = new ReferencedEnvelope(53.73,40, -60,-95.1193,CRS.decode("EPSG:4326")); // xMin,yMin -95.1193,40 : xMax,yMax -60,53.73 BBoxAsserts.assertEqualsBbox(expected, data.getBbox(), 0.01); }
@Override protected void setProperty(EObject eObject, String property, Object value, boolean lax) { if ("typeName".equals(property)) { // in wfs 1.0 we are only allowed a singel type name QueryType query = (QueryType) eObject; ArrayList list = new ArrayList(); list.add(value); query.setTypeName(list); } else if ("PropertyName".equals(property)) { // in wfs 1.0 propertynames are ogc:PropertyName PropertyName name = (PropertyName) value; super.setProperty(eObject, property, name.getPropertyName(), lax); } else { super.setProperty(eObject, property, value, lax); } } }
qt.setTypeName(Collections.singletonList(qname)); final String srsName = "EPSG:" + crs; try { qt.setSrsName(new URI(srsName));
final String typeName = (String) query.getTypeName().get(0); map.put("TYPENAME", typeName); if (query.getPropertyName().size() > 0) { List<String> propertyNames = query.getPropertyName(); StringBuilder pnames = new StringBuilder(); for (Iterator<String> it = propertyNames.iterator(); it.hasNext();) { URI srsName = query.getSrsName(); if (srsName != null) { map.put("SRSNAME", srsName.toString()); final Filter filter = query.getFilter();
/** * @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; } }
@Override public Object getProperty(Object object, QName name) throws Exception { if ("typeName".equals(name.getLocalPart())) { QueryType query = (QueryType) object; if (!query.getTypeName().isEmpty()) { // bit of a hack but handle both string and qname Object obj = query.getTypeName().get(0); if (obj instanceof String) { obj = new XSQNameBinding(namespaceContext).parse(null, obj); } return obj; } return null; } else if ("PropertyName".equals(name.getLocalPart())) { List l = new ArrayList(); for (String s : (List<String>) super.getProperty(object, name)) { l.add(filterFactory.property(s)); } return l; } else { return super.getProperty(object, name); } }
/** * 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; }
final String srsName = "EPSG:" + crs; try { qt.setSrsName(new URI(srsName)); } catch (URISyntaxException e) { throw new ServiceException(
@Test public void testWFSGetFeature() throws Exception { GetFeatureType gf = WfsFactory.eINSTANCE.createGetFeatureType(); org.opengis.filter.Filter f1 = parseFilter("BBOX(the_geom, 40, -90, 45, -60)"); org.opengis.filter.Filter f2 = parseFilter("BBOX(the_geom, 5988504.35,851278.90, 7585113.55,1950872.01)"); QueryType q = WfsFactory.eINSTANCE.createQueryType(); q.setTypeName(Arrays.asList(new QName("http://acme.org", "foo", "acme"))); q.setFilter(f1); gf.getQuery().add(q); q = WfsFactory.eINSTANCE.createQueryType(); q.setTypeName(Arrays.asList(new QName("http://acme.org", "bar", "acme"))); gf.getQuery().add(q); getClass(); q.setFilter(f2); Operation op = op("GetFeature", "WFS", "1.0.0", gf); callback.operationDispatched(new Request(), op); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); BoundingBox expected = new ReferencedEnvelope(53.73, 40, -60, -95.1193, CRS.decode("EPSG:4326")); // xMin,yMin -95.1193,40 : xMax,yMax -60,53.73 BBoxAsserts.assertEqualsBbox(expected, data.getBbox(), 0.01); }
@Override protected void setProperty(EObject eObject, String property, Object value, boolean lax) { if ("typeName".equals(property)) { //in wfs 1.0 we are only allowed a singel type name QueryType query = (QueryType)eObject; ArrayList list = new ArrayList(); list.add(value); query.setTypeName(list); } else if ("PropertyName".equals(property)) { //in wfs 1.0 propertynames are ogc:PropertyName PropertyName name = (PropertyName) value; super.setProperty(eObject, property, name.getPropertyName(), lax); } else { super.setProperty(eObject, property, value, lax); } }
if ("typeName".equals(name.getLocalPart())) { QueryType query = (QueryType) object; List typeName = query.getTypeName(); StringBuilder typeNameList = new StringBuilder(); if (typeName != null) { } else if ("SortBy".equals(name.getLocalPart())) { QueryType query = (QueryType) object; List sortBy = query.getSortBy(); if (sortBy != null && sortBy.size() == 0) { return null;
@Override public Object getProperty(Object object, QName name) throws Exception { if ("typeName".equals(name.getLocalPart())) { QueryType query = (QueryType) object; if (!query.getTypeName().isEmpty()) { //bit of a hack but handle both string and qname Object obj = query.getTypeName().get(0); if (obj instanceof String) { obj = new XSQNameBinding(namespaceContext).parse(null, obj); } return obj; } return null; } else if ("PropertyName".equals(name.getLocalPart())) { List l = new ArrayList(); for (String s : (List<String>)super.getProperty(object, name)) { l.add(filterFactory.property(s)); } return l; } else { return super.getProperty(object, name); } }
final String srsName = "EPSG:" + crs; try { qt.setSrsName(new URI(srsName)); } catch (URISyntaxException e) { throw new ServiceException("Unable to determite coordinate system for featureType " + fc.getSchema().getTypeName() + ". Schema told us '" + srsName + "'", e);
wfsQuery.setTypeName(Collections.singletonList(query.getTypeName())); wfsQuery.setFilter(serverFilter); wfsQuery.setSrsName(new URI(srsName)); } catch (URISyntaxException e) { throw new RuntimeException("Can't create a URI from the query CRS: " + srsName, e); boolean retrieveAllProperties = propertyNames == null; if (!retrieveAllProperties) { List propertyName = wfsQuery.getPropertyName(); for (String propName : propertyNames) { propertyName.add(propName); if (sortByList != null) { for (SortBy sortBy : sortByList) { wfsQuery.getSortBy().add(sortBy);
@Override protected void setProperty(EObject eObject, String property, Object value, boolean lax) { if ("typeName".equals(property)) { QueryType query = (QueryType) eObject; if (query.getTypeName() == null) { query.setTypeName(new ArrayList()); } } super.setProperty(eObject, property, value, lax); } }