use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class SosRequestEncoderv20 method createTemporalFilter.
private void createTemporalFilter(final net.opengis.sos.x20.GetResultType.TemporalFilter temporalFilter, final TemporalFilter sosTemporalFilter) throws EncodingException {
final Encoder<XmlObject, TemporalFilter> encoder = getEncoder(FilterConstants.NS_FES_2, sosTemporalFilter);
final XmlObject encodedObject = encoder.encode(sosTemporalFilter);
temporalFilter.set(encodedObject);
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class DescribeSensorV2RequestEncoderTest method shouldThrowExceptionIfServiceIsMissing.
@Test
public void shouldThrowExceptionIfServiceIsMissing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + DescribeSensorV2RequestEncoder.class.getSimpleName() + " can not encode 'missing service'"));
new DescribeSensorV2RequestEncoder().create(new DescribeSensorRequest());
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class AbstractOmV20XmlStreamWriter method writeParameter.
/**
* Write om:parameter 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 writeParameter() throws XMLStreamException, EncodingException {
XmlEncoderKey key = new XmlEncoderKey(OmConstants.NS_OM_2, NamedValue.class);
Encoder<XmlObject, NamedValue<?>> encoder = getEncoder(key);
if (encoder != null) {
for (NamedValue<?> namedValue : getElement().getParameter()) {
start(OmConstants.QN_OM_20_PARAMETER);
writeXmlObject(encoder.encode(namedValue), OmConstants.QN_OM_20_NAMED_VALUE);
end(OmConstants.QN_OM_20_PARAMETER);
}
}
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class AqdGetObservationResponseXmlStreamWriter method writeFeatureCollectionDoc.
private void writeFeatureCollectionDoc() throws XMLStreamException, EncodingException {
start(GmlConstants.QN_FEATURE_COLLECTION_32);
addNamespaces();
addSchemaLocations();
FeatureCollection featureCollection = getElement();
addGmlId(featureCollection.getGmlId());
TimeInstant resultTime = new TimeInstant(new DateTime(DateTimeZone.UTC));
for (AbstractFeature abstractFeature : featureCollection.getMembers().values()) {
long start = System.currentTimeMillis();
Encoder<XmlObject, AbstractFeature> encoder = getEncoder(abstractFeature);
if (abstractFeature instanceof OmObservation) {
OmObservation observation = (OmObservation) abstractFeature;
if (observation.getValue() instanceof ObservationStream) {
try {
// start the timer task to write blank strings to avoid
// connection closing
startTimer();
ObservationStream mergeObservation = ((ObservationStream) observation.getValue()).merge();
LOGGER.debug("Observation processing requires {} ms", System.currentTimeMillis() - start);
int count = 0;
while (mergeObservation.hasNext()) {
OmObservation omObservation = mergeObservation.next();
if (abstractFeature.isSetGmlID()) {
if (count == 0) {
omObservation.setGmlId(abstractFeature.getGmlId());
} else {
omObservation.setGmlId(abstractFeature.getGmlId() + "_" + count);
}
count++;
}
omObservation.setResultTime(resultTime);
String xmlTextObservation = prepareObservation(omObservation, encoder);
// stop the timer task
stopTimer();
writeMember(xmlTextObservation);
}
} catch (OwsExceptionReport ex) {
throw new EncodingException(ex);
}
} else {
if (encoder instanceof XmlStreamWriter) {
encoder.encode(abstractFeature, getContext());
} else {
writeMember(abstractFeature, encoder);
}
}
} else {
writeMember(abstractFeature, encoder);
}
LOGGER.debug("Writing member requires {} ms", System.currentTimeMillis() - start);
}
end(GmlConstants.QN_FEATURE_COLLECTION_32);
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class WmlTVPEncoderv20Test method initObjects.
@Before
public void initObjects() {
encoder = new WmlTVPEncoderv20();
MultiValue<List<TimeValuePair>> value = new TVPValue();
String unit = "test-unit";
value.setUnit(unit);
TimeValuePair tvp1 = new TimeValuePair(new TimeInstant(new Date(UTC_TIMESTAMP)), new QuantityValue(52.1234567890));
List<TimeValuePair> valueList = CollectionHelper.list(tvp1);
value.setValue(valueList);
mv = new MultiObservationValues<>();
mv.setValue(value);
}
Aggregations