Class HotPixel
- java.lang.Object
-
- org.locationtech.jts.noding.snapround.HotPixel
-
public class HotPixel extends java.lang.Object
Implements a "hot pixel" as used in the Snap Rounding algorithm. A hot pixel is a square region centred on the rounded valud of the coordinate given, and of width equal to the size of the scale factor. It is a partially open region, which contains the interior of the tolerance square and the boundary minus the top and right segments. This ensures that every point of the space lies in a unique hot pixel. It also matches the rounding semantics for numbers.The hot pixel operations are all computed in the integer domain to avoid rounding problems.
Hot Pixels support being marked as nodes. This is used to prevent introducing nodes at line vertices which do not have other lines snapped to them.
- Version:
- 1.7
-
-
Constructor Summary
Constructors Constructor Description HotPixel(Coordinate pt, double scaleFactor)
Creates a new hot pixel centered on a rounded point, using a given scale factor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Coordinate
getCoordinate()
Gets the coordinate this hot pixel is based at.double
getScaleFactor()
Gets the scale factor for the precision grid for this pixel.double
getWidth()
Gets the width of the hot pixel in the original coordinate system.boolean
intersects(Coordinate p)
Tests whether a coordinate lies in (intersects) this hot pixel.boolean
intersects(Coordinate p0, Coordinate p1)
Tests whether the line segment (p0-p1) intersects this hot pixel.boolean
isNode()
Tests whether this pixel has been marked as a node.void
setToNode()
Sets this pixel to be a node.java.lang.String
toString()
-
-
-
Constructor Detail
-
HotPixel
public HotPixel(Coordinate pt, double scaleFactor)
Creates a new hot pixel centered on a rounded point, using a given scale factor. The scale factor must be strictly positive (non-zero).- Parameters:
pt
- the coordinate at the centre of the pixel (already rounded)scaleFactor
- the scaleFactor determining the pixel size. Must be > 0
-
-
Method Detail
-
getCoordinate
public Coordinate getCoordinate()
Gets the coordinate this hot pixel is based at.- Returns:
- the coordinate of the pixel
-
getScaleFactor
public double getScaleFactor()
Gets the scale factor for the precision grid for this pixel.- Returns:
- the pixel scale factor
-
getWidth
public double getWidth()
Gets the width of the hot pixel in the original coordinate system.- Returns:
- the width of the hot pixel tolerance square
-
isNode
public boolean isNode()
Tests whether this pixel has been marked as a node.- Returns:
- true if the pixel is marked as a node
-
setToNode
public void setToNode()
Sets this pixel to be a node.
-
intersects
public boolean intersects(Coordinate p)
Tests whether a coordinate lies in (intersects) this hot pixel.- Parameters:
p
- the coordinate to test- Returns:
- true if the coordinate intersects this hot pixel
-
intersects
public boolean intersects(Coordinate p0, Coordinate p1)
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-