/**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    List<Node> timePositions = node.getChildren("timePosition");
    TimeSequenceType results = Wcs10Factory.eINSTANCE.createTimeSequenceType();

    if (timePositions != null && !timePositions.isEmpty()) {
      for (Node timePositionNode : timePositions) {
        TimePositionType timePosition = Gml4wcsFactory.eINSTANCE.createTimePositionType();
        Date positionDate = ((Position) timePositionNode.getValue()).getDate();
        timePosition.setValue(positionDate);
        results.getTimePosition().add(timePosition);
      }

      return results;
    } else {
      List<Node> timePeriods = node.getChildren("timePeriod");
      if (timePeriods != null && !timePeriods.isEmpty()) {
        for (Node timePeriodNode : timePeriods) {
          Instant begining =
              new DefaultInstant((Position) timePeriodNode.getChild("beginPosition").getValue());
          Instant ending =
              new DefaultInstant((Position) timePeriodNode.getChild("endPosition").getValue());

          // Period timePeriod = new DefaultPeriod(begining, ending);
          TimePeriodType timePeriod = Wcs10Factory.eINSTANCE.createTimePeriodType();
          TimePositionType beginPosition = Gml4wcsFactory.eINSTANCE.createTimePositionType();
          TimePositionType endPosition = Gml4wcsFactory.eINSTANCE.createTimePositionType();

          beginPosition.setValue(begining.getPosition().getDate());
          endPosition.setValue(ending.getPosition().getDate());

          timePeriod.setBeginPosition(beginPosition);
          timePeriod.setEndPosition(endPosition);

          results.getTimePeriod().add(timePeriod);
        }

        return results;
      }
    }

    return null;
  }
예제 #2
0
  public static List<Filter> parseExtendedOperators(
      Node node, org.opengis.filter.FilterFactory factory) {
    List<Filter> extOps = new ArrayList();

    // TODO: this doesn't actually handle the case of an extended operator that does not take
    // any arguments
    if (node.hasChild(Expression.class)) {
      // case of a single operator containing a single expression
      Node n = node.getChild(Expression.class);
      Name opName = new NameImpl(n.getComponent().getNamespace(), n.getComponent().getName());

      Filter extOp =
          lookupExtendedOperator(opName, Arrays.asList((Expression) n.getValue()), factory);
      if (extOp != null) {
        extOps.add(extOp);
      }
    } else if (node.hasChild(Map.class)) {
      List<Node> children = node.getChildren(Map.class);
      for (Node n : children) {
        Name opName = new NameImpl(n.getComponent().getNamespace(), n.getComponent().getName());
        Map map = (Map) n.getValue();

        List<Expression> expressions = new ArrayList();
        for (Object o : map.values()) {
          if (o instanceof Expression) {
            expressions.add((Expression) o);
          }
        }

        Filter extOp = lookupExtendedOperator(opName, expressions, factory);
        if (extOp != null) {
          extOps.add(extOp);
        }
      }
    }

    return extOps;
  }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    CoordinateReferenceSystem crs = GML3ParsingUtils.crs(node);

    if (node.getChild("lowerCorner") != null) {
      DirectPosition l = (DirectPosition) node.getChildValue("lowerCorner");
      DirectPosition u = (DirectPosition) node.getChildValue("upperCorner");

      return new ReferencedEnvelope(
          l.getOrdinate(0), u.getOrdinate(0), l.getOrdinate(1), u.getOrdinate(1), crs);
    }

    if (node.hasChild(Coordinate.class)) {
      List c = node.getChildValues(Coordinate.class);
      Coordinate c1 = (Coordinate) c.get(0);
      Coordinate c2 = (Coordinate) c.get(1);

      return new ReferencedEnvelope(c1.x, c2.x, c1.y, c2.y, crs);
    }

    if (node.hasChild(DirectPosition.class)) {
      List dp = node.getChildValues(DirectPosition.class);
      DirectPosition dp1 = (DirectPosition) dp.get(0);
      DirectPosition dp2 = (DirectPosition) dp.get(1);

      return new ReferencedEnvelope(
          dp1.getOrdinate(0), dp2.getOrdinate(0), dp1.getOrdinate(1), dp2.getOrdinate(1), crs);
    }

    if (node.hasChild(CoordinateSequence.class)) {
      CoordinateSequence seq = (CoordinateSequence) node.getChildValue(CoordinateSequence.class);

      return new ReferencedEnvelope(seq.getX(0), seq.getX(1), seq.getY(0), seq.getY(1), crs);
    }

    return null;
  }