Search in sources :

Example 11 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class WmlTDREncoderv20 method createDataRecord.

private XmlObject createDataRecord(AbstractObservationValue<?> observationValue, String unit) throws EncodingException {
    // AbstractPhenomenon observableProperty =
    // sosObservation.getObservationConstellation().getObservableProperty();
    SweQuantity quantity = new SweQuantity();
    quantity.setDefinition(observationValue.getObservableProperty());
    quantity.setUom(unit);
    return createDataRecord(quantity, observationValue.getObservationID());
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity)

Example 12 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity 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;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) OmCompositePhenomenon(org.n52.shetland.ogc.om.OmCompositePhenomenon) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 13 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldQuantity.

@Test
public void should_encode_Datarecord_with_fieldQuantity() throws EncodingException {
    final String field1Name = "test-name";
    final double field1Value = 52.0;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweQuantity().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetQuantity(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getQuantity().getValue(), is(field1Value));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 14 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_count_with_quality_Quantity.

@Test
public void should_encode_count_with_quality_Quantity() throws EncodingException {
    final double qualityQuantityValue = 42.0;
    final SweCount sosCount = (SweCount) new SweCount().setQuality(Lists.newArrayList((SweQuality) new SweQuantity().setValue(qualityQuantityValue)));
    final XmlObject encode = sweCommonEncoderv101.encode(sosCount);
    assertThat(encode, instanceOf(Count.class));
    final Count xbCount = (Count) encode;
    assertThat(xbCount.getQualityArray(), is(not(nullValue())));
    assertThat(xbCount.getQualityArray().length, is(1));
    assertThat(xbCount.getQualityArray(0).isSetQuantity(), is(true));
    assertThat(xbCount.getQualityArray(0).getQuantity().getValue(), is(qualityQuantityValue));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Count(net.opengis.swe.x101.CountDocument.Count) Test(org.junit.Test)

Example 15 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonDecoderV101Test method should_decode_Boolean_with_Quality_Quantity.

@Test
public void should_decode_Boolean_with_Quality_Quantity() throws DecodingException {
    final BooleanDocument xbBoolean = BooleanDocument.Factory.newInstance();
    final BigDecimal quantityValue = BigDecimal.valueOf(42.5);
    xbBoolean.addNewBoolean().addNewQuality().addNewQuantity().setValue(quantityValue.doubleValue());
    final Object decodedObject = new SweCommonDecoderV101().decode(xbBoolean);
    assertThat(decodedObject, is(instanceOf(SweBoolean.class)));
    final SweBoolean sweBoolean = (SweBoolean) decodedObject;
    assertThat(sweBoolean.isSetQuality(), is(true));
    assertThat(sweBoolean.getQuality().size(), is(1));
    assertThat(sweBoolean.getQuality().iterator().next(), is(instanceOf(SweQuantity.class)));
    assertThat(((SweQuantity) sweBoolean.getQuality().iterator().next()).getValue(), is(quantityValue));
}
Also used : BooleanDocument(net.opengis.swe.x101.BooleanDocument) BigDecimal(java.math.BigDecimal) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Aggregations

SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)22 Test (org.junit.Test)11 XmlObject (org.apache.xmlbeans.XmlObject)9 SweField (org.n52.shetland.ogc.swe.SweField)9 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)9 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)9 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)8 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)8 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)7 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)5 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)5 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)5 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)4 EncodingException (org.n52.svalbard.encode.exception.EncodingException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 BigDecimal (java.math.BigDecimal)3 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)3 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)3 DataRecordType (net.opengis.swe.x101.DataRecordType)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3