Search in sources :

Example 1 with TimeAfterType

use of org.geotoolkit.ogc.xml.v110.TimeAfterType in project geotoolkit by Geomatys.

the class FilterFactoryImpl method after.

@Override
public TemporalOperator<Object> after(final Expression<Object, ?> expr1, final Expression<Object, ?> expr2) {
    Object temporal = null;
    PropertyNameType propName = null;
    if (expr1 instanceof PropertyNameType) {
        propName = (PropertyNameType) expr1;
        temporal = expr2;
    } else if (expr2 instanceof PropertyNameType) {
        propName = (PropertyNameType) expr2;
        temporal = expr1;
    }
    return new TimeAfterType(propName.getXPath(), temporal);
}
Also used : TimeAfterType(org.geotoolkit.ogc.xml.v110.TimeAfterType) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType)

Example 2 with TimeAfterType

use of org.geotoolkit.ogc.xml.v110.TimeAfterType 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)

Example 3 with TimeAfterType

use of org.geotoolkit.ogc.xml.v110.TimeAfterType 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);
}
Also used : OverlapsType(org.geotoolkit.ogc.xml.v110.OverlapsType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) TimeInstantType(org.geotoolkit.gml.xml.v321.TimeInstantType) ObjectFactory(org.geotoolkit.ogc.xml.v110.ObjectFactory) StringReader(java.io.StringReader) 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) JAXBElement(javax.xml.bind.JAXBElement) TimeAfterType(org.geotoolkit.ogc.xml.v200.TimeAfterType) UpperBoundaryType(org.geotoolkit.ogc.xml.v200.UpperBoundaryType) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) ContainsType(org.geotoolkit.ogc.xml.v200.ContainsType) BBOXType(org.geotoolkit.ogc.xml.v200.BBOXType) LowerBoundaryType(org.geotoolkit.ogc.xml.v200.LowerBoundaryType)

Aggregations

PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)3 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)2 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)2 TimeInstantType (org.geotoolkit.gml.xml.v321.TimeInstantType)2 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)2 ObjectFactory (org.geotoolkit.ogc.xml.v110.ObjectFactory)2 OverlapsType (org.geotoolkit.ogc.xml.v110.OverlapsType)2 BBOXType (org.geotoolkit.ogc.xml.v200.BBOXType)2 LiteralType (org.geotoolkit.ogc.xml.v200.LiteralType)2 LowerBoundaryType (org.geotoolkit.ogc.xml.v200.LowerBoundaryType)2 PropertyIsBetweenType (org.geotoolkit.ogc.xml.v200.PropertyIsBetweenType)2 TimeAfterType (org.geotoolkit.ogc.xml.v200.TimeAfterType)2 UpperBoundaryType (org.geotoolkit.ogc.xml.v200.UpperBoundaryType)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 JAXBElement (javax.xml.bind.JAXBElement)1 SortByType (org.geotoolkit.ogc.xml.v110.SortByType)1 SortPropertyType (org.geotoolkit.ogc.xml.v110.SortPropertyType)1 TimeAfterType (org.geotoolkit.ogc.xml.v110.TimeAfterType)1 ContainsType (org.geotoolkit.ogc.xml.v200.ContainsType)1