X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fcache%2FRowInfo.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fcache%2FRowInfo.java;h=809c572e48979255366e05ef7d2342329a38d1d7;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/cache/RowInfo.java b/src/tim/prune/function/cache/RowInfo.java new file mode 100644 index 0000000..809c572 --- /dev/null +++ b/src/tim/prune/function/cache/RowInfo.java @@ -0,0 +1,106 @@ +package tim.prune.function.cache; + +/** + * Class to hold the information for a single table row. + * Used to describe a tileset or for a single zoom level of a tileset. + */ +public class RowInfo +{ + private int _zoom = -1; + private int _minZoom = -1, _maxZoom = -1; + private int _numTiles = 0; + private long _totalSize = 0L; + + + /** + * Set the zoom level + * @param inZoom zoom level + */ + public void setZoom(int inZoom) { + _zoom = inZoom; + } + + /** + * Add a zoom level and adjust max/min + * @param inZoom zoom level + */ + public void addZoom(int inZoom) + { + if (_minZoom < 0 || _minZoom > inZoom) + _minZoom = inZoom; + if (_maxZoom < inZoom) + _maxZoom = inZoom; + } + + /** + * @return the zoom level + */ + public int getZoom() { + return _zoom; + } + + /** + * @return the zoom range as a string + */ + public String getZoomRange() + { + if (_minZoom < 0 && _maxZoom < 0) return ""; + if (_minZoom == _maxZoom || _maxZoom < 0) return "" + _minZoom; + if (_minZoom < 0) return "" + _maxZoom; + return "" + _minZoom + " - " + _maxZoom; + } + + /** + * Add a single tile of the given size + * @param inSize size in bytes + */ + public void addTile(long inSize) { + addTiles(1, inSize); + } + + /** + * Add the given tiles + * @param inNumTiles number of tiles to add + * @param inSize total size of the tiles in bytes + */ + public void addTiles(int inNumTiles, long inSize) + { + _numTiles += inNumTiles; + _totalSize += inSize; + } + + /** + * @return the total number of tiles found + */ + public int getNumTiles() { + return _numTiles; + } + + /** + * @return the total size of the tiles in bytes + */ + public long getTotalSize() { + return _totalSize; + } + + + /** + * Add the given RowInfo object to this one + * @param inOther other row object + */ + public void addRow(RowInfo inOther) + { + if (inOther == null) + return; + _numTiles += inOther._numTiles; + _totalSize += inOther._totalSize; + // TODO: Max age + // Zoom range + if (inOther._minZoom > 0) + addZoom(inOther._minZoom); + if (inOther._maxZoom > 0) + addZoom(inOther._maxZoom); + if (inOther._zoom > 0) + addZoom(inOther._zoom); + } +}