com.mapinfo.midev.geometry.operations

## Class GeometryOperations

- java.lang.Object
- - com.mapinfo.midev.geometry.operations.GeometryOperations

    public final class GeometryOperations
    extends Object

A class that supplies geometry operations.

### Field Summary

Fields
`static int` `DEFAULT_BUFFER_RESOLUTION` The default buffer resolution (12).

### Method Summary

All Methods Static Methods Concrete Methods
`static Area` `area(IGeometry geom, ComputationType model)` Returns the area of the geometry.
`static IFeatureGeometry` `buffer(IGeometry g, Offset distance)` Returns a geometry consisting of all the points within the `distance` of this geometry.
`static IFeatureGeometry` `buffer(IGeometry g, Offset distance, int resolution)` Returns a geometry consisting of all the points within the `distance` of the given geometry.
`static ClosestPoints` `closestPoints(IGeometry first, IGeometry second)` Returns the closest points between the two geometries.
`static ClosestPoints` `closestPoints(IGeometry first, IGeometry second, ComputationType model)` Returns the closest points between the two geometries.
`static IFeatureGeometry` `convexHull(IGeometry g)` Forms the convex hull of the geometry.
`static boolean` `disjoint(IGeometry first, IGeometry second)` Tests if two objects satisfy the 'DISJOINT' criteria, as defined in OGC Simple Feature Specification This test can return true for any combination of geometry objects.
`static Length` `distance(IGeometry first, IGeometry second)` Returns the minimum distance between the two geometries.
`static Length` `distance(IGeometry first, IGeometry second, ComputationType model)` Returns the minimum distance between the two geometries.
`static Length` `distanceToEdge(IGeometry first, IGeometry second, ComputationType model)` Returns the minimum distance between the two geometries.
`static IFeatureGeometry` `intersection(IGeometry first, IGeometry second)` Returns the geometry consisting of direct positions that lie in both specified geometries.
`static boolean` `intersects(Envelope env, IGeometry second)` Returns true if there is any direct position in common between the two geometries.
`static boolean` `intersects(IGeometry first, IGeometry second)` Returns true if there is any direct position in common between the two geometries.
`static Length` `length(IGeometry geom, ComputationType model)` Computes the length of a geometry.
`static boolean` `overlaps(IGeometry first, IGeometry second)` Tests if two objects satisfy the 'OVERLAPS' criteria, as defined in OGC Simple Feature Specification This test can return true for P/P, A/A, and L/L combinations; otherwise it returns false.
`static Length` `perimeter(IGeometry geom, ComputationType model)` Returns the total perimeter of the geometry.
`static IFeatureGeometry` `union(IGeometry first, IGeometry second)` Computes the set-union of the two geometries.
`static IFeatureGeometry` `union(Iterable geomList)` Computes the set-union of the list of geometries.
`static boolean` `within(IGeometry first, IGeometry second)` The first geometry is within the second if the intersection of the two is the first geometry, and the intersections of their interiors is non-empty.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_BUFFER_RESOLUTION

    public static final int DEFAULT_BUFFER_RESOLUTION

The default buffer resolution (12).

See Also:
  Constant Field Values

### Method Detail

#### area

    public static Area area(IGeometry geom,
                            ComputationType model)

Returns the area of the geometry. The area of a polygon is computed as the area of its exterior ring minus the areas of its interior rings. Points and curves have zero area.

Parameters:
  `geom` - the input geometry.
  `model` - the computation model (may be null, in which case the default for the coordinate system is used).
Returns:
  the area of the geometry.
Throws:
  `InvalidComputationTypeException` - if the ComputationType is inappropriate for the coordinate system.

#### buffer

    public static IFeatureGeometry buffer(IGeometry g,
                                          Offset distance,
                                          int resolution)

Returns a geometry consisting of all the points within the `distance` of the given geometry. A positive distance results in a larger geometry. A negative distance shrinks polygons, and causes points and curves to disappear. A distance of 0 is legal.

Parameters:
  `g` - the geometry to buffer.
  `distance` - the amount to enlarge or shrink the geometry by.
  `resolution` - the `resolution` specifies how many straight-line segments are used in approximating a circle. For example, with a resolution of 8, the buffer of a point will be an octagon. Buffers with larger `resolution` values take more time and space to compute.

  A positive buffer of a point will always have at least three straight-lines, even if the resolution is zero, one, or two. Curves and polygons have no minimum resolution value.

  Implementations may in the future return curved sections instead of straight-line approximations, ignoring this parameter.
Returns:
  the buffer of the geometry.
Throws:
  `UnsupportedGeometryOperationException` - if the resulting geometry is discovered to extend beyond the coordinate system (thrown on a best-effort basis).

#### buffer

    public static IFeatureGeometry buffer(IGeometry g,
                                          Offset distance)

Returns a geometry consisting of all the points within the `distance` of this geometry.

Equivalent to `buffer(g, distance, resolution)` with a default value for `resolution`.

Parameters:
  `g` - the geometry to buffer.
  `distance` - the amount to enlarge or shrink the geometry by.
Returns:
  the buffer of the geometry.

#### convexHull

    public static IFeatureGeometry convexHull(IGeometry g)

Forms the convex hull of the geometry.

Parameters:
  `g` - the input geometry.
Returns:
  the convex hull of the geometry.

#### distance

    public static Length distance(IGeometry first,
                                  IGeometry second,
                                  ComputationType model)

Returns the minimum distance between the two geometries. Distance is always non-negative (objects which intersect are distance zero from each other).

It is an error for either geometry to be empty.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
  `model` - the preferred computational model for computing the distance. If null, a default computational model is used.
Returns:
  the distance from geometry a to geometry b.
Throws:
  `InvalidGeometryException` - if either object is empty.
  `InvalidComputationTypeException` - if the ComputationType is inappropriate for the coordinate system.

#### distanceToEdge

    public static Length distanceToEdge(IGeometry first,
                                        IGeometry second,
                                        ComputationType model)

Returns the minimum distance between the two geometries. Unlike `GeometryOperations.distance(IGeometry, IGeometry, ComputationType)`, this method will return a distance when one geometry is contained within the other instead of returning zero. Zero can still be returned when geometry edges (or points) overlap.

It is an error for either geometry to be empty.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
  `model` - the preferred computational model for computing the distance. If null, a default computational model is used.
Returns:
  the distance from geometry a to geometry b.
Throws:
  `InvalidGeometryException` - if either object is empty.
  `InvalidComputationTypeException` - if the ComputationType is inappropriate for the coordinate system.

#### closestPoints

    public static ClosestPoints closestPoints(IGeometry first,
                                              IGeometry second)

Returns the closest points between the two geometries.

Distance is always non-negative (objects which overlap are distance zero from each other. In which case a shared point will be returned). This is identical to `closestPoints(first, second, model)` using a default computational model.

It is an error for either geometry to be empty.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  the closest points between the two geometries.
Throws:
  `InvalidGeometryException` - if either object is empty.

#### closestPoints

    public static ClosestPoints closestPoints(IGeometry first,
                                              IGeometry second,
                                              ComputationType model)

Returns the closest points between the two geometries. Distance is always non-negative (objects which intersect are distance zero from each other. In this case, a shared point will be returned).

It is an error for either geometry to be empty.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
  `model` - the preferred computational model for computing the distance. If null, a default computational model is used.
Returns:
  the closest points between the two geometries.
Throws:
  `InvalidGeometryException` - if either object is empty.
  `InvalidComputationTypeException` - if the ComputationType is inappropriate for the coordinate system.

#### distance

    public static Length distance(IGeometry first,
                                  IGeometry second)

Returns the minimum distance between the two geometries. Distance is always non-negative (objects which overlap are distance zero from each other). This is identical to `distance(a, b, model)` using a default computational model.

It is an error for either geometry to be empty.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  the distance from geometry a to geometry b.
Throws:
  `InvalidGeometryException` - if either object is empty.

#### intersection

    public static IFeatureGeometry intersection(IGeometry first,
                                                IGeometry second)

Returns the geometry consisting of direct positions that lie in both specified geometries.

This is set-intersection.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  a geometry formed from the direct positions that are common to both geometries.
Throws:
  `InvalidGeometryException` - if either object is empty.

#### length

    public static Length length(IGeometry geom,
                                ComputationType model)

Computes the length of a geometry.

Parameters:
  `geom` - the input geometry.
  `model` - the preferred computational model.
Returns:
  the total length of the curves in the geometry.
Throws:
  `UnsupportedGeometryOperationException` - if the geometry contains an object with area (polygon, ellipse, etc.).
  `InvalidComputationTypeException` - if the ComputationType is inappropriate for the coordinate system.

#### perimeter

    public static Length perimeter(IGeometry geom,
                                   ComputationType model)

Returns the total perimeter of the geometry. The perimeter of a polygon is the sum of the lengths of its rings (both exterior and holes). Curves are treated as thin polygons.

Parameters:
  `geom` - the input geometry.
  `model` - the computation model (may be null, in which case the default for the coordinate system is used).
Returns:
  the geometry perimeter.
Throws:
  `InvalidComputationTypeException` - if the ComputationType is inappropriate for the coordinate system.
  `UnsupportedGeometryOperationException` - if called on a LegacyText geometry.

#### union

    public static IFeatureGeometry union(IGeometry first,
                                         IGeometry second)

Computes the set-union of the two geometries.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  the geometry that represents the union of the specified geometries.

#### union

    public static IFeatureGeometry union(Iterable geomList)

Computes the set-union of the list of geometries.

Parameters:
  `geomList` - a list of geometries to be used.
Returns:
  the geometry that represents the union of the specified geometries.

#### disjoint

    public static boolean disjoint(IGeometry first,
                                   IGeometry second)

Tests if two objects satisfy the 'DISJOINT' criteria, as defined in OGC Simple Feature Specification This test can return true for any combination of geometry objects. It is implemented as `!intersects(first,second)`

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  true if the two geometry objects have no points in common

#### intersects

    public static boolean intersects(IGeometry first,
                                     IGeometry second)

Returns true if there is any direct position in common between the two geometries.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  true if the geometries overlap.

#### overlaps

    public static boolean overlaps(IGeometry first,
                                   IGeometry second)

Tests if two objects satisfy the 'OVERLAPS' criteria, as defined in OGC Simple Feature Specification This test can return true for P/P, A/A, and L/L combinations; otherwise it returns false. It returns false in cases where either WITHIN or CONTAINS are true.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  true if the two geometry objects have no points in common

#### intersects

    public static boolean intersects(Envelope env,
                                     IGeometry second)

Returns true if there is any direct position in common between the two geometries.

Parameters:
  `env` - first geometry to be used specified as an Envelope.
  `second` - second geometry to be used.
Returns:
  true if the geometries overlap.

#### within

    public static boolean within(IGeometry first,
                                 IGeometry second)

The first geometry is within the second if the intersection of the two is the first geometry, and the intersections of their interiors is non-empty.

For example, a line is within a polygon if the line does not extend outside the polygon and the line is not just along the boundary of the polygon.

Parameters:
  `first` - first geometry to be used.
  `second` - second geometry to be used.
Returns:
  true if the first geometry is within the second geometry.