com.mapinfo.midev.geometry

## Interface ICurveSegment

All Superinterfaces:
  IGeometry, Serializable

All Known Subinterfaces:
  ILineString

    public interface ICurveSegment
    extends IGeometry

A `ICurveSegment` is an ordered sequence of control points and the rule for interpolating a curve along the control points from the first to the last.

By policy, instances of classes that implement this interface cannot be empty and must contain at least a start position and an end position. Specific implementations of this interface could require that instances have more than two control points.

### Method Summary

All Methods Instance Methods Abstract Methods
`ILineString` `asLineString()` Returns an `ILineString` that approximates this `ICurveSegment`.
`ILineString` `asLineString(Length maxSpacing, Length maxOffset)` Returns an `ILineString` that approximates this `ICurveSegment`.
`DirectPosition` `getControlPoint(int i, DirectPosition dp)` Returns the specified control point as a `DirectPosition` and fills in the specified `DirectPosition`.
`int` `getControlPointCount()` Returns the number of control points in this `ICurveSegment`.
`IDirectPositionIterator` `getControlPointIterator()` Returns an `IDirectPositionIterator` that allows iterating over this `ICurveSegment`'s control points.
`IDirectPositionList` `getControlPoints()` Returns the control points of this `ICurveSegment` as an `IDirectPositionList`.
`ICurveSegment` `getCopy()` Get a (permanent) copy of this `IGeometry`.
`ICurveSegment` `getCopy(CoordSys crs)` Get a (permanent) copy of this `IGeometry` transformed to the given coordinate system.
`Length` `getEndDistance(ComputationType ct)` Returns the distance corresponding to the last direct position of this generic curve.
`DirectPosition` `getEndPosition()` Returns the last position of the curve.
`CurveInterpolationType` `getInterpolationType()` Returns the interpolation rule used for this segment.
`Length` `getLength(ComputationType ct)` Returns the length of this `ICurveSegment` using the specified `ComputationType`.
`DirectPosition` `getPointForDistance(Length len)` Returns the `DirectPosition` that lies at the specified distance along this curve.
`Length` `getStartDistance(ComputationType ct)` Returns the distance corresponding to the first direct position of this generic curve.
`DirectPosition` `getStartPosition()` Returns the first position of the curve.
`boolean` `isClosed()` Returns `true` if this `ICurveSegment` is a closed or not (i.e.
`boolean` `isLinear()` Returns `true` if this `ICurveSegment` consists entirely of straight lines; `false` if not.
`ICurveSegment` `reverse()` Returns an `ICurveSegment` that has the opposite orientation as this `ICurveSegment`.

### Methods inherited from interface com.mapinfo.midev.geometry.IGeometry

`contains, getArea, getCoordSys, getDimension, getEnvelope, getPerimeter, getSpatialInfo, getType, isEmpty, isTransient, mAllSet, mSet, zAllSet, zSet`

### Method Detail

#### getStartPosition

    DirectPosition getStartPosition()

Returns the first position of the curve.

Returns:
  the first position of the curve.

#### getEndPosition

    DirectPosition getEndPosition()

Returns the last position of the curve.

Returns:
  the last position of the curve.

#### isLinear

    boolean isLinear()

Returns `true` if this `ICurveSegment` consists entirely of straight lines; `false` if not.

Returns:
  `true` if this `ICurveSegment` consists entirely of straight lines; `false` if not.

#### getStartDistance

    Length getStartDistance(ComputationType ct)

Returns the distance corresponding to the first direct position of this generic curve.

The start distance for any `ICurve` or `IRing` is always 0.0. However, the start distance for any `ICurveSegment` contained in an `ICurve` or `IRing` is always the distance along that `ICurve` or `IRing` where it's first direct position lies. The start distance for a stand alone `ICurveSegment` that is not part of an `ICurve` or `IRing` is always 0.0.

For any generic curve:

       pointForDistance(startDistance(ct)) == first direct position
       endDistance(ct) - startDistance(ct) == getLength() or getPerimeter()

Parameters:
  `ct` - ComputationType to use for the distance calculation
Returns:
  the distance corresponding to the first direct position of this generic curve.
Throws:
  `InvalidComputationTypeException` - if the given computation type is incompatible with the coordinate system of this geometry

#### getEndDistance

    Length getEndDistance(ComputationType ct)

Returns the distance corresponding to the last direct position of this generic curve.

The end distance for any `ICurve` or `IRing` is always the same value as that returned by `ICurve.getLength(ComputationType)` or `IGeometry.getPerimeter(ComputationType)` respectively. However, the end distance for any `ICurveSegment` contained in an `ICurve` or `IRing` is always the distance along that `ICurve` or `IRing` where it's last direct position lies. The end distance for a stand alone `ICurveSegment` that is not part of an `ICurve` or `IRing` is always the same as it's length.

For any generic curve:

       pointForDistance(endDistance(ct)) == last direct position
       endDistance(ct) - startDistance(ct) == getLength() or getPerimeter()

Parameters:
  `ct` - ComputationType to use for the distance calculation
Returns:
  the distance corresponding to the last direct position of this generic curve.
Throws:
  `InvalidComputationTypeException` - if the given computation type is incompatible with the coordinate system of this geometry

#### getPointForDistance

    DirectPosition getPointForDistance(Length len)

Returns the `DirectPosition` that lies at the specified distance along this curve.

Parameters:
  `len` - length along this generic curve to return the point. Value must be inclusively between the values returned by `ICurveSegment.getStartDistance(ComputationType)` and `ICurveSegment.getEndDistance(ComputationType)`
Returns:
  the `DirectPosition` that lies at the specified distance along this curve.
Throws:
  `InvalidComputationTypeException` - if the computation type of the length is incompatible with the coordinate system of the geometry or if the value of len is not inclusively between the values returned by `ICurveSegment.getStartDistance(ComputationType)` and `ICurveSegment.getEndDistance(com.mapinfo.midev.unit.ComputationType)`

#### getControlPointCount

    int getControlPointCount()

Returns the number of control points in this `ICurveSegment`.

This method will always return a value of at least two since all implementations of this interface must have, at a minimum, a start position and an end position.

Returns:
  the number of control points in this `ICurveSegment`.

#### getInterpolationType

    CurveInterpolationType getInterpolationType()

Returns the interpolation rule used for this segment.

Returns:
  the interpolation rule used for this segment.

#### getControlPoint

    DirectPosition getControlPoint(int i,
                                   DirectPosition dp)

Returns the specified control point as a `DirectPosition` and fills in the specified `DirectPosition`.

Parameters:
  `i` - zero based index of the control point to return.
  `dp` - direct position to contain the values, cannot be null.
Returns:
  the specified control point as a `DirectPosition`.

#### getControlPointIterator

    IDirectPositionIterator getControlPointIterator()

Returns an `IDirectPositionIterator` that allows iterating over this `ICurveSegment`'s control points.

Returns:
  an `IDirectPositionIterator` that allows iterating over this `ICurveSegment`'s control points.

#### isClosed

    boolean isClosed()

Returns `true` if this `ICurveSegment` is a closed or not (i.e. last control point == first control point); `false` if not.

Returns:
  `true` if this `ICurveSegment` is a closed or not (i.e. last control point == first control point); `false` if not.

#### reverse

    ICurveSegment reverse()

Returns an `ICurveSegment` that has the opposite orientation as this `ICurveSegment`.

Returns:
  an `ICurveSegment` that has the opposite orientation as this `ICurveSegment`.

#### getControlPoints

    IDirectPositionList getControlPoints()

Returns the control points of this `ICurveSegment` as an `IDirectPositionList`.

Returns:
  the control points of this `ICurveSegment` as an `IDirectPositionList`.

#### getCopy

    ICurveSegment getCopy()

Description copied from interface: `IGeometry`
Get a (permanent) copy of this `IGeometry`.

Specified by:
  `getCopy` in interface `IGeometry`
Returns:
  permanent copy of this `IGeometry`.
See Also:
  `IGeometry.getCopy(CoordSys)`, `IGeometry.isTransient()`

#### getCopy

    ICurveSegment getCopy(CoordSys crs)

Description copied from interface: `IGeometry`
Get a (permanent) copy of this `IGeometry` transformed to the given coordinate system.

Specified by:
  `getCopy` in interface `IGeometry`
Parameters:
  `crs` - coordinate system of the returned copy
Returns:
  copy of this `IGeometry` in the given coordinate system
See Also:
  `IGeometry.isTransient()`

#### getLength

    Length getLength(ComputationType ct)

Returns the length of this `ICurveSegment` using the specified `ComputationType`.

Parameters:
  `ct` - the preferred computation model.
Returns:
  the length of this `ICurveSegment` using the specified `ComputationType`.
Throws:
  `InvalidComputationTypeException` - if the given computation type is incompatible with the coordinate system of this geometry

#### asLineString

    ILineString asLineString()

Returns an `ILineString` that approximates this `ICurveSegment`.

Returns:
  an `ILineString` that approximates this `ICurveSegment`.

#### asLineString

    ILineString asLineString(Length maxSpacing,
                             Length maxOffset)

Returns an `ILineString` that approximates this `ICurveSegment`.

Approximates the `ICurveSegment` as a single `ILineString`. The first position of the second and subsequent segments of this curve are omitted because they would be x/y equal to the end position of the previous segment.

Regardless of parameters, the control points of all the curve segments are always included (except the first position of all but the first segment, as explained above). If both parameters are zero, then only the control points are returned.

Parameters:
  `maxSpacing` - the maximum distance between points in the constructed `ILineString`. A maxSpacing of zero means "no limit".
  `maxOffset` - the maximum deviation of the constructed `ILineString` from this curve. A maxOffset of zero means "no limit".
Returns:
  an `ILineString` that approximates this `ICurveSegment`.