// Type definitions for jsts 0.16.0 // Project: https://github.com/bjornharrtell/jsts // Definitions by: Stephane Alie // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module jsts { export var version: string; module geom { /** * A lightweight class used to store coordinates on the 2-dimensional * Cartesian plane. It is distinct from {@link Point}, which is a subclass of * {@link Geometry}. Unlike objects of type {@link Point} (which contain * additional information such as an envelope, a precision model, and spatial * reference system information), a Coordinate only contains * coordinate values and accessor methods. */ export class Coordinate { /** * @constructor */ constructor(x: number, y: number); /** * @constructor */ constructor(c: Coordinate); /** * Gets or sets the x value. */ x: number; /** * Gets or sets the y value. */ y: number; /** * Gets or sets the z value. */ z: number; /** * Sets this Coordinates (x,y,z) values to that of * other. * * @param {Coordinate} * other the Coordinate to copy. */ setCoordinate(other: Coordinate): void; /** * Clones this instance. * * @return {Coordinate} A point instance cloned from this. */ clone(): Coordinate; /** * Computes the 2-dimensional Euclidean distance to another location. The * Z-ordinate is ignored. * * @param {Coordinate} * p a point. * @return {number} the 2-dimensional Euclidean distance between the * locations. */ distance(p: Coordinate): number; /** * Returns whether the planar projections of the two Coordinates * are equal. * * @param {Coordinate} * other a Coordinate with which to do the 2D * comparison. * @return {boolean} true if the x- and y-coordinates are * equal; the z-coordinates do not have to be equal. */ equals2D(other: Coordinate): boolean; /** * Returns true if other has the same values for * the x and y ordinates. Since Coordinates are 2.5D, this routine ignores the * z value when making the comparison. * * @param {Coordinate} * other a Coordinate with which to do the comparison. * @return {boolean} true if other is a * Coordinate with the same values for the x and y * ordinates. */ equals(other: Coordinate): boolean; /** * Compares this {@link Coordinate} with the specified {@link Coordinate} for * order. This method ignores the z value when making the comparison. Returns: * * Note: This method assumes that ordinate values are valid numbers. NaN * values are not handled correctly. * * @param {Coordinate} * other the Coordinate with which this * Coordinate is being compared. * @return {number} -1, zero, or 1 as explained above. */ compareTo(other: Coordinate): number; } /** * Defines a rectangular region of the 2D coordinate plane. It is often used to * represent the bounding box of a {@link Geometry}, e.g. the minimum and * maximum x and y values of the {@link Coordinate}s. *

* Note that Envelopes support infinite or half-infinite regions, by using the * values of Double.POSITIVE_INFINITY and * Double.NEGATIVE_INFINITY. *

