use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createClassification.
/**
* Creates the classification section of the SensorML description.
*
* @param classifications
* SOS classifications
*
* @return XML Classification array
*/
private Classification[] createClassification(List<SmlClassifier> classifications) {
Classification xbClassification = Classification.Factory.newInstance(getXmlOptions());
ClassifierList xbClassifierList = xbClassification.addNewClassifierList();
classifications.forEach(sosSMLClassifier -> {
Classifier xbClassifier = xbClassifierList.addNewClassifier();
if (sosSMLClassifier.getName() != null) {
xbClassifier.setName(sosSMLClassifier.getName());
}
Term xbTerm = xbClassifier.addNewTerm();
xbTerm.setValue(sosSMLClassifier.getValue());
if (sosSMLClassifier.isSetDefinition()) {
xbTerm.setDefinition(sosSMLClassifier.getDefinition());
}
if (sosSMLClassifier.isSetCodeSpace()) {
xbTerm.addNewCodeSpace().setHref(sosSMLClassifier.getCodeSpace());
}
});
return new Classification[] { xbClassification };
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createInputs.
/**
* Creates the inputs section of the SensorML description.
*
* @param inputs
* SOS SWE representation.
*
* @return XML Inputs element
*
* @throws EncodingException
* if an error occurs
*/
private Inputs createInputs(List<SmlIo> inputs) throws EncodingException {
Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
InputList xbInputList = xbInputs.addNewInputList();
int counter = 1;
for (SmlIo sosSMLIo : inputs) {
if (!sosSMLIo.isSetName()) {
sosSMLIo.setIoName("input_" + counter++);
}
addIoComponentPropertyType(xbInputList.addNewInput(), sosSMLIo);
}
return xbInputs;
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createCharacteristics.
/**
* Creates the characteristics section of the SensorML description.
*
* @param smlCharacteristics
* SOS characteristics list
*
* @return XML Characteristics array
*
* @throws EncodingException
* If an error occurs
*/
private Characteristics[] createCharacteristics(final List<SmlCharacteristics> smlCharacteristics) throws EncodingException {
final List<Characteristics> characteristicsList = Lists.newArrayListWithExpectedSize(smlCharacteristics.size());
for (final SmlCharacteristics sosSMLCharacteristics : smlCharacteristics) {
final Characteristics xbCharacteristics = Characteristics.Factory.newInstance(getXmlOptions());
if (sosSMLCharacteristics.isSetName()) {
xbCharacteristics.setName(sosSMLCharacteristics.getName());
}
if (sosSMLCharacteristics.isSetAbstractDataRecord()) {
if (sosSMLCharacteristics.getDataRecord() instanceof SweSimpleDataRecord) {
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCharacteristics.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
if (sosSMLCharacteristics.isSetTypeDefinition()) {
xbSimpleDataRecord.setDefinition(sosSMLCharacteristics.getTypeDefinition());
}
if (sosSMLCharacteristics.getDataRecord().isSetFields()) {
for (final SweField field : sosSMLCharacteristics.getDataRecord().getFields()) {
final AnyScalarPropertyType xbField = xbSimpleDataRecord.addNewField();
xbField.setName(field.getName().getValue());
addSweSimpleTypeToField(xbField, field.getElement());
}
}
} else if (sosSMLCharacteristics.getDataRecord() instanceof SweDataRecord) {
throw unsupportedCharacteristicsType(SweAggregateType.DataRecord);
} else {
throw unsupportedCharacteristicsType(sosSMLCharacteristics.getDataRecord().getClass().getName());
}
} else if (sosSMLCharacteristics.isSetHref()) {
if (sosSMLCharacteristics.isSetName()) {
xbCharacteristics.setName(sosSMLCharacteristics.getName());
}
xbCharacteristics.setHref(sosSMLCharacteristics.getHref());
if (sosSMLCharacteristics.isSetTitle()) {
xbCharacteristics.setTitle(sosSMLCharacteristics.getTitle());
}
}
characteristicsList.add(xbCharacteristics);
}
return characteristicsList.toArray(new Characteristics[characteristicsList.size()]);
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createInputs.
// /**
// * Creates the location section of the SensorML description.
// *
// * @param dot
// * the described object
// * @param location
// * SOS location representation.
// *
// * @throws EncodingException
// * if an error occurs
// */
// private void createLocation(DescribedObjectType dot, SmlLocation location) throws EncodingException {
// dot.addNewLocation().addNewAbstractGeometry().set(encodeObjectToXmlGml32(location.getPoint()));
// }
/**
* Creates the inputs section of the SensorML description.
*
* @param inputs
* SOS SWE representation.
*
* @return XML Inputs element
*
* @throws EncodingException
* if an error occurs
*/
private Inputs createInputs(final List<SmlIo> inputs) throws EncodingException {
final Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
final InputListType xbInputList = xbInputs.addNewInputList();
int counter = 1;
for (final SmlIo sosSMLIo : inputs) {
if (!sosSMLIo.isSetName()) {
sosSMLIo.setIoName("input_" + counter++);
} else {
sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
}
addInput(xbInputList.addNewInput(), sosSMLIo);
}
return xbInputs;
}
Aggregations