public class HotPixel
extends java.lang.Object
The hot pixel operations are all computed in the integer domain to avoid rounding problems.
Modifier and Type | Field and Description |
---|---|
private Coordinate[] |
corner
The corners of the hot pixel, in the order:
10
23
|
private LineIntersector |
li |
private double |
maxx |
private double |
maxy |
private double |
minx |
private double |
miny |
private Coordinate |
originalPt |
private Coordinate |
p0Scaled |
private Coordinate |
p1Scaled |
private Coordinate |
pt |
private Coordinate |
ptScaled |
private static double |
SAFE_ENV_EXPANSION_FACTOR |
private Envelope |
safeEnv |
private double |
scaleFactor |
Constructor and Description |
---|
HotPixel(Coordinate pt,
double scaleFactor,
LineIntersector li)
Creates a new hot pixel, using a given scale factor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
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 pixel
|
private void |
copyScaled(Coordinate p,
Coordinate pScaled) |
Coordinate |
getCoordinate()
Gets the coordinate this hot pixel is based at.
|
Envelope |
getSafeEnvelope()
Returns a "safe" envelope that is guaranteed to contain the hot pixel.
|
private void |
initCorners(Coordinate pt) |
boolean |
intersects(Coordinate p0,
Coordinate p1)
Tests whether the line segment (p0-p1)
intersects this hot pixel.
|
private boolean |
intersectsPixelClosure(Coordinate p0,
Coordinate p1)
Test whether the given segment intersects
the closure of this hot pixel.
|
private boolean |
intersectsScaled(Coordinate p0,
Coordinate p1) |
private boolean |
intersectsToleranceSquare(Coordinate p0,
Coordinate p1)
Tests whether the segment p0-p1 intersects the hot pixel tolerance square.
|
private double |
scale(double val) |
private LineIntersector li
private Coordinate pt
private Coordinate originalPt
private Coordinate ptScaled
private Coordinate p0Scaled
private Coordinate p1Scaled
private double scaleFactor
private double minx
private double maxx
private double miny
private double maxy
private Coordinate[] corner
private Envelope safeEnv
private static final double SAFE_ENV_EXPANSION_FACTOR
public HotPixel(Coordinate pt, double scaleFactor, LineIntersector li)
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 segmentspublic Coordinate getCoordinate()
public Envelope getSafeEnvelope()
private void initCorners(Coordinate pt)
private double scale(double val)
public boolean intersects(Coordinate p0, Coordinate p1)
p0
- the first coordinate of the line segment to testp1
- the second coordinate of the line segment to testprivate void copyScaled(Coordinate p, Coordinate pScaled)
private boolean intersectsScaled(Coordinate p0, Coordinate p1)
private boolean intersectsToleranceSquare(Coordinate p0, Coordinate p1)
p0
- p1
- private boolean intersectsPixelClosure(Coordinate p0, Coordinate p1)
p0
- the start point of a line segmentp1
- the end point of a line segmenttrue
if the segment intersects the closure of the pixel's tolerance squarepublic boolean addSnappedNode(NodedSegmentString segStr, int segIndex)
segStr
- segIndex
-