Search in sources :

Example 11 with Wfs20FeatureCollection

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

the class FeatureCollectionConverterWfs20 method marshal.

@Override
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    if (value != null) {
        Wfs20FeatureCollection wfc = (Wfs20FeatureCollection) value;
        String schemaLoc = generateSchemaLocationFromMetacards(wfc.getMembers(), prefixToUriMapping);
        for (Entry<String, String> entry : prefixToUriMapping.entrySet()) {
            writer.addAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + entry.getKey(), entry.getValue());
        }
        writer.addAttribute(Wfs20Constants.ATTRIBUTE_SCHEMA_LOCATION, schemaLoc);
        Geometry allGeometry = getBounds(wfc.getMembers());
        if (!allGeometry.isEmpty()) {
            XmlNode.writeEnvelope(Wfs20Constants.GML_PREFIX + ":" + "boundedBy", context, writer, allGeometry.getEnvelopeInternal());
        }
        for (Metacard mc : wfc.getMembers()) {
            writer.startNode(Wfs20Constants.GML_PREFIX + ":" + FEATURE_MEMBER);
            context.convertAnother(mc);
            writer.endNode();
        }
    } else {
        LOGGER.debug("Incoming value was null");
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Metacard(ddf.catalog.data.Metacard) Wfs20FeatureCollection(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection)

Aggregations

Wfs20FeatureCollection (org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection)11 Metacard (ddf.catalog.data.Metacard)8 XStream (com.thoughtworks.xstream.XStream)7 Test (org.junit.Test)7 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)6 InputStream (java.io.InputStream)6 HashMap (java.util.HashMap)5 FeatureConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.FeatureConverter)5 GmlGeometryConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 JAXBException (javax.xml.bind.JAXBException)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 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)1