public class SpatialUtils
extends java.lang.Object
Constructor and Description |
---|
SpatialUtils() |
Modifier and Type | Method and Description |
---|---|
static JGeometrySegmentPoint |
createSegmentPoint(double pointX, double pointY, double[] lineOrdinates, int segmentIndex)
Creates a JGeometrySegmentPoint for the given line ordinates.
|
static double |
distToLine(java.awt.geom.Point2D point, JGeometry line)
Gets the distance from the given point to the nearest point at the given line
|
static double |
getDataSRSTolerance(java.awt.geom.AffineTransform affineTransform, double pxTolerance)
Gets a tolerance in the data coordinate system given a tolerance in pixels
|
static double |
getDistance(double x1, double y1, double x2, double y2)
Gets the distance between two points
|
static double |
getDistance(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2)
Gets the distance between two points
|
static double |
getLineLength(double[] lineOrdinates)
Gets the length of a line.
|
static JGeometrySegment |
getLineNearestSegment(double[] ordinates, java.awt.geom.Point2D targetPoint, double tolerance)
Gets the line's segment nearest to the given point as long as it is not farer than the given tolerance
|
static JGeometrySegment |
getLineNearestSegment(JGeometry line, java.awt.geom.Point2D targetPoint, double tolerance)
Gets the line's segment nearest to the given point as long as it is not farer than the given tolerance
|
static JGeometrySegmentPoint |
getLineSegmentPoint(double[] ordinates, java.awt.geom.Point2D targetPoint, double tolerance)
Gets the nearest segment point in the line to the given point as long as it is not farer than the given tolerance.
|
static JGeometrySegmentPoint |
getLineSegmentPoint(JGeometry line, java.awt.geom.Point2D point)
Gets the nearest segment point in the line to the given point.
|
static JGeometrySegmentPoint |
getLineSegmentPoint(JGeometry line, java.awt.geom.Point2D targetPoint, double tolerance)
Gets the nearest segment point in the line to the given point as long as it is not farer than the given tolerance.
|
static java.awt.geom.Rectangle2D |
getMBR(JGeometry geom, double threshold)
Gets the MBR of the given geometry containing the given threshold
|
static java.awt.geom.Point2D |
getPointOnLine(double[] lineOrdinates, double positionPercentage)
Gets the spatial location of a point in the line given a percentage of the line's length
|
static double |
getPositionPercentage(JGeometry lineGeom, JGeometrySegmentPoint segmentPoint)
Given a line and a line's segment point, gives the corresponding percentage of that point relative to the line's length.
|
static double |
getPositionPercentage(JGeometry lineGeom, java.awt.geom.Point2D point, double tolerance)
Given a line and a point, gives the corresponding percentage of that point relative to the line's length.
|
static JGeometrySegmentPoint |
getSegmentPoint(double[] lineOrdinates, double positionPercentage)
Gets the line segment point information corresponding to a position in the line given as a percentage of the line's length
|
static JGeometry |
getSubLine(JGeometry line, double startPos, double endPos)
Gets the geometry of a portion of the given line
|
static JGeometry |
getSubLine(JGeometry line, JGeometrySegmentPoint startSegPoint, JGeometrySegmentPoint endSegPoint)
Gets the geometry of a portion of the given line
|
static JGeometry |
getSubLine(JGeometry line, java.awt.geom.Point2D startPoint, java.awt.geom.Point2D endPoint, double tolerance)
Gets the geometry of a portion of the given line
|
static double |
getSubLineLength(JGeometry lineGeom, JGeometrySegmentPoint segmentPoint)
Gets the length from the line's start point to the given point in the line.
|
static double |
getSubLineLength(JGeometry lineGeom, java.awt.geom.Point2D point, double tolerance)
Gets the length from the line's start point to the given point in the line.
|
static boolean |
isSamePoint(double[] point1, double[] point2)
Tells whether the given points are located at the same position
|
static JGeometry |
joinAdjacentLines(JGeometry srcLine, JGeometry endLine)
Joins two lines into one single line
|
static JGeometry |
moveLinePoint(JGeometry line, int pointIndex, java.awt.geom.Point2D newPoint)
Replaces line's point by another
|
static JGeometry |
translate(JGeometry geom, double transX, double transY)
Translates a geometry
|
public static double getDataSRSTolerance(java.awt.geom.AffineTransform affineTransform, double pxTolerance) throws java.awt.geom.NoninvertibleTransformException
affineTransform
- the affine transform used for converting between coordinate systemspxTolerance
- a tolerance in pixelsjava.awt.geom.NoninvertibleTransformException
public static double getDistance(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2)
point1
- a point objectpoint2
- a point objectpublic static double getDistance(double x1, double y1, double x2, double y2)
x1
- the first point's x ordinatey1
- the first point's y ordinatex2
- the second point's x ordinatey2
- the second point's y ordinatepublic static double distToLine(java.awt.geom.Point2D point, JGeometry line)
point
- a point objectline
- a line string geometry objectpublic static boolean isSamePoint(double[] point1, double[] point2)
point1
- a two-valued array containing the coordinates of a pointpoint2
- a two-valued array containing the coordinates of a pointpublic static JGeometry moveLinePoint(JGeometry line, int pointIndex, java.awt.geom.Point2D newPoint)
line
- a line string geometry objectpointIndex
- the index of the point to be replaced. Given the line's ordinate array, the index corresponds to the position por the x ordinate of the point that is going to be replaced.newPoint
- a point object that will be the new line's pointpublic static double getLineLength(double[] lineOrdinates)
lineOrdinates
- the line ordinatespublic static java.awt.geom.Point2D getPointOnLine(double[] lineOrdinates, double positionPercentage)
lineOrdinates
- the line ordinatespositionPercentage
- a percentage of the line's lengthpublic static JGeometrySegmentPoint getSegmentPoint(double[] lineOrdinates, double positionPercentage)
lineOrdinates
- the line ordinatespositionPercentage
- a percentage of the line's lengthpublic static JGeometrySegmentPoint createSegmentPoint(double pointX, double pointY, double[] lineOrdinates, int segmentIndex)
pointX
- the x ordinate of the segment pointpointY
- the y ordinate of the segment pointlineOrdinates
- a line ordinatessegmentIndex
- the index of the line segment. The index is based on the number of segments in the line, not the ordinates, and it is zero based.public static JGeometrySegmentPoint getLineSegmentPoint(JGeometry line, java.awt.geom.Point2D targetPoint, double tolerance)
line
- a line stringtargetPoint
- a point objecttolerance
- the maximum distance between the given point and the line's pointpublic static JGeometrySegmentPoint getLineSegmentPoint(double[] ordinates, java.awt.geom.Point2D targetPoint, double tolerance)
ordinates
- a line string ordinatestargetPoint
- a point objecttolerance
- the maximum distance between the given point and the line's pointpublic static JGeometrySegmentPoint getLineSegmentPoint(JGeometry line, java.awt.geom.Point2D point)
line
- a line stringpoint
- a point objectpublic static JGeometrySegment getLineNearestSegment(JGeometry line, java.awt.geom.Point2D targetPoint, double tolerance)
line
- a line stringtargetPoint
- a point objecttolerance
- the value bounding the distancepublic static JGeometrySegment getLineNearestSegment(double[] ordinates, java.awt.geom.Point2D targetPoint, double tolerance)
ordinates
- a line string ordinatestargetPoint
- a point objecttolerance
- the value bounding the distancepublic static JGeometry getSubLine(JGeometry line, java.awt.geom.Point2D startPoint, java.awt.geom.Point2D endPoint, double tolerance)
line
- a line stringstartPoint
- a point of the original line that will be the start point of the sub lineendPoint
- a point of the original line that will be the end point of the sub linetolerance
- tells how far can be the given start and end points to be considered as points in the linepublic static JGeometry getSubLine(JGeometry line, double startPos, double endPos)
line
- a line stringstartPoint
- a point of the original line that will be the start point of the sub lineendPoint
- a point of the original line that will be the end point of the sub linepublic static JGeometry getSubLine(JGeometry line, JGeometrySegmentPoint startSegPoint, JGeometrySegmentPoint endSegPoint)
line
- a line stringstartSegPoint
- a segment point of the original line that will be the start point of the sub lineendSegPoint
- a segment point of the original line that will be the end point of the sub linepublic static double getPositionPercentage(JGeometry lineGeom, java.awt.geom.Point2D point, double tolerance)
lineGeom
- a line stringpoint
- a point objecttolerance
- the maximum distance from the point to the line to be considered as a point on the linepublic static double getPositionPercentage(JGeometry lineGeom, JGeometrySegmentPoint segmentPoint)
lineGeom
- a line stringsegmentPoint
- the line's segment pointpublic static double getSubLineLength(JGeometry lineGeom, java.awt.geom.Point2D point, double tolerance)
lineGeom
- a line stringpoint
- a point objecttolerance
- the maximum distance from the point to the linepublic static double getSubLineLength(JGeometry lineGeom, JGeometrySegmentPoint segmentPoint)
lineGeom
- a line stringsegmentPoint
- a line's segment pointpublic static JGeometry translate(JGeometry geom, double transX, double transY)
geom
- a geometry objecttransX
- the distance the geometry will be moved in the x dimensiontransY
- the distance the geometry will be moved in the y dimensionpublic static java.awt.geom.Rectangle2D getMBR(JGeometry geom, double threshold)
geom
- a geometry objectthreshold
- an additional distance added to each side of the resulting MBRpublic static JGeometry joinAdjacentLines(JGeometry srcLine, JGeometry endLine)
srcLine
- a line string which will be the initial line segments of the resulting linesendLine
- a line string which will be the last line segments of the resulting lines