Class Joiner
java.lang.Object
org.apache.sis.internal.feature.j2d.PathBuilder
org.apache.sis.internal.processing.isoline.Joiner
Assembles arbitrary number of
PolylineBuffer
s in a single Java2D Shape
for an isoline level.
This class extends PathBuilder
with two additional features: remove spikes caused by ambiguities,
then apply a MathTransform
on all coordinate values.
Spikes
If the shape delimited by given polylines has a part with zero width or height (i.e. a spike), truncates the polylines for removing that spike. This situation happens when some pixel values are exactly equal to isoline value, as in the picture below: The spike may appear or not depending on the convention adopted for strictly equal values. In above picture, the spike appears because the convention used in this implementation is:- ○: pixel value < isoline value.
- ●: pixel value ≥ isoline value.
- ○: pixel value ≤ isoline value.
- ●: pixel value > isoline value.
PolylineBuffer
instances.
Rational: having a spike require that we move forward then backward on the same coordinates,
which is possible only with a non-null PolylineBuffer.opposite
field.- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.opengis.referencing.operation.MathTransform
Final transform to apply on coordinates, ornull
if none. -
Constructor Summary
ConstructorsConstructorDescriptionJoiner
(org.opengis.referencing.operation.MathTransform gridToCRS) Creates an initially empty set of isoline shapes. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
filterChunk
(double[] coordinates, int lower, int upper) Detects and removes spikes for avoiding convention-dependent results.protected int
filterFull
(double[] coordinates, int upper) Applies user-specified coordinate transform on all points of the whole polyline.Methods inherited from class org.apache.sis.internal.feature.j2d.PathBuilder
append, append, build, createPolyline, snapshot, toString, toString
-
Field Details
-
gridToCRS
private final org.opengis.referencing.operation.MathTransform gridToCRSFinal transform to apply on coordinates, ornull
if none.
-
-
Constructor Details
-
Joiner
Joiner(org.opengis.referencing.operation.MathTransform gridToCRS) Creates an initially empty set of isoline shapes.
-
-
Method Details
-
filterChunk
protected int filterChunk(double[] coordinates, int lower, int upper) Detects and removes spikes for avoiding convention-dependent results. SeeJoiner
class-javadoc for a description of the problem.We perform the analysis in this method instead of in
filterFull(double[], int)
on the the assumption that spikes can appear only between two calls toappend(…)
(because having a spike requires that we move forward then backward on the same coordinates, which happen only with two distinctPolylineBuffer
instances). It reduce the amount of coordinates to examine since we can check only the extremities instead of looking for spikes anywhere in the array.- Overrides:
filterChunk
in classPathBuilder
- Parameters:
coordinates
- the coordinates to filter. Values can be modified in-place.lower
- index of first coordinate to filter. Always even.upper
- index after the last coordinate to filter. Always even.- Returns:
- number of valid coordinates after filtering.
-
filterFull
protected int filterFull(double[] coordinates, int upper) throws org.opengis.referencing.operation.TransformException Applies user-specified coordinate transform on all points of the whole polyline. This method is invoked afterfilterChunk(double[], int, int)
.- Overrides:
filterFull
in classPathBuilder
- Parameters:
coordinates
- the coordinates to filter. Values can be modified in-place.upper
- index after the last coordinate to filter. Always even.- Returns:
- number of valid coordinates after filtering.
Should be
upper
, unless some coordinates have been removed. Must be an even number ≥ 0 and ≤ upper. - Throws:
org.opengis.referencing.operation.TransformException
- if this method wanted to apply a coordinate operation and that transform failed.
-