use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class TrajectoryObservation method setValue.
@SuppressWarnings("rawtypes")
@Override
public void setValue(ObservationValue<?> value) {
if (value instanceof StreamingValue || value.getValue() instanceof TLVTValue) {
super.setValue(value);
} else {
Geometry geometry = null;
if (isSetSpatialFilteringProfileParameter()) {
geometry = getSpatialFilteringProfileParameter().getValue().getValue();
} else {
if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
}
}
TLVTValue tlvpValue = convertSingleValueToMultiValue((SingleObservationValue<?>) value, geometry);
if (!tlvpValue.isSetUnit() && ((AbstractObservationValue<?>) value).isSetUnit()) {
tlvpValue.setUnit(((AbstractObservationValue<?>) value).getUnit());
}
final MultiObservationValues<List<TimeLocationValueTriple>> multiValue = new MultiObservationValues<List<TimeLocationValueTriple>>();
multiValue.setValue(tlvpValue);
if (!multiValue.isSetObservationID()) {
if (value instanceof AbstractObservationValue && ((AbstractObservationValue) value).isSetObservationID()) {
multiValue.setObservationID(((AbstractObservationValue) value).getObservationID());
} else if (isSetObservationID()) {
multiValue.setObservationID(getObservationID());
}
}
super.setValue(multiValue);
}
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class UVFEncoder method writeLine3.
private void writeLine3(Writer fw, OmObservation o, String lineEnding) throws IOException {
// 3.Zeile 88888 0 0 0.000
StringBuilder sb = new StringBuilder(45);
if (o.getObservationConstellation().isSetIdentifier()) {
sb.append(ensureIdentifierLength(o.getObservationConstellation().getIdentifier(), UVFConstants.MAX_IDENTIFIER_LENGTH));
} else if (o.isSetIdentifier()) {
sb.append(ensureIdentifierLength(o.getIdentifier(), UVFConstants.MAX_IDENTIFIER_LENGTH));
} else {
if (!o.isSetObservationID()) {
o.setObservationID(JavaHelper.generateID(o.toString()));
}
sb.append(ensureIdentifierLength(o.getObservationID(), UVFConstants.MAX_IDENTIFIER_LENGTH));
}
fillWithSpaces(sb, UVFConstants.MAX_IDENTIFIER_LENGTH);
AbstractFeature f = o.getObservationConstellation().getFeatureOfInterest();
if (o.getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) o.getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) f;
// Rechtswert
String xString = sf.isSetGeometry() ? Double.toString(sf.getGeometry().getCoordinate().y) : "";
xString = ensureValueLength(xString, 10);
sb.append(xString);
fillWithSpaces(sb, 25);
// Hochwert
String yString = sf.isSetGeometry() ? Double.toString(sf.getGeometry().getCoordinate().x) : "";
yString = ensureValueLength(yString, 10);
sb.append(yString);
fillWithSpaces(sb, 35);
if (sf.isSetGeometry() && !Double.isNaN(sf.getGeometry().getCoordinate().z)) {
String zString = Double.toString(sf.getGeometry().getCoordinate().z);
zString = ensureValueLength(zString, 10);
sb.append(zString);
}
}
fillWithSpaces(sb, 45);
writeToFile(fw, sb.toString(), lineEnding);
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class GmlEncoderv321 method createFeature.
private XmlObject createFeature(AbstractFeature feature, EncodingContext ctx) throws EncodingException {
FeaturePropertyType featurePropertyType = FeaturePropertyType.Factory.newInstance(getXmlOptions());
if (isNotSamplingFeature(feature) || ctx.has(XmlBeansEncodingFlags.REFERENCED)) {
featurePropertyType.setHref(feature.getIdentifierCodeWithAuthority().getValue());
return featurePropertyType;
} else {
AbstractSamplingFeature samplingFeature = (AbstractSamplingFeature) feature;
if (samplingFeature.isSetGmlID()) {
featurePropertyType.setHref("#" + samplingFeature.getGmlId());
return featurePropertyType;
} else {
if (ctx.has(XmlBeansEncodingFlags.ENCODE) && !ctx.getBoolean(XmlBeansEncodingFlags.ENCODE) || !samplingFeature.isEncode()) {
featurePropertyType.setHref(feature.getIdentifierCodeWithAuthority().getValue());
if (feature instanceof SamplingFeature && samplingFeature.isSetName()) {
featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
}
return featurePropertyType;
}
if (!samplingFeature.isSetGeometry()) {
featurePropertyType.setHref(samplingFeature.getIdentifierCodeWithAuthority().getValue());
if (samplingFeature.isSetName()) {
featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
}
return featurePropertyType;
}
if (samplingFeature.isSetUrl()) {
featurePropertyType.setHref(samplingFeature.getUrl());
if (samplingFeature.isSetName()) {
featurePropertyType.setTitle(samplingFeature.getFirstName().getValue());
}
return featurePropertyType;
} else {
String namespace = ctx.getString(XmlEncoderFlags.ENCODE_NAMESPACE).orElseGet(() -> OMHelper.getNamespaceForFeatureType(samplingFeature.getFeatureType()));
XmlObject encodedXmlObject = encodeObjectToXml(namespace, samplingFeature);
if (encodedXmlObject != null) {
return encodedXmlObject;
} else {
if (feature.isSetXml()) {
try {
// XmlDescription? <-- XmlCursor
return XmlObject.Factory.parse(feature.getXml());
} catch (XmlException xmle) {
throw new EncodingException("Error while encoding featurePropertyType!", xmle);
}
} else {
featurePropertyType.setHref(feature.getIdentifierCodeWithAuthority().getValue());
if (samplingFeature.isSetName()) {
featurePropertyType.setTitle(feature.getFirstName().getValue());
}
return featurePropertyType;
}
}
}
}
}
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv100 method createFeature.
private XmlObject createFeature(AbstractFeature absFeature) throws EncodingException {
if (absFeature instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sampFeat = (AbstractSamplingFeature) absFeature;
if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGPOINT) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT) || sampFeat.getGeometry() instanceof Point) {
SamplingPointDocument xbSamplingPointDoc = SamplingPointDocument.Factory.newInstance(getXmlOptions());
SamplingPointType xbSamplingPoint = xbSamplingPointDoc.addNewSamplingPoint();
addValuesToFeature(xbSamplingPoint, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingPoint.addNewPosition().addNewPoint().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingPointDoc;
} else if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGCURVE) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE) || sampFeat.getGeometry() instanceof LineString) {
SamplingCurveDocument xbSamplingCurveDoc = SamplingCurveDocument.Factory.newInstance(getXmlOptions());
SamplingCurveType xbSamplingCurve = xbSamplingCurveDoc.addNewSamplingCurve();
addValuesToFeature(xbSamplingCurve, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingCurve.addNewShape().addNewCurve().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingCurveDoc;
} else if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGSURFACE) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_SURFACE) || sampFeat.getGeometry() instanceof Polygon) {
SamplingSurfaceDocument xbSamplingSurfaceDoc = SamplingSurfaceDocument.Factory.newInstance(getXmlOptions());
SamplingSurfaceType xbSamplingSurface = xbSamplingSurfaceDoc.addNewSamplingSurface();
addValuesToFeature(xbSamplingSurface, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingSurface.addNewShape().addNewSurface().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingSurfaceDoc;
}
} else if (absFeature instanceof FeatureCollection) {
createFeatureCollection((FeatureCollection) absFeature);
}
throw new UnsupportedEncoderInputException(this, absFeature);
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv100 method addValuesToFeature.
private void addValuesToFeature(SamplingFeatureType xbSamplingFeature, AbstractSamplingFeature sampFeat) throws EncodingException {
xbSamplingFeature.setId(sampFeat.getGmlId());
if (sampFeat.isSetIdentifier()) {
sampFeat.getIdentifierCodeWithAuthority().setCodeSpace("uniquID");
xbSamplingFeature.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, sampFeat.getIdentifierCodeWithAuthority()));
}
if (sampFeat.isSetName()) {
for (CodeType sosName : sampFeat.getName()) {
xbSamplingFeature.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, sosName));
}
}
// TODO: CHECK
if (sampFeat.getSampledFeatures() != null && !sampFeat.getSampledFeatures().isEmpty()) {
for (AbstractFeature sampledFeature : sampFeat.getSampledFeatures()) {
FeaturePropertyType sp = xbSamplingFeature.addNewSampledFeature();
sp.setHref(sampledFeature.getIdentifier());
if (sampFeat.isSetName() && sampFeat.getFirstName().isSetValue()) {
sp.setTitle(sampFeat.getFirstName().getValue());
}
// xbSamplingFeature.addNewSampledFeature().set(createFeature(sampledFeature));
}
} else {
xbSamplingFeature.addNewSampledFeature().setHref(GmlConstants.NIL_UNKNOWN);
}
// set metadataProperty
setMetaDataProperty(xbSamplingFeature, sampFeat);
}
Aggregations