Search in sources :

Example 16 with BoundingBoxType

use of org.geotoolkit.ows.xml.v100.BoundingBoxType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method summmaryRecordUnmarshalingTest.

/**
 * Test summary Record Marshalling.
 */
@Test
public void summmaryRecordUnmarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    /*
         * Test marshalling csw summmary Record v2.0.2
         */
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:SummaryRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "  <dc:title>(JASON-1)</dc:title>\n" + "  <dc:type>clearinghouse</dc:type>\n" + "  <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "  <dc:subject>oceans elevation 2</dc:subject>\n" + "  <dc:format>format 11-11</dc:format>\n" + "  <dc:format>format 22-22</dc:format>\n" + "  <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "  <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "    <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "</csw:SummaryRecord>\n";
    StringReader sr = new StringReader(xml);
    SummaryRecordType result = (SummaryRecordType) unmarshaller.unmarshal(sr);
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    List<SimpleLiteral> formats = new ArrayList<>();
    formats.add(new SimpleLiteral("format 11-11"));
    formats.add(new SimpleLiteral("format 22-22"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    List<SimpleLiteral> Abstract = new ArrayList<>();
    Abstract.add(new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm."));
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    SummaryRecordType expResult = new SummaryRecordType(id, title, type, bbox, subject, formats, modified, Abstract);
    assertEquals(expResult, result);
    /*
         * Test marshalling csw summmary Record v2.0.2
         */
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:SummaryRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "  <dc:identifier>urn:ogc-x:df:F7807C8AB645</dc:identifier>\n" + "  <dc:title>(JASON-1)</dc:title>\n" + "  <dc:title>(JASON-2)</dc:title>\n" + "  <dc:type>clearinghouse</dc:type>\n" + "  <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "  <dc:subject>oceans elevation 2</dc:subject>\n" + "  <dc:format>format 11-11</dc:format>\n" + "  <dc:format>format 22-22</dc:format>\n" + "  <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "  <dct:modified>2007-11-15 21:26:48</dct:modified>\n" + "  <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "  <dct:abstract>Jason-2 blablablablabla.</dct:abstract>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "    <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>100.0 -6.04</ows:LowerCorner>\n" + "    <ows:UpperCorner>-144.0 5.9</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "</csw:SummaryRecord>\n";
    sr = new StringReader(xml);
    result = (SummaryRecordType) unmarshaller.unmarshal(sr);
    List<SimpleLiteral> ids = new ArrayList<>();
    ids.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
    ids.add(new SimpleLiteral("urn:ogc-x:df:F7807C8AB645"));
    List<SimpleLiteral> titles = new ArrayList<>();
    titles.add(new SimpleLiteral("(JASON-1)"));
    titles.add(new SimpleLiteral("(JASON-2)"));
    type = new SimpleLiteral("clearinghouse");
    subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    formats = new ArrayList<>();
    formats.add(new SimpleLiteral("format 11-11"));
    formats.add(new SimpleLiteral("format 22-22"));
    List<SimpleLiteral> modifieds = new ArrayList<>();
    modifieds.add(new SimpleLiteral("2007-11-15 21:26:49"));
    modifieds.add(new SimpleLiteral("2007-11-15 21:26:48"));
    Abstract = new ArrayList<>();
    Abstract.add(new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm."));
    Abstract.add(new SimpleLiteral("Jason-2 blablablablabla."));
    bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    bbox.add(new WGS84BoundingBoxType(100, -6.04, -144, 5.9));
    expResult = new SummaryRecordType(ids, titles, type, bbox, subject, formats, modifieds, Abstract);
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 17 with BoundingBoxType

use of org.geotoolkit.ows.xml.v100.BoundingBoxType in project geotoolkit by Geomatys.

the class GetCoverageType method getResponseCRS.

/**
 * {@inheritDoc}
 */
@Override
public CoordinateReferenceSystem getResponseCRS() throws FactoryException {
    if (output == null || output.getGridCRS() == null || output.getGridCRS().getSrsName() == null || output.getGridCRS().getSrsName().getValue() == null) {
        return null;
    }
    final CoordinateReferenceSystem objCrs = CRS.forCode(output.getGridCRS().getSrsName().getValue());
    final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue();
    /*
         * If the bounding box contains at least 3 dimensions and the CRS specified is just
         * a 2D one, then we have to add a VerticalCRS to the one gotten by the crs decoding step.
         * Otherwise the CRS decoded is already fine, and we just return it.
         */
    if (boundingBox.getDimensions().intValue() > 2 && objCrs.getCoordinateSystem().getDimension() < 3) {
        final VerticalCRS verticalCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
        return new GeodeticObjectBuilder().addName(objCrs.getName().getCode() + " (3D)").createCompoundCRS(objCrs, verticalCRS);
    } else {
        return objCrs;
    }
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v110.BoundingBoxType) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) GeodeticObjectBuilder(org.apache.sis.internal.referencing.GeodeticObjectBuilder) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 18 with BoundingBoxType

use of org.geotoolkit.ows.xml.v100.BoundingBoxType in project geotoolkit by Geomatys.

the class BboxAdaptorTest method supportedCrsWPS2.

@Test
public void supportedCrsWPS2() throws FactoryException {
    final BoundingBoxData bboxDataType = new BoundingBoxData();
    final SupportedCRS scrs = new SupportedCRS("ESPG:4326");
    bboxDataType.getSupportedCRS().add(scrs);
    final BboxAdaptor adaptor = BboxAdaptor.create(bboxDataType);
    assertEquals(Envelope.class, adaptor.getValueClass());
    final BoundingBoxType litValue = new BoundingBoxType("EPSG:4326", -180, -90, +180, +90);
    final DataOutput output = new DataOutput();
    final Data data = new Data(litValue);
    output.setData(data);
    final Envelope result = adaptor.fromWPS2Input(output);
    final GeneralEnvelope env = new GeneralEnvelope(CRS.forCode("EPSG:4326"));
    env.setRange(0, -180, +180);
    env.setRange(1, -90, +90);
    assertEquals(env, new GeneralEnvelope(result));
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v200.BoundingBoxType) DataOutput(org.geotoolkit.wps.xml.v200.DataOutput) BoundingBoxData(org.geotoolkit.wps.xml.v200.BoundingBoxData) Data(org.geotoolkit.wps.xml.v200.Data) BoundingBoxData(org.geotoolkit.wps.xml.v200.BoundingBoxData) Envelope(org.opengis.geometry.Envelope) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope) SupportedCRS(org.geotoolkit.wps.xml.v200.SupportedCRS) Test(org.junit.Test)

Example 19 with BoundingBoxType

use of org.geotoolkit.ows.xml.v100.BoundingBoxType in project geotoolkit by Geomatys.

the class BboxAdaptor method toWPS2Input.

@Override
public DataInput toWPS2Input(Envelope candidate) {
    // change envelope crs if not supported
    if (!crss.contains(candidate.getCoordinateReferenceSystem())) {
        try {
            candidate = Envelopes.transform(candidate, crss.get(0));
        } catch (TransformException ex) {
            throw new UnconvertibleObjectException(ex.getMessage(), ex);
        }
    }
    final BoundingBoxType litValue = new BoundingBoxType(candidate);
    final Data data = new Data();
    data.getContent().add(litValue);
    final DataInput dit = new DataInput();
    dit.setData(data);
    return dit;
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v200.BoundingBoxType) DataInput(org.geotoolkit.wps.xml.v200.DataInput) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) TransformException(org.opengis.referencing.operation.TransformException) BoundingBoxData(org.geotoolkit.wps.xml.v200.BoundingBoxData) Data(org.geotoolkit.wps.xml.v200.Data)

Example 20 with BoundingBoxType

use of org.geotoolkit.ows.xml.v100.BoundingBoxType in project geotoolkit by Geomatys.

the class ExecuteTest method testRequestAndMarshall.

@Test
public void testRequestAndMarshall() throws Exception {
    final WebProcessingClient client = new WebProcessingClient(new URL("http://test.com"), null, WPSVersion.v100);
    final ExecuteRequest request = client.createExecute();
    final Execute execute = request.getContent();
    final GeographicCRS epsg4326 = CommonCRS.WGS84.geographic();
    final GeneralEnvelope env = new GeneralEnvelope(epsg4326);
    env.setRange(0, 10, 10);
    env.setRange(1, 10, 10);
    execute.setIdentifier("identifier");
    final List<DataInput> inputs = execute.getInput();
    inputs.add(new DataInput("literal", new Data(new LiteralValue("10", null, null))));
    inputs.add(new DataInput("bbox", new Data(new BoundingBoxType(env))));
    inputs.add(new DataInput("complex", new Data(new Format("UTF-8", WPSMimeType.APP_GML.val(), WPSSchema.OGC_GML_3_1_1.getValue(), null), new PointType(new DirectPosition2D(epsg4326, 0, 0)))));
    inputs.add(new DataInput("reference", new Reference("http://link.to/reference/", null, null)));
    execute.getOutput().add(new OutputDefinition("output", false));
    assertEquals("WPS", execute.getService());
    assertEquals("1.0.0", execute.getVersion().toString());
    assertEquals(execute.getIdentifier().getValue(), "identifier");
    final StringWriter stringWriter = new StringWriter();
    final Marshaller marshaller = WPSMarshallerPool.getInstance().acquireMarshaller();
    marshaller.marshal(execute, stringWriter);
    String result = stringWriter.toString();
    try (final InputStream expected = expectedRequest()) {
        assertXmlEquals(expected, result, "xmlns:*", "crs", "srsName");
    }
    WPSMarshallerPool.getInstance().recycle(marshaller);
}
Also used : Marshaller(javax.xml.bind.Marshaller) Execute(org.geotoolkit.wps.xml.v200.Execute) Reference(org.geotoolkit.wps.xml.v200.Reference) InputStream(java.io.InputStream) Data(org.geotoolkit.wps.xml.v200.Data) LiteralValue(org.geotoolkit.wps.xml.v200.LiteralValue) WebProcessingClient(org.geotoolkit.wps.client.WebProcessingClient) DirectPosition2D(org.apache.sis.geometry.DirectPosition2D) URL(java.net.URL) DataInput(org.geotoolkit.wps.xml.v200.DataInput) BoundingBoxType(org.geotoolkit.ows.xml.v200.BoundingBoxType) ExecuteRequest(org.geotoolkit.wps.client.ExecuteRequest) Format(org.geotoolkit.wps.xml.v200.Format) StringWriter(java.io.StringWriter) PointType(org.geotoolkit.gml.xml.v321.PointType) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope) OutputDefinition(org.geotoolkit.wps.xml.v200.OutputDefinition) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 ArrayList (java.util.ArrayList)13 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)13 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)13 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)13 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)11 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)9 StringWriter (java.io.StringWriter)8 Marshaller (javax.xml.bind.Marshaller)8 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)7 RecordType (org.geotoolkit.csw.xml.v202.RecordType)7 StringReader (java.io.StringReader)6 Unmarshaller (javax.xml.bind.Unmarshaller)6 JAXBElement (javax.xml.bind.JAXBElement)3 GeneralEnvelope (org.apache.sis.geometry.GeneralEnvelope)3 BoundingBoxType (org.geotoolkit.ows.xml.v110.BoundingBoxType)3 BoundingBoxType (org.geotoolkit.ows.xml.v200.BoundingBoxType)3 Data (org.geotoolkit.wps.xml.v200.Data)3 List (java.util.List)2 GeodeticObjectBuilder (org.apache.sis.internal.referencing.GeodeticObjectBuilder)2