use of org.geotoolkit.ogc.xml.v100.SpatialOpsType in project ddf by codice.
the class TestWfsSource method testIntersectQuery.
@Test
public void testIntersectQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
setUp(ONE_GML_PROPERTY_SCHEMA, Arrays.asList(new Intersect(), new BBOX()), SRS_NAME, ONE_FEATURE, null);
Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
QueryImpl intersectQuery = new QueryImpl(intersectFilter);
intersectQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(intersectQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, intersectQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetSpatialOps());
assertTrue(query.getFilter().getSpatialOps().getValue() instanceof SpatialOpsType);
}
use of org.geotoolkit.ogc.xml.v100.SpatialOpsType in project geotoolkit by Geomatys.
the class FilterToOGC100Converter method apply.
@Override
public FilterType apply(final Filter filter) {
if (filter == null) {
return null;
}
JAXBElement<?> sf = visit(filter);
if (sf == null) {
return null;
}
final FilterType ft = ogc_factory.createFilterType();
if (sf.getValue() instanceof ComparisonOpsType) {
ft.setComparisonOps((JAXBElement<? extends ComparisonOpsType>) sf);
} else if (sf.getValue() instanceof LogicOpsType) {
ft.setLogicOps((JAXBElement<? extends LogicOpsType>) sf);
} else if (sf.getValue() instanceof SpatialOpsType) {
ft.setSpatialOps((JAXBElement<? extends SpatialOpsType>) sf);
} else {
// should not happen
throw new IllegalArgumentException("invalide filter element : " + sf);
}
return ft;
}
use of org.geotoolkit.ogc.xml.v100.SpatialOpsType in project geotoolkit by Geomatys.
the class OGC110toGTTransformer method visitLogicOp.
/**
* Transform a SLD logic Filter v1.1 in GT filter.
*/
public Filter visitLogicOp(final JAXBElement<? extends org.geotoolkit.ogc.xml.v110.LogicOpsType> jax) throws NoSuchAuthorityCodeException, FactoryException {
final org.geotoolkit.ogc.xml.v110.LogicOpsType ops = jax.getValue();
final String OpName = jax.getName().getLocalPart();
if (ops instanceof org.geotoolkit.ogc.xml.v110.UnaryLogicOpType) {
final org.geotoolkit.ogc.xml.v110.UnaryLogicOpType unary = (org.geotoolkit.ogc.xml.v110.UnaryLogicOpType) ops;
if (OGCJAXBStatics.FILTER_LOGIC_NOT.equalsIgnoreCase(OpName)) {
Filter filter = null;
if (unary.getComparisonOps() != null) {
filter = visitComparisonOp(unary.getComparisonOps());
} else if (unary.getLogicOps() != null) {
filter = visitLogicOp(unary.getLogicOps());
} else if (unary.getSpatialOps() != null) {
filter = visitSpatialOp(unary.getSpatialOps());
}
if (filter == null) {
throw new IllegalArgumentException("Invalide filter element" + unary);
}
return filterFactory.not(filter);
}
} else if (ops instanceof org.geotoolkit.ogc.xml.v110.BinaryLogicOpType) {
final org.geotoolkit.ogc.xml.v110.BinaryLogicOpType binary = (org.geotoolkit.ogc.xml.v110.BinaryLogicOpType) ops;
if (OGCJAXBStatics.FILTER_LOGIC_AND.equalsIgnoreCase(OpName)) {
final List<Filter> filters = new ArrayList<Filter>();
for (final JAXBElement<? extends ComparisonOpsType> ele : binary.getComparisonOps()) {
if (ele.getValue() instanceof ComparisonOpsType) {
filters.add(visitComparisonOp(ele));
}
}
for (final JAXBElement<? extends LogicOpsType> ele : binary.getLogicOps()) {
if (ele.getValue() instanceof LogicOpsType) {
filters.add(visitLogicOp(ele));
}
}
for (final JAXBElement<? extends SpatialOpsType> ele : binary.getSpatialOps()) {
if (ele.getValue() instanceof SpatialOpsType) {
filters.add(visitSpatialOp(ele));
}
}
if (filters.isEmpty()) {
return Filter.include();
} else if (filters.size() == 1) {
return filters.get(0);
} else {
return filterFactory.and((List) filters);
}
} else if (OGCJAXBStatics.FILTER_LOGIC_OR.equalsIgnoreCase(OpName)) {
final List<Filter> filters = new ArrayList<Filter>();
for (final JAXBElement<? extends ComparisonOpsType> ele : binary.getComparisonOps()) {
if (ele.getValue() instanceof ComparisonOpsType) {
filters.add(visitComparisonOp(ele));
}
}
for (final JAXBElement<? extends LogicOpsType> ele : binary.getLogicOps()) {
if (ele.getValue() instanceof LogicOpsType) {
filters.add(visitLogicOp(ele));
}
}
for (final JAXBElement<? extends SpatialOpsType> ele : binary.getSpatialOps()) {
if (ele.getValue() instanceof SpatialOpsType) {
filters.add(visitSpatialOp(ele));
}
}
if (filters.isEmpty()) {
return Filter.include();
} else if (filters.size() == 1) {
return filters.get(0);
} else {
return filterFactory.or((List) filters);
}
}
}
throw new IllegalArgumentException("Unknowed filter element" + jax);
}
use of org.geotoolkit.ogc.xml.v100.SpatialOpsType in project ddf by codice.
the class TestWfsSource method testBboxQuery.
@Test
public void testBboxQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
List<Object> bbox = new ArrayList<Object>();
bbox.add(new BBOX());
setUp(ONE_GML_PROPERTY_SCHEMA, bbox, SRS_NAME, ONE_FEATURE, null);
Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
QueryImpl intersectQuery = new QueryImpl(intersectFilter);
intersectQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(intersectQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, intersectQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetSpatialOps());
assertTrue(query.getFilter().getSpatialOps().getValue() instanceof SpatialOpsType);
}
use of org.geotoolkit.ogc.xml.v100.SpatialOpsType in project ddf by codice.
the class TestWfsSource method testGmlImport.
@Test
public void testGmlImport() throws UnsupportedQueryException, WfsException, SecurityServiceException {
List<Object> bbox = new ArrayList<Object>();
bbox.add(new BBOX());
setUp(GML_IMPORT_SCHEMA, bbox, SRS_NAME, ONE_FEATURE, null);
Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
QueryImpl intersectQuery = new QueryImpl(intersectFilter);
intersectQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(intersectQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, intersectQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetSpatialOps());
assertTrue(query.getFilter().getSpatialOps().getValue() instanceof SpatialOpsType);
}
Aggregations