Search in sources :

Example 71 with Type

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)));
    }
}
Also used : PositionType(net.opengis.swe.x101.PositionType) SosConstants(org.n52.shetland.ogc.sos.SosConstants) Contact(net.opengis.sensorML.x101.ContactDocument.Contact) Time(org.n52.shetland.ogc.gml.time.Time) PointType(net.opengis.gml.PointType) Phone(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Phone) ComponentList(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList) SmlLocation(org.n52.shetland.ogc.sensorML.elements.SmlLocation) SweAggregateType(org.n52.shetland.ogc.swe.SweConstants.SweAggregateType) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) ProcessMethod(org.n52.shetland.ogc.sensorML.ProcessMethod) Map(java.util.Map) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument) SchemaType(org.apache.xmlbeans.SchemaType) CodeType(org.n52.shetland.ogc.gml.CodeType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) VectorType(net.opengis.swe.x101.VectorType) SensorML(org.n52.shetland.ogc.sensorML.SensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) IoComponentPropertyType(net.opengis.sensorML.x101.IoComponentPropertyType) Set(java.util.Set) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Connections(net.opengis.sensorML.x101.ConnectionsDocument.Connections) Inputs(net.opengis.sensorML.x101.InputsDocument.Inputs) SchemaLocation(org.n52.shetland.w3c.SchemaLocation) SmlDocumentation(org.n52.shetland.ogc.sensorML.elements.SmlDocumentation) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SmlClassifier(org.n52.shetland.ogc.sensorML.elements.SmlClassifier) AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) QName(javax.xml.namespace.QName) ProcessMethodType(net.opengis.sensorML.x101.ProcessMethodType) Joiner(com.google.common.base.Joiner) ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlPosition(org.n52.shetland.ogc.sensorML.elements.SmlPosition) SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SmlLocation2(net.opengis.sensorML.x101.SmlLocation.SmlLocation2) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) XmlCursor(org.apache.xmlbeans.XmlCursor) ContactInfo(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo) XmlHelper(org.n52.svalbard.util.XmlHelper) MediaType(org.n52.janmayen.http.MediaType) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) Components(net.opengis.sensorML.x101.ComponentsDocument.Components) Lists(com.google.common.collect.Lists) ComponentType(net.opengis.sensorML.x101.ComponentType) ConnectionList(net.opengis.sensorML.x101.ConnectionsDocument.Connections.ConnectionList) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) Link(net.opengis.sensorML.x101.LinkDocument.Link) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) AbstractSmlDocumentation(org.n52.shetland.ogc.sensorML.elements.AbstractSmlDocumentation) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) SmlConnection(org.n52.shetland.ogc.sensorML.elements.SmlConnection) ProcessModelType(net.opengis.sensorML.x101.ProcessModelType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SweField(org.n52.shetland.ogc.swe.SweField) XmlException(org.apache.xmlbeans.XmlException) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordType(net.opengis.swe.x101.DataRecordType) Address(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Address) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) LoggerFactory(org.slf4j.LoggerFactory) Documentation(net.opengis.sensorML.x101.DocumentationDocument.Documentation) SmlContact(org.n52.shetland.ogc.sensorML.SmlContact) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) ComponentDocument(net.opengis.sensorML.x101.ComponentDocument) MethodPropertyType(net.opengis.sensorML.x101.MethodPropertyType) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SmlDocumentationList(org.n52.shetland.ogc.sensorML.elements.SmlDocumentationList) ProcedureDescriptionFormat(org.n52.shetland.ogc.sos.ProcedureDescriptionFormat) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) ImmutableSet(com.google.common.collect.ImmutableSet) AbstractVoidSweDataComponentVisitor(org.n52.shetland.ogc.swe.AbstractVoidSweDataComponentVisitor) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) ImmutableMap(com.google.common.collect.ImmutableMap) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList) Classifier(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList.Classifier) Classification(net.opengis.sensorML.x101.ClassificationDocument.Classification) Sets(com.google.common.collect.Sets) ClassifierList(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList) System(org.n52.shetland.ogc.sensorML.System) Objects(java.util.Objects) List(java.util.List) Characteristics(net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics) GmlConstants(org.n52.shetland.ogc.gml.GmlConstants) Identifier(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) Outputs(net.opengis.sensorML.x101.OutputsDocument.Outputs) SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) CollectionHelper(org.n52.shetland.util.CollectionHelper) Person(net.opengis.sensorML.x101.PersonDocument.Person) SupportedType(org.n52.shetland.ogc.SupportedType) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) SmlLink(org.n52.shetland.ogc.sensorML.elements.SmlLink) Position(net.opengis.sensorML.x101.PositionDocument.Position) SystemDocument(net.opengis.sensorML.x101.SystemDocument) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) Document(net.opengis.sensorML.x101.DocumentDocument.Document) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) RulesDefinition(net.opengis.sensorML.x101.ProcessMethodType.Rules.RulesDefinition) SensorMLConstants(org.n52.shetland.ogc.sensorML.SensorMLConstants) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) SystemType(net.opengis.sensorML.x101.SystemType) DataArrayType(net.opengis.swe.x101.DataArrayType) SweConstants(org.n52.shetland.ogc.swe.SweConstants) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) XmlObject(org.apache.xmlbeans.XmlObject) ProcessModelDocument(net.opengis.sensorML.x101.ProcessModelDocument) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList) Logger(org.slf4j.Logger) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) AbstractOptionalSweDataComponentVisitor(org.n52.shetland.ogc.swe.AbstractOptionalSweDataComponentVisitor) DocumentList(net.opengis.sensorML.x101.DocumentListDocument.DocumentList) Identification(net.opengis.sensorML.x101.IdentificationDocument.Identification) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) Term(net.opengis.sensorML.x101.TermDocument.Term) XmlOptions(org.apache.xmlbeans.XmlOptions) Sos1Constants(org.n52.shetland.ogc.sos.Sos1Constants) InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) CodingHelper(org.n52.svalbard.util.CodingHelper) Collections(java.util.Collections) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) XmlObject(org.apache.xmlbeans.XmlObject) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Example 72 with Type

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();
    }
}
Also used : ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) ComponentDocument(net.opengis.sensorML.x101.ComponentDocument) SystemType(net.opengis.sensorML.x101.SystemType) ProcessModelDocument(net.opengis.sensorML.x101.ProcessModelDocument) System(org.n52.shetland.ogc.sensorML.System) SystemDocument(net.opengis.sensorML.x101.SystemDocument) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ProcessModelType(net.opengis.sensorML.x101.ProcessModelType)

