use of org.n52.shetland.ogc.gml.CodeWithAuthority in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method createWmlGetObservationResponse.
/**
* Encodes a SOS GetObservationResponse to a single WaterML 2.0 observation
* or to a WaterML 1.0 ObservationCollection
*
* @param getObservationResonse
* SOS GetObservationResponse
* @return Encoded response
* @throws EncodingException
* If an error occurs
*/
protected XmlObject createWmlGetObservationResponse(GetObservationResponse getObservationResonse) throws EncodingException {
// TODO: set schemaLocation if final
Map<CodeWithAuthority, String> gmlID4sfIdentifier = Maps.newHashMap();
int sfIdCounter = 1;
try {
if (getObservationResonse.getObservationCollection() != null && !getObservationResonse.getObservationCollection().hasNext()) {
ObservationStream observations = getObservationResonse.getObservationCollection();
OmObservation observation = observations.next();
if (!observations.hasNext()) {
OMObservationDocument omObservationDoc = OMObservationDocument.Factory.newInstance(getXmlOptions());
omObservationDoc.setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
return omObservationDoc;
} else {
CollectionDocument xmlCollectionDoc = CollectionDocument.Factory.newInstance(getXmlOptions());
CollectionType wmlCollection = xmlCollectionDoc.addNewCollection();
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
while (observations.hasNext()) {
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observations.next(), gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
}
return xmlCollectionDoc;
}
} else {
// TODO: HydrologieProfile-Exception
throw new EncodingException("Combination does not exists!");
}
} catch (NoSuchElementException | OwsExceptionReport e) {
throw new EncodingException(e);
}
}
use of org.n52.shetland.ogc.gml.CodeWithAuthority in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method checkAndAddIdentifier.
private void checkAndAddIdentifier(ObservationProcess op, ObservationProcessType opt) throws EncodingException {
if (op.isSetIdentifier() && !opt.isSetIdentifier()) {
CodeWithAuthority codeWithAuthority = op.getIdentifierCodeWithAuthority();
Encoder<?, CodeWithAuthority> encoder = getEncoder(getEncoderKey(GmlConstants.NS_GML_32, codeWithAuthority));
if (encoder != null) {
XmlObject xmlObject = (XmlObject) encoder.encode(codeWithAuthority);
opt.addNewIdentifier().set(xmlObject);
} else {
throw new EncodingException("Error while encoding geometry value, needed encoder is missing!");
}
}
}
use of org.n52.shetland.ogc.gml.CodeWithAuthority in project arctic-sea by 52North.
the class AqdEncoder 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.CodeWithAuthority in project arctic-sea by 52North.
the class AbstractProcessDecoder method parseInspireId.
private void parseInspireId(ProcessType pt, Process process) {
IdentifierType identifier = pt.getInspireId().getIdentifier();
String localId = identifier.getLocalId();
String namespace = identifier.getNamespace();
CodeWithAuthority codeWithAuthority;
if (localId.contains(namespace)) {
codeWithAuthority = new CodeWithAuthority(localId, namespace);
} else {
codeWithAuthority = new CodeWithAuthority(getIdentifier(localId, namespace), namespace);
}
process.setIdentifier(codeWithAuthority);
}
use of org.n52.shetland.ogc.gml.CodeWithAuthority 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);
}
}
Aggregations