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)));
}
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;
}
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));
}
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);
}
}
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;
}
Aggregations