use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsGreaterThan.
@Test
public void testFilterComparisonPropertyIsGreaterThan() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISGREATER);
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_ISGREATER);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterSpatialOverlaps.
@Test
public void testFilterSpatialOverlaps() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_SPA_OVERLAPS2);
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);
assertEquals(right.apply(null).toString().trim(), "LINESTRING (46.652 10.466, 47.114 11.021, 46.114 12.114, 45.725 12.523)");
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
// write test - not yet
// FilterType ft = TRANSFORMER_OGC.apply(filter);
// assertNotNull(ft.getSpatialOps());
//
// SpatialOpsType cot = ft.getSpatialOps().getValue();
// assertEquals( ft.getLogicOps().getName().getLocalPart(), SEJAXBStatics.FILTER_SPATIAL_OVERLAPS);
// OverlapsType pibt = (OverlapsType) cot;
//
// BinarySpatialOperator leftoptype = (BinarySpatialOperator) pibt.getComparisonOps().getValue();
//
// PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
// LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
//
// assertEquals(lf.getContent(), valueStr);
// assertEquals(rg.getContent().get(0).toString().trim(), valueFStr );
//
// MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_SPA_OVERLAPS2);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testExpAdd.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR EXPRESSION //////////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testExpAdd() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_EXP_ADD);
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_ADD);
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_ADD);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsGreaterThanOrEqual.
@Test
public void testFilterComparisonPropertyIsGreaterThanOrEqual() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISGREATEROREQUAL);
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_ISGREATEROREQUAL);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsNull.
@Test
public void testFilterComparisonPropertyIsNull() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISNULL);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
NullOperator prop = (NullOperator) filter;
ValueReference center = (ValueReference) prop.getExpressions().get(0);
assertEquals(center.getXPath(), valueStr);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getComparisonOps());
ComparisonOpsType cot = ft.getComparisonOps().getValue();
PropertyIsNullType pibt = (PropertyIsNullType) cot;
PropertyNameType pnt = (PropertyNameType) pibt.getPropertyName();
assertEquals(pnt.getContent(), valueStr);
MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISNULL);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
Aggregations