Search in sources :

Example 1 with MonitoringPointType

use of net.opengis.waterml.x20.MonitoringPointType in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method addVerticalDatum.

private void addVerticalDatum(MonitoringPointType mpt, List<Referenceable<VerticalDatum>> verticalDatums) throws EncodingException {
    for (Referenceable<VerticalDatum> verticalDatum : verticalDatums) {
        VerticalDatumPropertyType vdpt = mpt.addNewVerticalDatum();
        if (verticalDatum.isReference()) {
            Reference reference = verticalDatum.getReference();
            reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(vdpt::setActuate);
            reference.getArcrole().ifPresent(vdpt::setArcrole);
            reference.getHref().map(URI::toString).ifPresent(vdpt::setHref);
            reference.getRole().ifPresent(vdpt::setRole);
            reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(vdpt::setShow);
            reference.getTitle().ifPresent(vdpt::setTitle);
            reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(vdpt::setType);
        } else {
            if (verticalDatum.isInstance()) {
                Nillable<VerticalDatum> nillable = verticalDatum.getInstance();
                if (nillable.isPresent()) {
                    XmlObject xml = encodeGML(nillable.get());
                    if (xml != null && xml instanceof VerticalDatumType) {
                        vdpt.setVerticalDatum((VerticalDatumType) xml);
                    } else {
                        vdpt.setNil();
                        vdpt.setNilReason(Nillable.missing().get());
                    }
                } else {
                    vdpt.setNil();
                    if (nillable.hasReason()) {
                        vdpt.setNilReason(nillable.getNilReason().get());
                    } else {
                        vdpt.setNilReason(Nillable.missing().get());
                    }
                }
            }
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) Reference(org.n52.shetland.w3c.xlink.Reference) VerticalDatum(org.n52.shetland.ogc.gml.VerticalDatum) Actuate(org.n52.shetland.w3c.xlink.Actuate) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CodeType(org.n52.shetland.ogc.gml.CodeType) MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) CollectionType(net.opengis.waterml.x20.CollectionType) MediaType(org.n52.janmayen.http.MediaType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) OMObservationType(net.opengis.om.x20.OMObservationType) ShowType(org.w3.x1999.xlink.ShowType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 2 with MonitoringPointType

use of net.opengis.waterml.x20.MonitoringPointType in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method createMonitoringPoint.

/**
 * Creates a WaterML 2.0 MonitoringPoint XML object from SOS feature object
 *
 * @param absFeature
 *            SOS feature
 * @return WaterML 2.0 MonitoringPoint XML object
 * @throws EncodingException
 *             If an error occurs
 */
protected XmlObject createMonitoringPoint(AbstractFeature absFeature) throws EncodingException {
    if (absFeature instanceof AbstractSamplingFeature) {
        AbstractSamplingFeature sampFeat = (AbstractSamplingFeature) absFeature;
        StringBuilder builder = new StringBuilder();
        builder.append("mp_");
        builder.append(JavaHelper.generateID(absFeature.getIdentifierCodeWithAuthority().getValue()));
        absFeature.setGmlId(builder.toString());
        MonitoringPointDocument monitoringPointDoc = MonitoringPointDocument.Factory.newInstance(getXmlOptions());
        if (sampFeat.isSetXml()) {
            try {
                XmlObject feature = XmlObject.Factory.parse(sampFeat.getXml());
                if (XmlHelper.getNamespace(feature).equals(WaterMLConstants.NS_WML_20)) {
                    if (feature instanceof MonitoringPointDocument) {
                        monitoringPointDoc = (MonitoringPointDocument) feature;
                    } else if (feature instanceof MonitoringPointType) {
                        monitoringPointDoc.setSFSpatialSamplingFeature((MonitoringPointType) feature);
                    }
                    XmlHelper.updateGmlIDs(monitoringPointDoc.getDomNode(), absFeature.getGmlId(), null);
                    return monitoringPointDoc;
                }
            } catch (XmlException xmle) {
                throw new EncodingException("Error while encoding GetFeatureOfInterest response, invalid samplingFeature description!", xmle);
            }
        }
        MonitoringPointType mpt = monitoringPointDoc.addNewMonitoringPoint();
        // set gml:id
        mpt.setId(absFeature.getGmlId());
        if (sampFeat.isSetIdentifier()) {
            XmlObject xmlObject = encodeGML(sampFeat.getIdentifierCodeWithAuthority());
            if (xmlObject != null) {
                mpt.addNewIdentifier().set(xmlObject);
            }
        }
        if (sampFeat.isSetName()) {
            for (CodeType sosName : sampFeat.getName()) {
                mpt.addNewName().set(encodeGML(sosName));
            }
        }
        if (sampFeat.isSetDescription()) {
            if (!mpt.isSetDescription()) {
                mpt.addNewDescription();
            }
            mpt.getDescription().setStringValue(sampFeat.getDescription());
        }
        // TODO: CHECK
        if (sampFeat.getSampledFeatures() != null && !sampFeat.getSampledFeatures().isEmpty()) {
            if (sampFeat.getSampledFeatures().size() == 1) {
                XmlObject encodeObjectToXml = encodeObjectToXml(GmlConstants.NS_GML_32, sampFeat.getSampledFeatures().get(0));
                mpt.addNewSampledFeature().set(encodeObjectToXml);
            } else {
                FeatureCollection featureCollection = new FeatureCollection();
                featureCollection.setGmlId("sampledFeatures_" + absFeature.getGmlId());
                for (AbstractFeature sampledFeature : sampFeat.getSampledFeatures()) {
                    featureCollection.addMember(sampledFeature);
                }
                XmlObject encodeObjectToXml = encodeGML(featureCollection);
                mpt.addNewSampledFeature().set(encodeObjectToXml);
            }
        } else {
            mpt.addNewSampledFeature().setHref(GmlConstants.NIL_UNKNOWN);
        }
        if (sampFeat.isSetParameter()) {
            addParameter(mpt, sampFeat);
        }
        // set position
        ShapeType xbShape = mpt.addNewShape();
        Encoder<XmlObject, Geometry> encoder = getEncoder(getEncoderKey(GmlConstants.NS_GML_32, sampFeat.getGeometry()));
        if (encoder != null) {
            XmlObject xmlObject = encoder.encode(sampFeat.getGeometry(), new EncodingContext().with(XmlBeansEncodingFlags.GMLID, absFeature.getGmlId()));
            xbShape.addNewAbstractGeometry().set(xmlObject);
            XmlHelper.substituteElement(xbShape.getAbstractGeometry(), xmlObject);
        } else {
            throw new EncodingException("Error while encoding geometry for feature, needed encoder is missing!");
        }
        if (absFeature instanceof WmlMonitoringPoint) {
            addMonitoringPointValues(mpt, (WmlMonitoringPoint) absFeature);
        }
        sampFeat.wasEncoded();
        return monitoringPointDoc;
    }
    throw new UnsupportedEncoderInputException(this, absFeature);
}
Also used : MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) MonitoringPointDocument(net.opengis.waterml.x20.MonitoringPointDocument) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) EncodingException(org.n52.svalbard.encode.exception.EncodingException) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) WmlMonitoringPoint(org.n52.shetland.ogc.om.series.wml.WmlMonitoringPoint) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) Geometry(org.locationtech.jts.geom.Geometry) FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) XmlException(org.apache.xmlbeans.XmlException) CodeType(org.n52.shetland.ogc.gml.CodeType) XmlObject(org.apache.xmlbeans.XmlObject)

Example 3 with MonitoringPointType

use of net.opengis.waterml.x20.MonitoringPointType in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method addRelatedParty.

private void addRelatedParty(MonitoringPointType mpt, List<Referenceable<CiResponsibleParty>> relatedParties) throws EncodingException {
    for (Referenceable<CiResponsibleParty> relatedParty : relatedParties) {
        CIResponsiblePartyPropertyType citppt = mpt.addNewRelatedParty();
        if (relatedParty.isReference()) {
            Reference reference = relatedParty.getReference();
            reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(citppt::setActuate);
            reference.getArcrole().ifPresent(citppt::setArcrole);
            reference.getHref().map(URI::toString).ifPresent(citppt::setHref);
            reference.getRole().ifPresent(citppt::setRole);
            reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(citppt::setShow);
            reference.getTitle().ifPresent(citppt::setTitle);
            reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(citppt::setType);
        } else {
            if (relatedParty.isInstance()) {
                Nillable<CiResponsibleParty> nillable = relatedParty.getInstance();
                if (nillable.isPresent()) {
                    XmlObject xml = encodeObjectToXml(nillable.get().getDefaultElementEncoding(), nillable.get());
                    if (xml != null && xml instanceof CIResponsiblePartyType) {
                        citppt.setCIResponsibleParty((CIResponsiblePartyType) xml);
                    } else {
                        citppt.setNil();
                        citppt.setNilReason(Nillable.missing().get());
                    }
                } else {
                    citppt.setNil();
                    if (nillable.hasReason()) {
                        citppt.setNilReason(nillable.getNilReason().get());
                    } else {
                        citppt.setNilReason(Nillable.missing().get());
                    }
                }
            }
        }
    }
}
Also used : CiResponsibleParty(org.n52.shetland.iso.gmd.CiResponsibleParty) ActuateType(org.w3.x1999.xlink.ActuateType) Reference(org.n52.shetland.w3c.xlink.Reference) Actuate(org.n52.shetland.w3c.xlink.Actuate) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) VerticalDatumPropertyType(net.opengis.gml.x32.VerticalDatumPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CodeType(org.n52.shetland.ogc.gml.CodeType) MonitoringPointType(net.opengis.waterml.x20.MonitoringPointType) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) ShapeType(net.opengis.samplingSpatial.x20.ShapeType) CollectionType(net.opengis.waterml.x20.CollectionType) MediaType(org.n52.janmayen.http.MediaType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) VerticalDatumType(net.opengis.gml.x32.VerticalDatumType) OMObservationType(net.opengis.om.x20.OMObservationType) ShowType(org.w3.x1999.xlink.ShowType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Aggregations

ShapeType (net.opengis.samplingSpatial.x20.ShapeType)3 MonitoringPointType (net.opengis.waterml.x20.MonitoringPointType)3 XmlObject (org.apache.xmlbeans.XmlObject)3 CodeType (org.n52.shetland.ogc.gml.CodeType)3 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)2 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)2 OMObservationType (net.opengis.om.x20.OMObservationType)2 CollectionType (net.opengis.waterml.x20.CollectionType)2 ObservationProcessType (net.opengis.waterml.x20.ObservationProcessType)2 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)2 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)2 MediaType (org.n52.janmayen.http.MediaType)2 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)2 Actuate (org.n52.shetland.w3c.xlink.Actuate)2 Reference (org.n52.shetland.w3c.xlink.Reference)2 Show (org.n52.shetland.w3c.xlink.Show)2 Type (org.n52.shetland.w3c.xlink.Type)2 ActuateType (org.w3.x1999.xlink.ActuateType)2 ShowType (org.w3.x1999.xlink.ShowType)2 TypeType (org.w3.x1999.xlink.TypeType)2