Search in sources :

Example 6 with LiteralValue

use of org.geotoolkit.wps.xml.v200.LiteralValue in project geotoolkit by Geomatys.

the class LiteralAdaptorTest method doubleWPS2.

@Test
public void doubleWPS2() {
    final DomainMetadataType metaType = new DomainMetadataType(null, "xs:double");
    final LiteralDataDomain domain = new LiteralDataDomain();
    domain.setDataType(metaType);
    final LiteralAdaptor adaptor = LiteralAdaptor.create(domain);
    assertEquals(Double.class, adaptor.getValueClass());
    final DataOutput output = new DataOutput();
    final LiteralValue lit = new LiteralValue();
    lit.setValue("3.14");
    final Data data = new Data(lit);
    output.setData(data);
    final Object result = adaptor.fromWPS2Input(output);
    assertEquals(3.14, (Double) result, DELTA);
}
Also used : DomainMetadataType(org.geotoolkit.ows.xml.v200.DomainMetadataType) DataOutput(org.geotoolkit.wps.xml.v200.DataOutput) LiteralValue(org.geotoolkit.wps.xml.v200.LiteralValue) Data(org.geotoolkit.wps.xml.v200.Data) LiteralDataDomain(org.geotoolkit.wps.xml.v200.LiteralDataDomain) Test(org.junit.Test)

Example 7 with LiteralValue

use of org.geotoolkit.wps.xml.v200.LiteralValue in project geotoolkit by Geomatys.

the class LiteralAdaptor method toWPS2Input.

public DataInput toWPS2Input(Object candidate, boolean rawLiteral) {
    final Data data = new Data();
    final LiteralValue litValue = new LiteralValue();
    litValue.setDataType(WPSConvertersUtils.getDataTypeString("2.0.0", getValueClass()));
    litValue.setValue(String.valueOf(candidate));
    litValue.setUom(unit == null ? null : unit.getName());
    if (rawLiteral) {
        data.getContent().add(String.valueOf(candidate));
    } else {
        data.getContent().add(litValue);
    }
    final DataInput dit = new DataInput();
    dit.setData(data);
    return dit;
}
Also used : DataInput(org.geotoolkit.wps.xml.v200.DataInput) Data(org.geotoolkit.wps.xml.v200.Data) LiteralValue(org.geotoolkit.wps.xml.v200.LiteralValue)

Aggregations

Data (org.geotoolkit.wps.xml.v200.Data)7 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 Test (org.junit.Test)4 DomainMetadataType (org.geotoolkit.ows.xml.v200.DomainMetadataType)3 DataOutput (org.geotoolkit.wps.xml.v200.DataOutput)3 LiteralDataDomain (org.geotoolkit.wps.xml.v200.LiteralDataDomain)3 DataInput (org.geotoolkit.wps.xml.v200.DataInput)2 InputStream (java.io.InputStream)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 Marshaller (javax.xml.bind.Marshaller)1 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)1 GeneralEnvelope (org.apache.sis.geometry.GeneralEnvelope)1 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)1 PointType (org.geotoolkit.gml.xml.v321.PointType)1 GeoJSONObject (org.geotoolkit.internal.geojson.binding.GeoJSONObject)1 BoundingBoxType (org.geotoolkit.ows.xml.v200.BoundingBoxType)1 ExecuteRequest (org.geotoolkit.wps.client.ExecuteRequest)1 WebProcessingClient (org.geotoolkit.wps.client.WebProcessingClient)1 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)1