* When Envelope objects are created or initialized, the supplies extent values * are automatically sorted into the correct order. */ export class Envelope { /** * Test the point q to see whether it intersects the Envelope defined by p1-p2 * * NOTE: calls intersectsEnvelope if four arguments are given to simulate * overloaded function * * @param {jsts.geom.Coordinate} * p1 one extremal point of the envelope. * @param {jsts.geom.Coordinate} * p2 another extremal point of the envelope. * @param {jsts.geom.Coordinate} * q the point to test for intersection. * @return {boolean} true if q intersects the envelope p1-p2. */ static intersects(p1: Coordinate, p2: Coordinate, q: Coordinate): boolean; /** * Test the envelope defined by p1-p2 for intersection with the envelope defined * by q1-q2 * * @param {jsts.geom.Coordinate} * p1 one extremal point of the envelope P. * @param {jsts.geom.Coordinate} * p2 another extremal point of the envelope P. * @param {jsts.geom.Coordinate} * q1 one extremal point of the envelope Q. * @param {jsts.geom.Coordinate} * q2 another extremal point of the envelope Q. * @return {boolean} true if Q intersects P. */ static intersectsEnvelope(p1: Coordinate, p2: Coordinate, q1: Coordinate, q2: Coordinate): boolean; /** * Creates an Envelope for a region defined by maximum and * minimum values. * * @param {number} x1 the first x-value. * @param {number} x2 the second x-value. * @param {number} y1 the first y-value. * @param {number} y2 the second y-value. */ constructor(x1: number, x2: number, y1: number, y2: number); /** * Initialize an Envelope to a region defined by two Coordinates. * * @param {jsts.geom.Coordinate} p1 the first Coordinate. * @param {jsts.geom.Coordinate} p2 the second Coordinate. */ constructor(p1: Coordinate, p2: Coordinate); /** * Initialize an Envelope to a region defined by a single * Coordinate. * * @param {jsts.geom.Coordinate} p the Coordinate. */ constructor(p: Coordinate); /** * Initialize an Envelope from an existing Envelope. * * @param {jsts.geom.Envelope} env the Envelope to initialize from. */ constructor(env: Envelope); /** * the minimum x-coordinate. */ minx: number; /** * the maximum x-coordinate. */ maxx: number; /** * the minimum y-coordinate. */ miny: number; /** * the maximum y-coordinate. */ maxy: number; /** * Makes this Envelope a "null" envelope, that is, the envelope * of the empty geometry. */ setToNull(): void; /** * Returns true if this Envelope is a "null" * envelope. * * @return {boolean} true if this Envelope is * uninitialized or is the envelope of the empty geometry. */ isNull(): boolean; /** * Returns the difference between the maximum and minimum y values. * * @return {number} max y - min y, or 0 if this is a null Envelope. */ getHeight(): number; /** * Returns the difference between the maximum and minimum x values. * * @return {number} max x - min x, or 0 if this is a null Envelope. */ getWidth(): number; /** * Returns the Envelopes minimum x-value. min x > max x * indicates that this is a null Envelope. * * @return {number} the minimum x-coordinate. */ getMinX(): number; /** * Returns the Envelopes maximum x-value. min x > max x * indicates that this is a null Envelope. * * @return {number} the maximum x-coordinate. */ getMaxX(): number; /** * Returns the Envelopes minimum y-value. min y > max y * indicates that this is a null Envelope. * * @return {number} the minimum y-coordinate. */ getMinY(): number; /** * Returns the Envelopes maximum y-value. min y > max y * indicates that this is a null Envelope. * * @return {number} the maximum y-coordinate. */ getMaxY(): number; /** * Gets the area of this envelope. * * @return {number} the area of the envelope, 0.0 if the envelope is null. */ getArea(): number; /** * Enlarges this Envelope so that it contains the given * {@link Coordinate}. Has no effect if the point is already on or within the * envelope. * * @param {jsts.geom.Coordinate} p the Coordinate to expand to include. */ expandToInclude(p: Coordinate): void; /** * Enlarges this Envelope so that it contains the given point. * Has no effect if the point is already on or within the envelope. * * @param {number} x the value to lower the minimum x to or to raise the maximum x to. * @param {number} y the value to lower the minimum y to or to raise the maximum y to. */ expandToInclude(x: number, y: number): void; /** * Enlarges this Envelope so that it contains the * other Envelope. Has no effect if other is * wholly on or within the envelope. * * @param {jsts.geom.Envelope} other the Envelope to expand to include. */ expandToInclude(other: Envelope): void; /** * Expands this envelope by a given distance in all directions. Both positive * and negative distances are supported. * * @param {number} distance the distance to expand the envelope. */ expandBy(distance: number): void; /** * Expands this envelope by a given distance in all directions. Both positive * and negative distances are supported. * * @param {number} * deltaX the distance to expand the envelope along the the X axis. * @param {number} * deltaY the distance to expand the envelope along the the Y axis. */ expandBy(deltaX: number, deltaY: number): void; /** * Translates this envelope by given amounts in the X and Y direction. * * @param {number} * transX the amount to translate along the X axis. * @param {number} * transY the amount to translate along the Y axis. */ translate(transX: number, transY: number): void; /** * Computes the coordinate of the centre of this envelope (as long as it is * non-null * * @return {jsts.geom.Coordinate} the centre coordinate of this envelope null * if the envelope is null. */ centre(): Coordinate; /** * Computes the intersection of two {@link Envelopes} * * @param {jsts.geom.Envelope} * env the envelope to intersect with. * @return {jsts.geom.Envelope} a new Envelope representing the intersection of * the envelopes (this will be the null envelope if either argument is * null, or they do not intersect. */ intersection(env: Envelope): Envelope; /** * Check if the region defined by other overlaps (intersects) the * region of this Envelope. * * @param {jsts.geom.Envelope} * other the Envelope which this Envelope * is being checked for overlapping. * @return {boolean} true if the Envelopes * overlap. */ intersects(other: Envelope): boolean; /** * Check if the point p overlaps (lies inside) the region of this * Envelope. * * @param {jsts.geom.Coordinate} * p the Coordinate to be tested. * @return {boolean} true if the point overlaps this * Envelope. */ intersects(p: Coordinate): boolean; /** * Check if the point (x, y) overlaps (lies inside) the region of * this Envelope. * * @param {number} * x the x-ordinate of the point. * @param {number} * y the y-ordinate of the point. * @return {boolean} true if the point overlaps this * Envelope. */ intersects(x: number, y: number): boolean; /** * Tests if the Envelope other lies wholely inside this * Envelope (inclusive of the boundary). *

* Note that this is not the same definition as the SFS * contains, which would exclude the envelope boundary. * * @param {jsts.geom.Envelope} * other the Envelope to check. * @return {boolean} true if other is contained in this * Envelope. * * @see covers(Envelope) */ contains(other: Envelope): boolean; /** * Tests if the given point lies in or on the envelope. *

* Note that this is not the same definition as the SFS * contains, which would exclude the envelope boundary. * * @param {jsts.geom.Coordinate} * p the point which this Envelope is being checked for * containing. * @return {boolean} true if the point lies in the interior or on * the boundary of this Envelope. * * @see covers(Coordinate) */ contains(p: Coordinate): boolean; /** * Tests if the given point lies in or on the envelope. *

* Note that this is not the same definition as the SFS * contains, which would exclude the envelope boundary. * * @param {number} * x the x-coordinate of the point which this Envelope * is being checked for containing. * @param {number} * y the y-coordinate of the point which this Envelope * is being checked for containing. * @return {boolean} true if (x, y) lies in the * interior or on the boundary of this Envelope. * * @see covers(double, double) */ contains(x: number, y: number): boolean; /** * Tests if the given point lies in or on the envelope. * * @param {number} * x the x-coordinate of the point which this Envelope * is being checked for containing. * @param {number} * y the y-coordinate of the point which this Envelope * is being checked for containing. * @return {boolean} true if (x, y) lies in the * interior or on the boundary of this Envelope. */ covers(x: number, y: number): boolean; /** * Tests if the given point lies in or on the envelope. * * @param {jsts.geom.Coordinate} * p the point which this Envelope is being checked for * containing. * @return {boolean} true if the point lies in the interior or on * the boundary of this Envelope. */ covers(p: Coordinate): boolean; /** * Tests if the Envelope other lies wholely inside this * Envelope (inclusive of the boundary). * * @param {jsts.geom.Envelope} * other the Envelope to check. * @return {boolean} true if this Envelope covers the * other. */ covers(other: Envelope): boolean; /** * Computes the distance between this and another Envelope. * * @param {jsts.geom.Envelope} * env The Envelope to test this Envelope * against. * @return {number} The distance between overlapping Envelopes is 0. Otherwise, * the distance is the Euclidean distance between the closest points. */ distance(env: Envelope): number; /** * @param {jsts.geom.Envelope} * other the Envelope to check against. * @return {boolean} true if envelopes are equal. */ equals(other: Envelope): boolean; /** * @return {string} String representation of this Envelope. */ toString(): string; /** * @return {jsts.geom.Envelope} A new instance copied from this. */ clone(): Envelope; } /** * The base class for all geometric objects. */ export class Geometry { /** * Creates a new Geometry via the specified GeometryFactory. */ constructor(factory?: any); /** * The bounding box of this Geometry. */ envelope: Envelope; /** * Gets the factory which contains the context in which this geometry was created. * * @return {jsts.geom.GeometryFactory} the factory for this geometry. */ getFactory(): any; /** * Returns the name of this object's com.vivid.jts.geom interface. * * @return {string} The name of this Geometrys most specific jsts.geom interface. */ getGeometryType(): string; /** *Returns the number of {@link Geometry}s in a {@link GeometryCollection} * (or 1, if the geometry is not a collection). * * @return {number} the number of geometries contained in this geometry. */ getNumGeometries(): number; /** * Returns an element {@link Geometry} from a {@link GeometryCollection} (or * this, if the geometry is not a collection). * * @param {number} n The index of the geometry element. * * @return {Geometry} the n'th geometry contained in this geometry. */ getGeometryN(n: number): Geometry; /** * Returns the PrecisionModel used by the Geometry. * * @return {PrecisionModel} the specification of the grid of allowable points, for this * Geometry and all other Geometrys. */ getPrecisionModel(): any; /** * 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. * * @return {Coordinate} a {@link Coordinate} which is a vertex of this * Geometry. null if this Geometry is empty. */ getCoordinate(): 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. *

* In general, the array cannot be assumed to be the actual internal storage for * the vertices. Thus modifying the array may not modify the geometry itself. * Use the {@link CoordinateSequence#setOrdinate} method (possibly on the * components) to modify the underlying data. If the coordinates are modified, * {@link #geometryChanged} must be called afterwards. * * @return {Coordinate[]} the vertices of this Geometry. * @see geometryChanged * @see CoordinateSequence#setOrdinate */ getCoordinates(): Coordinate[]; /** * Returns the count of this Geometrys vertices. The * Geometry s contained by composite Geometrys * must be Geometry's; that is, they must implement getNumPoints * * @return {number} the number of vertices in this Geometry. */ getNumPoints(): number; /** * Tests whether this {@link Geometry} is simple. In general, the SFS * specification of simplicity follows the rule: *

* Simplicity is defined for each {@link Geometry} subclass as follows: *