|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.tools.Geometry
public class Geometry
Some tools for geometry related tasks.
Nested Class Summary | |
---|---|
static class |
Geometry.PolygonIntersection
|
Constructor Summary | |
---|---|
Geometry()
|
Method Summary | |
---|---|
static java.util.Set<Node> |
addIntersections(java.util.List<Way> ways,
boolean test,
java.util.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. |
static EastNorth |
closestPointToLine(EastNorth lineP1,
EastNorth lineP2,
EastNorth point)
|
static EastNorth |
closestPointToSegment(EastNorth segmentP1,
EastNorth segmentP2,
EastNorth point)
Calculates closest point to a line segment. |
static EastNorth |
getCentroid(java.util.List<Node> 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(java.util.ArrayList<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,
java.util.List<Node> polygonNodes)
Tests if point is inside a polygon. |
static Geometry.PolygonIntersection |
polygonIntersection(java.util.List<Node> first,
java.util.List<Node> second)
Tests if two polygons intersect. |
static boolean |
segmentsParallel(EastNorth p1,
EastNorth p2,
EastNorth p3,
EastNorth p4)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Geometry()
Method Detail |
---|
public static java.util.Set<Node> addIntersections(java.util.List<Way> ways, boolean test, java.util.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(java.util.ArrayList<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 node
public static EastNorth getSegmentSegmentIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4)
public static EastNorth getLineLineIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4)
public static boolean segmentsParallel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4)
public static EastNorth closestPointToSegment(EastNorth segmentP1, EastNorth segmentP2, EastNorth point)
segmentP1
- segmentP2
- point
-
public static EastNorth closestPointToLine(EastNorth lineP1, EastNorth lineP2, EastNorth point)
public static boolean angleIsClockwise(EastNorth commonNode, EastNorth firstNode, EastNorth secondNode)
commonNode
- starting point for both vectorsfirstNode
- first vector end nodesecondNode
- second vector end node
public static Geometry.PolygonIntersection polygonIntersection(java.util.List<Node> first, java.util.List<Node> second)
first
- second
-
public static boolean nodeInsidePolygon(Node point, java.util.List<Node> polygonNodes)
polygonNodes
- list of nodes from polygon path.point
- the point to test
public static double closedWayArea(Way way)
way
- Way to measure, should be closed (first node is the same as last node)
protected static double calcX(Node p1)
protected static double calcY(Node p1)
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.
java.lang.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(java.util.List<Node> nodes)
public static EastNorth getSegmentAltituteIntersection(EastNorth sp1, EastNorth sp2, EastNorth ap)
sp1
- sp2
- ap
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |