File: RowInfo.java

package info (click to toggle)
gpsprune 19.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,516 kB
  • sloc: java: 42,704; sh: 25; makefile: 24; python: 15
file content (106 lines) | stat: -rw-r--r-- 2,085 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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);
	}
}