/* * GeoTools - OpenSource mapping toolkit * http://geotools.org * (C) 2002-2006, GeoTools Project Managment Committee (PMC) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotools.filter.v1_0; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; import org.geotools.filter.FilterFactory; import org.geotools.xml.ComplexBinding; import org.geotools.xml.ElementInstance; import org.geotools.xml.Node; import org.opengis.filter.FilterFactory2; import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.PropertyName; import org.opengis.filter.spatial.BinarySpatialOperator; import org.picocontainer.MutablePicoContainer; import javax.xml.namespace.QName; /** * Binding object for the type http://www.opengis.net/ogc:BinarySpatialOpType. * *
*
*
* <xsd:complexType name="BinarySpatialOpType">
* <xsd:complexContent>
* <xsd:extension base="ogc:SpatialOpsType">
* <xsd:sequence>
* <xsd:element ref="ogc:PropertyName"/>
* <xsd:choice>
* <xsd:element ref="gml:_Geometry"/>
* <xsd:element ref="gml:Box"/>
* </xsd:choice>
* </xsd:sequence>
* </xsd:extension>
* </xsd:complexContent>
* </xsd:complexType>
*
*
*
*
*
* @generated
*/
public class OGCBinarySpatialOpTypeBinding implements ComplexBinding {
private FilterFactory factory;
private GeometryFactory gFactory;
public OGCBinarySpatialOpTypeBinding(FilterFactory factory,
GeometryFactory gFactory) {
this.factory = factory;
this.gFactory = gFactory;
}
/**
* @generated
*/
public QName getTarget() {
return OGC.BINARYSPATIALOPTYPE;
}
/**
*
*
*
* @generated modifiable
*/
public int getExecutionMode() {
return AFTER;
}
/**
*
*
*
* @generated modifiable
*/
public Class getType() {
return BinarySpatialOperator.class;
}
/**
*
* We check out the instance for the op
so we can fail early.
*
*
* @generated modifiable
*/
public void initialize(ElementInstance instance, Node node,
MutablePicoContainer context) {
}
/**
*
*
*
* @generated modifiable
*/
public Object parse(ElementInstance instance, Node node, Object value)
throws Exception {
//TODO: replace with element bindings
PropertyName e1 = (PropertyName) node.getChildValue(PropertyName.class);
Expression e2 = null;
if (node.hasChild(Geometry.class)) {
e2 = factory.literal(node.getChildValue(Geometry.class));
} else {
//turn bounding box into geometry
//TODO: not sure if this should be done here but I am pretty sure filter
// implementation expect this to be a geometry
Envelope bbox = (Envelope) node.getChildValue(Envelope.class);
e2 = factory.literal(gFactory.createPolygon(
gFactory.createLinearRing(
new Coordinate[] {
new Coordinate(bbox.getMinX(), bbox.getMinY()),
new Coordinate(bbox.getMinX(), bbox.getMaxY()),
new Coordinate(bbox.getMaxX(), bbox.getMaxY()),
new Coordinate(bbox.getMaxX(), bbox.getMinY()),
new Coordinate(bbox.getMinX(), bbox.getMinY())
}), null));
}
String name = instance.getName();
//