/** * 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}; }
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 { 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; }