Search in sources :

Example 6 with AbstractGeometryType

use of net.opengis.gml.x32.AbstractGeometryType in project ddf by codice.

the class CswFilterFactory method createBinarySpatialOpTypeUsingGeometry.

@SuppressWarnings("unchecked")
private BinarySpatialOpType createBinarySpatialOpTypeUsingGeometry(PropertyNameType propertyName, JAXBElement<? extends AbstractGeometryType> geometry) {
    BinarySpatialOpType binarySpatialOpType = new BinarySpatialOpType();
    binarySpatialOpType.setPropertyName(propertyName);
    binarySpatialOpType.setGeometry((JAXBElement<AbstractGeometryType>) geometry);
    return binarySpatialOpType;
}
Also used : AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) BinarySpatialOpType(net.opengis.filter.v_1_1_0.BinarySpatialOpType)

Example 7 with AbstractGeometryType

use of net.opengis.gml.x32.AbstractGeometryType in project ddf by codice.

the class GeometryAdapter method unmarshalFrom.

public static Attribute unmarshalFrom(GeometryElement element) throws ConversionFailedException {
    AttributeImpl attribute = null;
    GML311ToJTSGeometryConverter converter = new GML311ToJTSGeometryConverter();
    WKTWriter wktWriter = new WKTWriter();
    for (Value xmlValue : element.getValue()) {
        JAXBElement<AbstractGeometryType> xmlGeometry = xmlValue.getGeometry();
        Geometry geometry = converter.createGeometry(new DefaultRootObjectLocator(xmlValue), xmlGeometry.getValue());
        String wkt = wktWriter.write(geometry);
        if (attribute == null) {
            attribute = new AttributeImpl(element.getName(), wkt);
        } else {
            attribute.addValue(wkt);
        }
    }
    return attribute;
}
Also used : GML311ToJTSGeometryConverter(org.jvnet.ogc.gml.v_3_1_1.jts.GML311ToJTSGeometryConverter) Geometry(com.vividsolutions.jts.geom.Geometry) WKTWriter(com.vividsolutions.jts.io.WKTWriter) DefaultRootObjectLocator(org.jvnet.jaxb2_commons.locator.DefaultRootObjectLocator) AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Value(ddf.catalog.transformer.xml.binding.GeometryElement.Value)

Example 8 with AbstractGeometryType

use of net.opengis.gml.x32.AbstractGeometryType in project ddf by codice.

the class Gml3ToWktImpl method convert.

@SuppressWarnings("unchecked")
public String convert(InputStream xml) throws ValidationExceptionImpl {
    AbstractGeometryType geometry = null;
    try {
        JAXBElement<AbstractGeometryType> jaxbElement = parser.unmarshal(configurator, JAXBElement.class, xml);
        geometry = jaxbElement.getValue();
        GML311ToJTSGeometryConverter geometryConverter = new GML311ToJTSGeometryConverter();
        Geometry jtsGeo = geometryConverter.createGeometry(new DefaultRootObjectLocator(jaxbElement), geometry);
        WKTWriter wktWriter = new WKTWriter();
        return wktWriter.write(jtsGeo);
    } catch (ParserException e) {
        LOGGER.debug("Cannot parse gml", e);
        throw new ValidationExceptionImpl(e, Collections.singletonList("Cannot parse gml"), new ArrayList<String>());
    } catch (ConversionFailedException e) {
        LOGGER.debug("Cannot convert gml311 geo object {} to jts", geometry, e);
        throw new ValidationExceptionImpl(e, Collections.singletonList("Cannot convert geo object"), new ArrayList<String>());
    }
}
Also used : GML311ToJTSGeometryConverter(org.jvnet.ogc.gml.v_3_1_1.jts.GML311ToJTSGeometryConverter) Geometry(com.vividsolutions.jts.geom.Geometry) DefaultRootObjectLocator(org.jvnet.jaxb2_commons.locator.DefaultRootObjectLocator) WKTWriter(com.vividsolutions.jts.io.WKTWriter) ParserException(org.codice.ddf.parser.ParserException) ConversionFailedException(org.jvnet.ogc.gml.v_3_1_1.jts.ConversionFailedException) AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) ValidationExceptionImpl(ddf.catalog.validation.impl.ValidationExceptionImpl) ArrayList(java.util.ArrayList)

Example 9 with AbstractGeometryType

use of net.opengis.gml.x32.AbstractGeometryType in project arctic-sea by 52North.

the class GmlEncoderv321 method createAbstractGeometry.

private AbstractGeometryType createAbstractGeometry(AbstractGeometry element, EncodingContext ctx) throws EncodingException {
    XmlObject xbGeometry = createPosition(element.getGeometry(), ctx);
    AbstractGeometryType abstractGeometryType = null;
    if (xbGeometry instanceof AbstractGeometryType) {
        abstractGeometryType = (AbstractGeometryType) xbGeometry;
    } else if (xbGeometry instanceof GeometryPropertyType) {
        abstractGeometryType = ((GeometryPropertyType) xbGeometry).getAbstractGeometry();
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    if (element.isSetIdentifier()) {
        abstractGeometryType.setIdentifier(createCodeWithAuthorityType(element.getIdentifierCodeWithAuthority()));
    }
    if (element.isSetName()) {
        for (org.n52.shetland.ogc.gml.CodeType codeType : element.getName()) {
            abstractGeometryType.addNewName().set(createCodeType(codeType));
        }
    }
    if (element.isSetDescription()) {
        abstractGeometryType.addNewDescription().setStringValue(element.getDescription());
    }
    return abstractGeometryType;
}
Also used : AbstractGeometryType(net.opengis.gml.x32.AbstractGeometryType) XmlObject(org.apache.xmlbeans.XmlObject) GeometryPropertyType(net.opengis.gml.x32.GeometryPropertyType) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

AbstractGeometryType (net.opengis.gml.v_3_1_1.AbstractGeometryType)7 Geometry (com.vividsolutions.jts.geom.Geometry)3 JAXBElement (javax.xml.bind.JAXBElement)3 WKTWriter (com.vividsolutions.jts.io.WKTWriter)2 Value (ddf.catalog.transformer.xml.binding.GeometryElement.Value)2 AbstractGeometryType (net.opengis.gml.x32.AbstractGeometryType)2 GeometryPropertyType (net.opengis.gml.x32.GeometryPropertyType)2 DefaultRootObjectLocator (org.jvnet.jaxb2_commons.locator.DefaultRootObjectLocator)2 GML311ToJTSGeometryConverter (org.jvnet.ogc.gml.v_3_1_1.jts.GML311ToJTSGeometryConverter)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 ParseException (com.vividsolutions.jts.io.ParseException)1 WKTReader (com.vividsolutions.jts.io.WKTReader)1 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 GeometryElement (ddf.catalog.transformer.xml.binding.GeometryElement)1 ValidationExceptionImpl (ddf.catalog.validation.impl.ValidationExceptionImpl)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 AnyValueType (net.opengis.cat.wrs.v_1_0_2.AnyValueType)1