use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class ObservationEncoder method getFieldForValue.
private SweField getFieldForValue(String phenomenon, Value<?> value) throws EncodingException {
final SweAbstractDataComponent def;
if (value instanceof BooleanValue) {
def = new SweBoolean();
} else if (value instanceof CategoryValue) {
SweCategory sweCategory = new SweCategory();
CategoryValue categoryValue = (CategoryValue) value;
sweCategory.setCodeSpace(categoryValue.getUnit());
def = sweCategory;
} else if (value instanceof CountValue) {
def = new SweCount();
} else if (value instanceof QuantityValue) {
SweQuantity sweQuantity = new SweQuantity();
QuantityValue quantityValue = (QuantityValue) value;
sweQuantity.setUom(quantityValue.getUnit());
def = sweQuantity;
} else if (value instanceof TextValue) {
def = new SweText();
} else if (value instanceof NilTemplateValue) {
def = new SweText();
} else if (value instanceof BooleanValue) {
def = new SweBoolean();
} else if (value instanceof GeometryValue) {
def = new SweText();
} else {
throw new UnsupportedEncoderInputException(this, value);
}
def.setDefinition(phenomenon);
return new SweField(phenomenon, def);
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractObservationResponseEncoder method encodeResponse.
@Override
protected void encodeResponse(ObjectNode json, T t) throws EncodingException {
ArrayNode obs = json.putArray(JSONConstants.OBSERVATIONS);
try {
ObservationStream observationCollection = t.getObservationCollection();
encodeObservationStream(observationCollection, obs);
} catch (OwsExceptionReport ex) {
throw new EncodingException(ex);
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class FeatureOfInterestEncoder method encodeFeatureCollection.
private JsonNode encodeFeatureCollection(AbstractFeature t) throws EncodingException {
FeatureCollection featureCollection = (FeatureCollection) t;
ArrayNode a = nodeFactory().arrayNode();
for (AbstractFeature af : featureCollection) {
a.add(encodeObjectToJson(af));
}
return a;
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractMonitoringFeatureEncoder method setInvolvedIn.
private void setInvolvedIn(AbstractMonitoringFeatureType amft, AbstractMonitoringFeature abstractMonitoringFeature) throws EncodingException {
if (abstractMonitoringFeature.isSetInvolvedIn()) {
for (EnvironmentalMonitoringActivity environmentalMonitoringActivity : abstractMonitoringFeature.getInvolvedIn()) {
if (environmentalMonitoringActivity.isSetSimpleAttrs()) {
InvolvedIn ii = amft.addNewInvolvedIn();
ii.setHref(environmentalMonitoringActivity.getSimpleAttrs().getHref());
if (environmentalMonitoringActivity.getSimpleAttrs().isSetTitle()) {
ii.setTitle(environmentalMonitoringActivity.getSimpleAttrs().getTitle());
}
} else {
amft.addNewInvolvedIn().addNewEnvironmentalMonitoringActivity().set(encodeEF(environmentalMonitoringActivity));
}
}
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractMonitoringObjectEncoder method setNarrower.
private void setNarrower(AbstractMonitoringObjectType amot, AbstractMonitoringObject abstractMonitoringObject) throws EncodingException {
if (abstractMonitoringObject.isSetNarrower()) {
for (Hierarchy narrower : abstractMonitoringObject.getNarrower()) {
if (narrower.isSetSimpleAttrs()) {
Narrower n = amot.addNewNarrower();
n.setHref(narrower.getSimpleAttrs().getHref());
if (narrower.getSimpleAttrs().isSetTitle()) {
n.setTitle(narrower.getSimpleAttrs().getTitle());
}
} else {
amot.addNewNarrower().addNewHierarchy().set(encodeEF(narrower));
}
}
}
}
Aggregations