Home Reference Source
import Line from 'cgil-geom2d/src/Line.js'
public class | source

Line

Static Method Summary

Static Public Methods
public static

fromLine(otherLine: Line): Line

get a new Line that is a copy (clone) of the otherLine passed has parameter

Constructor Summary

Public Constructor
public

constructor(startPoint: Point, endPoint: Point, params: Object)

Creates a line

Member Summary

Public Members
public get

Get the endPoint value.

public set

endPoint(otherPoint: Point)

Set the endPoint value

public get

Get the starting Point.

public set

startPoint(otherPoint: Point)

Set the starting Point.

Private Members
private
private
private

Method Summary

Public Methods
public

give the length of the line

public

gives the slope of the line or m defined as Δy/Δx in the line equation y = m*x + b (b is y-intercept)

public

give the array [deltaX, deltaY] corresponding to difference in cartesian coordinates of this line

public

gives the y-intercept of the line or b in the line equation y = m*x + b (m is the Slope defined as Δy/Δx)

public

give an array representation of this Line class instance, you can use Array.flatten() to convert to [x1, y1, x2, y2] if flatten is not implemented use reduce instead : arrResult.reduce((acc, val) => acc.concat(val), []);

public

toEWKT(srid: number): string

give an Postgis Extended Well-known text (EWKT) representation of this class instance https://postgis.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT

public

give a GeoJSON geometry (http://geojson.org/) representation of this class instance geometry

public

give a string representation of this Line class instance

public

give an OGC Well-known text (WKT) representation of this class instance https://en.wikipedia.org/wiki/Well-known_text

Static Public Methods

public static fromLine(otherLine: Line): Line source

get a new Line that is a copy (clone) of the otherLine passed has parameter

Params:

NameTypeAttributeDescription
otherLine Line

is the Line you want to copy

Return:

Line

a new Line located at the same cartesian coordinates as otherLine

Public Constructors

public constructor(startPoint: Point, endPoint: Point, params: Object) source

Creates a line

Params:

NameTypeAttributeDescription
startPoint Point

of the Line (will be copied by value)

endPoint Point

of the Line (will be copied by value)

params Object

Public Members

public get endPoint: Point: * source

Get the endPoint value.

Return:

Point

The endPoint value.

public set endPoint(otherPoint: Point) source

Set the endPoint value

public get startPoint: Point: * source

Get the starting Point.

Return:

Point

The starting Point of this line.

public set startPoint(otherPoint: Point) source

Set the starting Point.

Private Members

private _endPoint: * source

private _options: * source

private _startPoint: * source

Public Methods

public getLength(): number source

give the length of the line

Return:

number

the length

public getSlope(): number source

gives the slope of the line or m defined as Δy/Δx in the line equation y = m*x + b (b is y-intercept)

Return:

number

a number the slope of the Line and Infinity if line is vertical

public getVectorArray(): number source

give the array [deltaX, deltaY] corresponding to difference in cartesian coordinates of this line

Return:

number

the length

public getYIntercept(): number source

gives the y-intercept of the line or b in the line equation y = m*x + b (m is the Slope defined as Δy/Δx)

Return:

number

a number the y-intercept of the Line and NaN if line is vertical

public toArray(): Array source

give an array representation of this Line class instance, you can use Array.flatten() to convert to [x1, y1, x2, y2] if flatten is not implemented use reduce instead : arrResult.reduce((acc, val) => acc.concat(val), []);

Return:

Array

an Array giving the coord of the line like this [[x1, y1], [x2, y2]]

public toEWKT(srid: number): string source

give an Postgis Extended Well-known text (EWKT) representation of this class instance https://postgis.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT

Params:

NameTypeAttributeDescription
srid number

is the Spatial reference systems identifier EPSG code default is 21781 for Switzerland MN03

Return:

string

public toGeoJSON(): string source

give a GeoJSON geometry (http://geojson.org/) representation of this class instance geometry

Return:

string

public toString(): string source

give a string representation of this Line class instance

Return:

string

public toWKT(): string source

give an OGC Well-known text (WKT) representation of this class instance https://en.wikipedia.org/wiki/Well-known_text

Return:

string