Search in sources :

Example 1 with FeaturePropertyType

use of net.opengis.gml.FeaturePropertyType in project arctic-sea by 52North.

the class GmlEncoderv311 method createFeature.

private XmlObject createFeature(AbstractFeature sosAbstractFeature) throws EncodingException {
    if (sosAbstractFeature instanceof SamplingFeature) {
        SamplingFeature sampFeat = (SamplingFeature) sosAbstractFeature;
        if (sosAbstractFeature.isSetGmlID()) {
            FeaturePropertyType featureProperty = FeaturePropertyType.Factory.newInstance(getXmlOptions());
            featureProperty.setHref("#" + sosAbstractFeature.getGmlId());
            return featureProperty;
        } else {
            if (!sampFeat.isSetGeometry()) {
                FeaturePropertyType featureProperty = FeaturePropertyType.Factory.newInstance(getXmlOptions());
                featureProperty.setHref(sosAbstractFeature.getIdentifierCodeWithAuthority().getValue());
                if (sampFeat.isSetName()) {
                    featureProperty.setTitle(sampFeat.getFirstName().getValue());
                }
                return featureProperty;
            }
            StringBuilder builder = new StringBuilder();
            builder.append("sf_");
            builder.append(JavaHelper.generateID(sosAbstractFeature.getIdentifierCodeWithAuthority().getValue()));
            sosAbstractFeature.setGmlId(builder.toString());
            Encoder<XmlObject, SamplingFeature> encoder = getEncoder(SfConstants.NS_SA, sampFeat);
            return encoder.encode(sampFeat);
        }
    } else if (sosAbstractFeature instanceof FeatureCollection) {
        return createFeatureCollection((FeatureCollection) sosAbstractFeature);
    }
    throw new UnsupportedEncoderInputException(this, sosAbstractFeature);
}
Also used : FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) FeaturePropertyType(net.opengis.gml.FeaturePropertyType) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 2 with FeaturePropertyType

use of net.opengis.gml.FeaturePropertyType in project arctic-sea by 52North.

the class SamplingEncoderv100 method addValuesToFeature.

private void addValuesToFeature(SamplingFeatureType xbSamplingFeature, AbstractSamplingFeature sampFeat) throws EncodingException {
    xbSamplingFeature.setId(sampFeat.getGmlId());
    if (sampFeat.isSetIdentifier()) {
        sampFeat.getIdentifierCodeWithAuthority().setCodeSpace("uniquID");
        xbSamplingFeature.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, sampFeat.getIdentifierCodeWithAuthority()));
    }
    if (sampFeat.isSetName()) {
        for (CodeType sosName : sampFeat.getName()) {
            xbSamplingFeature.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, sosName));
        }
    }
    // TODO: CHECK
    if (sampFeat.getSampledFeatures() != null && !sampFeat.getSampledFeatures().isEmpty()) {
        for (AbstractFeature sampledFeature : sampFeat.getSampledFeatures()) {
            FeaturePropertyType sp = xbSamplingFeature.addNewSampledFeature();
            sp.setHref(sampledFeature.getIdentifier());
            if (sampFeat.isSetName() && sampFeat.getFirstName().isSetValue()) {
                sp.setTitle(sampFeat.getFirstName().getValue());
            }
        // xbSamplingFeature.addNewSampledFeature().set(createFeature(sampledFeature));
        }
    } else {
        xbSamplingFeature.addNewSampledFeature().setHref(GmlConstants.NIL_UNKNOWN);
    }
    // set metadataProperty
    setMetaDataProperty(xbSamplingFeature, sampFeat);
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeaturePropertyType(net.opengis.sampling.x10.SamplingFeaturePropertyType) FeaturePropertyType(net.opengis.gml.FeaturePropertyType)

Aggregations

FeaturePropertyType (net.opengis.gml.FeaturePropertyType)2 SamplingFeaturePropertyType (net.opengis.sampling.x10.SamplingFeaturePropertyType)1 XmlObject (org.apache.xmlbeans.XmlObject)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)1 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1