use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class SensorMLEncoderv101 method addIoComponentPropertyType.
/**
* Adds a SOS SWE simple type to a XML SML IO component.
*
* @param ioComponentPropertyType
* SML IO component
* @param sosSMLIO
* SOS SWE simple type.
*
* @throws EncodingException
* if the encoding fails
*/
private void addIoComponentPropertyType(IoComponentPropertyType ioComponentPropertyType, SmlIo sosSMLIO) throws EncodingException {
ioComponentPropertyType.setName(sosSMLIO.getIoName());
if (sosSMLIO.isSetHref()) {
ioComponentPropertyType.setHref(sosSMLIO.getTitle());
if (sosSMLIO.isSetTitle()) {
ioComponentPropertyType.setTitle(sosSMLIO.getTitle());
}
} else {
XmlObject encodeObjectToXml;
XmlObject xml = encodeObjectToXml(SweConstants.NS_SWE_101, sosSMLIO.getIoValue());
if (xml instanceof DataArrayDocument) {
encodeObjectToXml = ((DataArrayDocument) xml).getDataArray1();
} else {
encodeObjectToXml = xml;
}
sosSMLIO.getIoValue().accept(new SweDataComponentAdder(ioComponentPropertyType)).map(h -> (AbstractDataComponentType) h.set(encodeObjectToXml)).ifPresent(h -> sosSMLIO.getIoValue().accept(new SweDataComponentSubstituter(h)));
}
}
use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createProcessDescription.
private XmlObject createProcessDescription(final AbstractProcess sensorDesc) throws EncodingException {
// TODO Review: System -> return doc; ProcessModel -> return type
if (sensorDesc instanceof System) {
System system = (System) sensorDesc;
SystemDocument xbSystemDoc = SystemDocument.Factory.newInstance(getXmlOptions());
SystemType xbSystem = xbSystemDoc.addNewSystem();
addAbstractProcessValues(xbSystem, system);
addSystemValues(xbSystem, system);
return xbSystem;
} else if (sensorDesc instanceof ProcessModel) {
// TODO: set values
ProcessModel processModel = (ProcessModel) sensorDesc;
ProcessModelDocument xbProcessModelDoc = ProcessModelDocument.Factory.newInstance(getXmlOptions());
ProcessModelType xbProcessModel = xbProcessModelDoc.addNewProcessModel();
addAbstractProcessValues(xbProcessModel, processModel);
addProcessModelValues(xbProcessModel, processModel);
return xbProcessModel;
} else if (sensorDesc instanceof org.n52.shetland.ogc.sensorML.Component) {
org.n52.shetland.ogc.sensorML.Component component = (org.n52.shetland.ogc.sensorML.Component) sensorDesc;
ComponentDocument cd = ComponentDocument.Factory.newInstance(getXmlOptions());
ComponentType ct = cd.addNewComponent();
addAbstractProcessValues(ct, component);
return ct;
} else {
throw unsupportedDescriptionType();
}
}
use of org.n52.shetland.w3c.xlink.Type in project series-rest-api by 52North.
the class IoParametersTest method when_jsonNearIntegerRadius_then_parsingSpatialFilter.
@Test
public void when_jsonNearIntegerRadius_then_parsingSpatialFilter() throws ParseException {
String nearJson = "{" + " \"center\":{" + " \"type\":\"Point\"," + " \"coordinates\":[6.7,51.7]" + " }," + " \"radius\": 50" + "}";
Map<String, String> map = Collections.singletonMap("near", nearJson);
IoParameters parameters = createFromSingleValueMap(map);
BoundingBox actual = parameters.getSpatialFilter();
WKTReader wktReader = new WKTReader();
Geometry ll = wktReader.read("POINT (5.97448206555656 51.25033919704064)");
Geometry ur = wktReader.read("POINT(7.42551793444344 52.14966080295937)");
assertTrue(actual.getLowerLeft().equals(ll));
assertTrue(actual.getUpperRight().equals(ur));
}
use of org.n52.shetland.w3c.xlink.Type in project series-rest-api by 52North.
the class IoParametersTest method when_jsonBbox_then_parsingSpatialFilter.
@Test
public void when_jsonBbox_then_parsingSpatialFilter() throws ParseException {
String bboxJson = "{" + " \"ll\":{" + " \"type\":\"Point\"," + " \"coordinates\":[6.7,51.7]" + " }," + " \"ur\":{" + " \"type\":\"Point\"," + " \"coordinates\":[7.9,51.9]" + " }" + "}";
Map<String, String> map = Collections.singletonMap("bbox", bboxJson);
IoParameters parameters = createFromSingleValueMap(map);
BoundingBox actual = parameters.getSpatialFilter();
WKTReader wktReader = new WKTReader();
Geometry ll = wktReader.read("POINT (6.7 51.7)");
Geometry ur = wktReader.read("POINT(7.9 51.9)");
assertTrue(actual.getLowerLeft().equals(ll));
assertTrue(actual.getUpperRight().equals(ur));
}
use of org.n52.shetland.w3c.xlink.Type in project series-rest-api by 52North.
the class QuantityIoFactory method createHandler.
@Override
public IoHandler<Data<QuantityValue>> createHandler(String outputMimeType) {
IoParameters parameters = getParameters();
Constants.MimeType mimeType = Constants.MimeType.toInstance(outputMimeType);
if (mimeType == Constants.MimeType.IMAGE_PNG) {
return createMultiChartRenderer(mimeType);
} else if (mimeType == Constants.MimeType.APPLICATION_PDF) {
ChartIoHandler imgRenderer = createMultiChartRenderer(mimeType);
return new PDFReportGenerator(parameters, createProcessChain(), imgRenderer);
} else if (isCsvOutput(mimeType)) {
CsvIoHandler<QuantityValue> handler = new SimpleCsvIoHandler<>(parameters, createProcessChain(), getMetadatas());
boolean zipOutput = parameters.getAsBoolean(Parameters.ZIP, false);
handler.setZipOutput(zipOutput || mimeType == Constants.MimeType.APPLICATION_ZIP);
return handler;
}
String msg = "The requested media type '" + outputMimeType + "' is not supported.";
IllegalArgumentException exception = new IllegalArgumentException(msg);
throw exception;
}
Aggregations