use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method encodeOffering.
private JsonNode encodeOffering(SosObservationOffering soo) throws EncodingException {
if (soo == null) {
return nodeFactory().nullNode();
}
ObjectNode jsoo = nodeFactory().objectNode();
SosOffering offering = soo.getOffering();
jsoo.put(JSONConstants.IDENTIFIER, offering.getIdentifier());
if (offering.isSetName()) {
jsoo.put(JSONConstants.NAME, offering.getFirstName().getValue());
}
if (soo.isSetProcedures()) {
jsoo.set(JSONConstants.PROCEDURE, soo.getProcedures().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
}
if (soo.isSetObservableProperties()) {
jsoo.set(JSONConstants.OBSERVABLE_PROPERTY, soo.getObservableProperties().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
}
if (soo.isSetRelatedFeature()) {
ArrayNode jrf = jsoo.putArray(JSONConstants.RELATED_FEATURE);
soo.getRelatedFeatures().forEach((feature, roles) -> {
jrf.addObject().put(JSONConstants.FEATURE_OF_INTEREST, feature).set(JSONConstants.ROLE, roles.stream().map(nodeFactory()::textNode).collect(toJsonArray()));
});
}
if (soo.isSetObservedArea() && soo.getObservedArea().isSetEnvelope() && soo.getObservedArea().isSetSrid()) {
Envelope e = soo.getObservedArea().getEnvelope();
ObjectNode oa = jsoo.putObject(JSONConstants.OBSERVED_AREA);
oa.putArray(JSONConstants.LOWER_LEFT).add(e.getMinX()).add(e.getMinY());
oa.putArray(JSONConstants.UPPER_RIGHT).add(e.getMaxX()).add(e.getMaxY());
oa.putObject(JSONConstants.CRS).put(JSONConstants.TYPE, JSONConstants.LINK).putObject(JSONConstants.PROPERTIES).put(JSONConstants.HREF, GeoJSONEncoder.SRID_LINK_PREFIX + soo.getObservedArea().getSrid());
}
if (soo.isSetPhenomenonTime()) {
jsoo.set(JSONConstants.PHENOMENON_TIME, encodeObjectToJson(soo.getPhenomenonTime()));
}
if (soo.isSetResultTime()) {
jsoo.set(JSONConstants.RESULT_TIME, encodeObjectToJson(soo.getResultTime()));
}
if (soo.isSetResponseFormats()) {
jsoo.set(JSONConstants.RESPONSE_FORMAT, soo.getResponseFormats().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
}
if (soo.isSetObservationTypes()) {
jsoo.set(JSONConstants.OBSERVATION_TYPE, soo.getObservationTypes().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
}
if (soo.isSetFeatureOfInterestTypes()) {
jsoo.set(JSONConstants.FEATURE_OF_INTEREST_TYPE, soo.getFeatureOfInterestTypes().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
}
if (soo.isSetProcedureDescriptionFormats()) {
jsoo.set(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, soo.getProcedureDescriptionFormats().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
}
// TODO soo.getResponseModes();
return jsoo;
}
use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method encodeResultTime.
private void encodeResultTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
// set resultTime [0..1]
if (offering.getResultTime() instanceof TimePeriod) {
TimePeriod tp = (TimePeriod) offering.getResultTime();
tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_RESULT_TIME, offeringCounter));
if (!tp.isEmpty()) {
XmlObject xmlObject = encodeGml(tp);
xbObsOff.addNewResultTime().addNewTimePeriod().set(xmlObject);
xbObsOff.getResultTime().substitute(Sos2Constants.QN_SOS_RESULT_TIME, xbObsOff.getResultTime().schemaType());
}
}
}
use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder 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 {
final ContentsType xbContType = xbContents.addNewContents();
// for gml:id generation
int offeringCounter = 0;
for (final SosObservationOffering offering : offerings) {
if (offering.isValidObservationOffering()) {
++offeringCounter;
encodeObservationOffering(offering, offeringCounter, xbContType);
}
}
// FIXME: change swes:AbstractOffering to sos:ObservationOffering and
// the namespace prefix ns to sos due to
// XMLBeans problems with substitution
// (http://www.mail-archive.com/dev%40xmlbeans.apache.org/msg00962.html).
renameContentsElementNames(xbContents);
}
use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method encodePhenomenonTime.
private void encodePhenomenonTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
// set up phenomenon time [0..1]
if (offering.getPhenomenonTime() instanceof TimePeriod) {
TimePeriod tp = (TimePeriod) offering.getPhenomenonTime();
if (!tp.isEmpty()) {
tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_PHENOMENON_TIME, offeringCounter));
XmlObject xmlObject = encodeGml(tp);
xbObsOff.addNewPhenomenonTime().addNewTimePeriod().set(xmlObject);
xbObsOff.getPhenomenonTime().substitute(Sos2Constants.QN_SOS_PHENOMENON_TIME, xbObsOff.getPhenomenonTime().schemaType());
}
}
}
use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method encodeObservationOffering.
private void encodeObservationOffering(SosObservationOffering offering, int offeringCounter, ContentsType xbContType) throws EncodingException {
final ObservationOfferingType xbObsOff = ObservationOfferingType.Factory.newInstance(getXmlOptions());
SosOffering sosOffering = offering.getOffering();
xbObsOff.setIdentifier(sosOffering.getIdentifier());
if (sosOffering.isSetName()) {
for (CodeType name : sosOffering.getName()) {
xbObsOff.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML_32, name));
}
}
if (sosOffering.isSetDescription()) {
xbObsOff.setDescription(sosOffering.getDescription());
}
encodeOfferingExtension(offering, xbObsOff);
offering.getProcedures().forEach(xbObsOff::setProcedure);
encodeObservableProperties(offering, xbObsOff);
encodeRelatedFeatures(offering, xbObsOff);
encodeObservedArea(offering, xbObsOff);
encodePhenomenonTime(offering, offeringCounter, xbObsOff);
encodeResultTime(offering, offeringCounter, xbObsOff);
encodeResponseFormat(offering, xbObsOff);
encodeObservationType(offering, xbObsOff);
encodeFeatureOfInterestTypes(offering, xbObsOff);
encodeProcedureDescriptionFormats(offering, xbObsOff);
xbContType.addNewOffering().setAbstractOffering(xbObsOff);
/*
* Offering addNewOffering = xbContType.addNewOffering();
* addNewOffering.addNewAbstractOffering().set(xbObsOff); XmlHelper
* .substituteElement(addNewOffering.getAbstractOffering(), xbObsOff);
*/
}
Aggregations