use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv20 method addSampledFeatures.
protected void addSampledFeatures(SFSamplingFeatureType sfsft, AbstractSamplingFeature sampFeat) throws EncodingException {
if (sampFeat.isSetSampledFeatures()) {
for (AbstractFeature sampledFeature : sampFeat.getSampledFeatures()) {
XmlObject encodeObjectToXml = encodeObjectToXml(GmlConstants.NS_GML_32, sampledFeature, new EncodingContext().with(XmlBeansEncodingFlags.REFERENCED));
sfsft.addNewSampledFeature().set(encodeObjectToXml);
}
} else {
sfsft.addNewSampledFeature().setHref(OGCConstants.UNKNOWN);
}
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv20 method encodeShape.
private void encodeShape(ShapeType xbShape, AbstractSamplingFeature sampFeat) throws EncodingException {
Encoder<XmlObject, Geometry> encoder = getEncoder(GmlConstants.NS_GML_32, sampFeat.getGeometry());
if (encoder != null) {
XmlObject xmlObject = encoder.encode(sampFeat.getGeometry(), EncodingContext.of(XmlBeansEncodingFlags.GMLID, sampFeat.getGmlId()));
if (xbShape.isSetAbstractGeometry()) {
xbShape.getAbstractGeometry().set(xmlObject);
} else {
xbShape.addNewAbstractGeometry().set(xmlObject);
}
XmlHelper.substituteElement(xbShape.getAbstractGeometry(), xmlObject);
} else {
throw new EncodingException("Error while encoding geometry for feature, needed encoder is missing!");
}
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv20 method createFeature.
@Override
protected XmlObject createFeature(FeaturePropertyType featurePropertyType, AbstractFeature abstractFeature, EncodingContext context) throws EncodingException {
if (abstractFeature instanceof AbstractSamplingFeature) {
final AbstractSamplingFeature samplingFeature = (AbstractSamplingFeature) abstractFeature;
String namespace;
if (context.has(XmlEncoderFlags.ENCODE_NAMESPACE) && context.get(XmlEncoderFlags.ENCODE_NAMESPACE).isPresent() && context.get(XmlEncoderFlags.ENCODE_NAMESPACE).get() instanceof String) {
namespace = (String) context.get(XmlEncoderFlags.ENCODE_NAMESPACE).get();
} else {
namespace = OMHelper.getNamespaceForFeatureType(samplingFeature.getFeatureType());
}
final XmlObject encodedXmlObject = encodeObjectToXml(namespace, samplingFeature);
if (encodedXmlObject != null) {
return encodedXmlObject;
} else {
if (samplingFeature.isSetXml()) {
try {
// XmlDescription? <-- XmlCursor
return XmlObject.Factory.parse(samplingFeature.getXml());
} catch (final XmlException xmle) {
throw new EncodingException("Error while encoding featurePropertyType!", xmle);
}
} else {
featurePropertyType.setHref(samplingFeature.getIdentifierCodeWithAuthority().getValue());
if (samplingFeature.isSetName()) {
featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
}
return featurePropertyType;
}
}
}
return featurePropertyType;
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv20 method setMetaDataProperty.
protected void setMetaDataProperty(SFSamplingFeatureType sfssft, AbstractSamplingFeature sampFeat) throws EncodingException {
if (sampFeat.isSetMetaDataProperty()) {
for (AbstractMetaData abstractMetaData : sampFeat.getMetaDataProperty()) {
XmlObject encodeObject = encodeObjectToXml(GmlConstants.NS_GML_32, abstractMetaData);
XmlObject substituteElement = XmlHelper.substituteElement(sfssft.addNewMetaDataProperty().addNewAbstractMetaData(), encodeObject);
substituteElement.set(encodeObject);
}
}
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class GetFeatureOfInterestXmlStreamWriter method writeGetFeatureOfInterestResponseDoc.
private void writeGetFeatureOfInterestResponseDoc() throws XMLStreamException, EncodingException {
start(Sos2StreamingConstants.QN_GET_FEATURE_OF_INTEREST_RESPONSE);
namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
namespace(Sos2Constants.NS_SOS_PREFIX, Sos2Constants.NS_SOS_20);
// write schemaLocation
schemaLocation(getSchemaLocation());
AbstractFeature feature = getElement().getAbstractFeature();
if (feature instanceof FeatureCollection) {
for (AbstractFeature f : (FeatureCollection) feature) {
writeFeatureMember(f);
}
} else if (feature instanceof AbstractSamplingFeature) {
writeFeatureMember(feature);
}
end(Sos2StreamingConstants.QN_GET_FEATURE_OF_INTEREST_RESPONSE);
}
Aggregations