use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsLessThanOrEqual.
@Test
public void testFilterComparisonPropertyIsLessThanOrEqual() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLESSOREQUAL);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
ValueReference left = (ValueReference) prop.getOperand1();
Literal right = (Literal) prop.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getComparisonOps());
ComparisonOpsType cot = ft.getComparisonOps().getValue();
BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(valueF, rg.getContent().get(0));
MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLESSOREQUAL);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsBetween.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR COMPARISON FILTERS //////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFilterComparisonPropertyIsBetween() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISBETWEEN);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
BetweenComparisonOperator prop = (BetweenComparisonOperator) filter;
ValueReference center = (ValueReference) prop.getExpression();
Literal lower = (Literal) prop.getLowerBoundary();
Literal upper = (Literal) prop.getUpperBoundary();
assertEquals(center.getXPath(), valueStr);
assertEquals(((Number) lower.apply(null)).floatValue(), 455f, DELTA);
assertEquals(((Number) upper.apply(null)).floatValue(), 457f, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getComparisonOps());
ComparisonOpsType cot = ft.getComparisonOps().getValue();
PropertyIsBetweenType pibt = (PropertyIsBetweenType) cot;
PropertyNameType pnt = (PropertyNameType) pibt.getExpressionType().getValue();
LiteralType low = (LiteralType) pibt.getLowerBoundary().getExpression().getValue();
LiteralType up = (LiteralType) pibt.getUpperBoundary().getExpression().getValue();
assertEquals(valueStr, pnt.getContent());
numberEquals(455, low.getContent().get(0));
numberEquals(457, up.getContent().get(0));
MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISBETWEEN);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterLogicalOr.
@Test
public void testFilterLogicalOr() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_OR);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
LogicalOperator prop = (LogicalOperator) filter;
BinaryComparisonOperator leftop = (BinaryComparisonOperator) prop.getOperands().get(0);
BinaryComparisonOperator rightop = (BinaryComparisonOperator) prop.getOperands().get(1);
ValueReference left = (ValueReference) leftop.getOperand1();
Literal right = (Literal) leftop.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), 455f, DELTA);
left = (ValueReference) rightop.getOperand1();
right = (Literal) rightop.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), 457f, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getLogicOps());
LogicOpsType cot = ft.getLogicOps().getValue();
assertEquals(ft.getLogicOps().getName().getLocalPart(), OGCJAXBStatics.FILTER_LOGIC_OR);
BinaryLogicOpType pibt = (BinaryLogicOpType) cot;
BinaryComparisonOpType leftoptype = (BinaryComparisonOpType) pibt.getComparisonOps().get(0).getValue();
BinaryComparisonOpType rightoptype = (BinaryComparisonOpType) pibt.getComparisonOps().get(1).getValue();
PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(455, rg.getContent().get(0));
lf = (PropertyNameType) rightoptype.getExpression().get(0).getValue();
rg = (LiteralType) rightoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(457, rg.getContent().get(0));
MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_LOG_OR);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class OGC110Test method testExpDiv.
@Test
public void testExpDiv() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_EXP_DIV);
assertNotNull(obj);
JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
assertNotNull(exp);
ValueReference left = (ValueReference) exp.getParameters().get(0);
Literal right = (Literal) exp.getParameters().get(1);
assertNotNull(left);
assertNotNull(right);
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
// Write test
jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
assertNotNull(jax);
assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_DIV);
JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
MARSHALLER.marshal(jax, TEST_FILE_EXP_DIV);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterLogicalAnd.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR LOGIC FILTERS ///////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFilterLogicalAnd() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_AND);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
LogicalOperator prop = (LogicalOperator) filter;
BinaryComparisonOperator leftop = (BinaryComparisonOperator) prop.getOperands().get(0);
BinaryComparisonOperator rightop = (BinaryComparisonOperator) prop.getOperands().get(1);
ValueReference left = (ValueReference) leftop.getOperand1();
Literal right = (Literal) leftop.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), 455f, DELTA);
left = (ValueReference) rightop.getOperand1();
right = (Literal) rightop.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), 457f, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getLogicOps());
LogicOpsType cot = ft.getLogicOps().getValue();
assertEquals(ft.getLogicOps().getName().getLocalPart(), OGCJAXBStatics.FILTER_LOGIC_AND);
BinaryLogicOpType pibt = (BinaryLogicOpType) cot;
BinaryComparisonOpType leftoptype = (BinaryComparisonOpType) pibt.getComparisonOps().get(0).getValue();
BinaryComparisonOpType rightoptype = (BinaryComparisonOpType) pibt.getComparisonOps().get(1).getValue();
PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(455, rg.getContent().get(0));
lf = (PropertyNameType) rightoptype.getExpression().get(0).getValue();
rg = (LiteralType) rightoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(457, rg.getContent().get(0));
MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_LOG_AND);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
Aggregations