PlanarSet

PlanarSet

Class representing a planar set - a generic container with ability to keep and retrieve shapes and perform spatial queries. Planar set is an extension of Set container, so it supports Set properties and methods

Constructor

new PlanarSet(shapes)

Create new instance of PlanarSet
Source:
Parameters:
Name Type Description
shapes array or set of geometric objects to store in planar set Each object should have a box property

Classes

PlanarSet

Methods

add(entry) → {PlanarSet}

Add new shape to planar set and to its spatial index.
If shape already exist, it will not be added again. This happens with no error, it is possible to use size property to check if a shape was actually added.
Method returns planar set object updated and may be chained
Source:
Parameters:
Name Type Description
entry AnyShape | Object shape to be added, should have valid box property Another option to transfer as an object {key: Box, value: AnyShape}
Returns:
Type:
PlanarSet

clear()

Clear planar set
Source:

delete(entry) → {boolean}

Delete shape from planar set. Returns true if shape was actually deleted, false otherwise
Source:
Parameters:
Name Type Description
entry AnyShape | Object shape to be deleted
Returns:
Type:
boolean

hit(point) → {Array.<AnyShape>}

Point location test. Returns array of shapes which contains given point
Source:
Parameters:
Name Type Description
point Point query point
Returns:
Type:
Array.<AnyShape>
2d range search in planar set.
Returns array of all shapes in planar set which bounding box is intersected with query box
Source:
Parameters:
Name Type Description
box Box query box
Returns:
Type:
Array.<AnyShape>

svg() → {String}

Returns svg string to draw all shapes in planar set
Source:
Returns:
Type:
String