Package com.treasure.hunt.utils
Class JTSUtils
- java.lang.Object
- 
- com.treasure.hunt.utils.JTSUtils
 
- 
 public final class JTSUtils extends java.lang.ObjectA utility class for the work withorg.locationtech.jts.
- 
- 
Field SummaryFields Modifier and Type Field Description static org.locationtech.jts.geom.PrecisionModelAPPROXIMATELY_PRECISIONstatic org.locationtech.jts.geom.GeometryFactoryGEOMETRY_FACTORYA static final sharedGeometryFactorywe use, such that every usage uses the same settings of the geometry factory.
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<org.locationtech.jts.geom.Point>circleLineIntersectionPoints(org.locationtech.jts.geom.Point pointA, org.locationtech.jts.geom.Point pointB, org.locationtech.jts.geom.Point center, double radius)Calculates the intersectionPoints, from a line and a circle.static java.util.ArrayList<org.locationtech.jts.geom.Coordinate>convexPolygonLineIntersection(org.locationtech.jts.geom.Polygon polygon, org.locationtech.jts.geom.LineSegment line)Tests whether the convex polygon polygon intersects with the line line and returns the intersecting coordinates if it does.static booleancoordinateEqual(org.locationtech.jts.geom.Coordinate a, org.locationtech.jts.geom.Coordinate b)static org.locationtech.jts.geom.CoordinatecoordinateInDistance(org.locationtech.jts.geom.Coordinate fixed, org.locationtech.jts.geom.Coordinate floating, double scale)Get the coordinate a given length-unit away from fixedCoordinatein vector (fixed to floating) direction.static org.locationtech.jts.algorithm.ConvexHullcreateConvexHull(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)Get theConvexHullfor a list ofCoordinates.static org.locationtech.jts.geom.LineStringcreateLineString(org.locationtech.jts.geom.Point a, org.locationtech.jts.geom.Point b)static org.locationtech.jts.geom.PointcreatePoint(double x, double y)static org.locationtech.jts.geom.PointcreatePoint(org.locationtech.jts.geom.Coordinate coordinate)static booleandoubleEqual(double a, double b)static booleandoubleEqualApproximately(double a, double b)static java.util.List<org.locationtech.jts.geom.Coordinate>getBoundaryIntersections(CanvasBoundary boundary, org.locationtech.jts.geom.LineSegment infinite)Get the intersections between the infinite line and the visual boundary.static java.util.List<org.locationtech.jts.geom.Coordinate>getCoordinateList(java.util.List<? extends org.locationtech.jts.geom.Geometry> geometries)static javafx.util.Pair<java.lang.Double,java.lang.Double>getLinearEquation(org.locationtech.jts.geom.Point pointA, org.locationtech.jts.geom.Point pointB)Works only for 2-dimensionalPoints.static org.locationtech.jts.geom.PointgetLineIntersection(javafx.util.Pair<java.lang.Double,java.lang.Double> function1, javafx.util.Pair<java.lang.Double,java.lang.Double> function2)static javafx.util.Pair<java.lang.Double,java.lang.Double>getOrthogonal(double gradient, org.locationtech.jts.geom.Point point)static booleanisApproximatelyOnLine(org.locationtech.jts.geom.Coordinate point, org.locationtech.jts.geom.LineSegment line)static booleanisBadHint(org.locationtech.jts.geom.Polygon rectangle, AngleHint hint)this function can be called to determine if the specified hint is a bad Hint defined be the paper in the context of the specified rectanglestatic org.locationtech.jts.geom.CoordinatelineWayIntersection(org.locationtech.jts.geom.LineSegment line, org.locationtech.jts.geom.LineSegment segment)Tests whether the line line intersects with the linesegment segment and returns the intersecting Coordinate (if one exists).static org.locationtech.jts.geom.CoordinatemiddleOfAngleHint(AngleHint angleHint)static org.locationtech.jts.geom.CoordinatemiddleOfAngleHint(org.locationtech.jts.geom.Coordinate right, org.locationtech.jts.geom.Coordinate center, org.locationtech.jts.geom.Coordinate left)static org.locationtech.jts.geom.CoordinatemiddleOfGeometryAngle(GeometryAngle angle)static org.locationtech.jts.math.Vector2DnegateX(org.locationtech.jts.math.Vector2D vector)static org.locationtech.jts.math.Vector2DnegateY(org.locationtech.jts.math.Vector2D vector)static org.locationtech.jts.geom.CoordinatenormalizedCoordinate(org.locationtech.jts.geom.Coordinate fixed, org.locationtech.jts.geom.Coordinate floating)Get the coordinate 1 length-unit away from fixedCoordinatein vector (fixed to floating) direction.static org.locationtech.jts.math.Vector2DnormalizedVector(org.locationtech.jts.geom.Coordinate from, org.locationtech.jts.geom.Coordinate to)static booleanpointInAngle(GeometryAngle geometryAngle, org.locationtech.jts.geom.Coordinate coordinate)static booleanpointInAngle(org.locationtech.jts.geom.Coordinate right, org.locationtech.jts.geom.Coordinate center, org.locationtech.jts.geom.Coordinate left, org.locationtech.jts.geom.Coordinate coordinate)Tests, whether a givenCoordinatelies inside the given angle, which is defined byright,centerandleft.static CirclerandomContainedCircle(Circle boundary, org.locationtech.jts.geom.Coordinate pivot, double radius)Shuffles a new circle covered by the boundary circle, containing the pivot coordinate and obtaining the given radius;static org.locationtech.jts.geom.CoordinaterandomInCircle(Circle circle)Generate a random coordinate in the given circle.static org.locationtech.jts.geom.PointshuffleTreasure()static booleansignsEqual(org.locationtech.jts.math.Vector2D v0, org.locationtech.jts.math.Vector2D v1)static org.locationtech.jts.geom.PolygontoPolygon(org.locationtech.jts.geom.Envelope envelope)static GeometryAnglevalidRandomAngle(org.locationtech.jts.geom.Coordinate searcher, org.locationtech.jts.geom.Coordinate treasure, double maxExtend)static GeometryAnglevalidRandomAngle(org.locationtech.jts.geom.Coordinate searcher, org.locationtech.jts.geom.Coordinate treasure, double maxExtend, double minExtend)
 
