use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class ProfileObservation method setFeatureGeometry.
private void setFeatureGeometry(List<Coordinate> coordinates, int srid) {
AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
Coordinate[] coords = coordinates.toArray(new Coordinate[0]);
try {
LineString lineString = new GeometryFactory().createLineString(coords);
lineString.setSRID(srid);
sf.setGeometry(lineString);
sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
} catch (InvalidSridException e) {
// TODO
}
}
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class TrajectoryObservation method checkForFeature.
/**
* Create geometry for featureOfInterest from
* {@link TimeLocationValueTriple}s
*
* @param values
* The {@link TimeLocationValueTriple}s to check for
* featureOfInterest
*/
private void checkForFeature(List<TimeLocationValueTriple> values) {
AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
Coordinate[] coords = getCoordinates(values);
int srid = 0;
if (sf.isSetGeometry()) {
srid = sf.getGeometry().getSRID();
coords = (Coordinate[]) ArrayUtils.addAll(sf.getGeometry().getCoordinates(), coords);
} else {
TimeLocationValueTriple next = values.iterator().next();
if (next.isSetLocation()) {
srid = next.getLocation().getSRID();
}
}
try {
if (coords.length == 1) {
Point point = new GeometryFactory().createPoint(coords[0]);
point.setSRID(srid);
sf.setGeometry(point);
} else if (coords.length > 1) {
LineString lineString = new GeometryFactory().createLineString(coords);
lineString.setSRID(srid);
sf.setGeometry(lineString);
}
} catch (InvalidSridException e) {
// TODO
}
}
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class MeasurementDecodingTest method testFeatureOfInterestName.
@Test
public void testFeatureOfInterestName() {
assertThat(observation, is(notNullValue()));
final OmObservationConstellation oc = observation.getObservationConstellation();
assertThat(oc, is(notNullValue()));
final AbstractFeature foi = oc.getFeatureOfInterest();
assertThat(foi, is(notNullValue()));
final List<CodeType> name = foi.getName();
assertThat(name, is(notNullValue()));
assertThat(name.size(), is(3));
assertThat(name.get(0), is(notNullValue()));
assertThat(name.get(0).getValue(), is(equalTo(FEATURE_NAME)));
assertThat(name.get(0).getCodeSpace().toString(), is(equalTo("http://x.y/z")));
assertThat(name.get(1), is(notNullValue()));
assertThat(name.get(1).getValue(), is(equalTo("othername1")));
assertThat(name.get(1).isSetCodeSpace(), is(false));
assertThat(name.get(2), is(notNullValue()));
assertThat(name.get(2).getValue(), is(equalTo("othername2")));
assertThat(name.get(2).isSetCodeSpace(), is(false));
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class MeasurementDecodingTest method testFeatureOfInterestIdentifier.
@Test
public void testFeatureOfInterestIdentifier() {
assertThat(observation, is(notNullValue()));
final OmObservationConstellation oc = observation.getObservationConstellation();
assertThat(oc, is(notNullValue()));
final AbstractFeature foi = oc.getFeatureOfInterest();
assertThat(foi, is(notNullValue()));
assertThat(foi.getIdentifierCodeWithAuthority(), is(notNullValue()));
assertThat(foi.getIdentifierCodeWithAuthority().getCodeSpace(), is(equalTo(UNKNOWN_CODESPACE)));
assertThat(foi.getIdentifierCodeWithAuthority().getValue(), is(equalTo(FEATURE_IDENTIFIER)));
}
use of org.n52.shetland.ogc.gml.AbstractFeature 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