Revision 14926
import/ext3D/trunk/libCacheService/src/org/gvsig/cacheservice/CacheService.java | ||
---|---|---|
5 | 5 |
import java.awt.geom.Rectangle2D; |
6 | 6 |
import java.io.File; |
7 | 7 |
/** |
8 |
*
|
|
8 |
* |
|
9 | 9 |
* @author Rafael Gait�n <rgaitan@dsic.upv.es>, modified code from cq RasterCache of Luis W. Sevilla. |
10 | 10 |
* |
11 | 11 |
*/ |
12 | 12 |
public abstract class CacheService { |
13 |
|
|
13 |
|
|
14 | 14 |
/** |
15 | 15 |
* Tipo planetario. Las coordenadas son Lat/Lon |
16 | 16 |
*/ |
... | ... | |
30 | 30 |
* calculado especialmente para ese raster. |
31 | 31 |
*/ |
32 | 32 |
public static int GLOBAL = 0x200; |
33 |
|
|
33 |
|
|
34 | 34 |
public static final Rectangle2D sphericGlobalBounds = |
35 | 35 |
new Rectangle2D.Double(-180,-90,360,180); |
36 | 36 |
public static final Rectangle2D planeGlobalBounds = |
37 |
new Rectangle2D.Double(-10000000,-10000000,20000000,20000000);
|
|
38 |
|
|
37 |
new Rectangle2D.Double(-20000000,-10000000,40000000,20000000);
|
|
38 |
|
|
39 | 39 |
public static int TILEID_TYPE_GOOGLE = 0x01; |
40 | 40 |
public static int TILEID_TYPE_OSGPLANET = 0x02; |
41 | 41 |
public static int TILEID_TYPE_VIRTUALEARTH = 0x03; |
42 |
|
|
42 |
|
|
43 | 43 |
private String _name = ""; |
44 | 44 |
private String _planet = ""; |
45 | 45 |
|
... | ... | |
49 | 49 |
private String _cacheDir = null; |
50 | 50 |
private int _tileSize = 256; |
51 | 51 |
|
52 |
|
|
52 |
|
|
53 | 53 |
private boolean _withHashDirs = false; |
54 | 54 |
private int _hashDirsNumber = 100; |
55 |
|
|
55 |
|
|
56 | 56 |
private int _minLevel = 0; |
57 | 57 |
private int _maxLevel = 20; |
58 |
|
|
58 |
|
|
59 | 59 |
private Rectangle2D _bounds; |
60 |
|
|
60 |
|
|
61 | 61 |
private Rectangle2D _fullExtent = sphericGlobalBounds; |
62 |
|
|
62 |
|
|
63 | 63 |
/** |
64 | 64 |
* @param planet |
65 | 65 |
* @param name |
... | ... | |
72 | 72 |
setBounds(sphericGlobalBounds); |
73 | 73 |
} |
74 | 74 |
|
75 |
|
|
75 |
|
|
76 | 76 |
/** |
77 | 77 |
* Devuelve el tama�o de Tile como Dimension; |
78 | 78 |
* @return |
79 |
*/
|
|
79 |
*/ |
|
80 | 80 |
public Dimension computeSz() { |
81 | 81 |
return new Dimension(getTileSize(),getTileSize()); |
82 | 82 |
} |
... | ... | |
93 | 93 |
double stepY = (getFullExtent().getMaxY()-getFullExtent().getMinY())/partsY; |
94 | 94 |
double l = getFullExtent().getMinX()+(double)tileNum.getX()*stepX; |
95 | 95 |
//double r = l+stepX; |
96 |
double t = getFullExtent().getMaxY()-(double)tileNum.getY()*stepY; |
|
97 |
double b = t-stepY; |
|
98 |
|
|
96 |
double b; |
|
97 |
if ((_cacheType & SPHERIC) == SPHERIC) |
|
98 |
b = getFullExtent().getMaxY()-(double)tileNum.getY()*stepY - stepY; |
|
99 |
else |
|
100 |
b = getFullExtent().getMinY()+(double)tileNum.getY()*stepY; |
|
101 |
|
|
99 | 102 |
return new Rectangle2D.Double(l,b,stepX, Math.abs(stepY)); |
100 | 103 |
} |
101 |
|
|
104 |
|
|
102 | 105 |
public Dimension getFullSize(int level) { |
103 | 106 |
int w = getTileSize() * (int)Math.pow(2,level); |
104 | 107 |
return new Dimension(w, w/2); |
105 | 108 |
} |
106 |
|
|
109 |
|
|
107 | 110 |
/** |
108 | 111 |
* Devuelve el numero de Tiles (ancho y alto) para ese nivel. |
109 | 112 |
* @param level |
... | ... | |
113 | 116 |
int w = (int)Math.pow(2,level); |
114 | 117 |
return new Dimension(w, w/2); |
115 | 118 |
} |
116 |
|
|
119 |
|
|
117 | 120 |
public boolean isFileInCache(String fName) { |
118 | 121 |
File cacheFile = new File(fName); |
119 | 122 |
return cacheFile.exists(); |
120 | 123 |
} |
121 |
|
|
122 |
|
|
124 |
|
|
125 |
|
|
123 | 126 |
public void setCacheDir(String dir) { |
124 | 127 |
_cacheDir = dir; |
125 | 128 |
} |
... | ... | |
137 | 140 |
if (!file.exists()) file.mkdirs(); |
138 | 141 |
return _cacheDir; |
139 | 142 |
} |
140 |
|
|
143 |
|
|
141 | 144 |
/** |
142 | 145 |
* @return Returns the cacheRootDir. |
143 | 146 |
*/ |
Also available in: Unified diff