Tile
, UpdatableTile
public class MinMaxTreeTile extends SimpleTile
Tile
with a min/max kd tree.
A n level min/max kd-tree contains sub-tiles merging individual cells together from coarse-grained (at level 0) to fine-grained (at level n-1). Level n-1, which is the deepest one, is computed from the raw cells by merging adjacent cells pairs columns (i.e. cells at indices (i, 2j) and (i, 2j+1) are merged together by computing and storing the minimum and maximum in a sub-tile. Level n-1 therefore has the same number of rows but half the number of columns of the raw tile, and its sub-tiles are 1 cell high and 2 cells wide. Level n-2 is computed from level n-1 by merging sub-tiles rows. Level n-2 therefore has half the number of rows and half the number of columns of the raw tile, and its sub-tiles are 2 cells high and 2 cells wide. Level n-3 is again computed by merging columns, level n-4 merging rows and so on. As depth decreases, the number of sub-tiles decreases and their size increase. Level 0 is reached when there is only either one row or one column of large sub-tiles.
During the merging process, if at some stage there is an odd number of rows or columns, then the last sub-tile at next level will not be computed by merging two rows/columns from the current level, but instead computed by simply copying the last single row/column. The process is therefore well defined for any raw tile initial dimensions. A direct consequence is that the dimension of the sub-tiles in the last row or column may be smaller than the dimension of regular sub-tiles.
If we consider for example a tall 107 ⨉ 19 raw tile, the min/max kd-tree will have 9 levels:
Level | Number of sub-tiles | Regular sub-tiles dimension |
8 | 107 ⨉ 10 | 1 ⨉ 2 |
7 | 54 ⨉ 10 | 2 ⨉ 2 |
6 | 54 ⨉ 5 | 2 ⨉ 4 |
5 | 27 ⨉ 5 | 4 ⨉ 4 |
4 | 27 ⨉ 3 | 4 ⨉ 8 |
3 | 14 ⨉ 3 | 8 ⨉ 8 |
2 | 14 ⨉ 2 | 8 ⨉ 16 |
1 | 7 ⨉ 2 | 16 ⨉ 16 |
0 | 7 ⨉ 1 | 16 ⨉ 32 |
MinMaxTreeTileFactory
Tile.Location
Modifier and Type | Method | Description |
---|---|---|
int[] |
getCrossedBoundaryColumns(int column1,
int column2,
int level) |
Get the index of sub-tiles start columns crossed.
|
int[] |
getCrossedBoundaryRows(int row1,
int row2,
int level) |
Get the index of sub-tiles start rows crossed.
|
int |
getLevels() |
Get the number of kd-tree levels (not counting raw elevations).
|
double |
getMaxElevation(int i,
int j,
int level) |
Get the maximum elevation at some level tree.
|
int |
getMergeLevel(int i1,
int j1,
int i2,
int j2) |
Get the deepest level at which two cells are merged in the same min/max sub-tile.
|
double |
getMinElevation(int i,
int j,
int level) |
Get the minimum elevation at some level tree.
|
boolean |
isColumnMerging(int level) |
Check if the merging operation between level and level-1 is a column merging.
|
int[] |
locateMax(int i,
int j,
int level) |
Locate the cell at which max elevation is reached for a specified level.
|
int[] |
locateMin(int i,
int j,
int level) |
Locate the cell at which min elevation is reached for a specified level.
|
protected void |
processUpdatedElevation(double[] elevations) |
Process elevation array at completion.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cellIntersection, getElevationAtIndices, getFloorLatitudeIndex, getFloorLongitudeIndex, getLatitudeAtIndex, getLatitudeRows, getLatitudeStep, getLocation, getLongitudeAtIndex, getLongitudeColumns, getLongitudeStep, getMaxElevation, getMaxElevationLatitudeIndex, getMaxElevationLongitudeIndex, getMaximumLatitude, getMaximumLongitude, getMinElevation, getMinElevationLatitudeIndex, getMinElevationLongitudeIndex, getMinimumLatitude, getMinimumLongitude, interpolateElevation, setElevation, setGeometry, tileUpdateCompleted
protected void processUpdatedElevation(double[] elevations)
This method is called at tile update completion, it is expected to be overridden by subclasses. The default implementation does nothing.
processUpdatedElevation
in class SimpleTile
elevations
- elevations arraypublic int getLevels()
getMinElevation(int, int, int)
,
getMaxElevation(int, int, int)
,
getMergeLevel(int, int, int, int)
public double getMinElevation(int i, int j, int level)
Note that the min elevation is not computed only at cell center, but considering that it is interpolated considering also Eastwards and Northwards neighbors, and extends up to the center of these neighbors. As an example, lets consider four neighboring cells in some Digital Elevation Model:
j+1 | 11 | 10 |
---|---|---|
j | 12 | 11 |
j/i | i | i+1 |
getMinElevation(i,
j, l)
must return 10 if l is chosen such that the sub-tile at
tree level l includes cell (i,j) but not cell (i+1, j+1). In other words,
interpolation implies sub-tile boundaries are overshoot by one column to
the East and one row to the North when computing min.i
- row index of the cellj
- column index of the celllevel
- tree levelgetLevels()
,
getMaxElevation(int, int, int)
,
getMergeLevel(int, int, int, int)
public double getMaxElevation(int i, int j, int level)
Note that the max elevation is not computed only at cell center, but considering that it is interpolated considering also Eastwards and Northwards neighbors, and extends up to the center of these neighbors. As an example, lets consider four neighboring cells in some Digital Elevation Model:
j+1 | 11 | 12 |
---|---|---|
j | 10 | 11 |
j/i | i | i+1 |
getMaxElevation(i,
j, l)
must return 12 if l is chosen such that the sub-tile at
tree level l includes cell (i,j) but not cell (i+1, j+1). In other words,
interpolation implies sub-tile boundaries are overshoot by one column to
the East and one row to the North when computing max.i
- row index of the cellj
- column index of the celllevel
- tree levelgetLevels()
,
getMinElevation(int, int, int)
,
getMergeLevel(int, int, int, int)
public int[] locateMin(int i, int j, int level)
Min is computed with respect to the continuous interpolated elevation, which
takes four neighboring cells into account. This implies that the cell at which
min value is reached for some level is either within the sub-tile for this level,
or in some case it may be one column outside to the East or one row outside to
the North. See SimpleTile.getMinElevation()
for a more complete explanation.
i
- row index of the cellj
- column index of the celllevel
- tree level of the sub-tile consideredpublic int[] locateMax(int i, int j, int level)
Max is computed with respect to the continuous interpolated elevation, which
takes four neighboring cells into account. This implies that the cell at which
max value is reached for some level is either within the sub-tile for this level,
or in some case it may be one column outside to the East or one row outside to
the North. See SimpleTile.getMaxElevation()
for a more complete explanation.
i
- row index of the cellj
- column index of the celllevel
- tree level of the sub-tile consideredpublic int getMergeLevel(int i1, int j1, int i2, int j2)
i1
- row index of first cellj1
- column index of first celli2
- row index of second cellj2
- column index of second cellgetLevels()
,
getMinElevation(int, int, int)
,
getMaxElevation(int, int, int)
public int[] getCrossedBoundaryRows(int row1, int row2, int level)
When going from one row to another row at some tree level, we cross sub-tiles boundaries. This method returns the index of these boundaries.
row1
- starting rowrow2
- ending rowlevel
- tree levelrow1
or row2
are
boundary rows, they will be in returned array)public int[] getCrossedBoundaryColumns(int column1, int column2, int level)
When going from one column to another column at some tree level, we cross sub-tiles boundaries. This method returns the index of these boundaries.
column1
- starting columncolumn2
- ending column (excluded)level
- tree levelcolumn1
or column2
are
boundary columns, they will be in returned array)public boolean isColumnMerging(int level)
level
- level to checkCopyright © 2014-2019 CS Systèmes d'information. All rights reserved.