Search in sources :

Example 1 with GenericMetaData

use of org.n52.shetland.ogc.gml.GenericMetaData in project arctic-sea by 52North.

the class GmlEncoderv311 method encode.

@Override
public XmlObject encode(Object element, EncodingContext ctx) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof Time) {
        encodedObject = createTime((Time) element, ctx);
    } else if (element instanceof Geometry) {
        encodedObject = createPosition((Geometry) element, ctx.get(XmlBeansEncodingFlags.GMLID));
    } else if (element instanceof CategoryValue) {
        encodedObject = createReferenceTypeForCategroyValue((CategoryValue) element);
    } else if (element instanceof org.n52.shetland.ogc.gml.ReferenceType) {
        encodedObject = createReferencType((org.n52.shetland.ogc.gml.ReferenceType) element);
    } else if (element instanceof CodeWithAuthority) {
        encodedObject = createCodeWithAuthorityType((CodeWithAuthority) element);
    } else if (element instanceof QuantityValue) {
        encodedObject = createMeasureType((QuantityValue) element);
    } else if (element instanceof org.n52.shetland.ogc.gml.CodeType) {
        encodedObject = createCodeType((org.n52.shetland.ogc.gml.CodeType) element);
    } else if (element instanceof AbstractFeature) {
        encodedObject = createFeature((AbstractFeature) element);
    } else if (element instanceof ReferencedEnvelope) {
        encodedObject = createEnvelope((ReferencedEnvelope) element);
    } else if (element instanceof EnvelopeOrGeometry) {
        EnvelopeOrGeometry geom = (EnvelopeOrGeometry) element;
        if (geom.getGeometry().isPresent()) {
            encodedObject = createPosition(geom.getGeometry().get(), ctx.get(XmlBeansEncodingFlags.GMLID));
        } else if (geom.getEnvelope().isPresent()) {
            encodedObject = createEnvelope(geom.getEnvelope().get());
        } else {
            throw new UnsupportedEncoderInputException(this, element);
        }
    } else if (element instanceof GenericMetaData) {
        encodedObject = createGenericMetaData((GenericMetaData) element, ctx);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    XmlHelper.validateDocument(encodedObject, EncodingException::new);
    return encodedObject;
}
Also used : GenericMetaData(org.n52.shetland.ogc.gml.GenericMetaData) EncodingException(org.n52.svalbard.encode.exception.EncodingException) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Time(org.n52.shetland.ogc.gml.time.Time) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) Geometry(org.locationtech.jts.geom.Geometry) EnvelopeOrGeometry(org.n52.shetland.util.EnvelopeOrGeometry) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) EnvelopeOrGeometry(org.n52.shetland.util.EnvelopeOrGeometry) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) CodeType(net.opengis.gml.CodeType) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 2 with GenericMetaData

use of org.n52.shetland.ogc.gml.GenericMetaData in project arctic-sea by 52North.

the class GmlEncoderv321 method createGenericMetaData.

private XmlObject createGenericMetaData(GenericMetaData element, EncodingContext ctx) throws EncodingException {
    GenericMetaDataDocument gmdd = GenericMetaDataDocument.Factory.newInstance(getXmlOptions());
    GenericMetaDataType gmdt = gmdd.addNewGenericMetaData();
    if (element.getContent() instanceof HasDefaultEncoding && ((HasDefaultEncoding<?>) element.getContent()).isSetDefaultElementEncoding()) {
        // TODO check
        gmdt.set(encodeObjectToXml(((HasDefaultEncoding<?>) element.getContent()).getDefaultElementEncoding(), element.getContent(), new EncodingContext().with(XmlBeansEncodingFlags.PROPERTY_TYPE, true)));
    }
    if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
        return gmdd;
    }
    return gmdt;
}
Also used : GenericMetaDataDocument(net.opengis.gml.x32.GenericMetaDataDocument) GenericMetaDataType(net.opengis.gml.x32.GenericMetaDataType) HasDefaultEncoding(org.n52.shetland.ogc.HasDefaultEncoding)

Aggregations

CodeType (net.opengis.gml.CodeType)1 GenericMetaDataDocument (net.opengis.gml.x32.GenericMetaDataDocument)1 GenericMetaDataType (net.opengis.gml.x32.GenericMetaDataType)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Geometry (org.locationtech.jts.geom.Geometry)1 HasDefaultEncoding (org.n52.shetland.ogc.HasDefaultEncoding)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 GenericMetaData (org.n52.shetland.ogc.gml.GenericMetaData)1 Time (org.n52.shetland.ogc.gml.time.Time)1 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)1 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)1 EnvelopeOrGeometry (org.n52.shetland.util.EnvelopeOrGeometry)1 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1