Search in sources :

Example 1 with BBOXType

use of net.opengis.fes.x20.BBOXType in project ddf by codice.

the class TestWfsFilterDelegate method testIntersectsAsBoundingBox.

@Test
public void testIntersectsAsBoundingBox() throws SAXException, IOException, JAXBException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.toString());
    FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
    assertNotNull(filter);
    assertTrue(filter.getSpatialOps().getValue() instanceof BBOXType);
    assertFalse(filter.isSetLogicOps());
    assertXMLEqual(MockWfsServer.getBboxXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) BBOXType(net.opengis.filter.v_2_0_0.BBOXType) Test(org.junit.Test)

Example 2 with BBOXType

use of net.opengis.fes.x20.BBOXType in project ddf by codice.

the class WfsFilterDelegate method buildBBoxType.

private JAXBElement<BBOXType> buildBBoxType(String propertyName, String wkt) {
    BBOXType bboxType = new BBOXType();
    JAXBElement<BoxType> box = createBoxType(wkt);
    bboxType.setBox(box.getValue());
    bboxType.setPropertyName(createPropertyNameType(propertyName).getValue());
    return filterObjectFactory.createBBOX(bboxType);
}
Also used : BBOXType(ogc.schema.opengis.filter.v_1_0_0.BBOXType) BoxType(ogc.schema.opengis.gml.v_2_1_2.BoxType)

Example 3 with BBOXType

use of net.opengis.fes.x20.BBOXType in project arctic-sea by 52North.

the class FesDecoderv20 method parseSpatialFilterType.

/**
 * Parses the spatial filter of a request.
 *
 * @param xbSpatialOpsType
 *            XmlBean representing the feature of interest parameter of the
 *            request
 * @return Returns SpatialFilter created from the passed foi request
 *         parameter
 *
 * @throws DecodingException
 *             * if creation of the SpatialFilter failed
 */
private SpatialFilter parseSpatialFilterType(SpatialOpsType xbSpatialOpsType) throws DecodingException {
    SpatialFilter spatialFilter = new SpatialFilter();
    try {
        if (xbSpatialOpsType instanceof BBOXType) {
            spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
            BBOXType xbBBOX = (BBOXType) xbSpatialOpsType;
            if (isValueReferenceExpression(xbBBOX.getExpression())) {
                spatialFilter.setValueReference(parseValueReference(xbBBOX.getExpression()));
            }
            XmlCursor geometryCursor = xbSpatialOpsType.newCursor();
            if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE_32)) {
                Object sosGeometry = decodeXmlObject(Factory.parse(geometryCursor.getDomNode()));
                if (sosGeometry instanceof Geometry) {
                    spatialFilter.setGeometry((Geometry) sosGeometry);
                } else if (sosGeometry instanceof ReferencedEnvelope) {
                    spatialFilter.setGeometry((ReferencedEnvelope) sosGeometry);
                } else {
                    throw new UnsupportedDecoderXmlInputException(this, xbSpatialOpsType);
                }
            } else {
                throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter operand is not supported by this SOS!");
            }
            geometryCursor.dispose();
        } else {
            throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter is not supported by this SOS!");
        }
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing spatial filter!", xmle);
    }
    return spatialFilter;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) BBOXType(net.opengis.fes.x20.BBOXType) XmlException(org.apache.xmlbeans.XmlException) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 4 with BBOXType

use of net.opengis.fes.x20.BBOXType in project arctic-sea by 52North.

the class FesEncoderv20 method encodeSpatialFilter.

private XmlObject encodeSpatialFilter(SpatialFilter spatialFilter) throws EncodingException {
    final BBOXDocument bboxDoc = BBOXDocument.Factory.newInstance(getXmlOptions());
    final BBOXType bbox = bboxDoc.addNewBBOX();
    if (spatialFilter.hasValueReference()) {
        bbox.set(encodeReferenceValue(spatialFilter.getValueReference()));
    }
    // TODO check if srid is needed, then add as HelperValue
    bbox.setExpression(encodeExpression(spatialFilter.getGeometry()));
    return bbox;
}
Also used : BBOXType(net.opengis.fes.x20.BBOXType) BBOXDocument(net.opengis.fes.x20.BBOXDocument)

Example 5 with BBOXType

use of net.opengis.fes.x20.BBOXType in project arctic-sea by 52North.

the class FesEncoderv20Test method should_return_BBoxType_for_spatialFilter.

// @Test
// deactivated until test fails on build server.
public final void should_return_BBoxType_for_spatialFilter() throws EncodingException {
    final SpatialFilter filter = new SpatialFilter();
    filter.setOperator(SpatialOperator.BBOX);
    filter.setGeometry(new GeometryFactory().toGeometry(new Envelope(1, 2, 3, 4)));
    filter.setValueReference("valueReference");
    final XmlObject encode = fesEncoder.encode(filter);
    assertThat(encode, is(instanceOf(BBOXType.class)));
    final BBOXType xbBBox = (BBOXType) encode;
    assertThat(xbBBox.isSetExpression(), is(TRUE));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) BBOXType(net.opengis.fes.x20.BBOXType) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) XmlObject(org.apache.xmlbeans.XmlObject) Envelope(org.locationtech.jts.geom.Envelope)

Aggregations

BBOXType (net.opengis.fes.x20.BBOXType)3 BBOXType (net.opengis.filter.v_2_0_0.BBOXType)3 FilterType (net.opengis.filter.v_2_0_0.FilterType)2 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.Test)2 SpatialFilter (org.n52.shetland.ogc.filter.SpatialFilter)2 ParseException (com.vividsolutions.jts.io.ParseException)1 BBOXDocument (net.opengis.fes.x20.BBOXDocument)1 BBOXType (net.opengis.filter.v_1_1_0.BBOXType)1 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)1 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)1 BBOXType (ogc.schema.opengis.filter.v_1_0_0.BBOXType)1 BoxType (ogc.schema.opengis.gml.v_2_1_2.BoxType)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlException (org.apache.xmlbeans.XmlException)1 Envelope (org.locationtech.jts.geom.Envelope)1 Geometry (org.locationtech.jts.geom.Geometry)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1