use of org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.converter.impl.GenericFeatureConverterWfs20 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.converter.impl.GenericFeatureConverterWfs20 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.converter.impl.GenericFeatureConverterWfs20 in project ddf by codice.
the class WfsSource method lookupFeatureConverter.
private void lookupFeatureConverter(String ftSimpleName, FeatureMetacardType ftMetacard) {
FeatureConverter featureConverter = null;
/**
* The list of feature converter factories injected into this class is a live list. So, feature converter factories
* can be added and removed from the system while running.
*/
if (CollectionUtils.isNotEmpty(featureConverterFactories)) {
for (FeatureConverterFactory factory : featureConverterFactories) {
if (ftSimpleName.equalsIgnoreCase(factory.getFeatureType())) {
featureConverter = factory.createConverter();
break;
}
}
}
// Found a specific feature converter
if (featureConverter != null) {
LOGGER.debug("WFS Source {}: Features of type: {} will be converted using {}", getId(), ftSimpleName, featureConverter.getClass().getSimpleName());
} else {
LOGGER.debug("WfsSource {}: Unable to find a feature specific converter; {} will be converted using the GenericFeatureConverter", getId(), ftSimpleName);
// Since we have no specific converter, we will check to see if we have a mapper to do
// feature property to metacard attribute mappings.
MetacardMapper featurePropertyToMetacardAttributeMapper = lookupMetacardAttributeToFeaturePropertyMapper(ftMetacard.getFeatureType());
if (featurePropertyToMetacardAttributeMapper != null) {
featureConverter = new GenericFeatureConverterWfs20(featurePropertyToMetacardAttributeMapper);
LOGGER.debug("WFS Source {}: Created {} for feature type {} with feature property to metacard attribute mapper.", getId(), featureConverter.getClass().getSimpleName(), ftSimpleName);
} else {
featureConverter = new GenericFeatureConverterWfs20();
LOGGER.debug("WFS Source {}: Created {} for feature type {} with no feature property to metacard attribute mapper.", getId(), featureConverter.getClass().getSimpleName(), ftSimpleName);
}
}
featureConverter.setSourceId(getId());
featureConverter.setMetacardType(ftMetacard);
featureConverter.setWfsUrl(wfsUrl);
featureConverter.setCoordinateOrder(coordinateOrder);
// Add the Feature Type name as an alias for xstream
LOGGER.debug("Registering feature converter {} for feature type {}.", featureConverter.getClass().getSimpleName(), ftSimpleName);
getFeatureCollectionReader().registerConverter(featureConverter);
}
Aggregations