All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geotools.feature.visitor.CalcResult Maven / Gradle / Ivy

Go to download

The main module contains the GeoTools public interfaces that are used by other GeoTools modules (and GeoTools applications). Where possible we make use industry standard terms as provided by OGC and ISO standards. The formal GeoTools public api consists of gt-metadata, jts and the gt-main module. The main module contains the default implementations that are available provided to other GeoTools modules using our factory system. Factories are obtained from an appropriate FactoryFinder, giving applications a chance configure the factory used using the Factory Hints facilities. FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expr = ff.add( expression1, expression2 ); If you find yourself using implementation specific classes chances are you doing it wrong: Expression expr = new AddImpl( expression1, expressiom2 );

The newest version!
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2005-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.feature.visitor;

import java.util.List;
import java.util.Map;
import java.util.Set;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Point;

/**
 * Encapsulates the results from a FeatureCalc, and includes methods for obtaining and merging
 * results.
 *
 * @author Cory Horner, Refractions
 * @see FeatureCalc
 * @since 2.2.M2
 */
public interface CalcResult {
    /**
     * The result obtained when a FeatureCalc found no features to visit. It lets itself merge with
     * any other result by just returning the other result as the output of the merge
     */
    public static final CalcResult NULL_RESULT =
            new AbstractCalcResult() {
                /** Always compatible */
                public boolean isCompatible(CalcResult targetResults) {
                    return true;
                };

                /** Just returns the other result */
                public CalcResult merge(CalcResult resultsToAdd) {
                    return resultsToAdd;
                };
            };

    /**
     * Returns true if the target results is a compatible type with the current results, with
     * compatible meaning that the two results may be merged.
     *
     * @param targetResults the second CalcResult Object
     * @return true if the targetResults can be merged with the current results
     */
    public boolean isCompatible(CalcResult targetResults);

    /**
     * Returns the merged results of two CalcResult. The way in which the results are merged is
     * dependent on the type of the results added. A new instance is created containing the merged
     * results.
     *
     * 

For example: merging two min functions would return the smaller of the two values; merging * a count and a sum would return an average. * * @return the merged results */ public CalcResult merge(CalcResult resultsToAdd); /** * Actual answer * * @return the calculation result as a generic object */ public Object getValue(); /** * Access getValue as an int * * @return the calculation result as a int (or 0 if not applicable) */ public int toInt(); /** * Access getValue as a double * * @return the calculation result as a double (or 0 if not applicable) */ public double toDouble(); /** * Access getValue as a string * * @return the calculation result as a string (or "" if not applicable) */ public String toString(); /** * Access getValue as a long * * @return the calculation result as a long (or 0 if not applicable) */ public long toLong(); /** * Access getValue as a float * * @return the calculation result as a float (or 0 if not applicable) */ public float toFloat(); /** * Access getValue as a geometry * * @return the calculation result as a geometry (or null if not applicable) */ public Geometry toGeometry(); /** * Access getValue as an envelope * * @return the calculation result as an envelope (or null if not applicable) */ public Envelope toEnvelope(); /** * Access getValue as a point * * @return the calculation result as a point (or null if not applicable) */ public Point toPoint(); /** * Access getValue as a set * * @return the calculation result as a set (or null if not applicable) */ public Set toSet(); /** * Access getValue as a list * * @return the calculation result as a list (or null if not applicable) */ public List toList(); /** * Access getValue as an array * * @return the calculation result as an array (or null if not applicable) */ public Object[] toArray(); /** * Access getValue as a map * * @return the calculation result as a map (or null if not applicable) */ public Map toMap(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy