Package aisutils :: Module grid :: Class Grid
[hide private]
[frames] | no frames]

Class Grid

source code

Provide a grid data structure. Will resize up to include the full range on the max size if not an interger size of stepSize. Units are whatever you desire. It is up to you to project them.

0,0 is at the lower left and (xNumCells-1,yNumCells-1) is the upper right cell

Instance Methods [hide private]
 
__init__(self, minx, miny, maxx, maxy, stepSize, gridType='occurrence', verbose=False)
Prepare a grid.
source code
 
describe(self) source code
 
getCell(self, x, y, verbose=False)
Returns: the i,j of the cell containing this coordinate
source code
 
getCellCenter(self, i, j) source code
 
getLineCells2pt(self, p1, p2, verbose=False) source code
 
getLineCellsWithCrossingsPts(self, p1, p2, verbose=False) source code
 
getLineCellsWithCrossings(self, x0, y0, x1, y1, verbose=False)
Scan convert a single line segment with two vertices.
source code
 
getLineCells(self, x0, y0, x1, y1, verbose=False)
Scan convert a single line segment with two vertices.
source code
 
getMultiSegLineCells(self, multiSegLine, verbose=False)
Return the cells for a multi vertex line.
source code
 
getMultiSegLineCellsWithCrossings(self, multiSegLine, verbose=False)
Return the cells for a multi vertex line.
source code
 
writeLayoutGnuplot(self, filename)
Write out the grid lines as gnuplot dat file
source code
 
addMultiSegLine(self, multiSegLine, verbose=False) source code
 
writeCellsGnuplot(self, filename, useSquares=False) source code
 
writeArcAsciiGrid(self, filename) source code
Class Variables [hide private]
  epsilon = 1e-06
Method Details [hide private]

__init__(self, minx, miny, maxx, maxy, stepSize, gridType='occurrence', verbose=False)
(Constructor)

source code 
Prepare a grid. Readjust the grid such that the stepSize divides evenly into the ranges. Compute and cache the number of cells.

getCell(self, x, y, verbose=False)

source code 
Returns:
the i,j of the cell containing this coordinate

getCellCenter(self, i, j)

source code 
Parameters:
  • i - the horizonal cell count from the left starting at 0 @return the x,y of the center of specified cell

getLineCellsWithCrossings(self, x0, y0, x1, y1, verbose=False)

source code 

Scan convert a single line segment with two vertices.

Used for when we need to calculated paraeters off the line to add a value to the cell. e.g. distance or speed wieghted by distance.

A line inside a cell returns the cell, 0., 1., and the distance
Returns:
a list of (cell(an i,j), startFrac, endFrac, distance) for a line
To Do:
  • make this actually be fast
  • switch to delta Y for N-S lines

getLineCells(self, x0, y0, x1, y1, verbose=False)

source code 
Scan convert a single line segment with two vertices.
Returns:
a list of cells for a line

To Do: make this actually be fast

getMultiSegLineCells(self, multiSegLine, verbose=False)

source code 
Return the cells for a multi vertex line. Handles the doubling that will happen at each endpoint
Parameters:
  • multiSegLine - ((x1,y1),(x2,y2),(x3,y3),(x4,y4)...)

getMultiSegLineCellsWithCrossings(self, multiSegLine, verbose=False)

source code 
Return the cells for a multi vertex line. Returns distances within cells, so that doubling is not an issue
Parameters:
  • multiSegLine - ((x1,y1),(x2,y2),(x3,y3),(x4,y4)...)
Returns:
list of (cell, startFrac, endFrac, distance)

writeCellsGnuplot(self, filename, useSquares=False)

source code 
Parameters:
  • useSquares - if true then write out the height of each cell as a square. False then it writes a point