- 
- 
- 
Field Detail- 
GEOMETRY_FACTORYpublic static final org.locationtech.jts.geom.GeometryFactory GEOMETRY_FACTORY A static final sharedGeometryFactorywe use, such that every usage uses the same settings of the geometry factory.
 - 
APPROXIMATELY_PRECISIONpublic static final org.locationtech.jts.geom.PrecisionModel APPROXIMATELY_PRECISION 
 
- 
 - 
Method Detail- 
createPointpublic static org.locationtech.jts.geom.Point createPoint(double x, double y)- Parameters:
- x- x-coordinate
- y- y-coordinate
- Returns:
- Pointlying on- (x,y).
 
 - 
createPointpublic static org.locationtech.jts.geom.Point createPoint(org.locationtech.jts.geom.Coordinate coordinate) - Parameters:
- coordinate- The- Coordinate, which should be converted to a- Point.
- Returns:
- Pointlying on- coordinate..
 
 - 
createLineStringpublic static org.locationtech.jts.geom.LineString createLineString(org.locationtech.jts.geom.Point a, org.locationtech.jts.geom.Point b)- Parameters:
- a- the begin of the- LineString.
- b- the end of the- LineString.
- Returns:
- A LineStringcontaining onlyaandb.
 
 - 
lineWayIntersectionpublic static org.locationtech.jts.geom.Coordinate lineWayIntersection(org.locationtech.jts.geom.LineSegment line, org.locationtech.jts.geom.LineSegment segment)Tests whether the line line intersects with the linesegment segment and returns the intersecting Coordinate (if one exists).- Parameters:
- line- a- LineSegment
- segment- a- LineSegment
- Returns:
- an intersection Pointof theLineSegmentobjectslineandlineSegment
 
 - 
