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
GridCoverage2D
instances, returning footprint in real world coordinates, as well as withRenderedImage
instances, 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 class
MarchingSquaresVectorizer.FootprintCoordinates
static class
MarchingSquaresVectorizer.ImageAnalysisResultThdLocal
static class
MarchingSquaresVectorizer.ImageLoadingType
-
Field Summary
Fields Modifier and Type Field Description static List<Range<Integer>>
DEFAULT_RANGES
static double
DEFAULT_SIMPLIFIER_FACTOR
static double
DEFAULT_THRESHOLD_AREA
-
Constructor Summary
Constructors Constructor Description MarchingSquaresVectorizer()
MarchingSquaresVectorizer(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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()
Geometry
getFootprint()
Return the precise footprintMarchingSquaresVectorizer.ImageLoadingType
getImageLoadingType()
double
getPolygonArea()
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
getRoiShape()
Return the ROIShape version of the footprint after computationGeometry
getSimplifiedFootprint()
Return 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 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 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 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.DEFERRED
vsMarchingSquaresVectorizer.ImageLoadingType.IMMEDIATE
-
getImageLoadingType
public MarchingSquaresVectorizer.ImageLoadingType getImageLoadingType()
-
process
public void process() throws Exception
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
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
.
-
-