use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testUnmarshalMultiQueryFeatureCollectionXmlToObjectWithMetacardMapper.
/*
* This test will check is the MetacardMapper maps the feature value of 'states.STATE_NAME' to the metacard property 'title'.
*/
@Test
public void testUnmarshalMultiQueryFeatureCollectionXmlToObjectWithMetacardMapper() {
//Create Metacard Mapper
String featureProp = "ext.states.STATE_NAME";
String metacardAttr = "title";
MetacardMapper metacardMapper = mock(MetacardMapper.class);
when(metacardMapper.getMetacardAttribute(featureProp)).thenReturn(metacardAttr);
XStream xstream = new XStream(new WstxDriver());
FeatureCollectionConverterWfs20 fcConverter = new FeatureCollectionConverterWfs20();
Map<String, FeatureConverter> fcMap = new HashMap<String, FeatureConverter>();
GenericFeatureConverterWfs20 converter = new GenericFeatureConverterWfs20(metacardMapper);
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.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(7, wfc.getMembers().size());
Metacard mc = wfc.getMembers().get(0);
assertEquals(mc.getTitle(), "Missouri");
// 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.104965 36.953869, -89.129585 36.86644, -89.166496 36.843422000000004,"));
}
use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testUnmarshalMultiQueryFeatureCollectionXmlToObject.
@Test
public void testUnmarshalMultiQueryFeatureCollectionXmlToObject() {
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.xml");
Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) xstream.fromXML(is);
assertEquals(7, 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.104965 36.953869, -89.129585 36.86644, -89.166496 36.843422000000004,"));
}
use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection in project ddf by codice.
the class TestGenericFeatureConverter method testMetacardCollectionToFeatureCollectionXml.
@Test
public void testMetacardCollectionToFeatureCollectionXml() {
XStream xstream = new XStream(new EnhancedStaxDriver());
xstream.setMode(XStream.NO_REFERENCES);
xstream.registerConverter(new FeatureCollectionConverterWfs20());
xstream.registerConverter(new GenericFeatureConverterWfs20());
xstream.registerConverter(new GmlGeometryConverter());
// Required the Implementing class. The interface would not work...
xstream.alias(Wfs20Constants.WFS_NAMESPACE_PREFIX + ":" + "FeatureCollection", Wfs20FeatureCollection.class);
Metacard mc = new SampleMetacard().getMetacard();
Wfs20FeatureCollection wfc = new Wfs20FeatureCollection();
wfc.getMembers().add(mc);
MetacardImpl mc2 = new SampleMetacard().getMetacard();
// Ignore the hack stuff, this was just to imitate having two different
// "MetacardTypes"
mc2.setType(new MetacardType() {
@Override
public String getName() {
return "otherType";
}
@Override
public Set<AttributeDescriptor> getAttributeDescriptors() {
return BasicTypes.BASIC_METACARD.getAttributeDescriptors();
}
@Override
public AttributeDescriptor getAttributeDescriptor(String arg0) {
return BasicTypes.BASIC_METACARD.getAttributeDescriptor(arg0);
}
});
wfc.getMembers().add(mc2);
String xml = xstream.toXML(wfc);
}
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");
}
Aggregations