Search in sources :

Example 6 with WfsFeatureCollection

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection in project ddf by codice.

the class TestGenericFeatureConverter method testUnmarshalFeatureCollectionXmlToObject.

@Test
public void testUnmarshalFeatureCollectionXmlToObject() {
    XStream xstream = new XStream(new WstxDriver());
    FeatureCollectionConverterWfs10 fcConverter = new FeatureCollectionConverterWfs10();
    Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
    GenericFeatureConverter converter = new GenericFeatureConverter();
    fcMap.put("video_data_set", converter);
    fcConverter.setFeatureConverterMap(fcMap);
    xstream.registerConverter(fcConverter);
    converter.setMetacardType(buildMetacardType());
    xstream.registerConverter(converter);
    xstream.registerConverter(new GmlGeometryConverter());
    xstream.alias("FeatureCollection", WfsFeatureCollection.class);
    InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/video_data_set_collection.xml");
    WfsFeatureCollection wfc = (WfsFeatureCollection) xstream.fromXML(is);
    assertThat(wfc.getFeatureMembers(), hasSize(4));
    Metacard mc = wfc.getFeatureMembers().get(0);
    assertThat(mc.getId(), is("video_data_set.1"));
}
Also used : WstxDriver(com.thoughtworks.xstream.io.xml.WstxDriver) Metacard(ddf.catalog.data.Metacard) GmlGeometryConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter) HashMap(java.util.HashMap) GenericFeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter) XStream(com.thoughtworks.xstream.XStream) InputStream(java.io.InputStream) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection) FeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.FeatureConverter) GenericFeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter) Test(org.junit.Test)

Example 7 with WfsFeatureCollection

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection in project ddf by codice.

the class FeatureCollectionConverterWfs10 method unmarshal.

@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    WfsFeatureCollection featureCollection = new WfsFeatureCollection();
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        String nodeName = reader.getNodeName();
        // namespace.
        if (featureMember.equals(nodeName)) {
            reader.moveDown();
            // lookup the converter for this featuretype
            featureCollection.getFeatureMembers().add((Metacard) context.convertAnother(null, MetacardImpl.class, featureConverterMap.get(reader.getNodeName())));
            reader.moveUp();
        }
        reader.moveUp();
    }
    return featureCollection;
}
Also used : WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection)

Example 8 with WfsFeatureCollection

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection in project ddf by codice.

the class TestGenericFeatureConverter method testUnmarshalFeatureCollectionNonWGS84XmlToObject.

@Test
public void testUnmarshalFeatureCollectionNonWGS84XmlToObject() {
    XStream xstream = new XStream(new WstxDriver());
    FeatureCollectionConverterWfs10 fcConverter = new FeatureCollectionConverterWfs10();
    Map<String, FeatureConverter> fcMap = new HashMap<>();
    GenericFeatureConverter converter = new GenericFeatureConverter("EPSG:26713");
    fcMap.put("video_data_set", converter);
    fcConverter.setFeatureConverterMap(fcMap);
    xstream.registerConverter(fcConverter);
    converter.setMetacardType(buildMetacardType());
    xstream.registerConverter(converter);
    xstream.registerConverter(new GmlGeometryConverter());
    xstream.alias("FeatureCollection", WfsFeatureCollection.class);
    InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/video_data_set_2.xml");
    WfsFeatureCollection wfc = (WfsFeatureCollection) xstream.fromXML(is);
    assertThat(wfc.getFeatureMembers(), hasSize(1));
    Metacard mc = wfc.getFeatureMembers().get(0);
    assertThat(mc.getId(), is("video_data_set.1"));
    assertThat(mc.getLocation(), is("MULTILINESTRING ((-103.85275410013904 44.48520433037816, -103.85142707963864 44.48544013668279))"));
}
Also used : WstxDriver(com.thoughtworks.xstream.io.xml.WstxDriver) Metacard(ddf.catalog.data.Metacard) GmlGeometryConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter) HashMap(java.util.HashMap) GenericFeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter) XStream(com.thoughtworks.xstream.XStream) InputStream(java.io.InputStream) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection) FeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.FeatureConverter) GenericFeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter) Test(org.junit.Test)

Aggregations

WfsFeatureCollection (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection)8 Metacard (ddf.catalog.data.Metacard)6 XStream (com.thoughtworks.xstream.XStream)4 GenericFeatureConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter)4 GmlGeometryConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter)4 Test (org.junit.Test)4 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 FeatureConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.FeatureConverter)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 XStreamException (com.thoughtworks.xstream.XStreamException)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 MetacardType (ddf.catalog.data.MetacardType)1 Result (ddf.catalog.data.Result)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 Query (ddf.catalog.operation.Query)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1