use of org.geotoolkit.ogc.xml.v110.BBOXType in project geotoolkit by Geomatys.
the class FilterXMLBindingTest method filterUnmarshalingTest.
/**
* Test simple Record Marshalling.
*
* @throws JAXBException
*/
@Test
public void filterUnmarshalingTest() throws JAXBException {
/*
* Test Unmarshalling spatial filter.
*/
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + " <ogc:Overlaps>" + '\n' + " <ogc:PropertyName>boundingBox</ogc:PropertyName>" + '\n' + " <gml:Envelope srsName=\"EPSG:4326\">" + '\n' + " <gml:lowerCorner>10.0 11.0</gml:lowerCorner>" + '\n' + " <gml:upperCorner>10.0 11.0</gml:upperCorner>" + '\n' + " </gml:Envelope>" + '\n' + " </ogc:Overlaps>" + '\n' + "</ogc:Filter>" + '\n';
StringReader sr = new StringReader(xml);
JAXBElement jb = (JAXBElement) unmarshaller.unmarshal(sr);
FilterType result = (FilterType) jb.getValue();
DirectPositionType lowerCorner = new DirectPositionType(10.0, 11.0);
DirectPositionType upperCorner = new DirectPositionType(10.0, 11.0);
EnvelopeType envelope = new EnvelopeType(lowerCorner, upperCorner, "EPSG:4326");
OverlapsType filterElement = new OverlapsType(new PropertyNameType("boundingBox"), envelope);
FilterType expResult = new FilterType(filterElement);
assertEquals(expResult.getSpatialOps().getValue(), result.getSpatialOps().getValue());
assertEquals(expResult, result);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + " <ogc:BBOX>" + '\n' + " <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + " <gml:Envelope srsName=\"EPSG:4326\">" + '\n' + " <gml:lowerCorner>10.0 11.0</gml:lowerCorner>" + '\n' + " <gml:upperCorner>10.0 11.0</gml:upperCorner>" + '\n' + " </gml:Envelope>" + '\n' + " </ogc:BBOX>" + '\n' + "</ogc:Filter>" + '\n';
sr = new StringReader(xml);
jb = (JAXBElement) unmarshaller.unmarshal(sr);
org.geotoolkit.ogc.xml.v200.FilterType result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
final org.geotoolkit.gml.xml.v311.ObjectFactory gmlFactory = new org.geotoolkit.gml.xml.v311.ObjectFactory();
BBOXType filterBox = new BBOXType("boundingBox", gmlFactory.createEnvelope(envelope));
org.geotoolkit.ogc.xml.v200.FilterType expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterBox);
assertEquals(((JAXBElement) ((BBOXType) expResult2.getSpatialOps().getValue()).getAny()).getValue(), ((JAXBElement) ((BBOXType) result2.getSpatialOps().getValue()).getAny()).getValue());
assertEquals(expResult2.getSpatialOps().getValue(), result2.getSpatialOps().getValue());
assertEquals(expResult2, result2);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\">" + '\n' + " <ogc:BBOX>" + '\n' + " <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + " $test" + '\n' + " </ogc:BBOX>" + '\n' + "</ogc:Filter>" + '\n';
sr = new StringReader(xml);
jb = (JAXBElement) unmarshaller.unmarshal(sr);
result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
filterBox = new BBOXType("boundingBox", "$test");
expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterBox);
assertEquals(expResult2.getSpatialOps().getValue(), result2.getSpatialOps().getValue());
assertEquals(expResult2, result2);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\">" + '\n' + " <ogc:Contains>" + '\n' + " <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + " $test" + '\n' + " </ogc:Contains>" + '\n' + "</ogc:Filter>" + '\n';
sr = new StringReader(xml);
jb = (JAXBElement) unmarshaller.unmarshal(sr);
result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
ContainsType filterContains = new ContainsType("boundingBox", "$test");
expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterContains);
assertEquals(expResult2.getSpatialOps().getValue(), result2.getSpatialOps().getValue());
assertEquals(expResult2, result2);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/fes/2.0\">" + '\n' + " <ogc:After>" + '\n' + " <ogc:ValueReference>boundingBox</ogc:ValueReference>" + '\n' + " $test" + '\n' + " </ogc:After>" + '\n' + "</ogc:Filter>" + '\n';
sr = new StringReader(xml);
jb = (JAXBElement) unmarshaller.unmarshal(sr);
result2 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
TimeAfterType filterAfter = new TimeAfterType("boundingBox", "$test");
expResult2 = new org.geotoolkit.ogc.xml.v200.FilterType(filterAfter);
assertEquals(expResult2.getTemporalOps().getValue(), result2.getTemporalOps().getValue());
assertEquals(expResult2, result2);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:gco=\"http://www.isotc211.org/2005/gco\" xmlns:gmx=\"http://www.isotc211.org/2005/gmx\" xmlns:gmi=\"http://www.isotc211.org/2005/gmi\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:ns8=\"http://www.opengis.net/gml\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\">\n" + " <fes:PropertyIsBetween>\n" + " <fes:ValueReference>prop</fes:ValueReference>\n" + " <fes:LowerBoundary>\n" + " <fes:Literal><gml:TimeInstant>\n" + " <gml:timePosition>2002</gml:timePosition>\n" + " </gml:TimeInstant></fes:Literal>\n" + " </fes:LowerBoundary>\n" + " <fes:UpperBoundary>\n" + " <fes:Literal><gml:TimeInstant>\n" + " <gml:timePosition>2004</gml:timePosition>\n" + " </gml:TimeInstant></fes:Literal>\n" + " </fes:UpperBoundary>\n" + " </fes:PropertyIsBetween>\n" + "</fes:Filter>";
sr = new StringReader(xml);
jb = (JAXBElement) unmarshaller.unmarshal(sr);
org.geotoolkit.ogc.xml.v200.FilterType result3 = (org.geotoolkit.ogc.xml.v200.FilterType) jb.getValue();
final org.geotoolkit.gml.xml.v321.ObjectFactory gml32Factory = new org.geotoolkit.gml.xml.v321.ObjectFactory();
final org.geotoolkit.ogc.xml.v200.ObjectFactory fesFactory = new org.geotoolkit.ogc.xml.v200.ObjectFactory();
PropertyIsBetweenType expPes = new PropertyIsBetweenType();
expPes.setExpression(fesFactory.createValueReference((String) "prop"));
final LowerBoundaryType lower = new LowerBoundaryType();
final TimeInstantType ti = new TimeInstantType("2002");
final LiteralType lowlit = new LiteralType(gml32Factory.createTimeInstant(ti));
lower.setExpression(fesFactory.createLiteral(lowlit));
expPes.setLowerBoundary(lower);
final UpperBoundaryType upper = new UpperBoundaryType();
final TimeInstantType ti2 = new TimeInstantType("2004");
final LiteralType upplit = new LiteralType(gml32Factory.createTimeInstant(ti2));
upper.setExpression(fesFactory.createLiteral(upplit));
expPes.setUpperBoundary(upper);
org.geotoolkit.ogc.xml.v200.FilterType expResult3 = new org.geotoolkit.ogc.xml.v200.FilterType(expPes);
assertTrue(result3.getComparisonOps().getValue() instanceof PropertyIsBetweenType);
PropertyIsBetweenType resPes = (PropertyIsBetweenType) result3.getComparisonOps().getValue();
assertEquals(expPes.getUpperBoundary(), resPes.getUpperBoundary());
assertEquals(expPes.getLowerBoundary(), resPes.getLowerBoundary());
assertEquals(expPes, resPes);
assertEquals(expResult3.getComparisonOps().getValue(), result3.getComparisonOps().getValue());
assertEquals(expResult3, result3);
}
use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class WfsFilterDelegate method buildBBoxType.
private JAXBElement<BBOXType> buildBBoxType(String propertyName, String wkt) {
BBOXType bboxType = new BBOXType();
bboxType.setExpression(filterObjectFactory.createValueReference(propertyName));
try {
bboxType.setAny(createEnvelope(getGeometryFromWkt(wkt)));
} catch (ParseException e) {
throw new UnsupportedOperationException("Unable to parse WKT Geometry [" + wkt + "]", e);
}
return filterObjectFactory.createBBOX(bboxType);
}
use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class CswFilterFactory method createBBoxType.
private JAXBElement<BBOXType> createBBoxType(String propertyName, String wkt) {
BBOXType bboxType = new BBOXType();
JAXBElement<EnvelopeType> envelope = createEnvelopeType(wkt);
bboxType.setEnvelope(envelope);
bboxType.setPropertyName(createPropertyNameType(propertyName));
return filterObjectFactory.createBBOX(bboxType);
}
use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class WfsFilterDelegateTest method testIntersectsAsBoundingBox.
@Test
public void testIntersectsAsBoundingBox() {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.getValue(), new LonLatCoordinateStrategy());
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BBOXType.class)));
assertThat(filter.isSetLogicOps(), is(false));
BBOXType bboxType = (BBOXType) filter.getSpatialOps().getValue();
EnvelopeType envelope = bboxType.getEnvelope().getValue();
DirectPositionType lowerCorner = envelope.getLowerCorner();
assertThat("The bounding box's lower corner was null.", lowerCorner, is(notNullValue()));
assertThat(lowerCorner.getValue(), is(asList(10.0, -10.0)));
DirectPositionType upperCorner = envelope.getUpperCorner();
assertThat("The bounding box's upper corner was null.", upperCorner, is(notNullValue()));
assertThat(upperCorner.getValue(), is(asList(40.0, 30.0)));
}
use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.
the class TestWfsFilterDelegate method testDisjointAsNotBBox.
@Test
public void testDisjointAsNotBBox() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.toString());
FilterType filter = delegate.disjoint(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getLogicOps().getValue() instanceof UnaryLogicOpType);
UnaryLogicOpType type = (UnaryLogicOpType) filter.getLogicOps().getValue();
assertTrue(type.getSpatialOps().getValue() instanceof BBOXType);
assertXMLEqual(MockWfsServer.getNotBboxXmlFilter(), getXmlFromMarshaller(filter));
}
Aggregations