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