Search in sources :

Example 1 with AbstractFeature

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);
}
Also used : AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature)

Example 2 with AbstractFeature

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)));
}
Also used : AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Test(org.junit.Test)

Example 3 with AbstractFeature

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()));
}
Also used : AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Test(org.junit.Test)

Example 4 with AbstractFeature

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

Example 5 with AbstractFeature

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);
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject)

Aggregations

AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)33 XmlObject (org.apache.xmlbeans.XmlObject)23 XmlException (org.apache.xmlbeans.XmlException)10 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)10 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)9 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)9 OmObservation (org.n52.shetland.ogc.om.OmObservation)8 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)8 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)8 Test (org.junit.Test)6 LineString (org.locationtech.jts.geom.LineString)6 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)6 EncodingException (org.n52.svalbard.encode.exception.EncodingException)6 FeaturePropertyType (net.opengis.gml.x32.FeaturePropertyType)4 CodeType (org.n52.shetland.ogc.gml.CodeType)4 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)4 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)4 DateTime (org.joda.time.DateTime)3 Time (org.n52.shetland.ogc.gml.time.Time)3