CoordinateArrays

Useful utility functions for handling Coordinate arrays

Version

1.7

class Object
trait Matchable
class Any

Type members

Classlikes

class BidirectionalComparator extends Comparator[Array[Coordinate]]

A {link Comparator} for {link Coordinate} arrays modulo their directionality. E.g. if two coordinate arrays are identical but reversed they will compare as equal under this ordering. If the arrays are not equal, the ordering returned is the ordering in the forward direction.

A {link Comparator} for {link Coordinate} arrays modulo their directionality. E.g. if two coordinate arrays are identical but reversed they will compare as equal under this ordering. If the arrays are not equal, the ordering returned is the ordering in the forward direction.

class ForwardComparator extends Comparator[Array[Coordinate]]

A {link Comparator} for {link Coordinate} arrays in the forward direction of their coordinates, using lexicographic ordering.

A {link Comparator} for {link Coordinate} arrays in the forward direction of their coordinates, using lexicographic ordering.

Value members

Concrete methods

def atLeastNCoordinatesOrNothing(n: Int, c: Array[Coordinate]): Array[Coordinate]

Returns either the given coordinate array if its length is greater than the given amount, or an empty coordinate array.

Returns either the given coordinate array if its length is greater than the given amount, or an empty coordinate array.

def compare(pts1: Array[Coordinate], pts2: Array[Coordinate]): Int

Compares two {link Coordinate} arrays in the forward direction of their coordinates, using lexicographic ordering.

Compares two {link Coordinate} arrays in the forward direction of their coordinates, using lexicographic ordering.

Value Params
pts2

return an integer indicating the order

def copyDeep(coordinates: Array[Coordinate]): Array[Coordinate]

Creates a deep copy of the argument {link Coordinate} array.

Creates a deep copy of the argument {link Coordinate} array.

Value Params
coordinates

an array of Coordinates return a deep copy of the input

def copyDeep(src: Array[Coordinate], srcStart: Int, dest: Array[Coordinate], destStart: Int, length: Int): Unit

Creates a deep copy of a given section of a source {link Coordinate} array into a destination Coordinate array. The destination array must be an appropriate size to receive the copied coordinates.

Creates a deep copy of a given section of a source {link Coordinate} array into a destination Coordinate array. The destination array must be an appropriate size to receive the copied coordinates.

Value Params
dest

the

destStart

the destination index to start copying to

length

the number of items to copy

src

an array of Coordinates

srcStart

the index to start copying from

def dimension(pts: Array[Coordinate]): Int

Determine dimension based on subclass of {link Coordinate}.

Determine dimension based on subclass of {link Coordinate}.

Value Params
pts

supplied coordinates return number of ordinates recorded

def envelope(coordinates: Array[Coordinate]): Envelope

Computes the envelope of the coordinates.

Computes the envelope of the coordinates.

Value Params
coordinates

the coordinates to scan return the envelope of the coordinates

def equals(coord1: Array[Coordinate], coord2: Array[Coordinate]): Boolean

