use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_set_identifier.
@Test
public void should_set_identifier() throws EncodingException {
final SensorML sensorMl = new SensorML();
final System system = new System();
sensorMl.addMember(system);
system.addIdentifier(new SmlIdentifier(TEST_NAME_1, OGCConstants.URN_UNIQUE_IDENTIFIER, TEST_ID_1));
final SystemType xbSystem = encodeSystem(sensorMl);
assertThat(xbSystem.getIdentificationArray().length, is(1));
final IdentifierList xbIdentifierList = xbSystem.getIdentificationArray()[0].getIdentifierList();
assertThat(xbIdentifierList.sizeOfIdentifierArray(), is(1));
final Identifier xbIdentifier = xbIdentifierList.getIdentifierArray(0);
assertThat(xbIdentifier.getName(), is(TEST_NAME_1));
assertThat(xbIdentifier.getTerm().getDefinition(), is(OGCConstants.URN_UNIQUE_IDENTIFIER));
assertThat(xbIdentifier.getTerm().getValue(), is(TEST_ID_1));
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_encode_single_contact_responsibleParty.
@Test
public void should_encode_single_contact_responsibleParty() throws EncodingException {
final SensorML sensorML = new SensorML();
final System system = new System();
sensorML.addMember(system);
final SmlResponsibleParty responsibleParty = createResponsibleParty("");
system.addContact(responsibleParty);
final SystemType xbSystem = encodeSystem(sensorML);
assertThat(xbSystem.sizeOfContactArray(), is(1));
assertThat(xbSystem.getContactArray(0).getContactList().getMemberArray(0).isSetResponsibleParty(), is(true));
final ResponsibleParty xbResponsibleParty = xbSystem.getContactArray(0).getContactList().getMemberArray(0).getResponsibleParty();
checkResponsibleParty(responsibleParty, xbResponsibleParty);
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method decodeAbstractProcess.
private AbstractProcess decodeAbstractProcess(SensorMLDocument xbSmlDoc) throws DecodingException {
// FIXME
// Object decoded = CodingHelper.decodeXmlObject(xbSmlDoc);
Object decoded = sensorMLDecoderV101.decode(xbSmlDoc);
assertThat(decoded, instanceOf(SensorML.class));
SensorML sml = (SensorML) decoded;
assertThat(sml.getMembers().size(), is(1));
return sml.getMembers().get(0);
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseSensorML.
@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF")
private SensorML parseSensorML(final SensorMLDocument xbSensorML) throws DecodingException {
final SensorML sensorML = new SensorML();
// get member process
for (final Member xbMember : xbSensorML.getSensorML().getMemberArray()) {
if (xbMember.getProcess() != null) {
if (xbMember.getProcess() instanceof AbstractProcessType) {
final AbstractProcessType xbAbstractProcess = xbMember.getProcess();
AbstractProcess abstractProcess = null;
if (xbAbstractProcess.schemaType() == SystemType.type) {
abstractProcess = parseSystem((SystemType) xbAbstractProcess);
} else if (xbAbstractProcess.schemaType() == ProcessModelType.type) {
abstractProcess = parseProcessModel((ProcessModelType) xbAbstractProcess);
} else if (xbAbstractProcess.schemaType() == ComponentType.type) {
abstractProcess = parseComponent((ComponentType) xbAbstractProcess);
} else {
throw unsupportedMemberProcess(xbMember);
}
sensorML.addMember(abstractProcess);
} else {
throw unsupportedMemberProcess(xbMember);
}
} else {
throw new DecodingException(XmlHelper.getLocalName(xbMember), "The process of a member of the SensorML Document is null (%s)!", xbMember.getProcess());
}
}
sensorML.setXml(xbSensorML.xmlText(getXmlOptions()));
return sensorML;
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class OmEncoderv20Test method shouldEncodeFeatureInObservationTemplate.
@Test
public void shouldEncodeFeatureInObservationTemplate() throws EncodingException, InvalidSridException, ParseException, XmlException, IOException {
//
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));
//
SensorML procedure = new SensorML();
procedure.setIdentifier(procedureIdentifier);
//
OmObservationConstellation observationTemplate = new OmObservationConstellation();
observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
observationTemplate.setProcedure(procedure);
observationTemplate.setFeatureOfInterest(featureOfInterest);
//
OMObservationType omObservation = (OMObservationType) omEncoderv20.encode(observationTemplate);
//
Assert.assertThat(omObservation.getType().getHref(), Is.is(OmConstants.OBS_TYPE_MEASUREMENT));
Assert.assertThat(omObservation.getPhenomenonTime().isNil(), Is.is(false));
Assert.assertThat(omObservation.getPhenomenonTime().isSetNilReason(), Is.is(true));
Assert.assertThat(omObservation.getPhenomenonTime().getNilReason(), Is.is("template"));
Assert.assertThat(omObservation.getResultTime().isNil(), Is.is(false));
Assert.assertThat(omObservation.getResultTime().isSetNilReason(), Is.is(true));
Assert.assertThat(omObservation.getResultTime().getNilReason(), Is.is("template"));
Assert.assertThat(omObservation.getProcedure().isNil(), Is.is(false));
Assert.assertThat(omObservation.getProcedure().getHref(), Is.is(procedureIdentifier));
Assert.assertThat(omObservation.getObservedProperty().isNil(), Is.is(false));
Assert.assertThat(omObservation.getObservedProperty().getHref(), Is.is(observedProperty));
Assert.assertThat(omObservation.getFeatureOfInterest(), Matchers.notNullValue());
XmlObject xmlObject = XmlObject.Factory.parse(omObservation.getFeatureOfInterest().newInputStream());
Assert.assertThat(xmlObject, Matchers.instanceOf(SFSamplingFeatureDocument.class));
SFSamplingFeatureType feature = ((SFSamplingFeatureDocument) xmlObject).getSFSamplingFeature();
Assert.assertThat(feature.getIdentifier().getStringValue(), Is.is(featureIdentifier));
Assert.assertThat(feature.getNameArray().length, Is.is(1));
Assert.assertThat(feature.getNameArray(0).getStringValue(), Is.is(featureName));
}
Aggregations