Search in sources :

Example 16 with LiteralType

use of org.geotoolkit.ogc.xml.v200.LiteralType in project geotoolkit by Geomatys.

the class FilterFactoryImpl method greaterOrEqual.

@Override
public BinaryComparisonOperator<Object> greaterOrEqual(final Expression<Object, ?> expr1, final Expression<Object, ?> expr2) {
    LiteralType lit = null;
    PropertyNameType propName = null;
    if (expr1 instanceof PropertyNameType) {
        propName = (PropertyNameType) expr1;
    } else if (expr2 instanceof PropertyNameType) {
        propName = (PropertyNameType) expr2;
    }
    if (expr1 instanceof LiteralType) {
        lit = (LiteralType) expr1;
    } else if (expr2 instanceof LiteralType) {
        lit = (LiteralType) expr2;
    }
    return new PropertyIsGreaterThanOrEqualToType(lit, propName, null);
}
Also used : LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) PropertyIsGreaterThanOrEqualToType(org.geotoolkit.ogc.xml.v110.PropertyIsGreaterThanOrEqualToType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType)

Example 17 with LiteralType

use of org.geotoolkit.ogc.xml.v200.LiteralType in project geotoolkit by Geomatys.

the class FilterFactoryImpl method touches.

@Override
public BinarySpatialOperator<Object> touches(final Expression<Object, ?> propertyName1, final Expression<Object, ?> geometry2) {
    PropertyNameType propertyName = null;
    if (propertyName1 instanceof PropertyNameType) {
        propertyName = (PropertyNameType) propertyName1;
    } else {
        throw new IllegalArgumentException("unexpected type instead of propertyNameType: " + propertyName1.getClass().getSimpleName());
    }
    // we transform the JTS geometry into a GML geometry
    Object geom = null;
    if (geometry2 instanceof LiteralType) {
        geom = ((LiteralType) geometry2).getValue();
        geom = GeometryToGML(geom);
    }
    return new TouchesType(propertyName, geom);
}
Also used : LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) TouchesType(org.geotoolkit.ogc.xml.v110.TouchesType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType)

Example 18 with LiteralType

use of org.geotoolkit.ogc.xml.v200.LiteralType in project geotoolkit by Geomatys.

the class FilterFactoryImpl method contains.

@Override
public BinarySpatialOperator<Object> contains(final Expression<Object, ?> geometry1, final Expression<Object, ?> geometry2) {
    // we get the propertyName
    PropertyNameType propertyName = null;
    if (geometry1 instanceof PropertyNameType) {
        propertyName = (PropertyNameType) geometry1;
    } else {
        throw new IllegalArgumentException("unexpected type instead of propertyNameType: " + geometry1.getClass().getSimpleName());
    }
    // we transform the JTS geometry into a GML geometry
    Object geom = null;
    if (geometry2 instanceof LiteralType) {
        geom = ((LiteralType) geometry2).getValue();
        geom = GeometryToGML(geom);
    }
    return new ContainsType(propertyName, geom);
}
Also used : TimeContainsType(org.geotoolkit.ogc.xml.v110.TimeContainsType) ContainsType(org.geotoolkit.ogc.xml.v110.ContainsType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType)

Example 19 with LiteralType

use of org.geotoolkit.ogc.xml.v200.LiteralType in project geotoolkit by Geomatys.

the class FilterFactoryImpl method within.

@Override
public BinarySpatialOperator<Object> within(final Expression<Object, ?> geometry1, final Expression<Object, ?> geometry2) {
    PropertyNameType propertyName = null;
    if (geometry1 instanceof PropertyNameType) {
        propertyName = (PropertyNameType) geometry1;
    } else {
        throw new IllegalArgumentException("unexpected type instead of propertyNameType: " + geometry1.getClass().getSimpleName());
    }
    // we transform the JTS geometry into a GML geometry
    Object geom = null;
    if (geometry2 instanceof LiteralType) {
        geom = ((LiteralType) geometry2).getValue();
        geom = GeometryToGML(geom);
    }
    return new WithinType(propertyName, geom);
}
Also used : LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) DWithinType(org.geotoolkit.ogc.xml.v110.DWithinType) WithinType(org.geotoolkit.ogc.xml.v110.WithinType)

