Class HotPixel
java.lang.Object
org.locationtech.jts.noding.snapround.HotPixel
Implements a "hot pixel" as used in the Snap Rounding algorithm.
A hot pixel contains the interior of the tolerance square and
the boundary
minus the top and right segments.
The hot pixel operations are all computed in the integer domain to avoid rounding problems.
- Version:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Coordinate[]
The corners of the hot pixel, in the order: 10 23private LineIntersector
private double
private double
private double
private double
private Coordinate
private Coordinate
private Coordinate
private Coordinate
private Coordinate
private static final double
private Envelope
private double
-
Constructor Summary
ConstructorsConstructorDescriptionHotPixel
(Coordinate pt, double scaleFactor, LineIntersector li) Creates a new hot pixel, using a given scale factor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addSnappedNode
(NodedSegmentString segStr, int segIndex) Adds a new node (equal to the snap pt) to the specified segment if the segment passes through the hot pixelprivate void
copyScaled
(Coordinate p, Coordinate pScaled) Gets the coordinate this hot pixel is based at.Returns a "safe" envelope that is guaranteed to contain the hot pixel.private void
boolean
intersects
(Coordinate p0, Coordinate p1) Tests whether the line segment (p0-p1) intersects this hot pixel.private boolean
Test whether the given segment intersects the closure of this hot pixel.private boolean
intersectsScaled
(Coordinate p0, Coordinate p1) private boolean
Tests whether the segment p0-p1 intersects the hot pixel tolerance square.private double
scale
(double val)
-
Field Details
-
li
-
pt
-
originalPt
-
ptScaled
-
p0Scaled
-
p1Scaled
-
scaleFactor
private double scaleFactor -
minx
private double minx -
maxx
private double maxx -
miny
private double miny -
maxy
private double maxy -
corner
The corners of the hot pixel, in the order: 10 23 -
safeEnv
-
SAFE_ENV_EXPANSION_FACTOR
private static final double SAFE_ENV_EXPANSION_FACTOR- See Also:
-
-
Constructor Details
-
HotPixel
Creates a new hot pixel, using a given scale factor. The scale factor must be strictly positive (non-zero).- Parameters:
pt
- the coordinate at the centre of the pixelscaleFactor
- the scaleFactor determining the pixel size. Must be > 0li
- the intersector to use for testing intersection with line segments
-
-
Method Details
-
getCoordinate
Gets the coordinate this hot pixel is based at.- Returns:
- the coordinate of the pixel
-
getSafeEnvelope
Returns a "safe" envelope that is guaranteed to contain the hot pixel. The envelope returned will be larger than the exact envelope of the pixel.- Returns:
- an envelope which contains the hot pixel
-
initCorners
-
scale
private double scale(double val) -
intersects
Tests whether the line segment (p0-p1) intersects this hot pixel.- Parameters:
p0
- the first coordinate of the line segment to testp1
- the second coordinate of the line segment to test- Returns:
- true if the line segment intersects this hot pixel
-
copyScaled
-
intersectsScaled
-
intersectsToleranceSquare
Tests whether the segment p0-p1 intersects the hot pixel tolerance square. Because the tolerance square point set is partially open (along the top and right) the test needs to be more sophisticated than simply checking for any intersection. However, it can take advantage of the fact that the hot pixel edges do not lie on the coordinate grid. It is sufficient to check if any of the following occur:- a proper intersection between the segment and any hot pixel edge
- an intersection between the segment and both the left and bottom hot pixel edges (which detects the case where the segment intersects the bottom left hot pixel corner)
- an intersection between a segment endpoint and the hot pixel coordinate
- Parameters:
p0
-p1
-- Returns:
-
intersectsPixelClosure
Test whether the given segment intersects the closure of this hot pixel. This is NOT the test used in the standard snap-rounding algorithm, which uses the partially closed tolerance square instead. This routine is provided for testing purposes only.- Parameters:
p0
- the start point of a line segmentp1
- the end point of a line segment- Returns:
true
if the segment intersects the closure of the pixel's tolerance square
-
addSnappedNode
Adds a new node (equal to the snap pt) to the specified segment if the segment passes through the hot pixel- Parameters:
segStr
-segIndex
-- Returns:
- true if a node was added to the segment
-