public class GeometryUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_EPSILON
Default epsilon for line tolerance
|
| Constructor and Description |
|---|
GeometryUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Map<GeometryType,Map<GeometryType,?>> |
childHierarchy(GeometryType geometryType)
Get the child type hierarchy of the provided geometry type.
|
static List<GeometryType> |
childTypes(GeometryType geometryType)
Get the immediate child Geometry Types of the provided geometry type
|
static boolean |
closedPolygon(LineString ring)
Check if the polygon ring is explicitly closed, where the first and last
point are the same
|
static boolean |
closedPolygon(List<Point> points)
Check if the polygon ring points are explicitly closed, where the first
and last point are the same
|
static boolean |
closedPolygon(Polygon polygon)
Check if the polygon outer ring is explicitly closed, where the first and
last point are the same
|
static Geometry |
deserialize(byte[] bytes)
Deserialize the bytes into a geometry
|
static double |
distance(Point point1,
Point point2)
Get the Pythagorean theorem distance between two points
|
static Point |
getCentroid(Geometry geometry)
Get the centroid point of a 2 dimensional representation of the Geometry
(balancing point of a 2d cutout of the geometry).
|
static int |
getDimension(Geometry geometry)
Get the dimension of the Geometry, 0 for points, 1 for curves, 2 for
surfaces.
|
static <T extends Geometry> |
hasM(List<T> geometries)
Determine if the geometries contain a M value
|
static <T extends Geometry> |
hasZ(List<T> geometries)
Determine if the geometries contain a Z value
|
static void |
minimizeGeometry(Geometry geometry,
double maxX)
Minimize the geometry using the shortest x distance between each
connected set of points.
|
static void |
normalizeGeometry(Geometry geometry,
double maxX)
Normalize the geometry so all points outside of the min and max value
range are adjusted to fall within the range.
|
static List<GeometryType> |
parentHierarchy(GeometryType geometryType)
Get the parent type hierarchy of the provided geometry type starting with
the immediate parent.
|
static GeometryType |
parentType(GeometryType geometryType)
Get the parent Geometry Type of the provided geometry type
|
static double |
perpendicularDistance(Point point,
Point lineStart,
Point lineEnd)
Calculate the perpendicular distance between the point and the line
represented by the start and end points.
|
static boolean |
pointInPolygon(Point point,
LineString ring)
Check if the point is in the polygon ring
|
static boolean |
pointInPolygon(Point point,
LineString ring,
double epsilon)
Check if the point is in the polygon ring
|
static boolean |
pointInPolygon(Point point,
List<Point> points)
Check if the point is in the polygon points
|
static boolean |
pointInPolygon(Point point,
List<Point> points,
double epsilon)
Check if the point is in the polygon points
|
static boolean |
pointInPolygon(Point point,
Polygon polygon)
Check if the point is in the polygon
|
static boolean |
pointInPolygon(Point point,
Polygon polygon,
double epsilon)
Check if the point is in the polygon
|
static boolean |
pointOnLine(Point point,
LineString line)
Check if the point is on the line
|
static boolean |
pointOnLine(Point point,
LineString line,
double epsilon)
Check if the point is on the line
|
static boolean |
pointOnLine(Point point,
List<Point> points)
Check if the point is on the line represented by the points
|
static boolean |
pointOnLine(Point point,
List<Point> points,
double epsilon)
Check if the point is on the line represented by the points
|
static boolean |
pointOnPath(Point point,
Point point1,
Point point2)
Check if the point is on the path between point 1 and point 2
|
static boolean |
pointOnPath(Point point,
Point point1,
Point point2,
double epsilon)
Check if the point is on the path between point 1 and point 2
|
static boolean |
pointOnPolygonEdge(Point point,
LineString ring)
Check if the point is on the polygon ring edge
|
static boolean |
pointOnPolygonEdge(Point point,
LineString ring,
double epsilon)
Check if the point is on the polygon ring edge
|
static boolean |
pointOnPolygonEdge(Point point,
List<Point> points)
Check if the point is on the polygon ring edge points
|
static boolean |
pointOnPolygonEdge(Point point,
List<Point> points,
double epsilon)
Check if the point is on the polygon ring edge points
|
static boolean |
pointOnPolygonEdge(Point point,
Polygon polygon)
Check if the point is on the polygon edge
|
static boolean |
pointOnPolygonEdge(Point point,
Polygon polygon,
double epsilon)
Check if the point is on the polygon edge
|
static byte[] |
serialize(Geometry geometry)
Serialize the geometry to bytes
|
static List<Point> |
simplifyPoints(List<Point> points,
double tolerance)
Simplify the ordered points (representing a line, polygon, etc) using the
Douglas Peucker algorithm to create a similar curve with fewer points.
|
public static final double DEFAULT_EPSILON
public static int getDimension(Geometry geometry)
geometry - geometry objectpublic static double distance(Point point1, Point point2)
point1 - point 1point2 - point 2public static Point getCentroid(Geometry geometry)
Point.getZ() and Point.getM() methods will
always return null.geometry - geometry objectpublic static void minimizeGeometry(Geometry geometry, double maxX)
geometry - geometrymaxX - max positive x value in the geometry projectionpublic static void normalizeGeometry(Geometry geometry, double maxX)
geometry - geometrymaxX - max positive x value in the geometry projectionpublic static List<Point> simplifyPoints(List<Point> points, double tolerance)
points - geometry pointstolerance - minimum tolerance in meters for consecutive pointspublic static double perpendicularDistance(Point point, Point lineStart, Point lineEnd)
point - pointlineStart - point representing the line startlineEnd - point representing the line endpublic static boolean pointInPolygon(Point point, Polygon polygon)
point - pointpolygon - polygonpublic static boolean pointInPolygon(Point point, Polygon polygon, double epsilon)
point - pointpolygon - polygonepsilon - epsilon line tolerancepublic static boolean pointInPolygon(Point point, LineString ring)
point - pointring - polygon ringpublic static boolean pointInPolygon(Point point, LineString ring, double epsilon)
point - pointring - polygon ringepsilon - epsilon line tolerancepublic static boolean pointInPolygon(Point point, List<Point> points)
point - pointpoints - polygon pointspublic static boolean pointInPolygon(Point point, List<Point> points, double epsilon)
point - pointpoints - polygon pointsepsilon - epsilon line tolerancepublic static boolean pointOnPolygonEdge(Point point, Polygon polygon)
point - pointpolygon - polygonpublic static boolean pointOnPolygonEdge(Point point, Polygon polygon, double epsilon)
point - pointpolygon - polygonepsilon - epsilon line tolerancepublic static boolean pointOnPolygonEdge(Point point, LineString ring)
point - pointring - polygon ringpublic static boolean pointOnPolygonEdge(Point point, LineString ring, double epsilon)
point - pointring - polygon ringepsilon - epsilon line tolerancepublic static boolean pointOnPolygonEdge(Point point, List<Point> points)
point - pointpoints - polygon pointspublic static boolean pointOnPolygonEdge(Point point, List<Point> points, double epsilon)
point - pointpoints - polygon pointsepsilon - epsilon line tolerancepublic static boolean closedPolygon(Polygon polygon)
polygon - polygonpublic static boolean closedPolygon(LineString ring)
ring - polygon ringpublic static boolean closedPolygon(List<Point> points)
points - polygon ring pointspublic static boolean pointOnLine(Point point, LineString line)
point - pointline - linepublic static boolean pointOnLine(Point point, LineString line, double epsilon)
point - pointline - lineepsilon - epsilon line tolerancepublic static boolean pointOnLine(Point point, List<Point> points)
point - pointpoints - line pointspublic static boolean pointOnLine(Point point, List<Point> points, double epsilon)
point - pointpoints - line pointsepsilon - epsilon line tolerancepublic static boolean pointOnPath(Point point, Point point1, Point point2)
point - pointpoint1 - path point 1point2 - path point 2public static boolean pointOnPath(Point point, Point point1, Point point2, double epsilon)
point - pointpoint1 - path point 1point2 - path point 2epsilon - epsilon line tolerancepublic static <T extends Geometry> boolean hasZ(List<T> geometries)
T - geometry typegeometries - list of geometriespublic static <T extends Geometry> boolean hasM(List<T> geometries)
T - geometry typegeometries - list of geometriespublic static List<GeometryType> parentHierarchy(GeometryType geometryType)
geometryType - geometry typepublic static GeometryType parentType(GeometryType geometryType)
geometryType - geometry typepublic static Map<GeometryType,Map<GeometryType,?>> childHierarchy(GeometryType geometryType)
geometryType - geometry typepublic static List<GeometryType> childTypes(GeometryType geometryType)
geometryType - geometry typepublic static byte[] serialize(Geometry geometry)
geometry - geometrypublic static Geometry deserialize(byte[] bytes)
bytes - serialized bytesCopyright © 2021 National Geospatial-Intelligence Agency. All rights reserved.