use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createDataRecord.
// TODO check types for SWE101
private DataRecordType createDataRecord(SweDataRecord sosDataRecord) throws EncodingException {
List<SweField> sosFields = sosDataRecord.getFields();
DataRecordType xbDataRecord = DataRecordType.Factory.newInstance(getXmlOptions());
if (sosDataRecord.isSetDefinition()) {
xbDataRecord.setDefinition(sosDataRecord.getDefinition());
}
if (sosDataRecord.isSetFields()) {
DataComponentPropertyType[] xbFields = new DataComponentPropertyType[sosFields.size()];
int xbFieldIndex = 0;
for (SweField sosSweField : sosFields) {
DataComponentPropertyType xbField = createField(sosSweField);
xbFields[xbFieldIndex] = xbField;
xbFieldIndex++;
}
xbDataRecord.setFieldArray(xbFields);
}
return xbDataRecord;
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class SweCommonEncoderv20 method createField.
private DataRecordType.Field createField(SweField field) throws EncodingException {
SweAbstractDataComponent element = field.getElement();
DataRecordType.Field xmlField = DataRecordType.Field.Factory.newInstance(getXmlOptions());
if (field.isSetName()) {
xmlField.setName(NcName.makeValid(field.getName().getValue()));
}
XmlObject encodeObjectToXml = createAbstractDataComponent(element, EncodingContext.empty());
XmlObject substituteElement = XmlHelper.substituteElement(xmlField.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
return xmlField;
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class WmlTDREncoderv20 method createDataRecord.
private XmlObject createDataRecord(SweQuantity quantity, String observationId) throws EncodingException {
SweField field = new SweField("observed_value", quantity);
SweDataRecord dataRecord = new SweDataRecord();
dataRecord.setIdentifier(DATA_RECORD_ID_PREFIX + observationId);
dataRecord.addField(field);
return encodeObjectToXml(SweConstants.NS_SWE_20, dataRecord, EncodingContext.of(XmlBeansEncodingFlags.FOR_OBSERVATION));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method setup.
@Before
public void setup() throws InvalidSridException, ParseException {
SensorML procedure = new SensorML();
procedure.setIdentifier(procedureIdentifier);
SamplingFeature featureOfInterest = new SamplingFeature(new CodeWithAuthority(featureIdentifier));
featureOfInterest.setIdentifier(featureIdentifier);
featureOfInterest.setName(new CodeType(featureName));
featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT(30 10)", 4326));
observationTemplate = new OmObservationConstellation();
observationTemplate.addOffering(offering);
observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
observationTemplate.setProcedure(procedure);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
observationTemplate.setFeatureOfInterest(featureOfInterest);
SweTextEncoding textEncoding = new SweTextEncoding();
textEncoding.setBlockSeparator(blockSeparator);
textEncoding.setTokenSeparator(tokenSeparator);
SweDataRecord resultStructure = new SweDataRecord();
SweTime sweTime = new SweTime();
sweTime.setDefinition(field1Definition);
sweTime.setUom(field1Uom);
resultStructure.addField(new SweField(field1Name, sweTime));
request = new InsertResultTemplateRequest(SosConstants.SOS, Sos2Constants.SERVICEVERSION, Sos2Constants.Operations.InsertResultTemplate.name());
request.setResultEncoding(new SosResultEncoding(textEncoding));
request.setResultStructure(new SosResultStructure(resultStructure));
request.setIdentifier(templateIdentifier);
request.setObservationTemplate(observationTemplate);
Supplier<XmlOptions> xmlOptions = () -> new XmlOptions();
encoder = new InsertResultTemplateRequestEncoder();
encoder.setXmlOptions(xmlOptions);
OmEncoderv20 omEncoder = new OmEncoderv20();
omEncoder.setXmlOptions(xmlOptions);
SamplingEncoderv20 samsEncoder = new SamplingEncoderv20();
samsEncoder.setXmlOptions(xmlOptions);
GmlEncoderv321 gml32Encoder = new GmlEncoderv321();
gml32Encoder.setXmlOptions(xmlOptions);
SweCommonEncoderv20 sweEncoderv20 = new SweCommonEncoderv20();
sweEncoderv20.setXmlOptions(xmlOptions);
EncoderRepository encoderRepository = new EncoderRepository();
encoderRepository.setEncoders(Arrays.asList(encoder, omEncoder, samsEncoder, gml32Encoder, sweEncoderv20));
encoderRepository.init();
encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class OmEncoderv20Test method createComplexObservation.
protected OmObservation createComplexObservation() {
DateTime now = new DateTime(DateTimeZone.UTC);
TimeInstant resultTime = new TimeInstant(now);
TimeInstant phenomenonTime = new TimeInstant(now);
TimePeriod validTime = new TimePeriod(now.minusMinutes(5), now.plusMinutes(5));
OmObservation observation = new OmObservation();
OmObservationConstellation observationConstellation = new OmObservationConstellation();
observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
OmCompositePhenomenon observableProperty = new OmCompositePhenomenon(PARENT_OBSERVABLE_PROPERTY);
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_1));
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_2));
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_3));
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_4));
observationConstellation.setObservableProperty(observableProperty);
observationConstellation.setObservationType(OmConstants.OBS_TYPE_COMPLEX_OBSERVATION);
observationConstellation.addOffering(OFFERING);
AbstractFeature procedure = new SosProcedureDescriptionUnknownType(PROCEDURE);
// procedure.setIdentifier(new CodeWithAuthority(PROCEDURE, CODE_SPACE));
observationConstellation.setProcedure(procedure);
observation.setObservationConstellation(observationConstellation);
observation.setParameter(null);
observation.setResultTime(resultTime);
observation.setTokenSeparator(TOKEN_SEPERATOR);
observation.setTupleSeparator(TUPLE_SEPERATOR);
observation.setValidTime(validTime);
ComplexValue complexValue = new ComplexValue();
SweDataRecord sweDataRecord = new SweDataRecord();
SweQuantity sweQuantity = new SweQuantity();
sweQuantity.setDefinition(CHILD_OBSERVABLE_PROPERTY_1);
sweQuantity.setUom("unit");
sweQuantity.setValue(42.0);
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_1_NAME, sweQuantity));
SweBoolean sweBoolean = new SweBoolean();
sweBoolean.setValue(Boolean.TRUE);
sweBoolean.setDefinition(CHILD_OBSERVABLE_PROPERTY_2);
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_2_NAME, sweBoolean));
SweCount sweCount = new SweCount();
sweCount.setDefinition(CHILD_OBSERVABLE_PROPERTY_3);
sweCount.setValue(42);
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_3_NAME, sweCount));
SweText sweText = new SweText();
sweText.setDefinition(CHILD_OBSERVABLE_PROPERTY_4);
sweText.setValue("42");
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_4_NAME, sweText));
SweCategory sweCategory = new SweCategory();
sweCategory.setDefinition(CHILD_OBSERVABLE_PROPERTY_5);
sweCategory.setCodeSpace(CODE_SPACE);
sweCategory.setValue("52");
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_5_NAME, sweCategory));
complexValue.setValue(sweDataRecord);
observation.setValue(new SingleObservationValue<>(phenomenonTime, complexValue));
return observation;
}
Aggregations