Search in sources :

Example 16 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class OmObservationTest method should_have_SpatialFilteringProfileParameter.

@Test
public final void should_have_SpatialFilteringProfileParameter() throws OwsExceptionReport, DecodingException {
    OmObservation omObservation = new OmObservation();
    NamedValue<Geometry> namedValue = new NamedValue<>();
    namedValue.setName(new ReferenceType(OmConstants.PARAM_NAME_SAMPLING_GEOMETRY));
    GeometryFactory fac = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326);
    namedValue.setValue(new GeometryValue(fac.createPoint(new Coordinate(34.5, 76.4))));
    // test no parameter is set
    assertFalse(omObservation.isSetParameter());
    assertFalse(omObservation.isSetSpatialFilteringProfileParameter());
    omObservation.addParameter(namedValue);
    // test with set SpatialFilteringProfile parameter
    assertTrue(omObservation.isSetParameter());
    assertTrue(omObservation.isSetSpatialFilteringProfileParameter());
    assertThat(omObservation.getSpatialFilteringProfileParameter(), is(equalTo(namedValue)));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) PrecisionModel(org.locationtech.jts.geom.PrecisionModel) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) Test(org.junit.Test)

Example 17 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SweEnvelope method toEnvelope.

public Envelope toEnvelope() throws OwsExceptionReport {
    Coordinate min = getLowerCornerAsCoordinate();
    Coordinate max = getUpperCornerAsCoordinate();
    if (min != null && max != null) {
        if (this.northingFirst) {
            return new Envelope(min.y, max.y, min.x, max.x);
        } else {
            return new Envelope(min.x, max.x, min.y, max.y);
        }
    }
    return null;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope)

Example 18 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class EReportingHeaderJSONDecoderTest method test.

