Пример #1
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    Expression color = null;
    Expression opacity = null;
    Graphic graphicFill = null;

    graphicFill = (Graphic) node.getChildValue("GraphicFill");

    // &quot;fill&quot; (color)
    // &quot;fill-opacity&quot;
    List params = node.getChildValues(CssParameter.class);

    for (Iterator itr = params.iterator(); itr.hasNext(); ) {
      CssParameter param = (CssParameter) itr.next();

      if ("fill".equals(param.getName())) {
        color = param.getExpression();
      }

      if ("fill-opacity".equals(param.getName())) {
        opacity = param.getExpression();
      }
    }

    Fill fill = styleFactory.createFill(color);

    if (opacity != null) {
      fill.setOpacity(opacity);
    }

    return fill;
  }
Пример #2
0
 @Override
 public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
   Graphic g = (Graphic) super.parse(instance, node, value);
   if (node.hasChild(AnchorPoint.class)) {
     g.setAnchorPoint((AnchorPoint) node.getChildValue(AnchorPoint.class));
   }
   if (node.hasChild(Displacement.class)) {
     g.setDisplacement((Displacement) node.getChildValue(Displacement.class));
   }
   return g;
 }
Пример #3
0
  /**
   * Returns a two element array of PropertyName, Literal ( Geometry )
   *
   * @param node The parse tree.
   * @return A two element array of expressions for a BinarySpatialOp type.
   */
  static Expression[] spatial(Node node, FilterFactory2 ff, GeometryFactory gf) {
    PropertyName name = (PropertyName) node.getChildValue(PropertyName.class);
    Expression spatial = null;

    if (node.hasChild(Geometry.class)) {
      spatial = ff.literal(node.getChildValue(Geometry.class));
    } else if (node.hasChild(Envelope.class)) {
      // JD: creating an envelope here would break a lot of our code, for instance alot of
      // code that encodes a filter into sql will choke on this
      Envelope envelope = (Envelope) node.getChildValue(Envelope.class);
      Polygon polygon =
          gf.createPolygon(
              gf.createLinearRing(
                  new Coordinate[] {
                    new Coordinate(envelope.getMinX(), envelope.getMinY()),
                    new Coordinate(envelope.getMaxX(), envelope.getMinY()),
                    new Coordinate(envelope.getMaxX(), envelope.getMaxY()),
                    new Coordinate(envelope.getMinX(), envelope.getMaxY()),
                    new Coordinate(envelope.getMinX(), envelope.getMinY())
                  }),
              null);

      if (envelope instanceof ReferencedEnvelope) {
        polygon.setUserData(((ReferencedEnvelope) envelope).getCoordinateReferenceSystem());
      }

      spatial = ff.literal(polygon);
    } else {
      // look for an expression that is not a property name
      for (Iterator c = node.getChildren().iterator(); c.hasNext(); ) {
        Node child = (Node) c.next();

        // if property name, skip
        if (child.getValue() instanceof PropertyName) {
          continue;
        }

        // if expression, use it
        if (child.getValue() instanceof Expression) {
          spatial = (Expression) child.getValue();
          break;
        }
      }
    }

    return new Expression[] {name, spatial};
  }
Пример #4
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    Mark mark = (Mark) super.parse(instance, node, value);

    if (mark.getWellKnownName() == null) {
      String format = (String) node.getChildValue("Format");
      int markIndex = -1;

      if (node.hasChild("MarkIndex")) {
        markIndex = (Integer) node.getChildValue("MarkIndex");
      }

      ExternalMark emark = null;

      if (node.hasChild("OnlineResource")) {
        emark =
            styleFactory.externalMark(
                new OnLineResourceImpl((URI) node.getChildValue("OnlineResource")),
                format,
                markIndex);
      } else if (node.hasChild("InlineContent")) {
        // TODO: implement this
        if (true) throw new UnsupportedOperationException("");
        InlineContent ic = (InlineContent) node.getChildValue("InlineContent");
        // emark = styleFactory.externalMark(inline);
      }

      mark.setExternalMark(emark);
    }

    return mark;
  }