convexPolygonLineIntersectionpublic static java.util.ArrayList<org.locationtech.jts.geom.Coordinate> convexPolygonLineIntersection(org.locationtech.jts.geom.Polygon polygon, org.locationtech.jts.geom.LineSegment line)Tests whether the convex polygon polygon intersects with the line line and returns the intersecting coordinates if it does.- Parameters:
- polygon- a- Polygon
- line- a- LineSegment
- Returns:
- an ArrayList of the intersecting coordinates if they exist, a empty ArrayList otherwise
 
 - 
doubleEqualpublic static boolean doubleEqual(double a, double b)
 - 
coordinateEqualpublic static boolean coordinateEqual(org.locationtech.jts.geom.Coordinate a, org.locationtech.jts.geom.Coordinate b)
 - 
doubleEqualApproximatelypublic static boolean doubleEqualApproximately(double a, double b)
 - 
middleOfAngleHintpublic static org.locationtech.jts.geom.Coordinate middleOfAngleHint(AngleHint angleHint) - Parameters:
- angleHint- where we want the middle point to go, from.
- Returns:
- Coordinategoing through the middle of the- AngleHint
 
 - 
middleOfGeometryAnglepublic static org.locationtech.jts.geom.Coordinate middleOfGeometryAngle(GeometryAngle angle) 
 - 
middleOfAngleHintpublic static org.locationtech.jts.geom.Coordinate middleOfAngleHint(org.locationtech.jts.geom.Coordinate right, org.locationtech.jts.geom.Coordinate center, org.locationtech.jts.geom.Coordinate left)- Parameters:
- right- opening line of the angle
- center- of the angle
- left- closing line of the angle
- Returns:
- Coordinategoing through the middle of the angle
 
 - 
normalizedVectorpublic static org.locationtech.jts.math.Vector2D normalizedVector(org.locationtech.jts.geom.Coordinate from, org.locationtech.jts.geom.Coordinate to)- Parameters:
- from- vector start
- to- vector end
- Returns:
- normalized Vector2Dgiven by twoCoordinatesfromandto.
 
 - 
coordinateInDistancepublic static org.locationtech.jts.geom.Coordinate coordinateInDistance(org.locationtech.jts.geom.Coordinate fixed, org.locationtech.jts.geom.Coordinate floating, double scale)Get the coordinate a given length-unit away from fixedCoordinatein vector (fixed to floating) direction.- Parameters:
- fixed- fixed relative coordinate
- floating- coordinate to provide direction vector
- scale- length between fixed and asked coordinate
- Returns:
- the Coordinatea given length-unit away from fixedCoordinatein vector direction
 
 - 
normalizedCoordinatepublic static org.locationtech.jts.geom.Coordinate normalizedCoordinate(org.locationtech.jts.geom.Coordinate fixed, org.locationtech.jts.geom.Coordinate floating)Get the coordinate 1 length-unit away from fixedCoordinatein vector (fixed to floating) direction.- Parameters:
- fixed- fixed relative coordinate
- floating- coordinate to provide direction vector
- Returns:
- coordinate 1 length-unit away from fixed Coordinatein vector direction
 
 - 
signsEqualpublic static boolean signsEqual(org.locationtech.jts.math.Vector2D v0, org.locationtech.jts.math.Vector2D v1)- Parameters:
- v0- first vector to check
- v1- second vector to check
- Returns:
- true, if both vectors- v0and- v1have coordinate-wise the same sign.- false, otherwise.
 
 - 
negateXpublic static org.locationtech.jts.math.Vector2D negateX(org.locationtech.jts.math.Vector2D vector) - Parameters:
- vector- vector to transform
- Returns:
- new Vector2Dwith negated x-Coordinate of avector.
 
 - 
negateYpublic static org.locationtech.jts.math.Vector2D negateY(org.locationtech.jts.math.Vector2D vector) - Parameters:
- vector- vector to transform
- Returns:
- new Vector2Dwith negated y-Coordinate of avector.
 
 - 
