Search in sources :

Example 1 with PropertyNameType

use of net.opengis.ogc.PropertyNameType in project arctic-sea by 52North.

the class OgcDecoderv100 method parseTemporalOperatorType.

/**
 * parses a single temporal filter of the requests and returns SOS temporal filter
 *
 * @param xbBinaryTemporalOp XmlObject representing the temporal filter
 *
 * @return Returns SOS representation of temporal filter
 *
 * @throws DecodingException if parsing of the element failed
 */
private Object parseTemporalOperatorType(BinaryTemporalOpType xbBinaryTemporalOp) throws DecodingException {
    TemporalFilter temporalFilter = new TemporalFilter();
    // FIXME local workaround against SOSHelper check value reference
    String valueRef = "phenomenonTime";
    try {
        NodeList nodes = xbBinaryTemporalOp.getDomNode().getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            if (nodes.item(i).getNamespaceURI() != null && !nodes.item(i).getLocalName().equals(FilterConstants.EN_VALUE_REFERENCE)) {
                // GML decoder will return TimeInstant or TimePriod
                Object timeObject = decodeXmlElement(XmlObject.Factory.parse(nodes.item(i)));
                if (timeObject instanceof PropertyNameType) {
                    PropertyNameType propType = (PropertyNameType) timeObject;
                // TODO here apply logic for ogc property
                // om:samplingTime etc
                // valueRef = propType.getDomNode().getNodeValue();
                }
                if (timeObject instanceof Time) {
                    TimeOperator operator;
                    Time time = (Time) timeObject;
                    String localName = XmlHelper.getLocalName(xbBinaryTemporalOp);
                    // change to SOS 1.0. TMDuring kind of
                    if (localName.equals(TimeOperator.TM_During.name()) && time instanceof TimePeriod) {
                        operator = TimeOperator.TM_During;
                    } else if (localName.equals(TimeOperator.TM_Equals.name()) && time instanceof TimeInstant) {
                        operator = TimeOperator.TM_Equals;
                    } else if (localName.equals(TimeOperator.TM_After.name()) && time instanceof TimeInstant) {
                        operator = TimeOperator.TM_After;
                    } else if (localName.equals(TimeOperator.TM_Before.name()) && time instanceof TimeInstant) {
                        operator = TimeOperator.TM_Before;
                    } else {
                        throw unsupportedTemporalFilterOperand();
                    }
                    temporalFilter.setOperator(operator);
                    temporalFilter.setTime(time);
                    // actually it should be eg om:samplingTime
                    temporalFilter.setValueReference(valueRef);
                    break;
                }
            }
        }
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing temporal filter!", xmle);
    }
    return temporalFilter;
}
Also used : TimeOperator(org.n52.shetland.ogc.filter.FilterConstants.TimeOperator) TemporalFilter(org.n52.shetland.ogc.filter.TemporalFilter) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlException(org.apache.xmlbeans.XmlException) NodeList(org.w3c.dom.NodeList) XmlObject(org.apache.xmlbeans.XmlObject) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) PropertyNameType(net.opengis.ogc.PropertyNameType)

Aggregations

PropertyNameType (net.opengis.ogc.PropertyNameType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 TimeOperator (org.n52.shetland.ogc.filter.FilterConstants.TimeOperator)1 TemporalFilter (org.n52.shetland.ogc.filter.TemporalFilter)1 Time (org.n52.shetland.ogc.gml.time.Time)1 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 NodeList (org.w3c.dom.NodeList)1