use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testGeoServerLatLonSwappingForPoint.
@Test
public void testGeoServerLatLonSwappingForPoint() {
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
fcMap.put("states", converter);
fcMap.put("streams", converter);
fcConverter.setFeatureConverterMap(fcMap);
xstream.registerConverter(fcConverter);
converter.setMetacardType(buildStatesMetacardType());
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.alias("FeatureCollection", Wfs20FeatureCollection.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/geoserver_sample_point.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(1, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getId(), "states.10");
// Verifies that lat/lon was swapped to lon/lat order for the WKT conversion
// to set the metacard's location
assertTrue(mc.getLocation().startsWith("POINT (-123.26 49.41)"));
}
use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testUnmarshalFeatureCollectionXmlToObject.
@Test
public void testUnmarshalFeatureCollectionXmlToObject() {
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
fcMap.put("video_data_set", converter);
fcConverter.setFeatureConverterMap(fcMap);
xstream.registerConverter(fcConverter);
converter.setMetacardType(buildMetacardType());
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.registerConverter(new GmlGeometryConverter());
xstream.alias("FeatureCollection", Wfs20FeatureCollection.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/video_data_set_collection.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(4, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getId(), "video_data_set.1");
}
use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testGeoServerLatLonSwappingForMultiPolygon.
@Test
public void testGeoServerLatLonSwappingForMultiPolygon() {
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20();
fcMap.put("states", converter);
fcMap.put("streams", converter);
fcConverter.setFeatureConverterMap(fcMap);
xstream.registerConverter(fcConverter);
converter.setMetacardType(buildStatesMetacardType());
converter.setCoordinateOrder(GeospatialUtil.LAT_LON_ORDER);
xstream.registerConverter(converter);
xstream.alias("FeatureCollection", Wfs20FeatureCollection.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/geoserver_sample_polygon.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(1, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getId(), "states.10");
// Verifies that lat/lon was swapped to lon/lat order for the WKT conversion
// to set the metacard's location
assertTrue(mc.getLocation().startsWith("MULTIPOLYGON (((-89.1 36.1, -89.1 37.1, -88.1 37.1, -88.1 36.1, -89.1 36.1"));
}
use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testUnmarshalNoMetacardTypeRegisteredInConverter.
@Test(expected = IllegalArgumentException.class)
public void testUnmarshalNoMetacardTypeRegisteredInConverter() throws Throwable {
XStream xstream = new XStream(new WstxDriver());
xstream.registerConverter(new GenericFeatureConverterWfs20());
xstream.registerConverter(new GmlGeometryConverter());
xstream.alias(FEATURE_TYPE, Metacard.class);
InputStream is = TestGenericFeatureConverter.class.getResourceAsStream("/video_data_set.xml");
try {
Wfs20FeatureCollection wfs = (Wfs20FeatureCollection) xstream.fromXML(is);
} catch (Exception e) {
throw e.getCause();
}
}
use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class FeatureCollectionConverterWfs20 method unmarshal.
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
Wfs20FeatureCollection featureCollection = new Wfs20FeatureCollection();
while (reader.hasMoreChildren()) {
reader.moveDown();
String nodeName = reader.getNodeName();
// namespace.
if (FEATURE_MEMBER.equals(nodeName)) {
reader.moveDown();
String subNodeName = reader.getNodeName();
//If the member contains a sub feature collection, step in and get members
if (subNodeName.equals(FEATURE_COLLECTION)) {
while (reader.hasMoreChildren()) {
reader.moveDown();
String subNodeName2 = reader.getNodeName();
if (FEATURE_MEMBER.equals(subNodeName2)) {
reader.moveDown();
// lookup the converter for this featuretype
featureCollection = addMetacardToFeatureCollection(featureCollection, context, reader);
reader.moveUp();
}
reader.moveUp();
}
} else {
// lookup the converter for this featuretype
featureCollection = addMetacardToFeatureCollection(featureCollection, context, reader);
}
reader.moveUp();
}
reader.moveUp();
}
return featureCollection;
}
Aggregations