pointInAnglepublic static boolean pointInAngle(GeometryAngle geometryAngle, org.locationtech.jts.geom.Coordinate coordinate) - Parameters:
- geometryAngle- the view- GeometryAnglethe method looks upon searching the given point
- coordinate- the- Coordinate, we want to know, whether it lies in the- geometryAngle.
- Returns:
- true, if- coordinatelies inside the given- geometryAngle.- false, otherwise.
 
 - 
pointInAnglepublic static boolean pointInAngle(org.locationtech.jts.geom.Coordinate right, org.locationtech.jts.geom.Coordinate center, org.locationtech.jts.geom.Coordinate left, org.locationtech.jts.geom.Coordinate coordinate)Tests, whether a givenCoordinatelies inside the given angle, which is defined byright,centerandleft.- Parameters:
- right- counter-clockwise, opening line of the angle.
- center- center of the angle.
- left- counter-clockwise, closing line of the angle.
- coordinate- the- Coordinate, we want to know, whether it lies in the given angle.
- Returns:
- true, if- coordinatelies in the given angle.- false, otherwise.
 
 - 
validRandomAnglepublic static GeometryAngle validRandomAngle(org.locationtech.jts.geom.Coordinate searcher, org.locationtech.jts.geom.Coordinate treasure, double maxExtend) - Parameters:
- searcher- the- Coordinateof the- Searcher.
- treasure- the- Coordinateof the treasure.
- maxExtend- number of- [0, 2 * Math.PI)defining, how wide the angle is opened.
- Returns:
- a valid GeometryAngle, randomly generated.
 
 - 
validRandomAnglepublic static GeometryAngle validRandomAngle(org.locationtech.jts.geom.Coordinate searcher, org.locationtech.jts.geom.Coordinate treasure, double maxExtend, double minExtend) - Parameters:
- searcher- the- Coordinateof the- Searcher.
- treasure- the- Coordinateof the treasure.
- maxExtend- number of- [0, 2 * Math.PI)defining, how wide the angle is opened.
- minExtend- number of- [0, maxExtend)
- Returns:
- a valid GeometryAngle, randomly generated.
 
 - 
getCoordinateListpublic static java.util.List<org.locationtech.jts.geom.Coordinate> getCoordinateList(java.util.List<? extends org.locationtech.jts.geom.Geometry> geometries) - Parameters:
- geometries- A list, containing- Geometry's, which should be converted to a list of- Coordinate's.
- Returns:
- A list of Coordinate's, whichgeometriesis converted to.
 
 - 
toPolygonpublic static org.locationtech.jts.geom.Polygon toPolygon(org.locationtech.jts.geom.Envelope envelope) - Parameters:
- envelope- An- Envelope, which will be converted to an- Polygon.
- Returns:
- A Polygon, aenvelopeis converted to.
 
 - 
getBoundaryIntersectionspublic static java.util.List<org.locationtech.jts.geom.Coordinate> getBoundaryIntersections(CanvasBoundary boundary, org.locationtech.jts.geom.LineSegment infinite) Get the intersections between the infinite line and the visual boundary.- Parameters:
- boundary- boundary supplying the border- LineSegments
- infinite- infinite line
- Returns:
- the intersections between the infinite line extension and the boundary LineSegments
 
 - 
randomContainedCirclepublic static Circle randomContainedCircle(Circle boundary, org.locationtech.jts.geom.Coordinate pivot, double radius) Shuffles a new circle covered by the boundary circle, containing the pivot coordinate and obtaining the given radius;- Parameters:
- boundary- circle to cover the generated circle
- pivot- coordinate, that must lay inside of the generated circle
- radius- radius of the generated circle
- Returns:
- a valid generated circle
 
 - 
createConvexHullpublic static org.locationtech.jts.algorithm.ConvexHull createConvexHull(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates) Get theConvexHullfor a list ofCoordinates.- Parameters:
- coordinates- the list of coordinates
- Returns:
- the convex hull for the list of coordinates
 
 - 
