use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class AbstractAqdResponseEncoder method processObservation.
protected void processObservation(OmObservation observation, TimePeriod timePeriod, TimeInstant resultTime, FeatureCollection featureCollection, AbstractEReportingHeader eReportingHeader, int counter) {
if (observation.isSetPhenomenonTime()) {
// generate gml:id
observation.setGmlId(getObservationId(counter));
// add xlink:href to eReportingHeader.content
eReportingHeader.addContent((AbstractFeature) new OmObservation().setIdentifier(new CodeWithAuthority(getObservationXlink(observation.getGmlId()))));
timePeriod.extendToContain(observation.getPhenomenonTime());
observation.setResultTime(resultTime);
featureCollection.addMember(observation);
}
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class AbstractOmV20XmlStreamWriter method writeFeatureOfIntererst.
/**
* Write om:featureOfInterest encoded or as xlink:href to stream
*
* @throws XMLStreamException
* If an error occurs when writing to stream
* @throws EncodingException
* If an error occurs when creating elements to be written
*/
protected void writeFeatureOfIntererst() throws XMLStreamException, EncodingException {
Optional<String> namespace = getDefaultFeatureEncodingNamespace();
AbstractFeature foi = getElement().getObservationConstellation().getFeatureOfInterest();
if (namespace.isPresent()) {
EncodingContext codingContext = EncodingContext.of(XmlEncoderFlags.ENCODE_NAMESPACE, namespace.get());
Encoder<XmlObject, AbstractFeature> encoder = getEncoder(GmlConstants.NS_GML_32, foi);
writeXmlObject(encoder.encode(foi, codingContext), OmConstants.QN_OM_20_FEATURE_OF_INTEREST);
} else {
empty(OmConstants.QN_OM_20_FEATURE_OF_INTEREST);
addXlinkHrefAttr(foi.getIdentifier());
if (foi.isSetName() && foi.getFirstName().isSetValue()) {
addXlinkTitleAttr(foi.getFirstName().getValue());
}
}
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseFeatureOfInterest.
private void parseFeatureOfInterest(FeaturesOfInterest featuresOfInterest, AbstractProcessV20 abstractProcess) throws DecodingException {
if (CollectionHelper.isNotNullOrEmpty(featuresOfInterest.getFeatureList().getFeatureArray())) {
SmlFeatureOfInterest smlFeatureOfInterest = new SmlFeatureOfInterest();
for (FeaturePropertyType fpt : featuresOfInterest.getFeatureList().getFeatureArray()) {
Object o = decodeXmlElement(fpt);
if (o instanceof AbstractFeature) {
smlFeatureOfInterest.addFeatureOfInterest((AbstractFeature) o);
}
}
abstractProcess.setSmlFeatureOfInterest(smlFeatureOfInterest);
}
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class SosDecoderv20 method checkReferencedElements.
private void checkReferencedElements(final List<OmObservation> observations, final Map<String, Time> phenomenonTimes, final Map<String, TimeInstant> resultTimes, final Map<String, AbstractFeature> features) throws DecodingException {
for (final OmObservation observation : observations) {
// phenomenonTime
final Time phenomenonTime = observation.getPhenomenonTime();
if (phenomenonTime.isReferenced()) {
observation.getValue().setPhenomenonTime(phenomenonTimes.get(phenomenonTime.getGmlId()));
}
// resultTime
final TimeInstant resultTime = observation.getResultTime();
if (resultTime.isReferenced()) {
if (resultTimes.containsKey(resultTime.getGmlId())) {
observation.setResultTime(resultTimes.get(resultTime.getGmlId()));
} else if (phenomenonTimes.containsKey(resultTime.getGmlId())) {
final Time iTime = phenomenonTimes.get(resultTime.getGmlId());
if (iTime instanceof TimeInstant) {
observation.setResultTime((TimeInstant) iTime);
} else if (iTime instanceof TimePeriod) {
final TimePeriod timePeriod = (TimePeriod) iTime;
observation.setResultTime(new TimeInstant(timePeriod.getEnd()));
} else {
throw new DecodingException("observation.resultTime", "The time value type is not supported");
}
}
}
// featureOfInterest
final AbstractFeature featureOfInterest = observation.getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest.isReferenced()) {
observation.getObservationConstellation().setFeatureOfInterest(features.get(featureOfInterest.getGmlId()));
}
}
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class GmlDecoderv321 method parseFeatureCollectionType.
private FeatureCollection parseFeatureCollectionType(FeatureCollectionType featureCollectionType) throws DecodingException {
final FeatureCollection feaColl = new FeatureCollection();
for (FeaturePropertyType feaPropType : featureCollectionType.getFeatureMemberArray()) {
Object decoded = decodeXmlElement(feaPropType);
feaColl.addMember((AbstractFeature) decoded);
}
return feaColl;
}
Aggregations