]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/cache/RowInfo.java
809c572e48979255366e05ef7d2342329a38d1d7
[GpsPrune.git] / tim / prune / function / cache / RowInfo.java
1 package tim.prune.function.cache;
2
3 /**
4  * Class to hold the information for a single table row.
5  * Used to describe a tileset or for a single zoom level of a tileset.
6  */
7 public class RowInfo
8 {
9         private int _zoom = -1;
10         private int _minZoom = -1, _maxZoom = -1;
11         private int _numTiles = 0;
12         private long _totalSize = 0L;
13
14
15         /**
16          * Set the zoom level
17          * @param inZoom zoom level
18          */
19         public void setZoom(int inZoom) {
20                 _zoom = inZoom;
21         }
22
23         /**
24          * Add a zoom level and adjust max/min
25          * @param inZoom zoom level
26          */
27         public void addZoom(int inZoom)
28         {
29                 if (_minZoom < 0 || _minZoom > inZoom)
30                         _minZoom = inZoom;
31                 if (_maxZoom < inZoom)
32                         _maxZoom = inZoom;
33         }
34
35         /**
36          * @return the zoom level
37          */
38         public int getZoom() {
39                 return _zoom;
40         }
41
42         /**
43          * @return the zoom range as a string
44          */
45         public String getZoomRange()
46         {
47                 if (_minZoom < 0 && _maxZoom < 0) return "";
48                 if (_minZoom == _maxZoom || _maxZoom < 0) return "" + _minZoom;
49                 if (_minZoom < 0) return "" + _maxZoom;
50                 return "" + _minZoom + " - " + _maxZoom;
51         }
52
53         /**
54          * Add a single tile of the given size
55          * @param inSize size in bytes
56          */
57         public void addTile(long inSize) {
58                 addTiles(1, inSize);
59         }
60
61         /**
62          * Add the given tiles
63          * @param inNumTiles number of tiles to add
64          * @param inSize total size of the tiles in bytes
65          */
66         public void addTiles(int inNumTiles, long inSize)
67         {
68                 _numTiles += inNumTiles;
69                 _totalSize += inSize;
70         }
71
72         /**
73          * @return the total number of tiles found
74          */
75         public int getNumTiles() {
76                 return _numTiles;
77         }
78
79         /**
80          * @return the total size of the tiles in bytes
81          */
82         public long getTotalSize() {
83                 return _totalSize;
84         }
85
86
87         /**
88          * Add the given RowInfo object to this one
89          * @param inOther other row object
90          */
91         public void addRow(RowInfo inOther)
92         {
93                 if (inOther == null)
94                         return;
95                 _numTiles  += inOther._numTiles;
96                 _totalSize += inOther._totalSize;
97                 // TODO: Max age
98                 // Zoom range
99                 if (inOther._minZoom > 0)
100                         addZoom(inOther._minZoom);
101                 if (inOther._maxZoom > 0)
102                         addZoom(inOther._maxZoom);
103                 if (inOther._zoom > 0)
104                         addZoom(inOther._zoom);
105         }
106 }