Package org.geotools.process.raster
Class MarchingSquaresVectorizer
- Object
-
- MarchingSquaresVectorizer
-
public final class MarchingSquaresVectorizer extends Object
Algorithm computing the image footprint. Some optimizations are made. When running along the image perimeter, whenever a closed polygon is found, the inner area is filled to make sure we won't analyze that.It can deal with
GridCoverage2Dinstances, returning footprint in real world coordinates, as well as withRenderedImageinstances, returning footprint in raster space coordinates- Author:
- Daniele Romagnoli, GeoSolutions SAS, Simone Giannecchini, GeoSolutions SAS, Andrea Aime, GeoSolutions SAS
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMarchingSquaresVectorizer.FootprintCoordinatesstatic classMarchingSquaresVectorizer.ImageAnalysisResultThdLocalstatic classMarchingSquaresVectorizer.ImageLoadingType
-
Field Summary
Fields Modifier and Type Field Description static List<Range<Integer>>DEFAULT_RANGESstatic doubleDEFAULT_SIMPLIFIER_FACTORstatic doubleDEFAULT_THRESHOLD_AREA
-
Constructor Summary
Constructors Constructor Description MarchingSquaresVectorizer()MarchingSquaresVectorizer(RenderedImage ri, RenderingHints hints, double thresholdArea, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges)Main Constructor usingRenderedImageas input.MarchingSquaresVectorizer(GridCoverage2D inGeodata, RenderingHints hints, double thresholdArea, double simplifierFactor, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges)Main Constructor usingGridCoverage2Das input.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanareEqual(double value, double pValue)Simple check returning where two double values are equalstatic PolygoncreateSimplePolygon(Coordinate[] coords)Create a simple polygon (no holes).voiddispose()GeometrygetFootprint()Return the precise footprintMarchingSquaresVectorizer.ImageLoadingTypegetImageLoadingType()doublegetPolygonArea()Return the area of the simplified footprint after computationstatic doublegetPolygonArea(int[] x, int[] y, int N)Calculates the area of a polygon from its vertices.static doublegetPolygonArea(List<Coordinate> coordinateList)Calculates the area of a polygon from the coordinates.ROIShapegetRoiShape()Return the ROIShape version of the footprint after computationGeometrygetSimplifiedFootprint()Return the simplified footprintvoidprocess()Executes the MarchingSquares algorithm to find the footprint.voidsetComputeSimplifiedFootprint(boolean computeSimplifiedFootprint)When set totrue, a simplified version of the footprint will be returned toovoidsetForceValid(boolean forceValid)When set totrue(the default) will perform extra checks on the output polygons to make sure they are valid geometriesvoidsetImageLoadingType(MarchingSquaresVectorizer.ImageLoadingType imageLoadingType)Specifies which type of imageLoading (MarchingSquaresVectorizer.ImageLoadingType) to be used,MarchingSquaresVectorizer.ImageLoadingType.DEFERREDvsMarchingSquaresVectorizer.ImageLoadingType.IMMEDIATEvoidsetRemoveCollinear(boolean removeCollinear)When set totrue(the default) will perform collinear vertices removal
-
-
-
Field Detail
-
DEFAULT_SIMPLIFIER_FACTOR
public static final double DEFAULT_SIMPLIFIER_FACTOR
- See Also:
- Constant Field Values
-
DEFAULT_THRESHOLD_AREA
public static final double DEFAULT_THRESHOLD_AREA
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MarchingSquaresVectorizer
public MarchingSquaresVectorizer(GridCoverage2D inGeodata, RenderingHints hints, double thresholdArea, double simplifierFactor, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges)
Main Constructor usingGridCoverage2Das input.- Parameters:
inGeodata- the inputGridCoverage2Dhints- hints to be used by inner processing, it usually contains tile caches, schedulersthresholdArea- the minimum area required by a polygon to be included in the resultsimplifierFactor- the simplifier factor to be applied to compute the simplified version of the biggest polygon.imageLoadingType- the type of imageLoading (DEFERRED vs IMMEDIATE).exclusionLuminanceRanges- the ranges of luminance values to be excluded by the computation.
-
MarchingSquaresVectorizer
public MarchingSquaresVectorizer(RenderedImage ri, RenderingHints hints, double thresholdArea, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges)
Main Constructor usingRenderedImageas input. Returned footprint coordinates will be in raster space.- Parameters:
ri- the inputRenderedImagehints- hints to be used by inner processing, it usually contains tile caches, schedulersthresholdArea- the minimum area required by a polygon to be included in the resultimageLoadingType- the type of imageLoading (DEFERRED vs IMMEDIATE).exclusionLuminanceRanges- the range of luminance values to be excluded by the computation.
-
MarchingSquaresVectorizer
public MarchingSquaresVectorizer()
-
-
Method Detail
-
getRoiShape
public ROIShape getRoiShape()
Return the ROIShape version of the footprint after computation
-
getPolygonArea
public double getPolygonArea()
Return the area of the simplified footprint after computation
-
getSimplifiedFootprint
public Geometry getSimplifiedFootprint()
Return the simplified footprint
-
getFootprint
public Geometry getFootprint()
Return the precise footprint
-
setRemoveCollinear
public void setRemoveCollinear(boolean removeCollinear)
When set totrue(the default) will perform collinear vertices removal
-
setForceValid
public void setForceValid(boolean forceValid)
When set totrue(the default) will perform extra checks on the output polygons to make sure they are valid geometries
-
setComputeSimplifiedFootprint
public void setComputeSimplifiedFootprint(boolean computeSimplifiedFootprint)
When set totrue, a simplified version of the footprint will be returned too
-
setImageLoadingType
public void setImageLoadingType(MarchingSquaresVectorizer.ImageLoadingType imageLoadingType)
Specifies which type of imageLoading (MarchingSquaresVectorizer.ImageLoadingType) to be used,MarchingSquaresVectorizer.ImageLoadingType.DEFERREDvsMarchingSquaresVectorizer.ImageLoadingType.IMMEDIATE
-
getImageLoadingType
public MarchingSquaresVectorizer.ImageLoadingType getImageLoadingType()
-
process
public void process() throws ExceptionExecutes the MarchingSquares algorithm to find the footprint.- Throws:
Exception
-
areEqual
public static final boolean areEqual(double value, double pValue)Simple check returning where two double values are equal
-
dispose
public void dispose()
-
getPolygonArea
public static double getPolygonArea(List<Coordinate> coordinateList)
Calculates the area of a polygon from the coordinates.- Returns:
- the area of the polygon.
-
getPolygonArea
public static double getPolygonArea(int[] x, int[] y, int N)Calculates the area of a polygon from its vertices.- Parameters:
x- the array of x coordinates.y- the array of y coordinates.N- the number of sides of the polygon.- Returns:
- the area of the polygon.
-
createSimplePolygon
public static Polygon createSimplePolygon(Coordinate[] coords)
Create a simple polygon (no holes).- Parameters:
coords- the coords of the polygon.- Returns:
- the
Polygon.
-
-