Package org.geotools.process.raster
Class MarchingSquaresVectorizer
Object
MarchingSquaresVectorizer
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 GridCoverage2D
instances, returning footprint in real world coordinates, as well as with
RenderedImage
instances, returning footprint in raster space coordinates
- Author:
- Daniele Romagnoli, GeoSolutions SAS, Simone Giannecchini, GeoSolutions SAS, Andrea Aime, GeoSolutions SAS
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
static final double
-
Constructor Summary
ConstructorsConstructorDescriptionMarchingSquaresVectorizer
(RenderedImage ri, RenderingHints hints, double thresholdArea, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges) Main Constructor usingRenderedImage
as input.MarchingSquaresVectorizer
(GridCoverage2D inGeodata, RenderingHints hints, double thresholdArea, double simplifierFactor, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges) Main Constructor usingGridCoverage2D
as input. -
Method Summary
Modifier and TypeMethodDescriptionstatic final boolean
areEqual
(double value, double pValue) Simple check returning where two double values are equalstatic Polygon
createSimplePolygon
(Coordinate[] coords) Create a simple polygon (no holes).void
dispose()
Return the precise footprintdouble
Return the area of the simplified footprint after computationstatic double
getPolygonArea
(int[] x, int[] y, int N) Calculates the area of a polygon from its vertices.static double
getPolygonArea
(List<Coordinate> coordinateList) Calculates the area of a polygon from the coordinates.ROIShape
Return the ROIShape version of the footprint after computationReturn the simplified footprintvoid
process()
Executes the MarchingSquares algorithm to find the footprint.void
setComputeSimplifiedFootprint
(boolean computeSimplifiedFootprint) When set totrue
, a simplified version of the footprint will be returned toovoid
setForceValid
(boolean forceValid) When set totrue
(the default) will perform extra checks on the output polygons to make sure they are valid geometriesvoid
setImageLoadingType
(MarchingSquaresVectorizer.ImageLoadingType imageLoadingType) Specifies which type of imageLoading (MarchingSquaresVectorizer.ImageLoadingType
) to be used,MarchingSquaresVectorizer.ImageLoadingType.DEFERRED
vsMarchingSquaresVectorizer.ImageLoadingType.IMMEDIATE
void
setRemoveCollinear
(boolean removeCollinear) When set totrue
(the default) will perform collinear vertices removal
-
Field Details
-
DEFAULT_RANGES
-
DEFAULT_SIMPLIFIER_FACTOR
public static final double DEFAULT_SIMPLIFIER_FACTOR- See Also:
-
DEFAULT_THRESHOLD_AREA
public static final double DEFAULT_THRESHOLD_AREA- See Also:
-
-
Constructor Details
-
MarchingSquaresVectorizer
public MarchingSquaresVectorizer(GridCoverage2D inGeodata, RenderingHints hints, double thresholdArea, double simplifierFactor, MarchingSquaresVectorizer.ImageLoadingType imageLoadingType, List<Range<Integer>> exclusionLuminanceRanges) Main Constructor usingGridCoverage2D
as input.- Parameters:
inGeodata
- the inputGridCoverage2D
hints
- 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 usingRenderedImage
as input. Returned footprint coordinates will be in raster space.- Parameters:
ri
- the inputRenderedImage
hints
- 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 Details
-
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
Return the simplified footprint -
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
Specifies which type of imageLoading (MarchingSquaresVectorizer.ImageLoadingType
) to be used,MarchingSquaresVectorizer.ImageLoadingType.DEFERRED
vsMarchingSquaresVectorizer.ImageLoadingType.IMMEDIATE
-
getImageLoadingType
-
process
Executes 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
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
Create a simple polygon (no holes).- Parameters:
coords
- the coords of the polygon.- Returns:
- the
Polygon
.
-