shuffleTreasurepublic static org.locationtech.jts.geom.Point shuffleTreasure() - Returns:
- A Point, where the treasure is located,msatisfyingPreferenceService.MIN_TREASURE_DISTANCE,PreferenceService.MAX_TREASURE_DISTANCEandPreferenceService.TREASURE_DISTANCE.
 
 - 
isApproximatelyOnLinepublic static boolean isApproximatelyOnLine(org.locationtech.jts.geom.Coordinate point, org.locationtech.jts.geom.LineSegment line)
 - 
randomInCirclepublic static org.locationtech.jts.geom.Coordinate randomInCircle(Circle circle) Generate a random coordinate in the given circle.- Parameters:
- circle- circle to cover the generated coordinate
- Returns:
- random coordinate in given circle
 
 - 
isBadHintpublic static boolean isBadHint(org.locationtech.jts.geom.Polygon rectangle, AngleHint hint)this function can be called to determine if the specified hint is a bad Hint defined be the paper in the context of the specified rectangle- Parameters:
- rectangle- the rectangle as- Polygon
- hint- the- AngleHint
- Returns:
- trueif the given- angleHintis a bad hint, related on the- StrategyFromPaper.- falseotherwise.
 
 - 
circleLineIntersectionPointspublic static java.util.List<org.locationtech.jts.geom.Point> circleLineIntersectionPoints(org.locationtech.jts.geom.Point pointA, org.locationtech.jts.geom.Point pointB, org.locationtech.jts.geom.Point center, double radius)Calculates the intersectionPoints, from a line and a circle. The line is described as going frompointAtopointBand the circle ist described by having his center oncenterand a radius ofradius.- Parameters:
- pointA- the first- Pointof the line
- pointB- the second- Pointof the line
- center- the center- Pointof the circle
- radius- the radius of the circle
- Returns:
- a list, containing 0, 1 or 2 Points, representing the intersections of the line and the circle.
 
 - 
getLinearEquationpublic static javafx.util.Pair<java.lang.Double,java.lang.Double> getLinearEquation(org.locationtech.jts.geom.Point pointA, org.locationtech.jts.geom.Point pointB)Works only for 2-dimensionalPoints.- Parameters:
- pointA- the first- Point, forming a line
- pointB- the second- Point, forming a line
- Returns:
- the linear equation y = xm + bof the line,pointAandpointBform. The linear equation is returned by a Pair containing the gradientmand the y-valueb, where the line cuts the y-axis.
- Throws:
- java.lang.IllegalArgumentException- if- pointAand- pointBdoes not form a function.
 
 - 
getOrthogonalpublic static javafx.util.Pair<java.lang.Double,java.lang.Double> getOrthogonal(double gradient, org.locationtech.jts.geom.Point point)- Parameters:
- gradient- the gradient to the line, we will calculate the orthogonal form.
- point- the- Point, the orthogonal will run though.
- Returns:
- the linear equation y = xm + bof the orthogonal line to a line with gradientgradient, running through pointpoint. The linear equation is returned by a Pair containing the gradientmand the y-valueb, where the line cuts the y-axis.
- Throws:
- java.lang.IllegalArgumentException- if the- gradientis 0, where there is no orthogonal.
 
 - 
getLineIntersectionpublic static org.locationtech.jts.geom.Point getLineIntersection(javafx.util.Pair<java.lang.Double,java.lang.Double> function1, javafx.util.Pair<java.lang.Double,java.lang.Double> function2)- Parameters:
- function1-- y = m1*x + b1, given as a pair containing the gradient- mand the y-coordinate- b, intersecting the y-axes.
- function2-- y = m2*x + b2, given as a pair containing the gradient- mand the y-coordinate- b, intersecting the y-axes.
- Returns:
- the intersection Point, offunction1andfunction2. Thus, we return
- Throws:
- java.lang.IllegalArgumentException- if both functions have no intersection or are equal.
 
 
- 
 
-