Modifier and Type | Class and Description |
---|---|
static class |
Geometry.PolygonIntersection |
Modifier | Constructor and Description |
---|---|
private |
Geometry() |
Modifier and Type | Method and Description |
---|---|
static Set<Node> |
addIntersections(List<Way> ways,
boolean test,
List<Command> cmds)
Will find all intersection and add nodes there for list of given ways.
|
static boolean |
angleIsClockwise(EastNorth commonNode,
EastNorth firstNode,
EastNorth secondNode)
This method tests if secondNode is clockwise to first node.
|
static boolean |
angleIsClockwise(Node commonNode,
Node firstNode,
Node secondNode)
This method tests if secondNode is clockwise to first node.
|
protected static double |
calcX(Node p1) |
protected static double |
calcY(Node p1) |
static double |
closedWayArea(Way way)
Returns area of a closed way in square meters.
|
private static EastNorth |
closestPointTo(EastNorth p1,
EastNorth p2,
EastNorth point,
boolean segmentOnly) |
static EastNorth |
closestPointToLine(EastNorth lineP1,
EastNorth lineP2,
EastNorth point)
Calculates closest point to a line.
|
static EastNorth |
closestPointToSegment(EastNorth segmentP1,
EastNorth segmentP2,
EastNorth point)
Calculates closest point to a line segment.
|
private static Area |
getArea(List<Node> polygon) |
static EastNorth |
getCentroid(List<Node> nodes)
Compute the centroid of nodes
|
static double |
getCornerAngle(EastNorth p1,
EastNorth p2,
EastNorth p3)
Returns angle of a corner defined with 3 point coordinates.
|
static EastNorth |
getLineLineIntersection(EastNorth p1,
EastNorth p2,
EastNorth p3,
EastNorth p4)
Finds the intersection of two lines of infinite length.
|
private static BBox |
getNodesBounds(List<Node> nodes) |
static EastNorth |
getSegmentAltituteIntersection(EastNorth sp1,
EastNorth sp2,
EastNorth ap)
Returns the coordinate of intersection of segment sp1-sp2 and an altitude
to it starting at point ap.
|
static double |
getSegmentAngle(EastNorth p1,
EastNorth p2)
Returns angle of a segment defined with 2 point coordinates.
|
static EastNorth |
getSegmentSegmentIntersection(EastNorth p1,
EastNorth p2,
EastNorth p3,
EastNorth p4)
Finds the intersection of two line segments
|
static boolean |
isClockwise(Way w)
Determines whether a way is oriented clockwise.
|
static boolean |
isToTheRightSideOfLine(Node lineP1,
Node lineP2,
Node lineP3,
Node testPoint)
Tests if given point is to the right side of path consisting of 3 points.
|
static boolean |
nodeInsidePolygon(Node point,
List<Node> polygonNodes)
Tests if point is inside a polygon.
|
static Geometry.PolygonIntersection |
polygonIntersection(List<Node> first,
List<Node> second)
Tests if two polygons intersect.
|
static boolean |
segmentsParallel(EastNorth p1,
EastNorth p2,
EastNorth p3,
EastNorth p4) |
private Geometry()
public static Set<Node> addIntersections(List<Way> ways, boolean test, List<Command> cmds)
ways
- a list of ways to testtest
- if false, do not build list of Commands, just return nodescmds
- list of commands, typically empty when handed to this method.
Will be filled with commands that add intersection nodes to
the ways.private static BBox getNodesBounds(List<Node> nodes)
public static boolean isToTheRightSideOfLine(Node lineP1, Node lineP2, Node lineP3, Node testPoint)
lineP1
- first point in pathlineP2
- second point in pathlineP3
- third point in pathtestPoint
- public static boolean angleIsClockwise(Node commonNode, Node firstNode, Node secondNode)
commonNode
- starting point for both vectorsfirstNode
- first vector end nodesecondNode
- second vector end nodepublic static EastNorth getSegmentSegmentIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4)
public static EastNorth getLineLineIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4)
IllegalArgumentException
- if a parameter is null or without valid coordinatespublic static boolean segmentsParallel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4)
private static EastNorth closestPointTo(EastNorth p1, EastNorth p2, EastNorth point, boolean segmentOnly)
public static EastNorth closestPointToSegment(EastNorth segmentP1, EastNorth segmentP2, EastNorth point)
segmentP1
- First point determining line segmentsegmentP2
- Second point determining line segmentpoint
- Point for which a closest point is searched on line segment [P1,P2]closestPointToLine(org.openstreetmap.josm.data.coor.EastNorth, org.openstreetmap.josm.data.coor.EastNorth, org.openstreetmap.josm.data.coor.EastNorth)
public static EastNorth closestPointToLine(EastNorth lineP1, EastNorth lineP2, EastNorth point)
lineP1
- First point determining linelineP2
- Second point determining linepoint
- Point for which a closest point is searched on line (P1,P2)closestPointToSegment(org.openstreetmap.josm.data.coor.EastNorth, org.openstreetmap.josm.data.coor.EastNorth, org.openstreetmap.josm.data.coor.EastNorth)
public static boolean angleIsClockwise(EastNorth commonNode, EastNorth firstNode, EastNorth secondNode)
commonNode
- starting point for both vectorsfirstNode
- first vector end nodesecondNode
- second vector end nodepublic static Geometry.PolygonIntersection polygonIntersection(List<Node> first, List<Node> second)
first
- second
- public static boolean nodeInsidePolygon(Node point, List<Node> polygonNodes)
polygonNodes
- list of nodes from polygon path.point
- the point to testpublic static double closedWayArea(Way way)
way
- Way to measure, should be closed (first node is the same as last node)public static boolean isClockwise(Way w)
2 * area = sum (X[n] * Y[n+1] - X[n+1] * Y[n])
.
If the area is negative the way is ordered in a clockwise direction.
See http://paulbourke.net/geometry/polyarea/w
- the way to be checked.IllegalArgumentException
- if way is not closed (see Way.isClosed()
).public static double getSegmentAngle(EastNorth p1, EastNorth p2)
p1
- p2
- public static double getCornerAngle(EastNorth p1, EastNorth p2, EastNorth p3)
p1
- p2
- Common endpointp3
- public static EastNorth getCentroid(List<Node> nodes)
nodes
- Nodes for which the centroid is wantedpublic static EastNorth getSegmentAltituteIntersection(EastNorth sp1, EastNorth sp2, EastNorth ap)
sp1
- sp2
- ap
-