Package org.geotools.geometry.jts
Class GeometryBuilder
Object
GeometryBuilder
A builder for
Geometry objects. Primarily intended to support fluent programming in test code.
Features include:
- Both 2D and 3D coordinate dimensions are supported (assuming the provided
CoordinateSequenceFactorysupports them) - Sequences of ordinate values can be supplied in a number of ways
- Rings do not need to be explicitly closed; a closing point will be supplied if needed
- Empty geometries of all types can be created
- Composite geometries are validated to ensure they have a consistent GeometryFactory and coordinate sequence
dimension
Examples of intended usage are:
GeometryBuilder gb = new GeometryBuilder(geomFact); LineString line = gb.linestring(1,2, 3,4); Polygon poly = gb.polygon(0,0, 0,1, 1,1, 1,0); Polygon box = gb.box(0,0, 1,1); Polygon hexagon = gb.circle(0,0, 1,1, 6); Polygon polyhole = gb.polygon(gb.linearring(0,0, 0,10, 10,10, 10,0), gb.linearring(1,1, 1,9, 9,9, 9,1))
- Author:
- Martin Davis - OpenGeo
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance using the defaultGeometryFactory.GeometryBuilder(GeometryFactory geomFact) Creates a new instance using a provided GeometryFactory. -
Method Summary
Modifier and TypeMethodDescriptionbox(double x1, double y1, double x2, double y2) Creates a rectangular 2D Polygon from X and Y bounds.boxZ(double x1, double y1, double x2, double y2, double z) Creates a rectangular 3D Polygon from X and Y bounds.circle(double x, double y, double radius, int nsides) Creates a circular Polygon with a given center, radius and number of sides.ellipse(double x1, double y1, double x2, double y2, int nsides) Creates an elliptical Polygon from a bounding box with a given number of sides.geometryCollection(Geometry... geoms) Creates a GeometryCollection from a set of GeometrysCreates an empty 2D LinearRinglinearRing(double... ord) Creates a 2D LinearRing.Creates an empty 3D LinearRinglinearRingZ(double... ord) Creates a 3D LinearRing.Creates an empty 2D LineStringlineString(double... ord) Creates a 2D LineString.Creates an empty 3D LineStringlineStringZ(double... ord) Creates a 3D LineString.multiLineString(LineString... lines) Creates a MultiLineString from a set of LineStringsmultiPoint(double x1, double y1, double x2, double y2) Creates a MultiPoint with 2 2D Points.multiPointZ(double x1, double y1, double z1, double x2, double y2, double z2) Creates a MultiPoint with 2 3D Points.multiPolygon(Polygon... polys) Creates a MultiPolygon from a set of Polygons.point()Creates an empty Pointpoint(double x) Creates a 1D Point.point(double x, double y) Creates a 2D Point.pointZ()Creates an empty Point with coordinate dimension = 3.pointZ(double x, double y, double z) Creates a 3D Point.polygon()Creates an empty 2D Polygon.polygon(double... ord) Creates a Polygon from a list of XY coordinates.polygon(LinearRing shell) Creates a Polygon from an exterior ring.polygon(LinearRing shell, LinearRing hole) Creates a Polygon with a hole from an exterior ring and an interior ring.Creates a Polygon with a hole from an exterior ring and an interior ring supplied by the rings of Polygons.polygonZ()Creates an empty 3D Polygon.polygonZ(double... ord) Creates a Polygon from a list of XYZ coordinates.
-
Constructor Details
-
GeometryBuilder
public GeometryBuilder()Create a new instance using the defaultGeometryFactory. -
GeometryBuilder
Creates a new instance using a provided GeometryFactory.- Parameters:
geomFact- the factory to use
-
-
Method Details
-
point
Creates an empty Point- Returns:
- an empty Point
-
pointZ
Creates an empty Point with coordinate dimension = 3.- Returns:
- an empty Point
-
point
Creates a 1D Point.- Parameters:
x- the X ordinate- Returns:
- a Point
-
point
Creates a 2D Point.- Parameters:
x- the X ordinatey- the Y ordinate- Returns:
- a Point
-
pointZ
Creates a 3D Point.- Parameters:
x- the X ordinatey- the Y ordinatez- the Z ordinate- Returns:
- a Point
-
lineString
Creates an empty 2D LineString- Returns:
- an empty LineString
-
lineStringZ
Creates an empty 3D LineString- Returns:
- an empty LineString
-
lineString
Creates a 2D LineString.- Parameters:
ord- the XY ordinates- Returns:
- a LineString
-
lineStringZ
Creates a 3D LineString.- Parameters:
ord- the XYZ ordinates- Returns:
- a LineString
-
linearRing
Creates an empty 2D LinearRing- Returns:
- an empty LinearRing
-
linearRingZ
Creates an empty 3D LinearRing- Returns:
- an empty LinearRing
-
linearRing
Creates a 2D LinearRing. If the supplied coordinate list is not closed, a closing coordinate is added.- Returns:
- a LinearRing
-
linearRingZ
Creates a 3D LinearRing. If the supplied coordinate list is not closed, a closing coordinate is added.- Parameters:
ord- the XYZ ordinates- Returns:
- a LinearRing
-
polygon
Creates an empty 2D Polygon.- Returns:
- an empty Polygon
-
polygonZ
Creates an empty 3D Polygon.- Returns:
- an empty Polygon
-
polygon
Creates a Polygon from a list of XY coordinates.- Parameters:
ord- a list of XY ordinates- Returns:
- a Polygon
-
polygonZ
Creates a Polygon from a list of XYZ coordinates.- Parameters:
ord- a list of XYZ ordinates- Returns:
- a Polygon
-
polygon
Creates a Polygon from an exterior ring. The coordinate dimension of the Polygon is the dimension of the LinearRing.- Parameters:
shell- the exterior ring- Returns:
- a Polygon
-
polygon
Creates a Polygon with a hole from an exterior ring and an interior ring.- Parameters:
shell- the exterior ringhole- the interior ring- Returns:
- a Polygon with a hole
-
polygon
Creates a Polygon with a hole from an exterior ring and an interior ring supplied by the rings of Polygons.- Parameters:
shell- the exterior ringhole- the interior ring- Returns:
- a Polygon with a hole
-
box
Creates a rectangular 2D Polygon from X and Y bounds.- Parameters:
x1- the lower X boundy1- the lower Y boundx2- the upper X boundy2- the upper Y bound- Returns:
- a 2D Polygon
-
boxZ
Creates a rectangular 3D Polygon from X and Y bounds.- Parameters:
x1- the lower X boundy1- the lower Y boundx2- the upper X boundy2- the upper Y boundz- the Z value for all coordinates- Returns:
- a 3D Polygon
-
ellipse
Creates an elliptical Polygon from a bounding box with a given number of sides.- Returns:
- a 2D Polygon
-
circle
Creates a circular Polygon with a given center, radius and number of sides.- Parameters:
x- the center X ordinatey- the center Y ordinateradius- the radiusnsides- the number of sides- Returns:
- a 2D Polygon
-
multiPoint
Creates a MultiPoint with 2 2D Points.- Parameters:
x1- the X ordinate of the first pointy1- the Y ordinate of the first pointx2- the X ordinate of the second pointy2- the Y ordinate of the second point- Returns:
- A MultiPoint
-
multiPointZ
Creates a MultiPoint with 2 3D Points.- Parameters:
x1- the X ordinate of the first pointy1- the Y ordinate of the first pointz1- the Z ordinate of the first pointx2- the X ordinate of the second pointy2- the Y ordinate of the second pointz2- the Z ordinate of the second point- Returns:
- A 3D MultiPoint
-
multiLineString
Creates a MultiLineString from a set of LineStrings- Parameters:
lines- the component LineStrings- Returns:
- a MultiLineString
-
multiPolygon
Creates a MultiPolygon from a set of Polygons.- Parameters:
polys- the component polygons- Returns:
- A MultiPolygon
-
geometryCollection
Creates a GeometryCollection from a set of Geometrys- Parameters:
geoms- the component Geometrys- Returns:
- a GeometryCollection
-