use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class UVFEncoder method writeLine3.
private void writeLine3(Writer fw, OmObservation o, String lineEnding) throws IOException {
// 3.Zeile 88888 0 0 0.000
StringBuilder sb = new StringBuilder(45);
if (o.getObservationConstellation().isSetIdentifier()) {
sb.append(ensureIdentifierLength(o.getObservationConstellation().getIdentifier(), UVFConstants.MAX_IDENTIFIER_LENGTH));
} else if (o.isSetIdentifier()) {
sb.append(ensureIdentifierLength(o.getIdentifier(), UVFConstants.MAX_IDENTIFIER_LENGTH));
} else {
if (!o.isSetObservationID()) {
o.setObservationID(JavaHelper.generateID(o.toString()));
}
sb.append(ensureIdentifierLength(o.getObservationID(), UVFConstants.MAX_IDENTIFIER_LENGTH));
}
fillWithSpaces(sb, UVFConstants.MAX_IDENTIFIER_LENGTH);
AbstractFeature f = o.getObservationConstellation().getFeatureOfInterest();
if (o.getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) o.getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) f;
// Rechtswert
String xString = sf.isSetGeometry() ? Double.toString(sf.getGeometry().getCoordinate().y) : "";
xString = ensureValueLength(xString, 10);
sb.append(xString);
fillWithSpaces(sb, 25);
// Hochwert
String yString = sf.isSetGeometry() ? Double.toString(sf.getGeometry().getCoordinate().x) : "";
yString = ensureValueLength(yString, 10);
sb.append(yString);
fillWithSpaces(sb, 35);
if (sf.isSetGeometry() && !Double.isNaN(sf.getGeometry().getCoordinate().z)) {
String zString = Double.toString(sf.getGeometry().getCoordinate().z);
zString = ensureValueLength(zString, 10);
sb.append(zString);
}
}
fillWithSpaces(sb, 45);
writeToFile(fw, sb.toString(), lineEnding);
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class MeasurementDecodingTest method testProcedure.
@Test
public void testProcedure() {
assertThat(observation, is(notNullValue()));
final OmObservationConstellation oc = observation.getObservationConstellation();
assertThat(oc, is(notNullValue()));
final AbstractFeature p = oc.getProcedure();
assertThat(p, is(notNullValue()));
assertThat(p.getIdentifier(), is(equalTo(PROCEDURE)));
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class MeasurementDecodingTest method testFeatureOfInterest.
@Test
public void testFeatureOfInterest() {
assertThat(observation, is(notNullValue()));
final OmObservationConstellation oc = observation.getObservationConstellation();
assertThat(oc, is(notNullValue()));
final AbstractFeature foi = oc.getFeatureOfInterest();
assertThat(foi, is(notNullValue()));
}
use of org.n52.shetland.ogc.gml.AbstractFeature 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")));
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class InsertSensorRequestDecoder method parseProcedureDescription.
private SosProcedureDescription<?> parseProcedureDescription(JsonNode path, String pdf) throws DecodingException {
try {
final XmlObject xb = XmlObject.Factory.parse(path.textValue());
Decoder<?, XmlObject> decoder = getProcedureDescriptionDecoder(pdf, xb);
if (decoder == null) {
throw new DecodingException(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, "The requested %s is not supported!", JSONConstants.PROCEDURE_DESCRIPTION_FORMAT);
}
Object decode = decoder.decode(xb);
if (decode instanceof SosProcedureDescription<?>) {
return (SosProcedureDescription<?>) decode;
} else if (decode instanceof AbstractFeature) {
return new SosProcedureDescription<AbstractFeature>((AbstractFeature) decode);
} else {
throw new DecodingException("The decoded element {} is not of type {}!", decode.getClass().getName(), AbstractFeature.class.getName());
}
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
}
}
Aggregations