On this page

# World

Class World defines the coordinate system for the model. It has transforms for multiple coordinate systems.

The world is defined by an object with 6 properties:

         WorldOptions = {
             minX: integer,
             maxX: integer,
             minY: integer,
             maxY: integer,
             minZ: integer,
             maxZ: integer,
         }

## Constructor

### new World(options)

Create a new World object given an Object with optional minX, maxX, minY, maxY, minZ, maxZ overriding class properties.

Parameters:

Name | Type | Description
--- | --- | ---
`options` | World | WorldOptions | Object | Object with overrides for class properties

Source
  - World.js, line 35

## Methods

### (static) defaultOptions(maxXopt, maxYopt, maxZopt)

Return a default options object, origin at center.

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`maxX` | number | <optional> | 16 | Integer max X value
`maxY` | number | <optional> | maxX | Integer max Y value
`maxZ` | number | <optional> | Math.max(maxX, maxY) | Integer max Z value

Source
  - World.js, line 53

Returns:

WorldOptions

### (static) defaultWorld(maxXopt, maxYopt, maxZopt) → {World}

Factory to create a default World instance.

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`maxX` | number | <optional> | 16 | Integer max X value
`maxY` | number | <optional> | maxX | Integer max Y value
`maxZ` | number | <optional> | Math.max(maxX, maxY) | Integer max Z value

Source
  - World.js, line 72

Returns:

Type:
  World

### bboxTransform(minX, minY, maxX, maxY) → {BBoxTransform}

Return an instance of a bounding box 2D transform. It linearly interpolates between the given minX, minY, maxX, maxY, and the world's values of the same properties.

The parameters are in the popular geojson order: west, south, east, north

Useful for Canvas (pixel) top-left transforms and geojson transforms.

Note minX etc NOT the world's but of the coord sys we want to use.

Parameters:

Name | Type | Description
--- | --- | ---
`minX` | number | min bounding box x value
`minY` | number | min bounding box y value
`maxX` | number | max bounding box x value
`maxY` | number | max bounding box y value

Source
  - World.js, line 206

Returns:

Instance of the BBoxTransform

Type:
  BBoxTransform

### getOptions() → {Object}

Return the options (minX, maxX, ..) used to create this world.

Source
  - World.js, line 125

Returns:

A WorldOptions object

Type:
  Object

### isOnWorld(x, y, zopt) → {boolean}

Given x,y,z values return true if within the world

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`x` | number |  |  | x value
`y` | number |  |  | y value
`z` | number | <optional> | this.centerZ | z value

Source
  - World.js, line 175

Returns:

Whether or not on-world

Type:
  boolean

### random3DPoint() → {Array}

Return a random 3D point within the World

Source
  - World.js, line 147

Returns:

A random x,y,z float array

Type:
  Array

### randomPatchPoint() → {Array}

Return a random Patch 2D integer point

Source
  - World.js, line 160

Returns:

A random x,y integer array

Type:
  Array

### randomPoint() → {Array}

Return a random 2D float point within the World

Source
  - World.js, line 135

Returns:

A random x,y float array

Type:
  Array

Type anything to view search result