|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.unidata.gis.SpatialGrid
public class SpatialGrid
Fast implementation for tracking data overlap and closest point in a 2D region. The region of interest is divided into non-overlapping cells. Each cell may contain zero or one data objects. This allows quickly finding if a data object may be drawn (markIfClear) and closest drawn object to a point (findClosest).
| Constructor Summary | |
|---|---|
SpatialGrid(int nx,
int ny)
Constructor |
|
| Method Summary | |
|---|---|
void |
clear()
clear all the grid cells |
Object |
findClosest(Point2D pt)
Find the closest marked cell to the given point |
boolean |
markIfClear(Rectangle2D rect,
Object o)
Check if the given rect intersects an already drawn one. |
void |
print()
print the grid |
void |
setGrid(Rectangle2D bbox,
Rectangle2D cellSize)
Set the grid scale. |
void |
setOverlap(int overlap)
Set how much the data may overlap. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SpatialGrid(int nx,
int ny)
nx - maximum number of grid columnsny - maximum number of grid rows| Method Detail |
|---|
public void setGrid(Rectangle2D bbox,
Rectangle2D cellSize)
bbox - bounding box we are only interested in points inside of thiscellSize - divide the bounding box into cells of this size.
maximum number of grid cells is nx x nypublic void setOverlap(int overlap)
overlap - percent overlappublic void print()
public void clear()
public boolean markIfClear(Rectangle2D rect,
Object o)
rect - the bounding box of the thing we want to drawo - store this object
public Object findClosest(Point2D pt)
pt - find the closest marked cell to this point
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||