Package org.geotools.filter.spatial

Source Code of org.geotools.filter.spatial.DisjointImpl

/*
*    GeoTools - The Open Source Java GIS Toolkit
*    http://geotools.org
*
*    (C) 2006-2008, Open Source Geospatial Foundation (OSGeo)
*   
*    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.spatial;

import org.opengis.filter.FilterVisitor;
import org.opengis.filter.expression.Expression;
import org.opengis.filter.spatial.Disjoint;

import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;

/**
*
*
* @source $URL$
*/
public class DisjointImpl extends AbstractPreparedGeometryFilter implements Disjoint {

    public DisjointImpl(Expression e1, Expression e2) {
        super(e1, e2);
    }

    public DisjointImpl(Expression e1, Expression e2, MatchAction matchAction) {
        super(e1, e2, matchAction);
    }
 
  @Override
        public boolean evaluateInternal(Geometry left, Geometry right) {
   
        switch (literals) {
        case BOTH:
            return cacheValue;
        case RIGHT: {
            return rightPreppedGeom.disjoint(left);
        }
        case LEFT: {
            return leftPreppedGeom.disjoint(right);
        }
        default: {
            return basicEvaluate(left, right);
        }
        }
   
  }
 
  @Override
  protected boolean basicEvaluate(Geometry left, Geometry right) {
    Envelope envLeft = left.getEnvelopeInternal();
    Envelope envRight = right.getEnvelopeInternal();
   
    if(envRight.intersects(envLeft))
            return left.disjoint(right);
       
         return true;
     }
 
  public Object accept(FilterVisitor visitor, Object extraData) {
    return visitor.visit(this,extraData);
  }

}
TOP

Related Classes of org.geotools.filter.spatial.DisjointImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.