use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SweCommonDecoderV101 method parseEnvelope.
private SweAbstractDataComponent parseEnvelope(EnvelopeType envelopeType) throws DecodingException {
String referenceFrame = null;
SweVector lowerCorner = null;
SweVector upperCorner = null;
SweTimeRange time = null;
if (envelopeType.isSetReferenceFrame()) {
referenceFrame = envelopeType.getReferenceFrame();
}
if (envelopeType.getLowerCorner() != null) {
lowerCorner = parseVectorProperty(envelopeType.getLowerCorner());
}
if (envelopeType.getUpperCorner() != null) {
upperCorner = parseVectorProperty(envelopeType.getUpperCorner());
}
if (envelopeType.isSetTime()) {
time = parseTimeRange(envelopeType.getTime().getTimeRange());
}
// FIXME get the northing first value for the reference frame
boolean northingFirst = false;
return new SweEnvelope(referenceFrame, upperCorner, lowerCorner, time, northingFirst);
}
use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SweCommonDecoderV20 method parseVector.
private SweAbstractDataComponent parseVector(VectorType vector) throws DecodingException {
final SweVector sweVector = new SweVector();
if (vector.isSetLocalFrame()) {
sweVector.setLocalFrame(vector.getLocalFrame());
}
sweVector.setReferenceFrame(vector.getReferenceFrame());
sweVector.setCoordinates(parseCoordinates(vector.getCoordinateArray()));
return sweVector;
}
use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SweCommonDecoderV20 method parseValues.
private List<List<String>> parseValues(final SweCount elementCount, final SweAbstractDataComponent elementType, final SweAbstractEncoding encoding, final EncodedValuesPropertyType encodedValuesPropertyType) throws DecodingException {
if (checkParameterTypes(elementType, encoding)) {
// Get swe values String via cursor as String
String values;
// TODO replace XmlCursor
/*
* if (encodedValuesPropertyType.schemaType() == XmlString.type) {
* XmlString xbString
*/
// @see SosDecoderv20#parseResultValues
XmlCursor xbCursor = encodedValuesPropertyType.newCursor();
xbCursor.toFirstContentToken();
if (xbCursor.isText()) {
values = xbCursor.getTextValue().trim();
xbCursor.dispose();
if (values != null && !values.isEmpty()) {
SweTextEncoding textEncoding = (SweTextEncoding) encoding;
String[] blocks = values.split(textEncoding.getBlockSeparator());
List<List<String>> resultValues = new ArrayList<>(blocks.length);
for (String block : blocks) {
String[] tokens = block.split(textEncoding.getTokenSeparator());
List<String> tokenList = Arrays.asList(tokens);
resultValues.add(tokenList);
}
return resultValues;
}
}
}
return null;
}
use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SwesExtensionDecoderv20 method decode.
@Override
public SwesExtension<?> decode(XmlObject xmlObject) throws DecodingException, UnsupportedDecoderInputException {
if (isSwesExtension(xmlObject)) {
XmlObject[] children = xmlObject.selectPath("./*");
if (children.length == 1) {
Object xmlObj = decodeXmlElement(children[0]);
if (xmlObj instanceof SweAbstractDataComponent) {
SwesExtension<SweAbstractDataComponent> extension = new SwesExtension<>();
extension.setValue((SweAbstractDataComponent) xmlObj);
return extension;
}
}
}
throw new UnsupportedDecoderXmlInputException(this, xmlObject);
}
use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class FieldEncoder method createField.
private ObjectNode createField(SweField field) {
ObjectNode jfield = nodeFactory().objectNode();
jfield.put(JSONConstants.NAME, field.getName().getValue());
SweAbstractDataComponent element = field.getElement();
if (element.isSetDefinition()) {
jfield.put(JSONConstants.DEFINITION, element.getDefinition());
}
if (element.isSetDescription()) {
jfield.put(JSONConstants.DESCRIPTION, element.getDescription());
}
if (element.isSetIdentifier()) {
jfield.put(JSONConstants.IDENTIFIER, element.getIdentifier());
}
if (element.isSetLabel()) {
jfield.put(JSONConstants.LABEL, element.getLabel());
}
return jfield;
}
Aggregations