Example 73 with Type

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));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) BoundingBox(org.n52.io.crs.BoundingBox) WKTReader(org.locationtech.jts.io.WKTReader) Test(org.junit.jupiter.api.Test)

Example 74 with Type

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));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) BoundingBox(org.n52.io.crs.BoundingBox) WKTReader(org.locationtech.jts.io.WKTReader) Test(org.junit.jupiter.api.Test)

Example 75 with Type

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;
}
Also used : SimpleCsvIoHandler(org.n52.io.handler.simple.SimpleCsvIoHandler) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) ChartIoHandler(org.n52.io.type.quantity.handler.img.ChartIoHandler) Constants(org.n52.io.Constants) IoParameters(org.n52.io.request.IoParameters) PDFReportGenerator(org.n52.io.type.quantity.handler.report.PDFReportGenerator)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)27 DecodingException (org.n52.svalbard.decode.exception.DecodingException)15 Actuate (org.n52.shetland.w3c.xlink.Actuate)14 Reference (org.n52.shetland.w3c.xlink.Reference)14 Show (org.n52.shetland.w3c.xlink.Show)14 Type (org.n52.shetland.w3c.xlink.Type)14 ActuateType (org.w3.x1999.xlink.ActuateType)14 ShowType (org.w3.x1999.xlink.ShowType)14 TypeType (org.w3.x1999.xlink.TypeType)14 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)13 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 XmlException (org.apache.xmlbeans.XmlException)9 Test (org.junit.Test)9 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)9 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 SupportedType (org.n52.shetland.ogc.SupportedType)6