Search in sources :

Example 6 with ObjectFactory

use of org.geotoolkit.swe.xml.v101.ObjectFactory in project geotoolkit by Geomatys.

the class SEforSLD110Test method testFTS.

@Test
public void testFTS() throws JAXBException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_SE_FTS);
    assertNotNull(obj);
    JAXBElement<?> jax = (JAXBElement<?>) obj;
    MutableFeatureTypeStyle fts = TRANSFORMER_GT.visitFTS(jax.getValue());
    assertNotNull(fts);
    assertEquals(fts.getName(), valueName);
    assertEquals(fts.getDescription().getTitle().toString(), valueTitle);
    assertEquals(fts.getDescription().getAbstract().toString(), valueAbstract);
    assertEquals(fts.featureTypeNames().iterator().next().tip().toString(), valueFTN);
    assertEquals(fts.rules().size(), 3);
    assertEquals(fts.semanticTypeIdentifiers().size(), 6);
    Iterator<SemanticType> ite = fts.semanticTypeIdentifiers().iterator();
    assertEquals(ite.next(), SemanticType.ANY);
    assertEquals(ite.next(), SemanticType.POINT);
    assertEquals(ite.next(), SemanticType.LINE);
    assertEquals(ite.next(), SemanticType.POLYGON);
    assertEquals(ite.next(), SemanticType.TEXT);
    assertEquals(ite.next(), SemanticType.RASTER);
    // Write test
    CoverageStyleType pvt = (CoverageStyleType) TRANSFORMER_OGC.visit(fts, null);
    assertNotNull(pvt);
    assertEquals(pvt.getName(), valueName);
    assertEquals(String.valueOf(pvt.getDescription().getTitle()), valueTitle);
    assertEquals(String.valueOf(pvt.getDescription().getAbstract()), valueAbstract);
    assertTrue(pvt.getCoverageName().contains(valueFTN));
    assertEquals(pvt.getRuleOrOnlineResource().size(), 3);
    assertEquals(pvt.getSemanticTypeIdentifier().size(), 6);
    assertEquals(pvt.getSemanticTypeIdentifier().get(0), "generic:any");
    assertEquals(pvt.getSemanticTypeIdentifier().get(1), "generic:point");
    assertEquals(pvt.getSemanticTypeIdentifier().get(2), "generic:line");
    assertEquals(pvt.getSemanticTypeIdentifier().get(3), "generic:polygon");
    assertEquals(pvt.getSemanticTypeIdentifier().get(4), "generic:text");
    assertEquals(pvt.getSemanticTypeIdentifier().get(5), "generic:raster");
    MARSHALLER.marshal(new ObjectFactory().createCoverageStyle(pvt), TEST_FILE_SE_FTS);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) SemanticType(org.opengis.style.SemanticType) ObjectFactory(org.geotoolkit.se.xml.v110.ObjectFactory) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) CoverageStyleType(org.geotoolkit.se.xml.v110.CoverageStyleType) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 7 with ObjectFactory

use of org.geotoolkit.swe.xml.v101.ObjectFactory in project geotoolkit by Geomatys.

