use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature 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.om.features.samplingFeatures.SamplingFeature 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;
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.
the class SamplingEncoderv20Test method setup.
@Before
public void setup() throws InvalidSridException, ParseException {
EncoderRepository encoderRepository = new EncoderRepository();
OmEncoderv20 omEncoderv20 = new OmEncoderv20();
omEncoderv20.setXmlOptions(XmlOptions::new);
omEncoderv20.setEncoderRepository(encoderRepository);
GmlEncoderv321 gmlEncoderv321 = new GmlEncoderv321();
gmlEncoderv321.setEncoderRepository(encoderRepository);
gmlEncoderv321.setXmlOptions(XmlOptions::new);
SensorMLEncoderv20 sensorMLEncoderv20 = new SensorMLEncoderv20();
sensorMLEncoderv20.setXmlOptions(XmlOptions::new);
sensorMLEncoderv20.setEncoderRepository(encoderRepository);
SweCommonEncoderv20 sweCommonEncoderv20 = new SweCommonEncoderv20();
sweCommonEncoderv20.setEncoderRepository(encoderRepository);
sweCommonEncoderv20.setXmlOptions(XmlOptions::new);
encoder = new SamplingEncoderv20();
encoder.setEncoderRepository(encoderRepository);
encoder.setXmlOptions(XmlOptions::new);
encoderRepository.setEncoders(Arrays.asList(omEncoderv20, gmlEncoderv321, sensorMLEncoderv20, sweCommonEncoderv20, encoder));
encoderRepository.init();
featureOfInterest = new SamplingFeature(new CodeWithAuthority("test-feature"));
featureOfInterest.setIdentifier("test-feature-identifier");
featureOfInterest.setName(new CodeType("test-feature-name"));
featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT (30 10)", 4326));
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.
the class TrajectoryObservation method cloneTemplate.
@Override
public OmObservation cloneTemplate() {
SamplingFeature sf = new SamplingFeature(new CodeWithAuthority(""));
sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
getObservationConstellation().setFeatureOfInterest(sf);
if (isSetSpatialFilteringProfileParameter()) {
removeSpatialFilteringProfileParameter();
}
return cloneTemplate(new TrajectoryObservation());
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.
the class FeatureCollectionTest method should_remove_member_from_feature_collection.
@Test
public final void should_remove_member_from_feature_collection() {
final FeatureCollection features = new FeatureCollection();
final String feature1Id = "feature-1";
final SamplingFeature feature1 = new SamplingFeature(new CodeWithAuthority(feature1Id));
features.addMember(feature1);
final String feature2Id = "feature-2";
final SamplingFeature feature2 = new SamplingFeature(new CodeWithAuthority(feature2Id));
features.addMember(feature2);
final SamplingFeature removedFeature = (SamplingFeature) features.removeMember(feature2Id);
assertThat(removedFeature, is(equalTo(feature2)));
assertThat(features.getMembers().size(), is(1));
assertThat(features.getMembers().containsKey(feature2Id), is(FALSE));
assertThat(features.getMembers().containsValue(feature2), is(FALSE));
assertThat(features.getMembers().containsKey(feature1Id), is(TRUE));
assertThat(features.getMembers().containsValue(feature1), is(TRUE));
}
Aggregations