# 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:
  - data_structures/planar_set.js, line 15

##### 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(shape) → {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:
  - data_structures/planar_set.js, line 36

##### Parameters:

Name | Type | Description
--- | --- | ---
`shape` | `Shape` | shape to be added, should have valid box property

##### Returns:

Type:
  `PlanarSet`

#### clear()

Clear planar set

Source:
  - data_structures/planar_set.js, line 62

#### delete(shape) → {boolean}

Delete shape from planar set. Returns true if shape was actually deleted, false otherwise

Source:
  - data_structures/planar_set.js, line 51

##### Parameters:

Name | Type | Description
--- | --- | ---
`shape` | `Shape` | shape to be deleted

##### Returns:

Type:
  `boolean`

#### hit(point) → {Array}

Point location test. Returns array of shapes which contains given point

Source:
  - data_structures/planar_set.js, line 83

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | `Point` | query point

##### Returns:

Type:
  `Array`

#### search(box) → {Array.<Shapes>}

2d range search in planar set.
Returns array of all shapes in planar set which bounding box is intersected with query box

Source:
  - data_structures/planar_set.js, line 73

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | `Box` | query box

##### Returns:

Type:
  `Array.<Shapes>`

#### svg() → {String}

Returns svg string to draw all shapes in planar set

Source:
  - data_structures/planar_set.js, line 93

##### Returns:

Type:
  `String`