the class SamplingXMLBindingTest method marshallingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void marshallingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
    final DirectPositionType pos = new DirectPositionType("urn:ogc:crs:espg:4326", 2, Arrays.asList(3.2, 6.5));
    final PointType location = new PointType("point-ID", pos);
    final SamplingPointType sp = new SamplingPointType("samplingID-007", "urn:sampling:test:007", "a sampling Test", new FeaturePropertyType(""), location);
    StringWriter sw = new StringWriter();
    marshaller.marshal(sp, sw);
    String result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    String expResult = "<sampling:SamplingPoint gml:id=\"samplingID-007\"" + " xmlns:sampling=\"http://www.opengis.net/sampling/1.0\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "    <gml:description>a sampling Test</gml:description>" + '\n' + "    <gml:name>urn:sampling:test:007</gml:name>" + '\n' + "    <gml:boundedBy>" + '\n' + "        <gml:Null>not_bounded</gml:Null>" + '\n' + "    </gml:boundedBy>" + '\n' + "    <sampling:sampledFeature xlink:href=\"\"/>" + '\n' + "    <sampling:position>" + '\n' + "        <gml:Point gml:id=\"point-ID\">" + '\n' + "            <gml:pos srsName=\"urn:ogc:crs:espg:4326\" srsDimension=\"2\">3.2 6.5</gml:pos>" + '\n' + "        </gml:Point>" + '\n' + "    </sampling:position>" + '\n' + "</sampling:SamplingPoint>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    final ObjectFactory facto = new ObjectFactory();
    FeatureCollectionType collection = new FeatureCollectionType();
    List<FeaturePropertyType> featProps = new ArrayList<FeaturePropertyType>();
    featProps.add(new FeaturePropertyType(facto.createSamplingPoint(sp)));
    collection.getFeatureMember().addAll(featProps);
    sw = new StringWriter();
    marshaller.marshal(collection, sw);
    result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    expResult = "<gml:FeatureCollection" + " xmlns:sampling=\"http://www.opengis.net/sampling/1.0\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "    <gml:featureMember>" + '\n' + "        <sampling:SamplingPoint gml:id=\"samplingID-007\">" + '\n' + "            <gml:description>a sampling Test</gml:description>" + '\n' + "            <gml:name>urn:sampling:test:007</gml:name>" + '\n' + "            <gml:boundedBy>" + '\n' + "                <gml:Null>not_bounded</gml:Null>" + '\n' + "            </gml:boundedBy>" + '\n' + "            <sampling:sampledFeature xlink:href=\"\"/>" + '\n' + "            <sampling:position>" + '\n' + "                <gml:Point gml:id=\"point-ID\">" + '\n' + "                    <gml:pos srsName=\"urn:ogc:crs:espg:4326\" srsDimension=\"2\">3.2 6.5</gml:pos>" + '\n' + "                </gml:Point>" + '\n' + "            </sampling:position>" + '\n' + "        </sampling:SamplingPoint>" + '\n' + "    </gml:featureMember>" + '\n' + "</gml:FeatureCollection>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : FeatureCollectionType(org.geotoolkit.gml.xml.v311.FeatureCollectionType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) StringWriter(java.io.StringWriter) ObjectFactory(org.geotoolkit.sampling.xml.v100.ObjectFactory) SamplingPointType(org.geotoolkit.sampling.xml.v100.SamplingPointType) ArrayList(java.util.ArrayList) PointType(org.geotoolkit.gml.xml.v311.PointType) SamplingPointType(org.geotoolkit.sampling.xml.v100.SamplingPointType) FeaturePropertyType(org.geotoolkit.gml.xml.v311.FeaturePropertyType)

Example 8 with ObjectFactory

use of org.geotoolkit.swe.xml.v101.ObjectFactory 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 9 with ObjectFactory

use of org.geotoolkit.swe.xml.v101.ObjectFactory 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)

Example 10 with ObjectFactory

use of org.geotoolkit.swe.xml.v101.ObjectFactory in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method ComponentMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void ComponentMarshalingTest() throws Exception {
    ComponentType compo = new ComponentType();
    compo.setValidTime(new TimePeriodType(new TimePositionType("2004-06-01")));
    Marshaller marshaller = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    StringWriter sw = new StringWriter();
    final ObjectFactory factory = new ObjectFactory();
    marshaller.marshal(factory.createComponent(compo), sw);
    String result = sw.toString();
    System.out.println("result:" + result);
}
Also used : ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) Marshaller(javax.xml.bind.Marshaller) TimePeriodType(org.geotoolkit.gml.xml.v311.TimePeriodType) StringWriter(java.io.StringWriter) ObjectFactory(org.geotoolkit.sml.xml.v100.ObjectFactory) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)35 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)26 Marshaller (javax.xml.bind.Marshaller)24 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 StringWriter (java.io.StringWriter)19 JAXBContext (javax.xml.bind.JAXBContext)19 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 ObjectFactory (no.seres.xsd.nav.inntektsmelding_m._20181211.ObjectFactory)16 QName (javax.xml.namespace.QName)15 BigInteger (java.math.BigInteger)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ObjectFactory (slash.navigation.kml.binding22.ObjectFactory)12 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11