Class Validator


  • public class Validator
    extends Object
    Performs basic JTS validation, and additional validation like checking polygon orientation.
    • Constructor Detail

      • Validator

        public Validator()
    • Method Detail

      • setCheckingBasicTopology

        public void setCheckingBasicTopology​(boolean checkingBasicTopology)
        Sets whether basic JTS validation should be performed
        Parameters:
        checkingBasicTopology - whether basic JTS validation should be performed
      • setCheckingNoRepeatedConsecutivePoints

        public void setCheckingNoRepeatedConsecutivePoints​(boolean checkingNoRepeatedConsecutivePoints)
        Sets whether consecutive points are not allowed to be the same
        Parameters:
        checkingNoRepeatedConsecutivePoints - whether consecutive points are not allowed to be the same
      • setCheckingNoHoles

        public void setCheckingNoHoles​(boolean checkingNoHoles)
        Sets whether polygons are not allowed to have holes
        Parameters:
        checkingNoHoles - whether polygons are not allowed to have holes
      • setCheckingPolygonOrientation

        public void setCheckingPolygonOrientation​(boolean checkingPolygonOrientation)
        Sets whether polygon orientation should be checked
        Parameters:
        checkingPolygonOrientation - whether to enforce the constraint that polygon shells should be oriented clockwise and holes should be oriented counterclockwise
      • setMinSegmentLength

        public void setMinSegmentLength​(double minSegmentLength)
        Sets the segment length below which the minimum-segment-length check will raise a validation error.
        Parameters:
        minSegmentLength - the threshold used by the minimum-segment-length check
        See Also:
        setCheckingMinSegmentLength(boolean)
      • setMinAngle

        public void setMinAngle​(double minAngle)
        Sets the angle below which the minimum-angle check will raise a validation error.
        Parameters:
        minAngle - the threshold used by the minimum-angle check, in degrees
        See Also:
        setCheckingMinAngle(boolean)
      • setMinPolygonArea

        public void setMinPolygonArea​(double minPolygonArea)
        Sets the area below which the minimum-polygon-area check will raise a validation error.
        Parameters:
        minPolygonArea - the threshould used by the minimum-polygon-area check
        See Also:
        setCheckingMinPolygonArea(boolean)
      • setCheckingLineStringsSimple

        public void setCheckingLineStringsSimple​(boolean checkingLineStringsSimple)
        Sets whether to enforce the constraint that LineStrings must be simple
        Parameters:
        checkingLineStringsSimple - whether to enforce the constraint that LineStrings must be simple
      • setCheckingMinSegmentLength

        public void setCheckingMinSegmentLength​(boolean checkingMinSegmentLength)
        Sets whether minimum segment length should be checked.
        Parameters:
        checkingMinSegmentLength - whether to enforce the constraint that segment length should be no less than the minimum
        See Also:
        setMinSegmentLength(double)
      • setCheckingMinAngle

        public void setCheckingMinAngle​(boolean checkingMinAngle)
        Sets whether minimum angle should be checked.
        Parameters:
        checkingMinAngle - whether to enforce the constraint that angle should be no less than the minimum
        See Also:
        setMinAngle(double)
      • setCheckingMinPolygonArea

        public void setCheckingMinPolygonArea​(boolean checkingMinPolygonArea)
        Sets whether minimum polygon area should be checked.
        Parameters:
        checkingMinPolygonArea - whether to enforce the constraint that area should be no less than the minimum, for single polygons and polygon elements of GeometryCollections (including MultiPolygons)
        See Also:
        setMinPolygonArea(double)
      • setDisallowedGeometryClasses

        public void setDisallowedGeometryClasses​(Collection disallowedGeometryClasses)
        Sets the Geometry classes that are not allowed in the dataset that will be validated.
        Parameters:
        disallowedGeometryClasses - Geometry classes (Polygon.class, for example) that are not allowed
      • validate

        public List validate​(Collection features,
                             TaskMonitor monitor)
        Checks a collection of features.
        Parameters:
        features - the Feature's to validate
        Returns:
        a List of ValidationErrors; if all features are valid, the list will be empty
      • addIfNotNull

        protected void addIfNotNull​(Object item,
                                    Collection collection)
      • validate

        protected void validate​(Feature feature,
                                List validationErrors)
        Checks a feature.
        Parameters:
        feature - the Feature to validate
        validationErrors - a List of ValidationError's to add to if the feature is not valid
      • validateNoRepeatedConsecutivePoints

        protected ValidationError validateNoRepeatedConsecutivePoints​(Feature feature)