Last updated

API / geotoolkit / util / Point / Point

Class: Point

util.Point.Point

This class is a 2D Point implementation. It holds the xy values that define a point coordinates in two dimensions.
It also provides some utility functions to manipulate Points, compare points or calculate distance between points.

Table of contents

Constructors
[new Point()](/solutions/geotoolkit/apis/classes/geotoolkit.util.point.point.md#new point())[new Point(point)](/solutions/geotoolkit/apis/classes/geotoolkit.util.point.point.md#new point(point))[new Point(x, y)](/solutions/geotoolkit/apis/classes/geotoolkit.util.point.point.md#new point(x, y))
Accessors
Methods
Css Properties
Name Type Description
xnumberX coordinate
ynumberY coordinate

Contents

Constructors

new Point()

new Point()


new Point(point)

new Point(point)

Parameters

Name Type Description
pointnumber[] | Point | OptionsPoint or an object with 'x' and 'y' properties or [x,y] array

new Point(x, y)

new Point(x?, y?)

Parameters

Name Type Description
Optional xnumberx coordinate
Optional ynumbery coordinate
Accessors

x

get x(): number

X position

Name

module:geotoolkit/util/Point~Point#x

Returns

number

set x(value): void

X position

Name

module:geotoolkit/util/Point~Point#x

Parameters

Name Type
valuenumber

Returns

void


y

get y(): number

Y position

Name

module:geotoolkit/util/Point~Point#y

Returns

number

set y(value): void

Y position

Name

module:geotoolkit/util/Point~Point#y

Parameters

Name Type
valuenumber

Returns

void

Methods

clone

clone(): Point

return clone object

Returns

Point

clone


equalsPoint

equalsPoint(point, epsilon?): boolean

compares a point against this one, if equal returns true

Parameters

Name Type Description
pointPointpoint to compare to
Optional epsilonnumberacceptance criteria

Returns

boolean

if these two points are equal


getClassName

getClassName(): string

Returns

string


getClosest

getClosest(x1, y1, x2, y2, dst?): Point

Finds closest point from current to the segment provided (represented by two points)

Parameters

Name Type Description
x1numberfirst segment point x-ordinate
y1numberfirst segment point y-ordinate
x2numbersecond segment point x-ordinate
y2numbersecond segment point y-ordinate
Optional dstPointdestination point

Returns

Point

point


getProperties

getProperties(): Required<Options>

Gets all the properties pertaining to this object

Returns

Required<Options>


getX

getX(): number

Return x value

Returns

number

x value


getY

getY(): number

Return x value

Returns

number

x value


round

round(): Point

round point coordinates

Returns

Point


setPoint

setPoint(point): Point

set Point coordinates

Parameters

Name Type Description
pointPointpoint

Returns

Point

setPoint(x, y): Point

set Point coordinates

Parameters

Name Type Description
xnumberx coordinate or the point
ynumbery coordinate

Returns

Point


setProperties

setProperties(properties?): Point

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsobject containing the properties to set

Returns

Point

this


setX

setX(x): Point

set X Point coordinate

Parameters

Name Type Description
xnumberx coordinate

Returns

Point


setY

setY(y): Point

set Y Point coordinates

Parameters

Name Type Description
ynumbery coordinate

Returns

Point


toString

toString(): string

Returns a string that represents the current point.

Returns

string

A string that represents the current point.


translate

translate(dx, dy): Point

translate point of dx, dy.

Parameters

Name Type Description
dxnumberdx
dynumberdy

Returns

Point


fromObject

Static fromObject(point?): Point

Create or get point from object

Parameters

Name Type Description
Optional pointnumber | Point | Options | [number, number]can be in format of constructor of Point

Returns

Point

point


getClassName

Static getClassName(): string

Returns

string


getDistance

Static getDistance(x1, y1, x2, y2): number

Calculates distance between two points

Parameters

Name Type Description
x1numberfirst point x-ordinate
y1numberfirst point y-ordinate
x2numbersecond point x-ordinate
y2numbersecond point y-ordinate

Returns

number

distance between points

Static getDistance(p1, p2): number

Calculates distance between two points

Parameters

Name Type Description
p1Pointfirst point object
p2Pointsecond point object

Returns

number

distance between points


getSquaredDistance

Static getSquaredDistance(p1, p2): number

Returns squared distance between two points

Parameters

Name Type Description
p1Pointfirst point object
p2Pointsecond point object

Returns

number

squared distance

Static getSquaredDistance(x1, y1, x2, y2): number

Returns squared distance between two points{x1, y1} and {x2, y2}

Parameters

Name Type Description
x1numberfirst point x-ordinate
y1numberfirst point y-ordinate
x2numbersecond point x-ordinate
y2numbersecond point y-ordinate

Returns

number

squared distance