Skip to content

API / geotoolkit / util / LineSegment / LineSegment

Class: LineSegment

util.LineSegment.LineSegment

This class is a 2D Line implementation. It holds two points define a line segment two dimensions.</br> It also provides some utility functions to manipulate Lines and do basic geometrical calculations</br> The line segment is defined by two points: start and end. </br> StartPoint----------------------------EndPoint

Table of contents

Constructors
[new LineSegment()](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.linesegment.linesegment.md#new linesegment())[new LineSegment(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.linesegment.linesegment.md#new linesegment(options))[new LineSegment(start, end)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.linesegment.linesegment.md#new linesegment(start, end))
Methods
Css Properties
Name Type Description
endPointEnd point
end-xnumberX coordinate
end-ynumberY coordinate
startPointStart point

Contents

Constructors

new LineSegment()

• new LineSegment()


new LineSegment(options)

• new LineSegment(options)

Parameters

Name Type
optionsOptions

new LineSegment(start, end)

• new LineSegment(start, end)

Parameters

Name Type Description
startPointstart Point
endPointend point
Methods

clone

▸ clone(): LineSegment

Clones this line segment and returns the newly created clone object

Returns

LineSegment

clone


findIntersection

▸ findIntersection(ls1, typeObject?, dst?): Point

Checks if two lines are intersecting. If they do, will return intersection point, if they don't, will return null. If second argument is passed, it will be assigned a property "intersectiontype", which will contain one of the IntersectionType types defining how the two line segments are correlated. If a destination point is provided, the point will be filled with intersection coordinates and returned. (optimization)

Parameters

Name Type Description
ls1LineSegmentThe line to check intersection with
Optional typeObjectObjectAn optional to which a property called &quot;intersectiontype&quot; will be added
Optional typeObject.intersectiontypeIntersectionType
Optional dstPointDestination point to fill with intersection coordinates

Returns

Point

Point of intersection if intersecting. Null otherwise


getClassName

▸ getClassName(): string

Returns

string


getDistance

▸ getDistance(x, y): number

Parameters

Name Type
xnumber
ynumber

Returns

number


getEnd

▸ getEnd(): Point

Return end point of the line segment

Returns

Point

End point


getLength

▸ getLength(): number

Returns the length of the line segment

Returns

number

Length of the segment


getProperties

▸ getProperties(): OptionsOut

Gets all the properties pertaining to this object

Returns

OptionsOut


getStart

▸ getStart(): Point

Return start point of the line segment

Returns

Point

Start point


setEnd

▸ setEnd(end): LineSegment

Parameters

Name Type
endPoint

Returns

LineSegment

▸ setEnd(x, y): LineSegment

Parameters

Name Type
xnumber
ynumber

Returns

LineSegment


setLineSegment

▸ setLineSegment(start, end): LineSegment

Sets the two points which define a line segment.

Parameters

Name Type Description
startPointPoint representing the &quot;start&quot; position
endPointPoint representing the &quot;end&quot; position

Returns

LineSegment

this


setProperties

▸ setProperties(properties?): LineSegment

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsobject containing the properties to set

Returns

LineSegment

this


setStart

▸ setStart(start): LineSegment

Parameters

Name Type
startPoint

Returns

LineSegment

▸ setStart(x, y): LineSegment

Parameters

Name Type
xnumber
ynumber

Returns

LineSegment


translate

▸ translate(dx, dy): LineSegment

Translates the line segment by the deltas passed as arguments

Parameters

Name Type Description
dxnumberChange in x coordinates
dynumberChange in y coordinates

Returns

LineSegment

this


fromObject

▸ Static fromObject(object?): LineSegment

Create or get LineSegment from object

Parameters

Name Type Description
Optional objectLineSegment | Optionsobject can be in format of constructor of LineSegment

Returns

LineSegment

line segment


getClassName

▸ Static getClassName(): string

Returns

string