RectangularGridSpatialModel2D

class RectangularGridSpatialModel2D(width: Double = Double.MAX_VALUE, height: Double = Double.MAX_VALUE, numRows: Int = 1, numCols: Int = 1, upperX: Double = 0.0, upperY: Double = 0.0) : SpatialModel

Creates a grid in the 2D plane. The grid is based on the standard user coordinate system, with (x,y) = (0,0) being the upper left most corner point, with the x-axis going from left to right and the y-axis going from the top down

Parameters

upperX

The x coordinate of the upper left most corner point

upperY

The y coordinate of the upper left most corner point

width

The width (along the x-axis) of the grid

height

The height (along the y-axis) of the grid

numRows

The number of rows in the grid (0-based)

numCols

The number of columns in the grid (0-based)

Constructors

Link copied to clipboard
constructor(width: Double = Double.MAX_VALUE, height: Double = Double.MAX_VALUE, numRows: Int = 1, numCols: Int = 1, upperX: Double = 0.0, upperY: Double = 0.0)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
inner class GridPoint(val x: Double, val y: Double, aName: String? = null) : SpatialModel.AbstractLocation

Represents a location within this spatial model.

Link copied to clipboard
inner class RectangularCell2D(row: Int, col: Int)

Properties

Link copied to clipboard

The line at the bottom of the grid

Link copied to clipboard

An iterator over the cells in the grid. The cells are accesses by rows (row, col): (0,0), then (0,1), etc 0th row first,

Link copied to clipboard

The cells in the grid as a list. The cells are accesses by rows (row, col): (0,0), then (0,1), etc 0th row first,

Link copied to clipboard
Link copied to clipboard
open override var defaultLocation: LocationIfc
Link copied to clipboard

The default velocity for elements that move within the spatial model

Link copied to clipboard
Link copied to clipboard
val id: Int
Link copied to clipboard

The line on the left side of the grid

Link copied to clipboard

The lower left corner point for the grid

Link copied to clipboard

The lower right corner point for the grid

Link copied to clipboard
Link copied to clipboard

The line on the right side of the grid

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The line at the top of the grid

Link copied to clipboard

The upper left corner point for the grid

Link copied to clipboard

The upper right corner point for the grid

Functions

Link copied to clipboard
open override fun attachObserver(observer: ObserverIfc<SpatialElementIfc>)

Allows the adding (attaching) of an observer to the observable

Link copied to clipboard

Returns the cell that the location is in or null

Returns the cell that the element is in or null

The cell that contains this (x,y) coordinate or null if no cell contains the coordinate.

The cell at this row, col. Null is returned if the row or column is outside the grid.

Link copied to clipboard
open override fun compareLocations(firstLocation: LocationIfc, secondLocation: LocationIfc): Boolean

Returns true if firstLocation is the same as secondLocation within the underlying spatial model. This is not object reference equality, but rather whether the locations within the underlying spatial model can be considered spatially (equivalent) according to the model. This may or may not imply that the distance between the locations is zero. No assumptions about distance are implied by true.

fun compareLocations(firstElement: SpatialElementIfc, secondElement: SpatialElementIfc): Boolean

Returns true if firstElement is the same as secondElement within the underlying spatial model. This is not object reference equality, but rather whether the elements within the underlying spatial model can be considered spatially (equivalent) according to the model. This may or may not imply that the distance between the elements is zero. No assumptions about distance are implied by true.

Link copied to clipboard

Checks if the x and y values are in the grid

Link copied to clipboard
open override fun countObservers(): Int

Returns how many observers are currently attached to the observable

Link copied to clipboard
open override fun detachAllObservers()

Detaches all the observers from the observable

Link copied to clipboard
open override fun detachObserver(observer: ObserverIfc<SpatialElementIfc>)

Allows the deletion (removing) of an observer from the observable

Link copied to clipboard
open override fun distance(fromLocation: LocationIfc, toLocation: LocationIfc): Double

Computes the distance between fromLocation and toLocation based on the spatial model's distance metric

fun distance(fromElement: SpatialElementIfc, toElement: SpatialElementIfc): Double

Computes the distance between fromElement and toElement based on the spatial model's distance metric

Link copied to clipboard

The elements in the cell containing location or an empty list

The elements in the cell containing spatialElement or an empty list.

The elements in the cell that contains x and y or an empty list

Link copied to clipboard
fun getRowMajorIndex(row: Int, col: Int): Int

The row major index is row(number of columns) + col + 1 Labeling starts at 1 and goes by row (across columns). For example for a 3 by 3 grid 4, 5, 6 7, 8, 9

Link copied to clipboard
open override fun isAttached(observer: ObserverIfc<SpatialElementIfc>): Boolean

Returns true if the observer is already attached

Link copied to clipboard

Checks if the spatial model contains the supplied element. True indicates that the element is within the spatial model. If the element has already been added to this spatial model then this method should return true

Link copied to clipboard
Link copied to clipboard

Returns an array with the 1st order Moore neighborhood for the given core cell.

Fills the supplied array with the 1st order Moore neighborhood for the given core cell.

Link copied to clipboard

Includes the non-null cells in the neighborhood into a List

Link copied to clipboard

The number of elements in the cell containing location

The number of elements in the cell containing spatialElement

The number of elements in the cell containing x and y

Link copied to clipboard
fun <T> Observable<T>.observe(block: (T?) -> Unit)
Link copied to clipboard
Link copied to clipboard
open override fun stopTracking(element: SpatialElement)
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun track(element: SpatialElement)

Causes the element to be tracked, held, by the spatial model. The user is responsible for maintaining this list