Example 20 with LiteralType

use of org.geotoolkit.ogc.xml.v200.LiteralType in project geotoolkit by Geomatys.

the class FilterXMLBindingTest method filterMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws JAXBException
 */
@Test
public void filterMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
    /*
         * Test marshalling spatial filter
         */
    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 filter = new FilterType(filterElement);
    StringWriter sw = new StringWriter();
    marshaller.marshal(filter, sw);
    String result = sw.toString();
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\" 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';
    LOGGER.log(Level.FINER, "result: {0}", result);
    LOGGER.log(Level.FINER, "expected: {0}", expResult);
    assertXmlEquals(expResult, result, "xmlns:*");
    ObjectFactory factory = new ObjectFactory();
    final BBOXType bbox = new BBOXType("propName", envelope);
    org.geotoolkit.ogc.xml.v200.FilterType filter2 = new org.geotoolkit.ogc.xml.v200.FilterType(bbox);
    sw = new StringWriter();
    marshaller.marshal(filter2, sw);
    result = sw.toString();
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:ns8=\"http://www.opengis.net/gml\">\n" + "  <fes:BBOX>\n" + "    <fes:ValueReference>propName</fes:ValueReference>\n" + "    <ns8:Envelope srsName=\"EPSG:4326\">\n" + "      <ns8:lowerCorner>10.0 11.0</ns8:lowerCorner>\n" + "      <ns8:upperCorner>10.0 11.0</ns8:upperCorner>\n" + "    </ns8:Envelope>\n" + "  </fes:BBOX>\n" + "</fes:Filter>";
    assertXmlEquals(expResult, result, "xmlns:*");
    /*--------------------------------------------*/
    /*- --------------- DEBUG --------------------*/
    /*--------------------------------------------*/
    String[] arr = new String[2];
    arr[0] = "boby";
    arr[1] = "DESC";
    SortPropertyType sp = new SortPropertyType(arr[0], SortOrderType.valueOf(arr[1]));
    SortByType sort = new SortByType(Arrays.asList(sp));
    JAXBElement<SortByType> jbSort = factory.createSortBy(sort);
    // marshaller.marshal(jbSort, System.out);
    sp = new SortPropertyType(arr[0], FilterUtilities.sortOrder(arr[1]));
    sort = new SortByType(Arrays.asList(sp));
    jbSort = factory.createSortBy(sort);
    // marshaller.marshal(jbSort, System.out);
    BBOXType filterBox = new BBOXType("boundingBox", "$test");
    org.geotoolkit.ogc.xml.v200.FilterType filter3 = new org.geotoolkit.ogc.xml.v200.FilterType(filterBox);
    sw = new StringWriter();
    marshaller.marshal(filter3, sw);
    result = sw.toString();
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\">\n" + "  <fes:BBOX>\n" + "    <fes:ValueReference>boundingBox</fes:ValueReference>$test</fes:BBOX>\n" + "</fes:Filter>";
    assertXmlEquals(expResult, result, "xmlns:*");
    TimeAfterType filterAfter = new TimeAfterType("boundingBox", "$test");
    org.geotoolkit.ogc.xml.v200.FilterType filter4 = new org.geotoolkit.ogc.xml.v200.FilterType(filterAfter);
    sw = new StringWriter();
    marshaller.marshal(filter4, sw);
    result = sw.toString();
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\">\n" + "  <fes:After>\n" + "    <fes:ValueReference>boundingBox</fes:ValueReference>$test</fes:After>\n" + "</fes:Filter>";
    assertXmlEquals(expResult, result, "xmlns:*");
    final org.geotoolkit.gml.xml.v321.ObjectFactory gmlFactory = new org.geotoolkit.gml.xml.v321.ObjectFactory();
    final org.geotoolkit.ogc.xml.v200.ObjectFactory fesFactory = new org.geotoolkit.ogc.xml.v200.ObjectFactory();
    PropertyIsBetweenType pes = new PropertyIsBetweenType();
    pes.setExpression(fesFactory.createValueReference((String) "prop"));
    final LowerBoundaryType lower = new LowerBoundaryType();
    final TimeInstantType ti = new TimeInstantType("2002");
    final LiteralType lowlit = new LiteralType(gmlFactory.createTimeInstant(ti));
    lower.setExpression(fesFactory.createLiteral(lowlit));
    pes.setLowerBoundary(lower);
    final UpperBoundaryType upper = new UpperBoundaryType();
    final TimeInstantType ti2 = new TimeInstantType("2004");
    final LiteralType upplit = new LiteralType(gmlFactory.createTimeInstant(ti2));
    upper.setExpression(fesFactory.createLiteral(upplit));
    pes.setUpperBoundary(upper);
    org.geotoolkit.ogc.xml.v200.FilterType filter5 = new org.geotoolkit.ogc.xml.v200.FilterType(pes);
    sw = new StringWriter();
    marshaller.marshal(filter5, sw);
    result = sw.toString();
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<fes:Filter xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:fes=\"http://www.opengis.net/fes/2.0\">\n" + "  <fes:PropertyIsBetween>\n" + "    <fes:ValueReference>prop</fes:ValueReference>\n" + "    <fes:LowerBoundary>\n" + "      <fes:Literal>\n" + "        <gml:TimeInstant>\n" + "          <gml:timePosition>2002</gml:timePosition>\n" + "        </gml:TimeInstant>\n" + "      </fes:Literal>\n" + "    </fes:LowerBoundary>\n" + "    <fes:UpperBoundary>\n" + "      <fes:Literal>\n" + "        <gml:TimeInstant>\n" + "          <gml:timePosition>2004</gml:timePosition>\n" + "        </gml:TimeInstant>\n" + "      </fes:Literal>\n" + "    </fes:UpperBoundary>\n" + "  </fes:PropertyIsBetween>\n" + "</fes:Filter>";
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : OverlapsType(org.geotoolkit.ogc.xml.v110.OverlapsType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) SortByType(org.geotoolkit.ogc.xml.v110.SortByType) TimeInstantType(org.geotoolkit.gml.xml.v321.TimeInstantType) StringWriter(java.io.StringWriter) ObjectFactory(org.geotoolkit.ogc.xml.v110.ObjectFactory) SortPropertyType(org.geotoolkit.ogc.xml.v110.SortPropertyType) PropertyIsBetweenType(org.geotoolkit.ogc.xml.v200.PropertyIsBetweenType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) LiteralType(org.geotoolkit.ogc.xml.v200.LiteralType) TimeAfterType(org.geotoolkit.ogc.xml.v200.TimeAfterType) UpperBoundaryType(org.geotoolkit.ogc.xml.v200.UpperBoundaryType) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) BBOXType(org.geotoolkit.ogc.xml.v200.BBOXType) LowerBoundaryType(org.geotoolkit.ogc.xml.v200.LowerBoundaryType)

Aggregations

LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)40 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)40 JAXBElement (javax.xml.bind.JAXBElement)39 Literal (org.opengis.filter.Literal)34 Marshaller (javax.xml.bind.Marshaller)33 Unmarshaller (javax.xml.bind.Unmarshaller)33 Test (org.junit.Test)33 ValueReference (org.opengis.filter.ValueReference)33 Filter (org.opengis.filter.Filter)25 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)21 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)17 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)16 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)13 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)11 Expression (org.opengis.filter.Expression)11 LiteralType (org.flyte.api.v1.LiteralType)10 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)9 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)9 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)9 LogicalOperator (org.opengis.filter.LogicalOperator)9