Search in sources :

Example 16 with SamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.

the class SamplingFeatureComplexTest method should_set_role_correct.

@Test
public void should_set_role_correct() {
    final String role = "test-role";
    final SamplingFeatureComplex sfc = new SamplingFeatureComplex(role, new SamplingFeature(new CodeWithAuthority("test-feature")));
    assertThat(sfc.getRelatedSamplingFeatureRole(), is(role));
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Test(org.junit.Test)

Example 17 with SamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.

the class SamplingFeatureTest method isSetRelatedSamplingFeatures_should_return_false_if_not_set.

@Test
public final void isSetRelatedSamplingFeatures_should_return_false_if_not_set() {
    final SamplingFeature feature = new SamplingFeature(null);
    assertThat(feature.isSetRelatedSamplingFeatures(), is(FALSE));
    feature.addRelatedSamplingFeature(new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature"))));
    assertThat(feature.isSetRelatedSamplingFeatures(), is(TRUE));
    feature.setRelatedSamplingFeatures(null);
    assertThat(feature.isSetRelatedSamplingFeatures(), is(FALSE));
    feature.setRelatedSamplingFeatures(Lists.<SamplingFeatureComplex>newArrayList());
    assertThat(feature.isSetRelatedSamplingFeatures(), is(FALSE));
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Test(org.junit.Test)

Example 18 with SamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.

the class SamplingFeatureTest method setRelatedSamplingFeatures_should_set_all_elements_and_reset_if_set_before.

@Test
public final void setRelatedSamplingFeatures_should_set_all_elements_and_reset_if_set_before() {
    final SamplingFeature feature = new SamplingFeature(null);
    final SamplingFeatureComplex relatedSamplingFeature = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature")));
    final SamplingFeatureComplex relatedSamplingFeature2 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-2")));
    List<SamplingFeatureComplex> list = Lists.newArrayList(relatedSamplingFeature, relatedSamplingFeature2);
    feature.setRelatedSamplingFeatures(list);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2);
    final SamplingFeatureComplex relatedSamplingFeature3 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-3")));
    final SamplingFeatureComplex relatedSamplingFeature4 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-4")));
    list = Lists.newArrayList(relatedSamplingFeature3, relatedSamplingFeature4);
    feature.setRelatedSamplingFeatures(list);
    validate(feature, relatedSamplingFeature3, relatedSamplingFeature4);
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Test(org.junit.Test)

Example 19 with SamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.

the class MeasurementDecodingTest method testFeatureOfInterestGeometry.

@Test
public void testFeatureOfInterestGeometry() {
    assertThat(observation, is(notNullValue()));
    final OmObservationConstellation oc = observation.getObservationConstellation();
    assertThat(oc, is(notNullValue()));
    assertThat(oc.getFeatureOfInterest(), is(notNullValue()));
    assertThat(oc.getFeatureOfInterest(), is(instanceOf(SamplingFeature.class)));
    SamplingFeature foi = (SamplingFeature) oc.getFeatureOfInterest();
    assertThat(foi.getGeometry(), is(notNullValue()));
    assertThat(foi.getGeometry(), is(instanceOf(Point.class)));
    assertThat(foi.getGeometry().getCoordinate().x, is(52.0));
    assertThat(foi.getGeometry().getCoordinate().y, is(7.0));
}
Also used : SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Test(org.junit.Test)

Example 20 with SamplingFeature

use of org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature in project arctic-sea by 52North.

the class SpecimenDecoderv20 method getSampledFeatures.

/**
 * Parse {@link FeaturePropertyType} sampledFeature to
 * {@link AbstractFeature} list.
 *
 * @param sampledFeature
 *            SampledFeature to parse
 * @return List with the parsed sampledFeature
 * @throws DecodingException
 *             If an error occurs
 */
private List<AbstractFeature> getSampledFeatures(final FeaturePropertyType sampledFeature) throws DecodingException {
    final List<AbstractFeature> sampledFeatures = new ArrayList<AbstractFeature>(1);
    if (sampledFeature != null && !sampledFeature.isNil()) {
        // if xlink:href is set
        if (sampledFeature.getHref() != null && !sampledFeature.getHref().isEmpty()) {
            if (sampledFeature.getHref().startsWith("#")) {
                sampledFeatures.add(new SamplingFeature(null, sampledFeature.getHref().replace("#", "")));
            } else {
                final AbstractSamplingFeature sampFeat = new SamplingFeature(new CodeWithAuthority(sampledFeature.getHref()));
                if (sampledFeature.getTitle() != null && !sampledFeature.getTitle().isEmpty()) {
                    sampFeat.addName(new CodeType(sampledFeature.getTitle()));
                }
                sampledFeatures.add(sampFeat);
            }
        } else {
            XmlObject abstractFeature = null;
            if (sampledFeature.getAbstractFeature() != null) {
                abstractFeature = sampledFeature.getAbstractFeature();
            } else if (sampledFeature.getDomNode().hasChildNodes()) {
                try {
                    abstractFeature = XmlObject.Factory.parse(XmlHelper.getNodeFromNodeList(sampledFeature.getDomNode().getChildNodes()));
                } catch (final XmlException xmle) {
                    throw new DecodingException("Error while parsing feature request!", xmle);
                }
            }
            if (abstractFeature != null) {
                final Object decodedObject = decodeXmlObject(abstractFeature);
                if (decodedObject instanceof AbstractFeature) {
                    sampledFeatures.add((AbstractFeature) decodedObject);
                }
            }
            throw new DecodingException("The requested sampledFeature type is not supported by this service!");
        }
    }
    return sampledFeatures;
}
Also used : AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) CodeType(org.n52.shetland.ogc.gml.CodeType) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Aggregations

SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)25 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)17 XmlObject (org.apache.xmlbeans.XmlObject)11 Test (org.junit.Test)10 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)8 CodeType (org.n52.shetland.ogc.gml.CodeType)8 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)7 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)7 SamplingFeatureComplex (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex)7 XmlException (org.apache.xmlbeans.XmlException)6 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)6 EncodingException (org.n52.svalbard.encode.exception.EncodingException)5 ArrayList (java.util.ArrayList)4 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)4 DateTime (org.joda.time.DateTime)3 LineString (org.locationtech.jts.geom.LineString)3 OmObservation (org.n52.shetland.ogc.om.OmObservation)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)3 FeaturePropertyType (net.opengis.gml.x32.FeaturePropertyType)2