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:
NameTypeDescription
optionsWorld | WorldOptions | Object

Object with overrides for class properties

Methods

(static) defaultOptions(maxXopt, maxYopt, maxZopt)

Return a default options object, origin at center.

Parameters:
NameTypeAttributesDefaultDescription
maxXnumber<optional>
16

Integer max X value

maxYnumber<optional>
maxX

Integer max Y value

maxZnumber<optional>
Math.max(maxX, maxY)

Integer max Z value

Returns:

WorldOptions

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

Factory to create a default World instance.

Parameters:
NameTypeAttributesDefaultDescription
maxXnumber<optional>
16

Integer max X value

maxYnumber<optional>
maxX

Integer max Y value

maxZnumber<optional>
Math.max(maxX, maxY)

Integer max Z value

Returns:
Type: 
World

getOptions() → {Object}

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

Returns:

A WorldOptions object

Type: 
Object

randomPoint() → {Array}

Return a random 2D float point within the World

Returns:

A random x,y float array

Type: 
Array

random3DPoint() → {Array}

Return a random 3D point within the World

Returns:

A random x,y,z float array

Type: 
Array

randomPatchPoint() → {Array}

Return a random Patch 2D integer point

Returns:

A random x,y integer array

Type: 
Array

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

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

Parameters:
NameTypeAttributesDefaultDescription
xnumber

x value

ynumber

y value

znumber<optional>
this.centerZ

z value

Returns:

Whether or not on-world

Type: 
boolean

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:
NameTypeDescription
minXnumber

min bounding box x value

minYnumber

min bounding box y value

maxXnumber

max bounding box x value

maxYnumber

max bounding box y value

Returns:

Instance of the BBoxTransform

Type: 
BBoxTransform