Search in sources :

Example 16 with BoundingBoxType

use of org.geotoolkit.ows.xml.v200.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.v200.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.v200.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.v200.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.v200.BoundingBoxType in project ddf by codice.

the class CswEndpoint method getInsertResultFromResponse.

private InsertResultType getInsertResultFromResponse(CreateResponse createResponse) throws CswException {
    InsertResultType result = new InsertResultType();
    WKTReader reader = new WKTReader();
    for (Metacard metacard : createResponse.getCreatedMetacards()) {
        BoundingBoxType boundingBox = new BoundingBoxType();
        Geometry geometry = null;
        String bbox = null;
        try {
            if (metacard.getAttribute(CswConstants.BBOX_PROP) != null) {
                bbox = metacard.getAttribute(CswConstants.BBOX_PROP).getValue().toString();
                geometry = reader.read(bbox);
            } else if (StringUtils.isNotBlank(metacard.getLocation())) {
                bbox = metacard.getLocation();
                geometry = reader.read(bbox);
            }
        } catch (ParseException e) {
            LOGGER.debug("Unable to parse BoundingBox : {}", bbox, e);
        }
        BriefRecordType briefRecordType = new BriefRecordType();
        if (geometry != null) {
            Envelope bounds = geometry.getEnvelopeInternal();
            if (bounds != null) {
                boundingBox.setCrs(CswConstants.SRS_NAME);
                boundingBox.setLowerCorner(Arrays.asList(bounds.getMinX(), bounds.getMinY()));
                boundingBox.setUpperCorner(Arrays.asList(bounds.getMaxX(), bounds.getMaxY()));
                briefRecordType.getBoundingBox().add(new net.opengis.ows.v_1_0_0.ObjectFactory().createBoundingBox(boundingBox));
            }
        }
        SimpleLiteral identifier = new SimpleLiteral();
        identifier.getContent().add(metacard.getId());
        briefRecordType.getIdentifier().add(new JAXBElement<>(CswConstants.DC_IDENTIFIER_QNAME, SimpleLiteral.class, identifier));
        SimpleLiteral title = new SimpleLiteral();
        title.getContent().add(metacard.getTitle());
        briefRecordType.getTitle().add(new JAXBElement<>(CswConstants.DC_TITLE_QNAME, SimpleLiteral.class, title));
        SimpleLiteral type = new SimpleLiteral();
        type.getContent().add(metacard.getContentTypeName());
        briefRecordType.setType(type);
        result.getBriefRecord().add(briefRecordType);
    }
    return result;
}
Also used : WKTReader(org.locationtech.jts.io.WKTReader) Envelope(org.locationtech.jts.geom.Envelope) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) BoundingBoxType(net.opengis.ows.v_1_0_0.BoundingBoxType) Geometry(org.locationtech.jts.geom.Geometry) Metacard(ddf.catalog.data.Metacard) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) SimpleLiteral(net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral) MimeTypeParseException(javax.activation.MimeTypeParseException) ParseException(org.locationtech.jts.io.ParseException) InsertResultType(net.opengis.cat.csw.v_2_0_2.InsertResultType)

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