use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class SosV1GetCapabilitiesResponseEncoder method setContents.
/**
* Sets the content section to the Capabilities document.
*
* @param xbContents SOS 2.0 contents section
* @param offerings SOS offerings for contents
* @param version SOS response version
*
* @throws EncodingException * if an error occurs.
*/
protected void setContents(Contents xbContents, Collection<SosObservationOffering> offerings, String version) throws EncodingException {
// Contents xbContType = xbContents.addNewContents();
ObservationOfferingList xbObservationOfferings = xbContents.addNewObservationOfferingList();
for (SosObservationOffering offering : offerings) {
ObservationOfferingType xbObservationOffering = xbObservationOfferings.addNewObservationOffering();
// TODO check NAme or ID
xbObservationOffering.setId(NcName.makeValid(offering.getOffering().getIdentifier()));
// envelope
if (offering.isSetObservedArea()) {
xbObservationOffering.addNewBoundedBy().addNewEnvelope().set(encodeObjectToXml(GmlConstants.NS_GML, offering.getObservedArea()));
}
// set gml:name to offering's id (not ncname resolved)
for (CodeType name : offering.getOffering().getName()) {
xbObservationOffering.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, name));
}
// set up time
if (offering.getPhenomenonTime() instanceof TimePeriod) {
xbObservationOffering.addNewTime().set(encodeObjectToXml(SweConstants.NS_SWE_101, offering.getPhenomenonTime()));
}
offering.getObservableProperties().forEach(phenomenon -> xbObservationOffering.addNewObservedProperty().setHref(phenomenon));
offering.getFeatureOfInterestTypes().forEach(featureOfInterestType -> xbObservationOffering.addNewFeatureOfInterest().setHref(featureOfInterestType));
offering.getProcedureDescriptionFormats().forEach(procedureDescriptionFormat -> xbObservationOffering.addNewProcedure().setHref(procedureDescriptionFormat));
offering.getProcedures().forEach(procedure -> xbObservationOffering.addNewProcedure().setHref(procedure));
offering.getFeatureOfInterest().forEach(featureOfInterest -> xbObservationOffering.addNewFeatureOfInterest().setHref(featureOfInterest));
offering.getResultModels().forEach(xbObservationOffering::addResultModel);
offering.getResponseFormats().forEach(responseFormat -> xbObservationOffering.addNewResponseFormat().setStringValue(responseFormat));
offering.getResponseModes().forEach(responseMode -> xbObservationOffering.addNewResponseMode().setStringValue(responseMode));
}
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class JSONDecoder method parseTimePeriod.
protected TimePeriod parseTimePeriod(JsonNode node) throws DateTimeParseException {
if (node.isArray()) {
ArrayNode array = (ArrayNode) node;
String startTime = array.get(0).textValue();
String endTime = array.get(1).textValue();
DateTime start = parseDateTime(startTime);
DateTime end = parseDateTime(endTime);
return new TimePeriod(start, end);
} else {
return null;
}
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class UVFEncoder method getTemporalBBoxFromObservations.
private TimePeriod getTemporalBBoxFromObservations(List<OmObservation> observationCollection) throws EncodingException {
DateTime start = null;
DateTime end = null;
for (OmObservation observation : observationCollection) {
Time phenomenonTime = observation.getPhenomenonTime();
if (phenomenonTime instanceof TimeInstant) {
final DateTime time = ((TimeInstant) phenomenonTime).getTimePosition().getTime();
if (start == null || time.isBefore(start)) {
start = time;
}
if (end == null || time.isAfter(end)) {
end = time;
}
} else {
final DateTime periodStart = ((TimePeriod) phenomenonTime).getStart();
if (start == null || periodStart.isBefore(start)) {
start = periodStart;
}
final DateTime periodEnd = ((TimePeriod) phenomenonTime).getEnd();
if (end == null || periodEnd.isAfter(end)) {
end = periodEnd;
}
}
}
if (start != null && end != null) {
return new TimePeriod(start, end);
} else {
final String message = "Could not extract centuries from observation collection";
LOGGER.error(message);
throw new EncodingException(message);
}
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class UVFEncoder method writeLine2.
private void writeLine2(Writer fw, OmObservation o, TimePeriod centuries, String lineEnding) throws IOException {
// 2.Zeile ABFLUSS m3/s 1900 1900
StringBuilder sb = new StringBuilder(39);
// Identifier
AbstractPhenomenon observableProperty = o.getObservationConstellation().getObservableProperty();
String observablePropertyIdentifier = observableProperty.getIdentifier();
if (observablePropertyIdentifier != null && !observablePropertyIdentifier.isEmpty()) {
observablePropertyIdentifier = ensureIdentifierLength(observablePropertyIdentifier, UVFConstants.MAX_IDENTIFIER_LENGTH);
}
sb.append(observablePropertyIdentifier);
fillWithSpaces(sb, UVFConstants.MAX_IDENTIFIER_LENGTH);
// Unit (optional)
String unit = getUnit(o);
if (unit != null && !unit.isEmpty()) {
unit = ensureIdentifierLength(unit, UVFConstants.MAX_IDENTIFIER_LENGTH);
sb.append(" ");
sb.append(unit);
}
fillWithSpaces(sb, 30);
// Centuries
sb.append(centuries.getStart().getCenturyOfEra() + "00 " + centuries.getEnd().getCenturyOfEra() + "00");
writeToFile(fw, sb.toString(), lineEnding);
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class AqdEncoder method processObservation.
protected void processObservation(OmObservation observation, TimePeriod timePeriod, TimeInstant resultTime, FeatureCollection featureCollection, AbstractEReportingHeader eReportingHeader, int counter) {
if (observation.isSetPhenomenonTime()) {
// generate gml:id
observation.setGmlId(getObservationId(counter));
// add xlink:href to eReportingHeader.content
eReportingHeader.addContent((AbstractFeature) new OmObservation().setIdentifier(new CodeWithAuthority(getObservationXlink(observation.getGmlId()))));
timePeriod.extendToContain(observation.getPhenomenonTime());
observation.setResultTime(resultTime);
featureCollection.addMember(observation);
}
}
Aggregations