public class GeometryUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ANGLE_TURN_CLOCKWISE
A value that indicates an orientation of clockwise, or a right turn.
|
static int |
ANGLE_TURN_COUNTERCLOCKWISE
A value that indicates an orientation of counterclockwise, or a left
turn.
|
static int |
ANGLE_TURN_NONE
A value that indicates an orientation of collinear, or no turn
(straight).
|
Modifier and Type | Method and Description |
---|---|
static double |
angleDiff(double ang1,
double ang2)
Computes the unoriented smallest difference between two angles.
|
static int |
angleGetTurn(double ang1,
double ang2)
Returns whether an angle must turn clockwise or counterclockwise to
overlap another angle.
|
static boolean |
areThreePointsInLine(Point a,
Point b,
Point c) |
static double |
calculateAngle(Point vertex,
Point p)
Find the angle in the counterclockwise direction between
the horizontal line and point p relative to the vertex
|
static double |
calculateAngle(Point vertex,
Point p1,
Point p2)
Calculate the angle between points p1 and p2 with vertex at vertex point
|
static Point |
calculateLambdaPoint(Point p1,
Point p2,
double lambda)
Calculates a point on the line that passes through two points whose
distance to the first is proportional to the distance between them
according to the lambda parameter
|
static boolean |
canAggregate(int geomTypeParent,
int geomTypeChild) |
static java.lang.Object |
convertTo(Geometry geom,
java.lang.String format) |
static Arc |
createArc(Point center,
double radius,
double startAngle,
double angleExt,
int subtype)
Creates an arc as of center, radius, start angle and extension angle.
|
static Arc |
createArc(Point start,
Point middle,
Point end,
int subtype)
Creates an arc as of three points.
|
static Circle |
createCircle(EuclideanLine2D line1,
EuclideanLine2D line2,
Point point,
int subtype)
Creates a circle from two tangents and one point.
|
static Circle |
createCircle(Geometry geometry1,
Geometry geometry2,
double radius,
Point firstPoint,
Point secondPoint,
int subtype)
Creates a circle from two tangent geometries and the radius.
|
static Circle |
createCircle(Point center,
double radius,
int subtype)
Creates a circle as of center and radius.
|
static Circle |
createCircle(Point firstPoint,
Point secondPoint,
Point thirdPoint,
int subtype)
Creates a circle from three points.
|
static Circle |
createCircle(Point firstPoint,
Point secondPoint,
Point thirdPoint,
Point fourthPoint,
Point fifthPoint,
int subtype)
Creates a circle from five points.The first two points are two points on a tangent to the circle.The next two are two points on another tangent to the circle.The last one is a point near the center of the circle.
|
static Arc |
createEllipse(Point firstPointAxisA,
Point secondPointAxisA,
double halfLengthAxisB,
int subtype)
Creates an ellipse from start and end point of A axis and half length
of B axis.
|
static Envelope |
createEnvelope(double minX,
double minY,
double maxX,
double maxY,
int subType) |
static Envelope |
createEnvelope(int subType) |
static Ellipse |
createFilledEllipse(Point firstPointAxisA,
Point secondPointAxisA,
double halfLengthAxisB,
int subtype)
Creates a filled ellipse from start and end point of A axis and half length
of B axis.
|
static Geometry |
createFrom(java.lang.Object data) |
static Geometry |
createFrom(java.lang.String wkt) |
static Geometry |
createFrom(java.lang.String wkt,
IProjection srs) |
static Geometry |
createFrom(java.lang.String wkt,
java.lang.String srs) |
static Line |
createLine(double x1,
double y1,
double x2,
double y2,
int subtype)
Creates line as of two point coordinates.
|
static Line |
createLine(int subType) |
static Line |
createLine(Point p1,
Point p2,
int subtype)
Creates line as of two point objects.
|
static MultiLine |
createMultiLine(int subType) |
static MultiPolygon |
createMultiPolygon(int subType) |
static Point |
createPoint(double x,
double y) |
static Point |
createPoint(double x,
double y,
double z) |
static Point |
createPoint(double x,
double y,
double z,
double m) |
static Point |
createPoint(Point center,
double radius,
double angle) |
static Polygon |
createPolygon(int subType) |
static Spline |
createSpline(java.util.List<Point> points,
int subtype)
Create Spline from point list
|
static java.util.List<Geometry> |
extractFrom(JsonValue json,
IProjection proj) |
static java.util.List<Geometry> |
extractFrom(java.lang.String s,
IProjection proj) |
static java.lang.String |
formatAngle(java.lang.String fmt,
double angle) |
static java.lang.String |
formatCoordinate(java.lang.String fmt,
double coordinate)
Returns a formatted string using the specified format string and coordinate values.Conversion options are:
%[flags][width][.precision]d The result is formatted as a integer number with the degress of the coordinate
%[flags][width][.precision]m The result is formatted as a integer number with the minutes of the coordinate
%[flags][width][.precision]s The result is formatted as a decimal number with the seconds of the coordinate. |
static java.lang.String |
formatCoordinate(java.lang.String fmt,
java.lang.String NS,
double coordinate) |
static Point |
getCenter(Point a,
Point b,
Point c,
int subtype)
Gets center point of three points.
|
static double |
getCoefDirection(Point center,
Point point1,
Point point2)
Returns the coefficient that expresses the direction in which the angle with vertex at center a and from point1 to point2 is beaten
coefDirection >= 0 then the direction is CCW
else the direction is CW
|
static int |
getGeometrySubtype(java.lang.String subtype) |
static java.lang.String |
getGeometrySubtypeName(int subtype) |
static GeometryType |
getGeometryType(int geometryType,
int geometrySubType) |
static int |
getGeometryType(java.lang.String typeName) |
static java.lang.String |
getGeometryTypeName(int type) |
static Point |
getMidPoint(Point a,
Point b,
int subtype)
Gets midpoint of two points
|
static boolean |
intersects(Geometry geom1,
Geometry geom2) |
static boolean |
isSubtype(int geomTypeParent,
int geomTypeChild) |
static boolean |
overlaps(Geometry polygon,
Geometry polygon2,
double theTolerance)
Returns true if two polygons overlap taking into account the given tolerance
|
static double |
parseCoordinate(java.lang.String source) |
static Geometry |
toAggregate(java.util.List<Geometry> geoms,
java.lang.StringBuilder warnings) |
static byte[] |
toEWKB(Geometry geom) |
static byte[] |
toWKB(Geometry geom) |
static java.lang.String |
toWKT(Geometry geom) |
public static final int ANGLE_TURN_CLOCKWISE
public static final int ANGLE_TURN_COUNTERCLOCKWISE
public static final int ANGLE_TURN_NONE
public static GeometryType getGeometryType(int geometryType, int geometrySubType)
public static boolean isSubtype(int geomTypeParent, int geomTypeChild)
public static boolean canAggregate(int geomTypeParent, int geomTypeChild)
public static Envelope createEnvelope(int subType)
public static Envelope createEnvelope(double minX, double minY, double maxX, double maxY, int subType)
public static Line createLine(int subType)
public static MultiLine createMultiLine(int subType)
public static Polygon createPolygon(int subType)
public static MultiPolygon createMultiPolygon(int subType)
public static Point createPoint(double x, double y)
public static Point createPoint(double x, double y, double z)
public static Point createPoint(double x, double y, double z, double m)
public static Geometry createFrom(java.lang.Object data)
public static Geometry createFrom(java.lang.String wkt, java.lang.String srs)
public static Geometry createFrom(java.lang.String wkt, IProjection srs)
public static Geometry createFrom(java.lang.String wkt)
public static java.lang.Object convertTo(Geometry geom, java.lang.String format)
public static java.lang.String toWKT(Geometry geom)
public static byte[] toWKB(Geometry geom)
public static byte[] toEWKB(Geometry geom)
public static java.lang.String getGeometryTypeName(int type)
public static java.lang.String getGeometrySubtypeName(int subtype)
public static int getGeometryType(java.lang.String typeName)
public static int getGeometrySubtype(java.lang.String subtype)
public static Circle createCircle(Point center, double radius, int subtype) throws CreateGeometryException
center
- of new circleradius
- of new circlesubtype
- subtype of circle. See Geometry.SUBTYPES
CreateGeometryException
public static Circle createCircle(Point firstPoint, Point secondPoint, Point thirdPoint, int subtype) throws CreateGeometryException
firstPoint
- of circlesecondPoint
- of circlethirdPoint
- of circlesubtype
- subtype of circle. See Geometry.SUBTYPES
CreateGeometryException
public static Circle createCircle(Point firstPoint, Point secondPoint, Point thirdPoint, Point fourthPoint, Point fifthPoint, int subtype) throws CreateGeometryException
firstPoint
- secondPoint
- thirdPoint
- fourthPoint
- fifthPoint
- subtype
- subtype of circle. See Geometry.SUBTYPES
CreateGeometryException
public static Circle createCircle(EuclideanLine2D line1, EuclideanLine2D line2, Point point, int subtype) throws CreateGeometryException
line1
- A tangent lineline2
- Another tangent linepoint
- A point near the center of the circle.subtype
- subtype of circle. See Geometry.SUBTYPES
CreateGeometryException
public static Circle createCircle(Geometry geometry1, Geometry geometry2, double radius, Point firstPoint, Point secondPoint, int subtype) throws CreateGeometryException
geometry1
- A tangent geometrygeometry2
- Another tangent geometryradius
- the radius of the cicle.firstPoint
- a point near tangent point of geometry1secondPoint
- a point near tangent point of geometry2subtype
- subtype of circle. See Geometry.SUBTYPES
CreateGeometryException
public static Arc createArc(Point center, double radius, double startAngle, double angleExt, int subtype) throws CreateGeometryException
center
- center of arc.radius
- of arc.startAngle
- of arc in radiansangleExt
- of arc in radianssubtype
- subtype of arc. See Geometry.SUBTYPES
CreateGeometryException
public static Arc createArc(Point start, Point middle, Point end, int subtype) throws BaseException
start
- point of arcmiddle
- point of arc. It can be any point of arc.end
- point of arcsubtype
- of arc. See Geometry.SUBTYPES
BaseException
public static Arc createEllipse(Point firstPointAxisA, Point secondPointAxisA, double halfLengthAxisB, int subtype) throws CreateGeometryException
firstPointAxisA
- first point of A axissecondPointAxisA
- second point of B axishalfLengthAxisB
- half length of B axissubtype
- of ellipse See Geometry.SUBTYPES
CreateGeometryException
public static Ellipse createFilledEllipse(Point firstPointAxisA, Point secondPointAxisA, double halfLengthAxisB, int subtype) throws CreateGeometryException
firstPointAxisA
- first point of A axissecondPointAxisA
- second point of B axishalfLengthAxisB
- half length of B axissubtype
- of ellipse See Geometry.SUBTYPES
CreateGeometryException
public static Point getCenter(Point a, Point b, Point c, int subtype) throws CreateGeometryException
a
- Point oneb
- Point twoc
- Point threesubtype
- of point created. See Geometry.SUBTYPES
CreateGeometryException
public static Point getMidPoint(Point a, Point b, int subtype) throws CreateGeometryException
a
- Point oneb
- Point twosubtype
- of point created. See Geometry.SUBTYPES
CreateGeometryException
public static Line createLine(double x1, double y1, double x2, double y2, int subtype) throws CreateGeometryException
x1
- The X1 coordinatey1
- The y1 coordinatex2
- The X2 coordinatey2
- The y2 coordinatesubtype
- of line. See Geometry.SUBTYPES
CreateGeometryException
public static Line createLine(Point p1, Point p2, int subtype) throws CreateGeometryException
p1
- First pointp2
- Second pointsubtype
- of line. See Geometry.SUBTYPES
CreateGeometryException
public static Spline createSpline(java.util.List<Point> points, int subtype) throws CreateGeometryException
points
- subtype
- CreateGeometryException
public static double calculateAngle(Point vertex, Point p1, Point p2)
vertex
- p1
- p2
- public static double calculateAngle(Point vertex, Point p)
vertex
- p
- public static java.lang.String formatCoordinate(java.lang.String fmt, double coordinate)
%[flags][width][.precision]d
The result is formatted as a integer number with the degress of the coordinate
%[flags][width][.precision]m
The result is formatted as a integer number with the minutes of the coordinate
%[flags][width][.precision]s
The result is formatted as a decimal number with the seconds of the coordinate.
%[flags][width][.precision]D
The result is formatted as a decimal number with the degress
%-
The result is formatted with the sign if it is negative
%+
The result is formatted with the sign
formatCoordinate("%-%d° %m' %s'' N", 39.89) | "39° 53' 24.000'' N" |
formatCoordinate("%-%d° %m' %.0s'' N", 39.89) | "39° 53' 24'' N" |
formatCoordinate("%+%d° %m' %.2s'' N (%4.4D)", 39.89) | "+39° 53' 24.00'' N (39.8900)" |
formatCoordinate("%-%d° %m' N", 39.89) | "39° 53' N" |
formatCoordinate("%-%d° %m' N", -39.89) | "-39° 53' N" |
formatCoordinate("%-%d° %m' N (%4.4D)", 39.89) | "39° 53' N (39.8900)" |
fmt
- coordinate
- public static java.lang.String formatCoordinate(java.lang.String fmt, java.lang.String NS, double coordinate)
public static java.lang.String formatAngle(java.lang.String fmt, double angle)
public static double parseCoordinate(java.lang.String source)
public static double getCoefDirection(Point center, Point point1, Point point2)
center
- point1
- point2
- public static Point calculateLambdaPoint(Point p1, Point p2, double lambda) throws CreateGeometryException, GeometryOperationNotSupportedException, GeometryOperationException
p1
- p2
- lambda
- CreateGeometryException
GeometryOperationNotSupportedException
GeometryOperationException
public static boolean overlaps(Geometry polygon, Geometry polygon2, double theTolerance) throws GeometryOperationNotSupportedException, GeometryOperationException
polygon
- polygon2
- theTolerance
- GeometryOperationNotSupportedException
GeometryOperationException
public static int angleGetTurn(double ang1, double ang2)
ang1
- an angle (in radians)ang2
- an angle (in radians)public static double angleDiff(double ang1, double ang2)
ang1
- the angle of one vector (in [-Pi, Pi] )ang2
- the angle of the other vector (in range [-Pi, Pi] )public static final java.util.List<Geometry> extractFrom(java.lang.String s, IProjection proj)
public static final java.util.List<Geometry> extractFrom(JsonValue json, IProjection proj)