Returns true if the two arrays are identical, both null, or pointwise equal (as compared using Coordinate#equals)

Returns true if the two arrays are identical, both null, or pointwise equal (as compared using Coordinate#equals)

See also

Coordinate#equals(Object)

def equals(coord1: Array[Coordinate], coord2: Array[Coordinate], coordinateComparator: Comparator[Coordinate]): Boolean

Returns true if the two arrays are identical, both null, or pointwise equal, using a user-defined {link Comparator} for {link Coordinate} s

Returns true if the two arrays are identical, both null, or pointwise equal, using a user-defined {link Comparator} for {link Coordinate} s

Value Params
coord1

an array of Coordinates

coord2

an array of Coordinates

coordinateComparator

a Comparator for Coordinates

def extract(pts: Array[Coordinate], startArg: Int, endArg: Int): Array[Coordinate]

Extracts a subsequence of the input {link Coordinate} array from indices <code>start</code> to <code>end</code> (inclusive). The input indices are clamped to the array size; If the end index is less than the start index, the extracted array will be empty.

Extracts a subsequence of the input {link Coordinate} array from indices <code>start</code> to <code>end</code> (inclusive). The input indices are clamped to the array size; If the end index is less than the start index, the extracted array will be empty.

Value Params
end

the index of the end of the subsequence to extract return a subsequence of the input array

pts

the input array

start

the index of the start of the subsequence to extract

def hasRepeatedPoints(coord: Array[Coordinate]): Boolean

Returns whether #equals returns true for any two consecutive Coordinates in the given array.

Returns whether #equals returns true for any two consecutive Coordinates in the given array.

def increasingDirection(pts: Array[Coordinate]): Int

Determines which orientation of the {link Coordinate} array is (overall) increasing. In other words, determines which end of the array is "smaller" (using the standard ordering on {link Coordinate}). Returns an integer indicating the increasing direction. If the sequence is a palindrome, it is defined to be oriented in a positive direction.

Determines which orientation of the {link Coordinate} array is (overall) increasing. In other words, determines which end of the array is "smaller" (using the standard ordering on {link Coordinate}). Returns an integer indicating the increasing direction. If the sequence is a palindrome, it is defined to be oriented in a positive direction.

Value Params
pts

the array of Coordinates to test return <code>1</code> if the array is smaller at the start or is a palindrome, <code>-1</code> if smaller at the end

def indexOf(coordinate: Coordinate, coordinates: Array[Coordinate]): Int

Returns the index of <code>coordinate</code> in <code>coordinates</code>. The first position is 0; the second, 1; etc.

Returns the index of <code>coordinate</code> in <code>coordinates</code>. The first position is 0; the second, 1; etc.

Value Params
coordinate

the <code>Coordinate</code> to search for

coordinates

the array to search return the position of <code>coordinate</code>, or -1 if it is not found

def intersection(coordinates: Array[Coordinate], env: Envelope): Array[Coordinate]

Extracts the coordinates which intersect an {link Envelope}

Extracts the coordinates which intersect an {link Envelope}

Value Params
coordinates

the coordinates to scan

env

the envelope to intersect with return an array of the coordinates which intersect the envelope

def isRing(pts: Array[Coordinate]): Boolean

Tests whether an array of {link Coordinate}s forms a ring, by checking length and closure. Self-intersection is not checked.

Tests whether an array of {link Coordinate}s forms a ring, by checking length and closure. Self-intersection is not checked.

Value Params
pts

an array of Coordinates return true if the coordinate form a ring.

def measures(pts: Array[Coordinate]): Int

Determine number of measures based on subclass of {link Coordinate}.

Determine number of measures based on subclass of {link Coordinate}.

Value Params
pts

supplied coordinates return number of measures recorded

def minCoordinate(coordinates: Array[Coordinate]): Coordinate

Returns the minimum coordinate, using the usual lexicographic comparison.

Returns the minimum coordinate, using the usual lexicographic comparison.

Value Params
coordinates

the array to search return the minimum coordinate in the array, found using <code>compareTo</code>

See also

Coordinate#compareTo(Object)

def ptNotInList(testPts: Array[Coordinate], pts: Array[Coordinate]): Coordinate

Finds a point in a list of points which is not contained in another list of points

Finds a point in a list of points which is not contained in another list of points

Value Params
pts

an array of { @link Coordinate}s to test the input points against return a { @link Coordinate} from <code>testPts</code> which is not in <code>pts</code>, ' or <code>null</code>

testPts

the { @link Coordinate}s to test

def removeNull(coord: Array[Coordinate]): Array[Coordinate]

Collapses a coordinate array to remove all null elements.

Collapses a coordinate array to remove all null elements.

Value Params
coord

the coordinate array to collapse return an array containing only non-null elements

def removeRepeatedPoints(coord: Array[Coordinate]): Array[Coordinate]

If the coordinate array argument has repeated points, constructs a new array containing no repeated points. Otherwise, returns the argument.

If the coordinate array argument has repeated points, constructs a new array containing no repeated points. Otherwise, returns the argument.

See also

#hasRepeatedPoints(Coordinate[])

def reverse(coord: Array[Coordinate]): Unit

Reverses the coordinates in an array in-place.

Reverses the coordinates in an array in-place.

def scroll(coordinates: Array[Coordinate], firstCoordinate: Coordinate): Unit

Shifts the positions of the coordinates until <code>firstCoordinate</code> is first.

Shifts the positions of the coordinates until <code>firstCoordinate</code> is first.

Value Params
coordinates

the array to rearrange

firstCoordinate

the coordinate to make first

def toCoordinateArray(coordList: Collection[_]): Array[Coordinate]

Converts the given Collection of Coordinates into a Coordinate array.

Converts the given Collection of Coordinates into a Coordinate array.