Search in sources :

Example 16 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project geotoolkit by Geomatys.

the class LiteralAdaptor method fromWPS2Input.

@Override
public T fromWPS2Input(DataOutput candidate) {
    final Data data = candidate.getData();
    final LiteralValue literalData = data.getLiteralData();
    final String value = literalData.getValue();
    return convert(value);
}
Also used : Data(org.geotoolkit.wps.xml.v200.Data) LiteralValue(org.geotoolkit.wps.xml.v200.LiteralValue)

Example 17 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project geotoolkit by Geomatys.

the class OctetStreamAdaptor method toWPS2Input.

@Override
public DataInput toWPS2Input(Path candidate) throws UnconvertibleObjectException {
    if (candidate instanceof ReferenceProxy)
        return super.toWPS2Input(candidate);
    final byte[] bytes;
    try {
        bytes = Files.readAllBytes(candidate);
    } catch (IOException ex) {
        throw new UnconvertibleObjectException(ex.getMessage(), ex);
    }
    final String base64 = Base64.getEncoder().encodeToString(bytes);
    final DataInput dit = new DataInput();
    final Data data = new Data();
    data.setEncoding("base64");
    data.getContent().add(base64);
    dit.setData(data);
    return dit;
}
Also used : ReferenceProxy(org.geotoolkit.wps.xml.ReferenceProxy) DataInput(org.geotoolkit.wps.xml.v200.DataInput) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Data(org.geotoolkit.wps.xml.v200.Data) IOException(java.io.IOException)

Example 18 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project geotoolkit by Geomatys.

the class WKTAdaptor method toWPS2Input.

@Override
public DataInput toWPS2Input(Object candidate) throws UnconvertibleObjectException {
    if (candidate instanceof ReferenceProxy)
        return super.toWPS2Input(candidate);
    final ComplexData cdt = new ComplexData();
    cdt.getContent().add(new org.geotoolkit.wps.xml.v200.Format(encoding, mimeType, null, null));
    Geometry geom = (Geometry) candidate;
    int srid = 0;
    int dimension = 2;
    try {
        CoordinateReferenceSystem crs = Geometries.wrap(geom).get().getCoordinateReferenceSystem();
        if (crs != null) {
            dimension = crs.getCoordinateSystem().getDimension();
            final IdentifiedObjectFinder finder = IdentifiedObjects.newFinder("EPSG");
            // TODO: Ensure no project strongly rely on that, then remove. It's pure non-sense/madness.
            // Note: If you read this after march 2020: do not ask : delete.
            finder.setIgnoringAxes(true);
            final CoordinateReferenceSystem epsgcrs = (CoordinateReferenceSystem) finder.findSingleton(crs);
            if (epsgcrs != null) {
                srid = IdentifiedObjects.lookupEPSG(epsgcrs);
                // force geometry in longitude first
                final CoordinateReferenceSystem crs2 = ((AbstractCRS) crs).forConvention(AxesConvention.RIGHT_HANDED);
                if (crs2 != crs) {
                    geom = org.apache.sis.internal.feature.jts.JTS.transform(geom, crs2);
                }
                if (crs2 != null)
                    dimension = crs2.getCoordinateSystem().getDimension();
            }
        }
    } catch (FactoryException | MismatchedDimensionException | TransformException ex) {
        throw new UnconvertibleObjectException(ex.getMessage(), ex);
    }
    // String wkt = geom.toText();
    WKTWriter writer = new WKTWriter(dimension);
    String wkt = writer.write(geom);
    if (srid > 0) {
        wkt = "SRID=" + srid + ";" + wkt;
    }
    cdt.getContent().add(wkt);
    final Data data = new Data();
    data.getContent().add(cdt);
    final DataInput dit = new DataInput();
    dit.setData(data);
    return dit;
}
Also used : IdentifiedObjectFinder(org.apache.sis.referencing.factory.IdentifiedObjectFinder) WKTWriter(org.locationtech.jts.io.WKTWriter) FactoryException(org.opengis.util.FactoryException) AbstractCRS(org.apache.sis.referencing.crs.AbstractCRS) TransformException(org.opengis.referencing.operation.TransformException) Data(org.geotoolkit.wps.xml.v200.Data) ComplexData(org.geotoolkit.wps.xml.v200.ComplexData) MismatchedDimensionException(org.opengis.geometry.MismatchedDimensionException) ReferenceProxy(org.geotoolkit.wps.xml.ReferenceProxy) Format(org.geotoolkit.wps.xml.v200.Format) Geometry(org.locationtech.jts.geom.Geometry) DataInput(org.geotoolkit.wps.xml.v200.DataInput) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) ComplexData(org.geotoolkit.wps.xml.v200.ComplexData) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 19 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project geotoolkit by Geomatys.

the class XMLAdaptor method toWPS2Input.

@Override
public DataInput toWPS2Input(Node candidate) throws UnconvertibleObjectException {
    if (candidate instanceof ReferenceProxy) {
        return super.toWPS2Input(candidate);
    }
    final ComplexData cdt = new ComplexData();
    cdt.getContent().add(new org.geotoolkit.wps.xml.v200.Format(encoding, mimeType, schema, null));
    if (candidate instanceof Document) {
        candidate = ((Document) candidate).getDocumentElement();
    }
    cdt.getContent().add(candidate);
    final Data data = new Data();
    data.getContent().add(cdt);
    final DataInput dit = new DataInput();
    dit.setData(data);
    return dit;
}
Also used : ReferenceProxy(org.geotoolkit.wps.xml.ReferenceProxy) Format(org.geotoolkit.wps.xml.v200.Format) DataInput(org.geotoolkit.wps.xml.v200.DataInput) ComplexData(org.geotoolkit.wps.xml.v200.ComplexData) Data(org.geotoolkit.wps.xml.v200.Data) ComplexData(org.geotoolkit.wps.xml.v200.ComplexData) Document(org.w3c.dom.Document)

Example 20 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project fiware-cygnus by telefonicaid.

the class NotifyContextRequestNGSIv2Deserializer method deserializeData.

private Data deserializeData(JsonObject jsonObject) {
    Data data = new Data();
    data.setId(jsonObject.get("id").getAsString());
    data.setType(jsonObject.get("type").getAsString());
    data.setAtributes(deserializeAttributes(jsonObject));
    return data;
}
Also used : Data(com.telefonica.iot.cygnus.containers.NotifyContextRequestNGSIv2.Data)

Aggregations

Test (org.junit.Test)65 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)53 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 Data (org.geotoolkit.wps.xml.v200.Data)42 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)20 IOException (java.io.IOException)16 DataInput (org.geotoolkit.wps.xml.v200.DataInput)15 Format (org.geotoolkit.wps.xml.v200.Format)12 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)10 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 ReferenceProxy (org.geotoolkit.wps.xml.ReferenceProxy)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 DataStoreException (org.apache.sis.storage.DataStoreException)8 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6