Search in sources :

Example 1 with SamplingFeature

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

the class SamplingFeatureComplexTest method should_set_relatedSamplingFeature_correct.

@Test
public void should_set_relatedSamplingFeature_correct() {
    final SamplingFeature feature = new SamplingFeature(new CodeWithAuthority("test-feature"));
    final SamplingFeatureComplex sfc = new SamplingFeatureComplex("test-role", feature);
    assertThat(sfc.getRelatedSamplingFeature(), is(feature));
}
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 2 with SamplingFeature

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

the class SamplingFeatureTest method addRelatedSamplingFeature_should_add_a_relatedSamplingFeature.

@Test
public final void addRelatedSamplingFeature_should_add_a_relatedSamplingFeature() {
    final SamplingFeature feature = new SamplingFeature(null);
    final SamplingFeatureComplex relatedSamplingFeature = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature")));
    feature.addRelatedSamplingFeature(relatedSamplingFeature);
    assertThat(feature.isSetRelatedSamplingFeatures(), is(TRUE));
    assertThat(feature.getRelatedSamplingFeatures(), hasSize(1));
    assertThat(feature.getRelatedSamplingFeatures().get(0), is(relatedSamplingFeature));
    final SamplingFeatureComplex relatedSamplingFeature2 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-2")));
    feature.addRelatedSamplingFeature(relatedSamplingFeature2);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2);
    feature.addRelatedSamplingFeature(null);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2);
}
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 3 with SamplingFeature

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

the class SamplingFeatureTest method validate.

private void validate(final SamplingFeature feature, final SamplingFeatureComplex... relatedSamplingFeatures) {
    assertThat(feature.isSetRelatedSamplingFeatures(), is(TRUE));
    assertThat(feature.getRelatedSamplingFeatures(), hasSize(relatedSamplingFeatures.length));
    for (final SamplingFeatureComplex relatedSamplingFeature : relatedSamplingFeatures) {
        assertThat(feature.getRelatedSamplingFeatures(), hasItem(relatedSamplingFeature));
    }
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex)

Example 4 with SamplingFeature

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

the class SamplingFeatureTest method addAllRelatedSamplingFeatures_should_add_all_elements.

@Test
public final void addAllRelatedSamplingFeatures_should_add_all_elements() {
    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.addAllRelatedSamplingFeatures(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.addAllRelatedSamplingFeatures(list);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2, 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 5 with SamplingFeature

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

the class MeasurementDecodingTest method testFeatureOfInterestSampledFeatures.

@Test
public void testFeatureOfInterestSampledFeatures() {
    assertThat(observation, is(notNullValue()));
    final OmObservationConstellation oc = observation.getObservationConstellation();
    assertThat(oc, is(notNullValue()));
    final AbstractFeature foi = oc.getFeatureOfInterest();
    assertThat(foi, is(notNullValue()));
    assertThat(foi, is(instanceOf(SamplingFeature.class)));
    SamplingFeature sf = (SamplingFeature) foi;
    assertThat(sf.getSampledFeatures(), is(notNullValue()));
    assertThat(sf.getSampledFeatures().size(), is(3));
    final AbstractFeature af1 = sf.getSampledFeatures().get(0);
    assertThat(af1, is(notNullValue()));
    assertThat(af1.getIdentifierCodeWithAuthority(), is(notNullValue()));
    assertThat(af1.getIdentifierCodeWithAuthority().getValue(), is(equalTo("sampledFeature1")));
    final AbstractFeature af2 = sf.getSampledFeatures().get(1);
    assertThat(af2, is(notNullValue()));
    assertThat(af2.getIdentifierCodeWithAuthority(), is(notNullValue()));
    assertThat(af2.getIdentifierCodeWithAuthority().getValue(), is(equalTo("sampledFeature2")));
    assertThat(af2.getName(), is(notNullValue()));
    assertThat(af2.getName().size(), is(1));
    assertThat(af2.getName().get(0), is(not(nullValue())));
    assertThat(af2.getName().get(0).isSetCodeSpace(), is(false));
    assertThat(af2.getName().get(0).getValue(), is(equalTo("sampledFeature2")));
    assertThat(af2, is(instanceOf(SamplingFeature.class)));
    SamplingFeature sf2 = (SamplingFeature) af2;
    assertThat(sf2.getGeometry(), is(notNullValue()));
    assertThat(sf2.getGeometry().getCoordinate().x, is(51.0));
    assertThat(sf2.getGeometry().getCoordinate().y, is(8.0));
    final AbstractFeature af3 = sf.getSampledFeatures().get(2);
    assertThat(af3, is(notNullValue()));
    assertThat(af3.getIdentifierCodeWithAuthority(), is(notNullValue()));
    assertThat(af3.getIdentifierCodeWithAuthority().getValue(), is(equalTo("sampledFeature3")));
}
Also used : AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Test(org.junit.Test)

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