use of org.opengis.filter.BinarySpatialOperator in project geotoolkit by Geomatys.
the class OGC110Test method testFilterSpatialDisjoint.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR SPATIAL FILTERS /////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFilterSpatialDisjoint() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_SPA_DISJOINT);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
BinarySpatialOperator prop = (BinarySpatialOperator) filter;
BinarySpatialOperator subfilter = (BinarySpatialOperator) prop;
ValueReference left = (ValueReference) subfilter.getOperand1();
Literal right = (Literal) subfilter.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertTrue(right.apply(null) instanceof Polygon);
assertEquals(right.apply(null).toString().trim(), "POLYGON ((48 18, 48 21, 52 21, 52 18, 48 18))");
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.opengis.filter.BinarySpatialOperator in project geotoolkit by Geomatys.
the class OGCforSLD110Test method testCustom1.
@Test
public void testCustom1() throws JAXBException, FactoryException {
StyleXmlIO util = new StyleXmlIO();
final Filter filter = util.readFilter(OGCforSLD110Test.class.getResource("/org/geotoolkit/test/filter/filterbbox.xml"), org.geotoolkit.sld.xml.Specification.Filter.V_1_1_0);
assertEquals(LogicalOperatorName.OR, filter.getOperatorType());
final LogicalOperator<Object> or = (LogicalOperator) filter;
final Filter f1 = or.getOperands().get(0);
final Filter f2 = or.getOperands().get(1);
assertEquals(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO, f1.getOperatorType());
assertEquals(SpatialOperatorName.BBOX, f2.getOperatorType());
final BinaryComparisonOperator<Object> ff1 = (BinaryComparisonOperator) f1;
final BinarySpatialOperator<Object> ff2 = (BinarySpatialOperator) f2;
assertTrue(ff1.getOperand1() instanceof ValueReference);
assertTrue(ff1.getOperand2() instanceof Literal);
assertTrue(ff2.getOperand1() instanceof ValueReference);
assertTrue(ff2.getOperand2() instanceof Literal);
assertEquals("sf:str4Property", ((ValueReference) ff1.getOperand1()).getXPath());
assertEquals("abc3", ((Literal) ff1.getOperand2()).getValue());
assertEquals("sf:attribut.Géométrie", ((ValueReference) ff2.getOperand1()).getXPath());
final Envelope2D geom = new Envelope2D((Envelope) ((Literal) ff2.getOperand2()).getValue());
assertEquals(34d, geom.getMinX(), 1e-7);
assertEquals(40d, geom.getMaxX(), 1e-7);
assertEquals(15d, geom.getMinY(), 1e-7);
assertEquals(19d, geom.getMaxY(), 1e-7);
final CoordinateReferenceSystem crs = geom.getCoordinateReferenceSystem();
assertEquals(CommonCRS.WGS84.geographic(), crs);
}
Aggregations