Пример #5
0
  public static List<Filter> BinaryLogicOperator_getChildFilters(
      Node node, org.opengis.filter.FilterFactory factory) {
    List<Filter> filters = node.getChildValues(Filter.class);
    if (filters.size() < 2) {
      // look for Id elements and turn them into fid filters
      // note: this is not spec compliant and is a bit lax
      List<Identifier> ids = node.getChildValues(Identifier.class);
      for (Identifier id : ids) {
        filters.add(factory.id(Collections.singleton(id)));
      }

      // look for extended operator(s)
      filters.addAll(parseExtendedOperators(node, factory));
    }

    // TODO: this parsing returns teh children out of order...
    return filters;
  }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    DescribeFeatureTypeType describeFeatureType = wfsfactory.createDescribeFeatureTypeType();

    WFSBindingUtils.service(describeFeatureType, node);
    WFSBindingUtils.version(describeFeatureType, node);
    WFSBindingUtils.outputFormat(describeFeatureType, node, "XMLSCHEMA");

    describeFeatureType.getTypeName().addAll(node.getChildValues(QName.class));

    return describeFeatureType;
  }
  /**
   *
   * <!-- 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;
  }
  /**
   *
   * <!-- 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;
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated modifiable
  */
 public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
   return node.getChildValue(Expression.class);
 }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    RasterSymbolizer rs = styleFactory.createRasterSymbolizer();

    // &lt;xsd:element ref="sld:Geometry" minOccurs="0"/&gt;
    if (node.hasChild("Geometry")) {
      PropertyName propertyName = (PropertyName) node.getChildValue("Geometry");
      rs.setGeometryPropertyName(propertyName.getPropertyName());
    }

    // &lt;xsd:element ref="sld:Opacity" minOccurs="0"/&gt;
    if (node.hasChild("Opacity")) {
      rs.setOpacity((Expression) node.getChildValue("Opacity"));
    }

    // &lt;xsd:element ref="sld:ChannelSelection" minOccurs="0"/&gt;
    if (node.hasChild("ChannelSelection")) {
      rs.setChannelSelection((ChannelSelection) node.getChildValue("ChannelSelection"));
    }

    // &lt;xsd:element ref="sld:OverlapBehavior" minOccurs="0"/&gt;
    if (node.hasChild("OverlapBehavior")) {
      rs.setOverlapBehavior((OverlapBehavior) node.getChildValue("OverlapBehavior"));
    }

    // &lt;xsd:element ref="sld:ColorMap" minOccurs="0"/&gt;
    if (node.hasChild("ColorMap")) {
      rs.setColorMap((ColorMap) node.getChildValue("ColorMap"));
    }

    // &lt;xsd:element ref="sld:ContrastEnhancement" minOccurs="0"/&gt;
    if (node.hasChild("ContrastEnhancement")) {
      rs.setContrastEnhancement((ContrastEnhancement) node.getChildValue("ContrastEnhancement"));
    }

    // &lt;xsd:element ref="sld:ShadedRelief" minOccurs="0"/&gt;
    if (node.hasChild("ShadedRelief")) {
      rs.setShadedRelief((ShadedRelief) node.getChildValue("ShadedRelief"));
    }

    // &lt;xsd:element ref="sld:ImageOutline" minOccurs="0"/&gt;
    if (node.hasChild("ImageOutline")) {
      ImageOutline imageOutput = (ImageOutline) node.getChildValue("ImageOutline");
      rs.setImageOutline(imageOutput.getSymbolizer());
    }

    return rs;
  }
Пример #11
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 {
    TextSymbolizer ts = styleFactory.createTextSymbolizer();

    // &lt;xsd:element ref="sld:Geometry" minOccurs="0"/&gt;
    if (node.hasChild("Geometry")) {
      Expression geometry = (Expression) node.getChildValue("Geometry");
      if (geometry instanceof PropertyName) {
        PropertyName propertyName = (PropertyName) geometry;
        ts.setGeometryPropertyName(propertyName.getPropertyName());
      } else {
        ts.setGeometry(geometry);
      }
    }

    // &lt;xsd:element ref="sld:Label" minOccurs="0"/&gt;
    if (node.hasChild("Label")) {
      ts.setLabel((Expression) node.getChildValue("Label"));
    }

    // &lt;xsd:element ref="sld:Font" minOccurs="0"/&gt;
    if (node.hasChild("Font")) {
      ts.setFonts(new Font[] {(Font) node.getChildValue("Font")});
    }

    // &lt;xsd:element ref="sld:LabelPlacement" minOccurs="0"/&gt;
    if (node.hasChild("LabelPlacement")) {
      ts.setPlacement((LabelPlacement) node.getChildValue("LabelPlacement"));
    }

    // &lt;xsd:element ref="sld:Halo" minOccurs="0"/&gt;
    if (node.hasChild("Halo")) {
      ts.setHalo((Halo) node.getChildValue("Halo"));
    }

    // &lt;xsd:element ref="sld:Fill" minOccurs="0"/&gt;
    if (node.hasChild("Fill")) {
      ts.setFill((Fill) node.getChildValue("Fill"));
    }

    if (node.hasChild("Priority")) {
      ts.setPriority((Expression) node.getChildValue("Priority"));
    }

    // &lt;xsd:element ref="sld:VendorOption" minOccurs="0" maxOccurs="unbounded"/&gt;
    for (CssParameter param : (List<CssParameter>) node.getChildValues(CssParameter.class)) {
      ts.getOptions().put(param.getName(), param.getExpression().evaluate(null, String.class));
    }
    return ts;
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated modifiable
  */
 public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
   return node.getChildValue(getGeometryType());
 }