use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class SamplingEncoderv100 method createFeatureCollection.
private XmlObject createFeatureCollection(FeatureCollection sosFeatureCollection) throws EncodingException {
SamplingFeatureCollectionDocument xbSampFeatCollDoc = SamplingFeatureCollectionDocument.Factory.newInstance(getXmlOptions());
SamplingFeatureCollectionType xbSampFeatColl = xbSampFeatCollDoc.addNewSamplingFeatureCollection();
xbSampFeatColl.setId("sfc_" + Long.toString(new DateTime().getMillis()));
for (AbstractFeature sosAbstractFeature : sosFeatureCollection.getMembers().values()) {
SamplingFeaturePropertyType xbFeatMember = xbSampFeatColl.addNewMember();
xbFeatMember.set(createFeature(sosAbstractFeature));
}
return xbSampFeatCollDoc;
}
use of org.n52.shetland.ogc.gml.AbstractFeature in project arctic-sea by 52North.
the class SamplingEncoderv20 method createFeature.
protected XmlObject createFeature(final AbstractFeature absFeature) throws EncodingException {
if (absFeature instanceof AbstractSamplingFeature) {
final AbstractSamplingFeature sampFeat = (AbstractSamplingFeature) absFeature;
final SFSpatialSamplingFeatureDocument xbSampFeatDoc = SFSpatialSamplingFeatureDocument.Factory.newInstance(getXmlOptions());
if (sampFeat.isSetXml()) {
try {
final XmlObject feature = XmlObject.Factory.parse(sampFeat.getXml(), getXmlOptions());
if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SAMS)) {
XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), absFeature.getGmlId(), null);
if (feature instanceof SFSpatialSamplingFeatureType) {
xbSampFeatDoc.setSFSpatialSamplingFeature((SFSpatialSamplingFeatureType) feature);
encodeShape(xbSampFeatDoc.getSFSpatialSamplingFeature().getShape(), sampFeat);
addNameDescription(xbSampFeatDoc.getSFSpatialSamplingFeature(), sampFeat);
return xbSampFeatDoc;
}
encodeShape(((SFSpatialSamplingFeatureDocument) feature).getSFSpatialSamplingFeature().getShape(), sampFeat);
addNameDescription(((SFSpatialSamplingFeatureDocument) feature).getSFSpatialSamplingFeature(), sampFeat);
sampFeat.wasEncoded();
return feature;
} else {
return encodeObjectToXml(XmlHelper.getNamespace(feature), absFeature);
}
} catch (final XmlException xmle) {
throw new EncodingException("Error while encoding GetFeatureOfInterest response, invalid samplingFeature description!", xmle);
}
}
final SFSpatialSamplingFeatureType xbSampFeature = xbSampFeatDoc.addNewSFSpatialSamplingFeature();
// TODO: CHECK for all fields set gml:id
addId(xbSampFeature, sampFeat);
addIdentifier(xbSampFeature, sampFeat);
// set type
addFeatureType(xbSampFeature, sampFeat);
// set type
addNameDescription(xbSampFeature, sampFeat);
setMetaDataProperty(xbSampFeature, sampFeat);
// set sampledFeatures
// TODO: CHECK
addSampledFeatures(xbSampFeature, sampFeat);
addParameter(xbSampFeature, sampFeat);
// set position
encodeShape(xbSampFeature.addNewShape(), sampFeat);
sampFeat.wasEncoded();
return xbSampFeatDoc;
}
throw new UnsupportedEncoderInputException(this, absFeature);
}
Aggregations