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;
}
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;
}
Aggregations