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"));
}
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;
}
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))"));
}
Aggregations