@Test
public void test() throws OwsExceptionReport, URISyntaxException, EncodingException, DecodingException {
    EReportingHeader header = getHeader();
    JsonNode encode = getEncoder().encode(header);
    EReportingHeader o = getDecoder().decode(encode);
    assertThat(o.getInspireID() != null, is(true));
    assertThat(o.getInspireID().getLocalId(), equalTo(header.getInspireID().getLocalId()));
    assertThat(o.getInspireID().getValue(), equalTo(header.getInspireID().getValue()));
    assertThat(o.getInspireID().getVersionId(), equalTo(header.getInspireID().getVersionId()));
    assertThat(o.getChange(), equalTo(header.getChange()));
    assertThat(o.getReportingPeriod().isInstance(), is(true));
    assertThat(o.getReportingPeriod().getInstance().isPresent(), is(true));
    assertThat(o.getReportingPeriod().getInstance().get(), equalTo(header.getReportingPeriod().getInstance().get()));
    assertThat(o.getReportingAuthority() != null, is(true));
    assertThat(o.getReportingAuthority(), instanceOf(RelatedParty.class));
    assertThat(o.getReportingAuthority().getIndividualName().isNil(), is(true));
    assertThat(o.getReportingAuthority().getIndividualName().getNilReason().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getIndividualName().getNilReason().get(), equalTo(header.getReportingAuthority().getIndividualName().getNilReason().get()));
    assertThat(o.getReportingAuthority().getOrganisationName().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getOrganisationName().get(), equalTo(header.getReportingAuthority().getOrganisationName().get()));
    assertThat(o.getReportingAuthority().getPositionName().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getPositionName().get(), equalTo(header.getReportingAuthority().getPositionName().get()));
    assertThat(o.getReportingAuthority().getRoles() != null, is(true));
    assertThat(o.getReportingAuthority().getRoles().size(), is(2));
    assertThat(o.getReportingAuthority().getRoles().get(0).isPresent(), is(true));
    assertThat(o.getReportingAuthority().getRoles().get(0).get().getHref().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getRoles().get(0).get().getHref().get(), equalTo(header.getReportingAuthority().getRoles().get(0).get().getHref().get()));
    assertThat(o.getReportingAuthority().getRoles().get(1).isNil(), is(true));
    assertThat(o.getReportingAuthority().getRoles().get(1).getNilReason().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getRoles().get(1).getNilReason(), equalTo(header.getReportingAuthority().getRoles().get(1).getNilReason()));
    assertThat(o.getReportingAuthority().getContact().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().size(), is(2));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(0).isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(0).get(), equalTo(header.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(0).get()));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(1).isNil(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(1).getNilReason().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(1).getNilReason(), equalTo(o.getReportingAuthority().getContact().get().getTelephoneFacsimile().get().get(1).getNilReason()));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneVoice().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneVoice().get().size(), is(1));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneVoice().get().get(0).isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getTelephoneVoice().get().get(0).get(), equalTo(header.getReportingAuthority().getContact().get().getTelephoneVoice().get().get(0).get()));
    assertThat(o.getReportingAuthority().getContact().get().getHoursOfService().isPresent(), is(true));
    checkPtFreeText(o.getReportingAuthority().getContact().get().getHoursOfService().get(), header.getReportingAuthority().getContact().get().getHoursOfService().get());
    assertThat(o.getReportingAuthority().getContact().get().getWebsite().isNil(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getWebsite().getNilReason().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getWebsite().getNilReason().get(), equalTo(header.getReportingAuthority().getContact().get().getWebsite().getNilReason().get()));
    assertThat(o.getReportingAuthority().getContact().get().getElectronicMailAddress().isNil(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getElectronicMailAddress().getNilReason().isPresent(), is(true));
    assertThat(o.getReportingAuthority().getContact().get().getElectronicMailAddress().getNilReason().get(), equalTo(header.getReportingAuthority().getContact().get().getWebsite().getNilReason().get()));
    checkAddress(o.getReportingAuthority().getContact().get().getAddress(), header.getReportingAuthority().getContact().get().getAddress());
    assertThat(o.getReportingAuthority().getContact().get().getAddress().get().getAdminUnits() != null, is(true));
    assertThat(o.getReportingAuthority().getContact().get().getAddress().get().getAdminUnits().size(), is(1));
    chekGeographicalName(o.getReportingAuthority().getContact().get().getAddress().get().getAdminUnits().get(0), header.getReportingAuthority().getContact().get().getAddress().get().getAdminUnits().get(0));
}
Also used : EReportingHeader(org.n52.shetland.aqd.EReportingHeader) RelatedParty(org.n52.shetland.inspire.base2.RelatedParty) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 19 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class AbstractObservationResponseEncoder method encodeResponse.

@Override
protected void encodeResponse(ObjectNode json, T t) throws EncodingException {
    ArrayNode obs = json.putArray(JSONConstants.OBSERVATIONS);
    try {
        ObservationStream observationCollection = t.getObservationCollection();
        encodeObservationStream(observationCollection, obs);
    } catch (OwsExceptionReport ex) {
        throw new EncodingException(ex);
    }
}
Also used : ObservationStream(org.n52.shetland.ogc.om.ObservationStream) EncodingException(org.n52.svalbard.encode.exception.EncodingException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 20 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SosDecoderv20 method parseGetFeatureOfInterest.

// private SwesExtensions parseSwesExtensions(final XmlObject[]
// extensionArray) throws OwsExceptionReport
// {
// final SwesExtensions extensions = new SwesExtensions();
// for (final XmlObject xbSwesExtension : extensionArray) {
// 
// final Object obj = CodingHelper.decodeXmlElement(xbSwesExtension);
// if (obj instanceof SwesExtension<?>) {
// extensions.addSwesExtension((SwesExtension<?>) obj);
// }
// }
// return extensions;
// }
/**
 * parses the passes XmlBeans document and creates a SOS
 * getFeatureOfInterest request
 *
 * @param getFoiDoc
 *            XmlBeans document representing the getFeatureOfInterest
 *            request
 * @return Returns SOS getFeatureOfInterest request
 *
 * @throws DecodingException
 *             * if validation of the request failed
 */
private OwsServiceRequest parseGetFeatureOfInterest(final GetFeatureOfInterestDocument getFoiDoc) throws DecodingException {
    final GetFeatureOfInterestRequest getFoiRequest = new GetFeatureOfInterestRequest();
    final GetFeatureOfInterestType getFoiType = getFoiDoc.getGetFeatureOfInterest();
    getFoiRequest.setService(getFoiType.getService());
    getFoiRequest.setVersion(getFoiType.getVersion());
    getFoiRequest.setFeatureIdentifiers(Arrays.asList(getFoiType.getFeatureOfInterestArray()));
    getFoiRequest.setObservedProperties(Arrays.asList(getFoiType.getObservedPropertyArray()));
    getFoiRequest.setProcedures(Arrays.asList(getFoiType.getProcedureArray()));
    getFoiRequest.setSpatialFilters(parseSpatialFilters4GetFeatureOfInterest(getFoiType.getSpatialFilterArray()));
    getFoiRequest.setExtensions(parseExtensibleRequest(getFoiType));
    return getFoiRequest;
}
Also used : GetFeatureOfInterestRequest(org.n52.shetland.ogc.sos.request.GetFeatureOfInterestRequest) GetFeatureOfInterestType(net.opengis.sos.x20.GetFeatureOfInterestType)

Aggregations

OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)27 EncodingException (org.n52.svalbard.encode.exception.EncodingException)14 Test (org.junit.Test)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)9 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)8 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)7 IOException (java.io.IOException)6 DateTime (org.joda.time.DateTime)6 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)6 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)5 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)5 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)5 LinkedList (java.util.LinkedList)4 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)4 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)4 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3