Polygon class
Represents a polygon with linear edges, which may include holes. The outer boundary (shell) and inner boundaries (holes) of the polygon are represented by {@link LinearRing}s. The boundary rings of the polygon may have any orientation. Polygons are closed, simple geometries by definition.
The polygon model conforms to the assertions specified in the OpenGIS Simple Features Specification for SQL.
A Polygon
is topologically valid if and only if:
- the coordinates which define it are valid coordinates
- the linear rings for the shell and holes are valid (i.e. are closed and do not self-intersect)
- holes touch the shell or another hole at at most one point (which implies that the rings of the shell and holes must not cross)
- the interior of the polygon is connected, or equivalently no sequence of touching holes makes the interior of the polygon disconnected (i.e. effectively split the polygon into two pieces).
@version 1.7
Constructors
- Polygon(LinearRing shell, PrecisionModel precisionModel, int SRID)
-
Constructs a
Polygon
with the given exterior boundary. -
Polygon.withFactory(LinearRing? shell, List<
LinearRing> ? holes, GeometryFactory factory) -
Constructs a
Polygon
with the given exterior boundary and interior boundaries. -
Polygon.withPrecisionModelSrid(LinearRing shell, List<
LinearRing> holes, PrecisionModel precisionModel, int SRID) -
Constructs a
Polygon
with the given exterior boundary and interior boundaries.
Properties
- envelope ↔ Envelope?
-
The bounding box of this
Geometry
.getter/setter pairinherited - geomFactory ↔ GeometryFactory
-
The {@link GeometryFactory} used to create this Geometry
latefinalinherited
- hashCode → int
-
Gets a hash code for the Geometry.
no setterinherited
-
holes
↔ List<
LinearRing> ? -
The interior boundaries, if any.
This instance var is never null.
If there are no holes, the array is of zero length.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shell ↔ LinearRing?
-
The exterior boundary,
or
null
if thisPolygon
is empty.getter/setter pair - SRID ↔ int
-
The ID of the Spatial Reference System used by this
Geometry
getter/setter pairinherited - userData ↔ Object?
-
An object reference which can be used to carry ancillary data defined
by the client.
getter/setter pairinherited
Methods
-
applyCF(
CoordinateFilter filter) → void -
Performs an operation with or on this
Geometry
's coordinates. If this method modifies any coordinate values, {@link #geometryChanged} must be called to update the geometry state. Note that you cannot use this method to modify this Geometry if its underlying CoordinateSequence's #get method returns a copy of the Coordinate, rather than the actual Coordinate stored (if it even stores Coordinate objects at all).override -
applyCSF(
CoordinateSequenceFilter filter) → void -
Performs an operation on the coordinates in this
Geometry
's {@link CoordinateSequence}s. If the filter reports that a coordinate value has been changed, {@link #geometryChanged} will be called automatically.override -
applyGCF(
GeometryComponentFilter filter) → void -
Performs an operation with or on this Geometry and its
component Geometry's. Only GeometryCollections and
Polygons have component Geometry's; for Polygons they are the LinearRings
of the shell and holes.
override
-
applyGF(
GeometryFilter filter) → void -
Performs an operation with or on this
Geometry
and its subelementGeometry
s (if any). Only GeometryCollections and subclasses have subelement Geometry's.override -
buffer(
double distance) → Geometry -
Computes a buffer area around this geometry having the given width. The
buffer of a Geometry is the Minkowski sum or difference of the geometry
with a disc of radius
abs(distance)
.inherited -
buffer2(
double distance, int quadrantSegments) → Geometry -
Computes a buffer area around this geometry having the given width and with
a specified accuracy of approximation for circular arcs.
inherited
-
buffer3(
double distance, int quadrantSegments, int endCapStyle) → Geometry -
Computes a buffer area around this geometry having the given
width and with a specified accuracy of approximation for circular arcs,
and using a specified end cap style.
inherited
-
clone(
) → Object -
Creates and returns a full copy of this {@link Polygon} object.
(including all coordinates contained by it).
override
-
compare(
List a, List b) → int -
Returns the first non-zero result of
compareTo
encountered as the twoCollection
s are iterated over. If, by the time one of the iterations is complete, no non-zero result has been encountered, returns 0 if the other iteration is also complete. Ifb
completes beforea
, a positive number is returned; if a before b, a negative number.inherited -
compareTo(
dynamic o) → int -
Returns whether this
Geometry
is greater than, equal to, or less than anotherGeometry
.inherited -
compareToSameClass(
Object o) → int -
Returns whether this
Geometry
is greater than, equal to, or less than anotherGeometry
having the same class.override -
compareToSameClassWithComparator(
Object o, Comparator< CoordinateSequence> comp) → int -
Returns whether this
Geometry
is greater than, equal to, or less than anotherGeometry
of the same class. using the given {@link CoordinateSequenceComparator}.override -
compareToWithComparator(
Object o, Comparator< CoordinateSequence> comp) → int -
Returns whether this
Geometry
is greater than, equal to, or less than anotherGeometry
, using the given {@link CoordinateSequenceComparator}.inherited -
computeEnvelopeInternal(
) → Envelope -
Returns the minimum and maximum x and y values in this
Geometry
, or a nullEnvelope
if thisGeometry
is empty. UnlikegetEnvelopeInternal
, this method calculates theEnvelope
each time it is called;getEnvelopeInternal
caches the result of this method.override -
contains(
Geometry g) → bool -
Tests whether this geometry contains the
argument geometry.
inherited
-
convexHull(
) → Geometry -
Computes the smallest convex
Polygon
that contains all the points in theGeometry
. This obviously applies only toGeometry
s which contain 3 or more points; the results for degenerate cases are specified as follows:override -
copy(
) → Geometry -
Creates a deep copy of this {@link Geometry} object.
Coordinate sequences contained in it are copied.
All instance fields are copied (i.e. the SRID and userData).
inherited
-
copyInternal(
) → Polygon -
An internal method to copy subclass-specific geometry data.
override
-
coveredBy(
Geometry g) → bool -
Tests whether this geometry is covered by the
argument geometry.
inherited
-
covers(
Geometry g) → bool -
Tests whether this geometry covers the
argument geometry.
inherited
-
createPointFromInternalCoord(
Coordinate coord, Geometry exemplar) → Point -
inherited
-
crosses(
Geometry g) → bool -
Tests whether this geometry crosses the
argument geometry.
inherited
-
difference(
Geometry other) → Geometry -
Computes a
Geometry
representing the closure of the point-set of the points contained in thisGeometry
that are not contained in theother
Geometry.inherited -
disjoint(
Geometry g) → bool -
Tests whether this geometry is disjoint from the argument geometry.
inherited
-
distance(
Geometry g) → double -
Returns the minimum distance between this
Geometry
and anotherGeometry
.inherited -
equal(
Coordinate a, Coordinate b, double tolerance) → bool -
inherited
-
equals(
Geometry? g) → bool -
Tests whether this geometry is
topologically equal to the argument geometry.
inherited
-
equalsExactGeom(
Geometry other) → bool -
Returns true if the two
Geometry
s are exactly equal. Two Geometries are exactly equal iff:inherited -
equalsExactWithTol(
Geometry other, double tolerance) → bool -
Returns true if the two
Geometry
s are exactly equal, up to a specified distance tolerance. Two Geometries are exactly equal within a distance tolerance if and only if:override -
equalsNorm(
Geometry? g) → bool -
Tests whether two geometries are exactly equal
in their normalized forms.
This is a convenience method which creates normalized
versions of both geometries before computing
{@link #equalsExact(Geometry)}.
inherited
-
equalsObj(
Object o) → bool -
Tests whether this geometry is structurally and numerically equal
to a given
Object
. If the argumentObject
is not aGeometry
, the result isfalse
. Otherwise, the result is computed using {@link #equalsExact(Geometry)}.inherited -
equalsTopo(
Geometry g) → bool -
Tests whether this geometry is topologically equal to the argument geometry
as defined by the SFS
equals
predicate.inherited -
geometryChanged(
) → void -
Notifies this geometry that its coordinates have been changed by an external
party (for example, via a {@link CoordinateFilter}).
When this method is called the geometry will flush
and/or update any derived information it has cached (such as its {@link Envelope} ).
The operation is applied to all component Geometries.
inherited
-
geometryChangedAction(
) → void -
Notifies this Geometry that its Coordinates have been changed by an external
party. When #geometryChanged is called, this method will be called for
this Geometry and its component Geometries.
inherited
-
getArea(
) → double -
Returns the area of this
Polygon
override -
getBoundary(
) → Geometry -
Computes the boundary of this geometry
override
-
getBoundaryDimension(
) → int -
Returns the dimension of this
Geometry
s inherent boundary.override -
getCentroid(
) → Point -
Computes the centroid of this
Geometry
. The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension geometries contribute zero "weight" to the centroid).inherited -
getCoordinate(
) → Coordinate? -
Returns a vertex of this
Geometry
(usually, but not necessarily, the first one). The returned coordinate should not be assumed to be an actual Coordinate object used in the internal representation.override -
getCoordinates(
) → List< Coordinate> -
Returns an array containing the values of all the vertices for
this geometry.
If the geometry is a composite, the array will contain all the vertices
for the components, in the order in which the components occur in the geometry.
override
-
getDimension(
) → int -
Returns the dimension of this geometry.
The dimension of a geometry is is the topological
dimension of its embedding in the 2-D Euclidean plane.
In the JTS spatial model, dimension values are in the set {0,1,2}.
override
-
getEnvelope(
) → Geometry -
Gets a Geometry representing the envelope (bounding box) of
this
Geometry
.inherited -
getEnvelopeInternal(
) → Envelope -
Gets an {@link Envelope} containing
the minimum and maximum x and y values in this
Geometry
. If the geometry is empty, an emptyEnvelope
is returned.inherited -
getExteriorRing(
) → LinearRing -
getFactory(
) → GeometryFactory -
Gets the factory which contains the context in which this geometry was created.
inherited
-
getGeometryN(
int n) → Geometry -
Returns an element {@link Geometry} from a {@link GeometryCollection}
(or
this
, if the geometry is not a collection).inherited -
getGeometryType(
) → String -
Returns the name of this Geometry's actual class.
override
-
getInteriorPoint(
) → Point -
Computes an interior point of this
Geometry
. An interior point is guaranteed to lie in the interior of the Geometry, if it possible to calculate such a point exactly. Otherwise, the point may lie on the boundary of the geometry.inherited -
getInteriorRingN(
int n) → LinearRing -
getLength(
) → double -
Returns the perimeter of this
Polygon
override -
getNumGeometries(
) → int -
Returns the number of {@link Geometry}s in a {@link GeometryCollection}
(or 1, if the geometry is not a collection).
inherited
-
getNumInteriorRing(
) → int -
getNumPoints(
) → int -
Returns the count of this
Geometry
s vertices. TheGeometry
s contained by compositeGeometry
s must be Geometry's; that is, they must implementgetNumPoints
override -
getPrecisionModel(
) → PrecisionModel -
Returns the
PrecisionModel
used by theGeometry
.inherited -
getSortIndex(
) → int -
override
-
getSRID(
) → int -
Returns the ID of the Spatial Reference System used by the
Geometry
.inherited -
getUserData(
) → Object? -
Gets the user data object for this geometry, if any.
inherited
-
intersection(
Geometry other) → Geometry -
Computes a
Geometry
representing the point-set which is common to both thisGeometry
and theother
Geometry.inherited -
intersects(
Geometry g) → bool -
Tests whether this geometry intersects the argument geometry.
inherited
-
isEmpty(
) → bool -
Tests whether the set of points covered by this
Geometry
is empty.override -
isEquivalentClass(
Geometry other) → bool -
Returns whether the two
Geometry
s are equal, from the point of view of theequalsExact
method. Called byequalsExact
. In general, twoGeometry
classes are considered to be "equivalent" only if they are the same class. An exception isLineString
, which is considered to be equivalent to its subclasses.inherited -
isGeometryCollection(
) → bool -
Tests whether this is an instance of a general {@link GeometryCollection},
rather than a homogeneous subclass.
inherited
-
isRectangle(
) → bool -
Tests whether this is a rectangular {@link Polygon}.
override
-
isSimple(
) → bool -
Tests whether this {@link Geometry} is simple.
The SFS definition of simplicity
follows the general rule that a Geometry is simple if it has no points of
self-tangency, self-intersection or other anomalous points.
inherited
-
isValid(
) → bool -
Tests whether this
Geometry
is topologically valid, according to the OGC SFS specification.inherited -
isWithinDistance(
Geometry geom, double distance) → bool -
Tests whether the distance from this
Geometry
to another is less than or equal to a specified value.inherited -
norm(
) → Geometry -
Creates a new Geometry which is a normalized
copy of this Geometry.
inherited
-
normalize(
) → void -
Converts this
Geometry
to normal form (or canonical form ). Normal form is a unique representation forGeometry
s. It can be used to test whether twoGeometry
s are equal in a way that is independent of the ordering of the coordinates within them. Normal form equality is a stronger condition than topological equality, but weaker than pointwise equality. The definitions for normal form use the standard lexicographical ordering for coordinates. "Sorted in order of coordinates" means the obvious extension of this ordering to sequences of coordinates.override -
normalized(
LinearRing ring, bool clockwise) → LinearRing -
normalizeRing(
LinearRing ring, bool clockwise) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
overlaps(
Geometry g) → bool -
Tests whether this geometry overlaps the
specified geometry.
inherited
-
relate(
Geometry g) → IntersectionMatrix -
Returns the DE-9IM {@link IntersectionMatrix} for the two
Geometry
s.inherited -
relateWithPattern(
Geometry g, String intersectionPattern) → bool -
Tests whether the elements in the DE-9IM
{@link IntersectionMatrix} for the two
Geometry
s match the elements inintersectionPattern
. The pattern is a 9-character string, with symbols drawn from the following set:inherited -
reverse(
) → Geometry -
Computes a new geometry which has all component coordinate sequences
in reverse order (opposite orientation) to this one.
override
-
setSRID(
int SRID) → void -
Sets the ID of the Spatial Reference System used by the
Geometry
.inherited -
setUserData(
Object? userData) → void -
A simple scheme for applications to add their own custom data to a Geometry.
An example use might be to add an object representing a Coordinate Reference System.
inherited
-
symDifference(
Geometry other) → Geometry -
Computes a
Geometry
representing the closure of the point-set which is the union of the points in thisGeometry
which are not contained in theother
Geometry, with the points in theother
Geometry not contained in thisGeometry
. If the result is empty, it is an atomic geometry with the dimension of the highest input dimension.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
toText(
) → String -
Returns the Well-known Text representation of this
Geometry
. For a definition of the Well-known Text format, see the OpenGIS Simple Features Specification.inherited -
touches(
Geometry g) → bool -
Tests whether this geometry touches the
argument geometry.
inherited
-
union(
) → Geometry -
Computes the union of all the elements of this geometry.
inherited
-
unionGeom(
Geometry other) → Geometry -
Computes a
Geometry
representing the point-set which is contained in both thisGeometry
and theother
Geometry.inherited -
within(
Geometry g) → bool -
Tests whether this geometry is within the
specified geometry.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited