Revision 12764
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.cache</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>org.gvsig.raster.cache</name> |
|
8 |
<description>Cache management for raster files</description> |
|
9 |
<version>2.2.69</version> |
|
10 |
<scm> |
|
11 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69</connection> |
|
12 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69</developerConnection> |
|
13 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69</url> |
|
14 |
</scm> |
|
15 |
|
|
16 |
<repositories> |
|
17 |
<repository> |
|
18 |
<id>gvsig-public-http-repository</id> |
|
19 |
<name>gvSIG maven public HTTP repository</name> |
|
20 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
21 |
<releases> |
|
22 |
<enabled>true</enabled> |
|
23 |
<updatePolicy>daily</updatePolicy> |
|
24 |
<checksumPolicy>warn</checksumPolicy> |
|
25 |
</releases> |
|
26 |
<snapshots> |
|
27 |
<enabled>true</enabled> |
|
28 |
<updatePolicy>daily</updatePolicy> |
|
29 |
<checksumPolicy>warn</checksumPolicy> |
|
30 |
</snapshots> |
|
31 |
</repository> |
|
32 |
</repositories> |
|
33 |
|
|
34 |
<parent> |
|
35 |
<groupId>org.gvsig</groupId> |
|
36 |
<artifactId>org.gvsig.desktop</artifactId> |
|
37 |
<version>2.0.301</version> |
|
38 |
</parent> |
|
39 |
|
|
40 |
<developers> |
|
41 |
<developer> |
|
42 |
<id>nbrodin</id> |
|
43 |
<name>Nacho Brodin</name> |
|
44 |
<email>nachobrodin@gmail.com</email> |
|
45 |
<roles> |
|
46 |
<role>Architect</role> |
|
47 |
<role>Developer</role> |
|
48 |
</roles> |
|
49 |
</developer> |
|
50 |
</developers> |
|
51 |
|
|
52 |
<dependencyManagement> |
|
53 |
<dependencies> |
|
54 |
|
|
55 |
|
|
56 |
<!-- |
|
57 |
Versions of child projects |
|
58 |
--> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
62 |
<version>2.2.69</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.raster.cache.lib.impl</artifactId> |
|
67 |
<version>2.2.69</version> |
|
68 |
</dependency> |
|
69 |
|
|
70 |
|
|
71 |
</dependencies> |
|
72 |
</dependencyManagement> |
|
73 |
|
|
74 |
|
|
75 |
<build> |
|
76 |
<plugins> |
|
77 |
<plugin> |
|
78 |
<groupId>org.apache.maven.plugins</groupId> |
|
79 |
<artifactId>maven-release-plugin</artifactId> |
|
80 |
<configuration> |
|
81 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/</tagBase> |
|
82 |
<goals>deploy</goals> |
|
83 |
</configuration> |
|
84 |
</plugin> |
|
85 |
<plugin> |
|
86 |
<groupId>org.apache.maven.plugins</groupId> |
|
87 |
<artifactId>maven-compiler-plugin</artifactId> |
|
88 |
<configuration> |
|
89 |
<source>1.5</source> |
|
90 |
<target>1.5</target> |
|
91 |
</configuration> |
|
92 |
</plugin> |
|
93 |
<plugin> |
|
94 |
<groupId>org.codehaus.mojo</groupId> |
|
95 |
<artifactId>animal-sniffer-maven-plugin</artifactId> |
|
96 |
<configuration> |
|
97 |
<skip>true</skip> |
|
98 |
</configuration> |
|
99 |
</plugin> |
|
100 |
</plugins> |
|
101 |
</build> |
|
102 |
<modules> |
|
103 |
<module>org.gvsig.raster.cache.lib.api</module> |
|
104 |
<module>org.gvsig.raster.cache.lib.impl</module> |
|
105 |
</modules> |
|
106 |
</project> |
|
0 | 107 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/resources/image/prueba.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Extent> |
|
5 |
<X>0.0</X> |
|
6 |
<Y>3.0</Y> |
|
7 |
<RotationX>0.0</RotationX> |
|
8 |
<RotationY>0.0</RotationY> |
|
9 |
<PixelSizeX>1.0</PixelSizeX> |
|
10 |
<PixelSizeY>-1.0</PixelSizeY> |
|
11 |
<Width>3.0</Width> |
|
12 |
<Height>3.0</Height> |
|
13 |
</Extent> |
|
14 |
<Dimension> |
|
15 |
<ImagePxWidth>3.0</ImagePxWidth> |
|
16 |
<ImagePxHeight>3.0</ImagePxHeight> |
|
17 |
</Dimension> |
|
18 |
</FLyrGeoRaster> |
|
19 |
</RasterMetaFile> |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/resources/image/001m09_1_0.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<Statistics> |
|
4 |
<BandCount>3</BandCount> |
|
5 |
<Band> |
|
6 |
<Max>124.0</Max> |
|
7 |
<Min>-125.0</Min> |
|
8 |
<SecondMax>118.0</SecondMax> |
|
9 |
<SecondMin>-119.0</SecondMin> |
|
10 |
<MaxRGB>255.0</MaxRGB> |
|
11 |
<MinRGB>0.0</MinRGB> |
|
12 |
<SecondMaxRGB>249.0</SecondMaxRGB> |
|
13 |
<SecondMinRGB>6.0</SecondMinRGB> |
|
14 |
<Mean>10.724756162873467</Mean> |
|
15 |
<Variance>3732.9921559140375</Variance> |
|
16 |
</Band> |
|
17 |
<Band> |
|
18 |
<Max>120.0</Max> |
|
19 |
<Min>-128.0</Min> |
|
20 |
<SecondMax>113.0</SecondMax> |
|
21 |
<SecondMin>-121.0</SecondMin> |
|
22 |
<MaxRGB>255.0</MaxRGB> |
|
23 |
<MinRGB>0.0</MinRGB> |
|
24 |
<SecondMaxRGB>248.0</SecondMaxRGB> |
|
25 |
<SecondMinRGB>8.0</SecondMinRGB> |
|
26 |
<Mean>-5.959546810839912</Mean> |
|
27 |
<Variance>3170.059813419536</Variance> |
|
28 |
</Band> |
|
29 |
<Band> |
|
30 |
<Max>115.0</Max> |
|
31 |
<Min>-128.0</Min> |
|
32 |
<SecondMax>102.0</SecondMax> |
|
33 |
<SecondMin>-116.0</SecondMin> |
|
34 |
<MaxRGB>255.0</MaxRGB> |
|
35 |
<MinRGB>0.0</MinRGB> |
|
36 |
<SecondMaxRGB>242.0</SecondMaxRGB> |
|
37 |
<SecondMinRGB>13.0</SecondMinRGB> |
|
38 |
<Mean>29.884241606350802</Mean> |
|
39 |
<Variance>5352.010158331949</Variance> |
|
40 |
</Band> |
|
41 |
</Statistics> |
|
42 |
<FLyrGeoRaster> |
|
43 |
<Extent> |
|
44 |
<X>687369.0</X> |
|
45 |
<Y>5292882.0</Y> |
|
46 |
<RotationX>0.0</RotationX> |
|
47 |
<RotationY>0.0</RotationY> |
|
48 |
<PixelSizeX>15.0</PixelSizeX> |
|
49 |
<PixelSizeY>-15.0</PixelSizeY> |
|
50 |
<Width>38565.0</Width> |
|
51 |
<Height>29130.0</Height> |
|
52 |
</Extent> |
|
53 |
<Dimension> |
|
54 |
<ImagePxWidth>2571.0</ImagePxWidth> |
|
55 |
<ImagePxHeight>1942.0</ImagePxHeight> |
|
56 |
</Dimension> |
|
57 |
</FLyrGeoRaster> |
|
58 |
<Histogram> |
|
59 |
<BandCount>3</BandCount> |
|
60 |
<DataType>0</DataType> |
|
61 |
<Band> |
|
62 |
<Min>-128.0</Min> |
|
63 |
<Max>127.0</Max> |
|
64 |
<Values>0 0 0 91443 0 0 0 0 0 87582 0 0 0 0 0 83416 0 0 0 0 0 80242 0 0 0 0 0 77785 0 0 0 0 0 0 76043 0 0 0 0 0 75204 0 0 0 0 0 73991 0 0 0 0 0 72935 0 0 0 0 0 0 71374 0 0 0 0 0 68978 0 0 0 0 0 65623 0 0 0 0 0 62017 0 0 0 0 0 57527 0 0 0 0 0 0 52522 0 0 0 0 0 46880 0 0 0 0 0 40535 0 0 0 0 0 34249 0 0 0 0 0 0 28144 0 0 0 0 0 21973 0 0 0 0 0 66785 154890 0 0 0 0 0 213232 0 0 0 0 0 332313 0 0 0 0 0 0 439405 0 0 0 0 0 495390 0 0 0 0 0 447438 0 0 0 0 0 330266 0 0 0 0 0 0 218374 0 0 0 0 0 143093 0 0 0 0 0 94619 0 0 0 0 0 63522 0 0 0 0 0 48709 0 0 0 0 0 0 46991 0 0 0 0 0 52318 0 0 0 0 0 60650 0 0 0 0 0 69485 0 0 0 0 0 0 77576 0 0 0 0 0 86087 0 0 0 0 0 92322 0 0 0 0 0 96139 0 0 0 0 0 94815 0 0 0</Values> |
|
65 |
</Band> |
|
66 |
<Band> |
|
67 |
<Min>-128.0</Min> |
|
68 |
<Max>127.0</Max> |
|
69 |
<Values>60432 0 0 0 0 0 0 75527 0 0 0 0 0 0 0 92307 0 0 0 0 0 0 110369 0 0 0 0 0 0 0 126309 0 0 0 0 0 0 139939 0 0 0 0 0 0 0 149451 0 0 0 0 0 0 154194 0 0 0 0 0 0 0 154621 0 0 0 0 0 0 148426 0 0 0 0 0 0 0 136584 0 0 0 0 0 0 120553 0 0 0 0 0 0 0 102244 0 0 0 0 0 0 82065 0 0 0 0 0 0 0 62891 0 0 0 0 0 0 45204 0 0 0 0 0 0 0 30684 0 0 0 0 0 0 58527 198081 0 0 0 0 0 0 0 294634 0 0 0 0 0 0 463009 0 0 0 0 0 0 0 573354 0 0 0 0 0 0 531548 0 0 0 0 0 0 0 374029 0 0 0 0 0 0 232874 0 0 0 0 0 0 0 139815 0 0 0 0 0 0 78379 0 0 0 0 0 0 0 42064 0 0 0 0 0 0 28627 0 0 0 0 0 0 0 24092 0 0 0 0 0 0 23115 0 0 0 0 0 0 0 25295 0 0 0 0 0 0 29655 0 0 0 0 0 0 0 37025 0 0 0 0 0 0 46959 0 0 0 0 0 0 0</Values> |
|
70 |
</Band> |
|
71 |
<Band> |
|
72 |
<Min>-128.0</Min> |
|
73 |
<Max>127.0</Max> |
|
74 |
<Values>243210 0 0 0 0 0 0 0 0 0 0 0 189162 0 0 0 0 0 0 0 0 0 0 0 0 158442 0 0 0 0 0 0 0 0 0 0 0 0 136969 0 0 0 0 0 0 0 0 0 0 0 0 117646 0 0 0 0 0 0 0 0 0 0 0 97359 0 0 0 0 0 0 0 0 0 0 0 0 77068 0 0 0 0 0 0 0 0 0 0 0 0 57309 0 0 0 0 0 0 0 0 0 0 0 0 39587 0 0 0 0 0 0 0 0 0 0 0 26383 0 0 0 0 0 0 0 0 0 0 0 0 51062 133876 0 0 0 0 0 0 0 0 0 0 0 0 135257 0 0 0 0 0 0 0 0 0 0 0 0 251799 0 0 0 0 0 0 0 0 0 0 0 385960 0 0 0 0 0 0 0 0 0 0 0 0 499935 0 0 0 0 0 0 0 0 0 0 0 0 575464 0 0 0 0 0 0 0 0 0 0 0 0 571982 0 0 0 0 0 0 0 0 0 0 0 500034 0 0 0 0 0 0 0 0 0 0 0 0 418372 0 0 0 0 0 0 0 0 0 0 0 0 326006 0 0 0 0 0 0 0 0 0 0 0 0</Values> |
|
75 |
</Band> |
|
76 |
</Histogram> |
|
77 |
</RasterMetaFile> |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/TestThreadPool.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.tile; |
|
2 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
5 |
* of the Valencian Government (CIT) |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
*/ |
|
23 |
|
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import junit.framework.TestCase; |
|
28 |
|
|
29 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
30 |
import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl; |
|
31 |
import org.gvsig.raster.cache.tile.pool.ThreadPool; |
|
32 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
33 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
38 |
*/ |
|
39 |
public class TestThreadPool extends TestCase { |
|
40 |
private static final int WIDTH = 3; |
|
41 |
private static final int HEIGHT = 3; |
|
42 |
private static final int DOWNLOAD_TIME = 500; |
|
43 |
|
|
44 |
public class MyDownloader implements Downloader { |
|
45 |
|
|
46 |
public Tile downloadTile(Tile tile) { |
|
47 |
//tile.getFile() -> Aqui se guarda el fichero descargado |
|
48 |
try { |
|
49 |
Thread.sleep(DOWNLOAD_TIME); |
|
50 |
} catch (InterruptedException e) { |
|
51 |
e.printStackTrace(); |
|
52 |
} |
|
53 |
return tile; |
|
54 |
} |
|
55 |
|
|
56 |
public Tile readTileFromDisk(Tile tile) throws TileGettingException { |
|
57 |
// TODO Auto-generated method stub |
|
58 |
return null; |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean) |
|
64 |
*/ |
|
65 |
public void cancelDownloading(boolean cancel) { |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
public Object[] getCrashImage(int w, int h) { |
|
70 |
// TODO Auto-generated method stub |
|
71 |
return null; |
|
72 |
} |
|
73 |
|
|
74 |
public Object[] getDownloadingImage(int w, int h) { |
|
75 |
// TODO Auto-generated method stub |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
public void start() { |
|
82 |
try { |
|
83 |
this.doSetUp(); |
|
84 |
} catch (Exception e) { |
|
85 |
e.printStackTrace(); |
|
86 |
} |
|
87 |
this.testStack(); |
|
88 |
} |
|
89 |
|
|
90 |
protected void doSetUp() throws Exception { |
|
91 |
System.err.println("TestThreadPool running..."); |
|
92 |
} |
|
93 |
|
|
94 |
public void testStack() { |
|
95 |
new DefaultLibrariesInitializer().fullInitialize(true); |
|
96 |
ThreadPool pool = new ThreadPoolImpl(false); |
|
97 |
MyDownloader d = new MyDownloader(); |
|
98 |
|
|
99 |
for (int x = 0; x < HEIGHT; x++) { |
|
100 |
for (int y = 0; y < WIDTH; y++) { |
|
101 |
Tile t = TileCacheLocator.getManager().createTile(0, x, y); |
|
102 |
t.setSharedPipe(pool.getTilePipe()); |
|
103 |
t.setDownloader(d); |
|
104 |
t.setFile(new File("")); |
|
105 |
pool.addTask(t); |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
int nCollected = 0; |
|
110 |
while (nCollected < (WIDTH * HEIGHT)) { |
|
111 |
Tile tile = (Tile)pool.getTilePipe().getAtomicTask(); |
|
112 |
System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority()); |
|
113 |
nCollected ++; |
|
114 |
} |
|
115 |
if(pool != null) |
|
116 |
pool.destroyPool(); |
|
117 |
} |
|
118 |
|
|
119 |
} |
|
0 | 120 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPool.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.download; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
|
|
26 |
import junit.framework.TestCase; |
|
27 |
|
|
28 |
import org.gvsig.raster.cache.tile.Tile; |
|
29 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
30 |
import org.gvsig.raster.cache.tile.impl.TileImpl; |
|
31 |
import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl; |
|
32 |
import org.gvsig.raster.cache.tile.pool.ThreadPool; |
|
33 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
38 |
*/ |
|
39 |
public class TestThreadPool extends TestCase { |
|
40 |
private static final int WIDTH = 3; |
|
41 |
private static final int HEIGHT = 3; |
|
42 |
private static final int DOWNLOAD_TIME = 500; |
|
43 |
|
|
44 |
public class MyDownloader implements Downloader { |
|
45 |
|
|
46 |
public Tile downloadTile(Tile tile) { |
|
47 |
//tile.getFile() -> Aqui se guarda el fichero descargado |
|
48 |
try { |
|
49 |
Thread.sleep(DOWNLOAD_TIME); |
|
50 |
} catch (InterruptedException e) { |
|
51 |
e.printStackTrace(); |
|
52 |
} |
|
53 |
return tile; |
|
54 |
} |
|
55 |
|
|
56 |
public Tile readTileFromDisk(Tile tile) throws TileGettingException { |
|
57 |
// TODO Auto-generated method stub |
|
58 |
return null; |
|
59 |
} |
|
60 |
|
|
61 |
public void cancelDownloading(boolean cancel) { |
|
62 |
// TODO Auto-generated method stub |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
public Object[] getCrashImage(int w, int h) { |
|
67 |
// TODO Auto-generated method stub |
|
68 |
return null; |
|
69 |
} |
|
70 |
|
|
71 |
public Object[] getDownloadingImage(int w, int h) { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
return null; |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
public void start() { |
|
78 |
this.setUp(); |
|
79 |
this.testStack(); |
|
80 |
} |
|
81 |
|
|
82 |
public void setUp() { |
|
83 |
System.err.println("TestThreadPool running..."); |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
public void testStack() { |
|
88 |
ThreadPool pool = new ThreadPoolImpl(false); |
|
89 |
MyDownloader d = new MyDownloader(); |
|
90 |
|
|
91 |
for (int x = 0; x < HEIGHT; x++) { |
|
92 |
for (int y = 0; y < WIDTH; y++) { |
|
93 |
TileImpl t = new TileImpl(0, x, y); |
|
94 |
t.setSharedPipe(pool.getTilePipe()); |
|
95 |
t.setDownloader(d); |
|
96 |
t.setFile(new File("")); |
|
97 |
pool.addTask(t); |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
int nCollected = 0; |
|
102 |
while (nCollected < (WIDTH * HEIGHT)) { |
|
103 |
Tile tile = (Tile)pool.getTilePipe().getAtomicTask(); |
|
104 |
System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority()); |
|
105 |
nCollected ++; |
|
106 |
} |
|
107 |
if(pool != null) |
|
108 |
pool.destroyPool(); |
|
109 |
} |
|
110 |
} |
|
0 | 111 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPoolWithPriorities.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.download; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.Random; |
|
26 |
|
|
27 |
import junit.framework.TestCase; |
|
28 |
|
|
29 |
import org.gvsig.raster.cache.tile.Tile; |
|
30 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
31 |
import org.gvsig.raster.cache.tile.impl.TileImpl; |
|
32 |
import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl; |
|
33 |
import org.gvsig.raster.cache.tile.pool.ThreadPool; |
|
34 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
35 |
|
|
36 |
/** |
|
37 |
* |
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
39 |
*/ |
|
40 |
public class TestThreadPoolWithPriorities extends TestCase { |
|
41 |
private static final int WIDTH = 3; |
|
42 |
private static final int HEIGHT = 3; |
|
43 |
private static final int DOWNLOAD_TIME = 500; |
|
44 |
|
|
45 |
public class MyDownloader implements Downloader { |
|
46 |
|
|
47 |
public Tile downloadTile(Tile tile) { |
|
48 |
//tile.getFile() -> Aqui se guarda el fichero descargado |
|
49 |
try { |
|
50 |
Thread.sleep(DOWNLOAD_TIME); |
|
51 |
} catch (InterruptedException e) { |
|
52 |
e.printStackTrace(); |
|
53 |
} |
|
54 |
return tile; |
|
55 |
} |
|
56 |
|
|
57 |
public Tile readTileFromDisk(Tile tile) throws TileGettingException { |
|
58 |
// TODO Auto-generated method stub |
|
59 |
return null; |
|
60 |
} |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean) |
|
65 |
*/ |
|
66 |
public void cancelDownloading(boolean cancel) { |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
public Object[] getCrashImage(int w, int h) { |
|
71 |
// TODO Auto-generated method stub |
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
75 |
public Object[] getDownloadingImage(int w, int h) { |
|
76 |
// TODO Auto-generated method stub |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
} |
|
81 |
|
|
82 |
public void start() { |
|
83 |
this.setUp(); |
|
84 |
this.testStack(); |
|
85 |
} |
|
86 |
|
|
87 |
public void setUp() { |
|
88 |
System.err.println("TestThreadPool running..."); |
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
public void testStack() { |
|
93 |
ThreadPool pool = new ThreadPoolImpl(); |
|
94 |
MyDownloader d = new MyDownloader(); |
|
95 |
Random r = new Random(); |
|
96 |
|
|
97 |
for (int x = 0; x < HEIGHT; x++) { |
|
98 |
for (int y = 0; y < WIDTH; y++) { |
|
99 |
TileImpl t = new TileImpl(0, x, y); |
|
100 |
t.setSharedPipe(pool.getTilePipe()); |
|
101 |
t.setDownloader(d); |
|
102 |
t.setFile(new File("")); |
|
103 |
t.setPriority(r.nextInt()); |
|
104 |
pool.addTask(t); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
((ThreadPoolImpl)pool).init(); |
|
109 |
|
|
110 |
int nCollected = 0; |
|
111 |
while (nCollected < (WIDTH * HEIGHT)) { |
|
112 |
Tile tile = (Tile)pool.getTilePipe().getAtomicTask(); |
|
113 |
System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority()); |
|
114 |
nCollected ++; |
|
115 |
} |
|
116 |
if(pool != null) |
|
117 |
pool.destroyPool(); |
|
118 |
} |
|
119 |
} |
|
0 | 120 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPool.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.pool; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
|
|
26 |
import junit.framework.TestCase; |
|
27 |
|
|
28 |
import org.gvsig.raster.cache.tile.Tile; |
|
29 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
30 |
import org.gvsig.raster.cache.tile.impl.TileImpl; |
|
31 |
import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl; |
|
32 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public class TestThreadPool extends TestCase { |
|
39 |
private static final int WIDTH = 3; |
|
40 |
private static final int HEIGHT = 3; |
|
41 |
private static final int DOWNLOAD_TIME = 500; |
|
42 |
|
|
43 |
public class MyDownloader implements Downloader { |
|
44 |
|
|
45 |
public Tile downloadTile(Tile tile) { |
|
46 |
//tile.getFile() -> Aqui se guarda el fichero descargado |
|
47 |
try { |
|
48 |
Thread.sleep(DOWNLOAD_TIME); |
|
49 |
} catch (InterruptedException e) { |
|
50 |
e.printStackTrace(); |
|
51 |
} |
|
52 |
return tile; |
|
53 |
} |
|
54 |
|
|
55 |
public Tile readTileFromDisk(Tile tile) throws TileGettingException { |
|
56 |
// TODO Auto-generated method stub |
|
57 |
return null; |
|
58 |
} |
|
59 |
|
|
60 |
/* |
|
61 |
* (non-Javadoc) |
|
62 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean) |
|
63 |
*/ |
|
64 |
public void cancelDownloading(boolean cancel) { |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
public Object[] getCrashImage(int w, int h) { |
|
69 |
// TODO Auto-generated method stub |
|
70 |
return null; |
|
71 |
} |
|
72 |
|
|
73 |
public Object[] getDownloadingImage(int w, int h) { |
|
74 |
// TODO Auto-generated method stub |
|
75 |
return null; |
|
76 |
} |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
public void start() { |
|
81 |
this.setUp(); |
|
82 |
this.testStack(); |
|
83 |
} |
|
84 |
|
|
85 |
public void setUp() { |
|
86 |
System.err.println("TestThreadPool running..."); |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
public void testStack() { |
|
91 |
ThreadPoolImpl pool = new ThreadPoolImpl(false); |
|
92 |
MyDownloader d = new MyDownloader(); |
|
93 |
org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl pipe = new org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl(); |
|
94 |
|
|
95 |
for (int x = 0; x < HEIGHT; x++) { |
|
96 |
for (int y = 0; y < WIDTH; y++) { |
|
97 |
TileImpl t = new TileImpl(0, x, y); |
|
98 |
t.setSharedPipe(pipe); |
|
99 |
t.setDownloader(d); |
|
100 |
t.setFile(new File("")); |
|
101 |
pool.addTask(t); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
int nCollected = 0; |
|
106 |
while (nCollected < (WIDTH * HEIGHT)) { |
|
107 |
Tile tile = (Tile)pipe.getAtomicTask(); |
|
108 |
System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority()); |
|
109 |
nCollected ++; |
|
110 |
} |
|
111 |
if(pool != null) |
|
112 |
pool.destroyPool(); |
|
113 |
} |
|
114 |
} |
|
0 | 115 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPoolWithPriorities.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.pool; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.Random; |
|
26 |
|
|
27 |
import junit.framework.TestCase; |
|
28 |
|
|
29 |
import org.gvsig.raster.cache.tile.Tile; |
|
30 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
31 |
import org.gvsig.raster.cache.tile.impl.TileImpl; |
|
32 |
import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl; |
|
33 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
38 |
*/ |
|
39 |
public class TestThreadPoolWithPriorities extends TestCase { |
|
40 |
private static final int WIDTH = 3; |
|
41 |
private static final int HEIGHT = 3; |
|
42 |
private static final int DOWNLOAD_TIME = 500; |
|
43 |
|
|
44 |
public class MyDownloader implements Downloader { |
|
45 |
|
|
46 |
public Tile downloadTile(Tile tile) { |
|
47 |
//tile.getFile() -> Aqui se guarda el fichero descargado |
|
48 |
try { |
|
49 |
Thread.sleep(DOWNLOAD_TIME); |
|
50 |
} catch (InterruptedException e) { |
|
51 |
e.printStackTrace(); |
|
52 |
} |
|
53 |
return tile; |
|
54 |
} |
|
55 |
|
|
56 |
public Tile readTileFromDisk(Tile tile) throws TileGettingException { |
|
57 |
// TODO Auto-generated method stub |
|
58 |
return null; |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean) |
|
64 |
*/ |
|
65 |
public void cancelDownloading(boolean cancel) { |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
public Object[] getCrashImage(int w, int h) { |
|
70 |
// TODO Auto-generated method stub |
|
71 |
return null; |
|
72 |
} |
|
73 |
|
|
74 |
public Object[] getDownloadingImage(int w, int h) { |
|
75 |
// TODO Auto-generated method stub |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
public void start() { |
|
82 |
this.setUp(); |
|
83 |
this.testStack(); |
|
84 |
} |
|
85 |
|
|
86 |
public void setUp() { |
|
87 |
System.err.println("TestThreadPool running..."); |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
public void testStack() { |
|
92 |
ThreadPoolImpl pool = new ThreadPoolImpl(); |
|
93 |
MyDownloader d = new MyDownloader(); |
|
94 |
org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl pipe = new org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl(); |
|
95 |
Random r = new Random(); |
|
96 |
|
|
97 |
for (int x = 0; x < HEIGHT; x++) { |
|
98 |
for (int y = 0; y < WIDTH; y++) { |
|
99 |
TileImpl t = new TileImpl(0, x, y); |
|
100 |
t.setSharedPipe(pipe); |
|
101 |
t.setDownloader(d); |
|
102 |
t.setFile(new File("")); |
|
103 |
t.setPriority(r.nextInt()); |
|
104 |
pool.addTask(t); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
pool.init(); |
|
109 |
|
|
110 |
int nCollected = 0; |
|
111 |
while (nCollected < (WIDTH * HEIGHT)) { |
|
112 |
Tile tile = (Tile)pipe.getAtomicTask(); |
|
113 |
System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority()); |
|
114 |
nCollected ++; |
|
115 |
} |
|
116 |
if(pool != null) |
|
117 |
pool.destroyPool(); |
|
118 |
} |
|
119 |
} |
|
0 | 120 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/provider/TestCacheStruct.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.provider; |
|
23 |
|
|
24 |
import junit.framework.TestCase; |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class TestCacheStruct extends TestCase { |
|
31 |
|
|
32 |
public void start() { |
|
33 |
this.setUp(); |
|
34 |
this.testStack(); |
|
35 |
} |
|
36 |
|
|
37 |
public void setUp() { |
|
38 |
System.err.println("TestCacheStruct running..."); |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
public void testStack() { |
|
43 |
System.err.println("TODO: SOLVE THIS TEST"); |
|
44 |
|
|
45 |
// int levels = 25; |
|
46 |
// FlatXFileSystemStrategy strat = new FlatXFileSystemStrategy(); |
|
47 |
// DefaultCacheStruct struct = new DefaultCacheStruct( |
|
48 |
// CacheStruct.FLAT, |
|
49 |
// levels, |
|
50 |
// new Rectangle2D.Double(142671.0, 4194630.0, 228883.5, 255217.5), |
|
51 |
// 28.5, |
|
52 |
// 256, |
|
53 |
// 256, |
|
54 |
// "myLayer", |
|
55 |
// strat, |
|
56 |
// "baseDir", |
|
57 |
// "tif"); |
|
58 |
// System.out.println("***World***"); |
|
59 |
// for (int i = 0; i < levels; i++) { |
|
60 |
// System.out.println("-Level:" + i + " " + |
|
61 |
// struct.getWorldWidthOfTileMatrixByLevel(i) + " X " + |
|
62 |
// struct.getWorldHeightOfTileMatrixByLevel(i) + " : " + |
|
63 |
// struct.getPixelSizeByLevel(i)); |
|
64 |
// } |
|
65 |
// |
|
66 |
// System.out.println("***Layer***"); |
|
67 |
// for (int i = 0; i < levels; i++) { |
|
68 |
// System.out.println("Level:" + i + |
|
69 |
// " X:" + struct.getLayerInitXTilePositionByLevel(i) + |
|
70 |
// " Y:" + struct.getLayerInitYTilePositionByLevel(i) + ", " + |
|
71 |
// struct.getLayerWidthOfTileMatrixByLevel(i) + " X " + |
|
72 |
// struct.getLayerHeightOfTileMatrixByLevel(i)); |
|
73 |
// } |
|
74 |
} |
|
75 |
} |
|
0 | 76 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.cache.tile.impl.TileCacheDefaultImplLibrary |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/FlatXFileSystemStrategy.java | ||
---|---|---|
1 |
/* TileRasterCache, a library to download tiles from several sources. |
|
2 |
* |
|
3 |
* Copyright (C) 2010 Prodevelop SL. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Prodevelop Integraci�n de Tecnolog�as SL |
|
22 |
* Plaza don Juan de Vilarrasa , 14-5 |
|
23 |
* 46000 Valencia |
|
24 |
* Spain |
|
25 |
* |
|
26 |
* +34 963 510 612 |
|
27 |
* +34 963 510 968 |
|
28 |
* gis@prodevelop.es |
|
29 |
* http://www.prodevelop.es |
|
30 |
* |
|
31 |
* author: Alberto Romeu Carrasco (aromeu@prodevelop.es) |
|
32 |
*/ |
|
33 |
|
|
34 |
package org.gvsig.raster.cache.tile.impl.disk; |
|
35 |
|
|
36 |
import java.io.File; |
|
37 |
|
|
38 |
|
|
39 |
/** |
|
40 |
* This IFileSystemStrategy creates a directory for each zoom level of a layer. |
|
41 |
* Inside the directory of a zoom level, creates a directory for each X row and |
|
42 |
* inside the directory of an X row stores a file with the Y row, so |
|
43 |
* OSM/0/0/0.tile represents the tile http://osm/0/0/0.png |
|
44 |
* |
|
45 |
* This strategy is the most spread for mobile map viewers (although is not the most efficient) |
|
46 |
* @author aromeu |
|
47 |
* |
|
48 |
*/ |
|
49 |
public class FlatXFileSystemStrategy extends DefaultFileSystemStrategy { |
|
50 |
|
|
51 |
public FlatXFileSystemStrategy() { |
|
52 |
super(); |
|
53 |
} |
|
54 |
|
|
55 |
public FlatXFileSystemStrategy(String tileNameSuffix) { |
|
56 |
super(tileNameSuffix); |
|
57 |
} |
|
58 |
|
|
59 |
public String getRelativeToLayerDirTilePath(int row, |
|
60 |
int col, |
|
61 |
int zoomLevel, |
|
62 |
String var, |
|
63 |
String z, |
|
64 |
String time) { |
|
65 |
if(zoomLevel < 0) { //Real zoom level |
|
66 |
return new StringBuffer() |
|
67 |
.append(var) |
|
68 |
.append(File.separator) |
|
69 |
.append(z) |
|
70 |
.append(File.separator) |
|
71 |
.append(time) |
|
72 |
.append(File.separator) |
|
73 |
.append("real") |
|
74 |
.append(File.separator) |
|
75 |
.append(col) |
|
76 |
.append(File.separator) |
|
77 |
.append(row).toString(); |
|
78 |
} else { |
|
79 |
return new StringBuffer() |
|
80 |
.append(var) |
|
81 |
.append(File.separator) |
|
82 |
.append(z) |
|
83 |
.append(File.separator) |
|
84 |
.append(time) |
|
85 |
.append(File.separator) |
|
86 |
.append(zoomLevel) |
|
87 |
.append(File.separator) |
|
88 |
.append(col) |
|
89 |
.append(File.separator) |
|
90 |
.append(row).toString(); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
public String getLayerNameSuffix() { |
|
95 |
return "_flatx"; |
|
96 |
} |
|
97 |
|
|
98 |
public String getName() { |
|
99 |
return FLATX; |
|
100 |
} |
|
101 |
} |
|
0 | 102 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/DefaultFileSystemStrategy.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.tile.impl.disk; |
|
2 |
|
|
3 |
import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy; |
|
4 |
|
|
5 |
|
|
6 |
public abstract class DefaultFileSystemStrategy implements ITileFileSystemStrategy { |
|
7 |
|
|
8 |
private String tileNameSuffix; |
|
9 |
private final static String DEFAULT_TILE_SUFFIX = ".tile.gvsig"; |
|
10 |
|
|
11 |
public DefaultFileSystemStrategy() { |
|
12 |
|
|
13 |
} |
|
14 |
|
|
15 |
public DefaultFileSystemStrategy(String tileNameSuffix) { |
|
16 |
this.tileNameSuffix = tileNameSuffix; |
|
17 |
} |
|
18 |
|
|
19 |
public String getTileNameSuffix() { |
|
20 |
if (tileNameSuffix == null) |
|
21 |
return DEFAULT_TILE_SUFFIX; |
|
22 |
return this.tileNameSuffix; |
|
23 |
} |
|
24 |
|
|
25 |
public void setTileNameSuffix(String suffix) { |
|
26 |
this.tileNameSuffix = suffix; |
|
27 |
} |
|
28 |
} |
|
0 | 29 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrix.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.provider; |
|
23 |
|
|
24 |
|
|
25 |
/** |
|
26 |
* Description of a tile matrix |
|
27 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
28 |
*/ |
|
29 |
public class TileMatrix { |
|
30 |
private double scaleDenominator = 0; |
|
31 |
private double[] topLeftCorner = null; |
|
32 |
private int tileWidth = 0; |
|
33 |
private int tileHeight = 0; |
|
34 |
private long matrixWidth = 0; |
|
35 |
private long matrixHeight = 0; |
|
36 |
private static final double MTS_X_GRADO = 111319.490793274; |
|
37 |
|
|
38 |
public double getScaleDenominator() { |
|
39 |
return scaleDenominator; |
|
40 |
} |
|
41 |
|
|
42 |
public void setScaleDenominator(double scaleDenominator) { |
|
43 |
this.scaleDenominator = scaleDenominator; |
|
44 |
} |
|
45 |
|
|
46 |
public int getTileWidth() { |
|
47 |
return tileWidth; |
|
48 |
} |
|
49 |
|
|
50 |
public void setTileWidth(int tileWidth) { |
|
51 |
this.tileWidth = tileWidth; |
|
52 |
} |
|
53 |
|
|
54 |
public int getTileHeight() { |
|
55 |
return tileHeight; |
|
56 |
} |
|
57 |
|
|
58 |
public void setTileHeight(int tileHeight) { |
|
59 |
this.tileHeight = tileHeight; |
|
60 |
} |
|
61 |
|
|
62 |
public long getMatrixWidth() { |
|
63 |
return matrixWidth; |
|
64 |
} |
|
65 |
|
|
66 |
public void setMatrixWidth(long matrixWidth) { |
|
67 |
this.matrixWidth = matrixWidth; |
|
68 |
} |
|
69 |
|
|
70 |
public long getMatrixHeight() { |
|
71 |
return matrixHeight; |
|
72 |
} |
|
73 |
|
|
74 |
public void setMatrixHeight(long matrixHeight) { |
|
75 |
this.matrixHeight = matrixHeight; |
|
76 |
} |
|
77 |
|
|
78 |
public double[] getTopLeftCorner() { |
|
79 |
return topLeftCorner; |
|
80 |
} |
|
81 |
|
|
82 |
public void setTopLeftCorner(double[] topLeftCorner) { |
|
83 |
this.topLeftCorner = topLeftCorner; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Gets the width in meters of a tile |
|
88 |
* @param projected |
|
89 |
* @return |
|
90 |
*/ |
|
91 |
public double getWidthMtsTile(boolean projected) { |
|
92 |
if(!projected) { |
|
93 |
return (scaleDenominator * tileWidth * 0.00028) / MTS_X_GRADO; |
|
94 |
} else { |
|
95 |
return (scaleDenominator * tileWidth * 0.00028); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Gets the height in meters of a tile |
|
101 |
* @param projected |
|
102 |
* @return |
|
103 |
*/ |
|
104 |
public double getHeightMtsTile(boolean projected) { |
|
105 |
if(!projected) { |
|
106 |
return (scaleDenominator * tileHeight * 0.00028) / MTS_X_GRADO; |
|
107 |
} else { |
|
108 |
return (scaleDenominator * tileHeight * 0.00028); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
public void print() { |
|
113 |
System.out.println(" *****TileMatrix******"); |
|
114 |
System.out.println(" scaleDenominator:" + getScaleDenominator()); |
|
115 |
if(topLeftCorner != null) |
|
116 |
System.out.println(" topLeftCorner:" + topLeftCorner[0] + ", " + topLeftCorner[1]); |
|
117 |
System.out.println(" tileWidth:" + getTileWidth()); |
|
118 |
System.out.println(" tileHeight:" + getTileHeight()); |
|
119 |
System.out.println(" matrixWidth:" + getMatrixWidth()); |
|
120 |
System.out.println(" matrixHeight:" + getMatrixHeight()); |
|
121 |
} |
|
122 |
} |
|
0 | 123 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixLimits.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.provider; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
|
|
26 |
/** |
|
27 |
* Limits of a tile matrix |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class TileMatrixLimits { |
|
31 |
private TileMatrix tileMatrix = null; |
|
32 |
private int minTileRow = 0; |
|
33 |
private int maxTileRow = 0; |
|
34 |
private int minTileCol = 0; |
|
35 |
private int maxTileCol = 0; |
|
36 |
|
|
37 |
public TileMatrix getTileMatrix() { |
|
38 |
if(tileMatrix == null) |
|
39 |
tileMatrix = new TileMatrix(); |
|
40 |
return tileMatrix; |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Gets the upper left corner and the lower right corner of the |
|
45 |
* selected tile |
|
46 |
* @param x X tile position |
|
47 |
* @param y Y tile position |
|
48 |
* @return |
|
49 |
*/ |
|
50 |
public Point2D[] getTileExtent(int x, int y) { |
|
51 |
double sizeTile = getTileMatrix().getTileWidth() * getTileMatrix().getScaleDenominator(); |
|
52 |
double initX = getTileMatrix().getTopLeftCorner()[0] + (sizeTile * x); |
|
53 |
double initY = getTileMatrix().getTopLeftCorner()[1] - (sizeTile * y); |
|
54 |
Point2D[] p = new Point2D[2]; |
|
55 |
p[0] = new Point2D.Double(initX, initY); |
|
56 |
p[1] = new Point2D.Double(initX + sizeTile, initY - sizeTile); |
|
57 |
return p; |
|
58 |
} |
|
59 |
|
|
60 |
public int getMinTileRow() { |
|
61 |
return minTileRow; |
|
62 |
} |
|
63 |
|
|
64 |
public void setMinTileRow(int minTileRow) { |
|
65 |
this.minTileRow = minTileRow; |
|
66 |
} |
|
67 |
|
|
68 |
public int getMaxTileRow() { |
|
69 |
return maxTileRow; |
|
70 |
} |
|
71 |
|
|
72 |
public void setMaxTileRow(int maxTileRow) { |
|
73 |
this.maxTileRow = maxTileRow; |
|
74 |
} |
|
75 |
|
|
76 |
public int getMinTileCol() { |
|
77 |
return minTileCol; |
|
78 |
} |
|
79 |
|
|
80 |
public void setMinTileCol(int minTileCol) { |
|
81 |
this.minTileCol = minTileCol; |
|
82 |
} |
|
83 |
|
|
84 |
public int getMaxTileCol() { |
|
85 |
return maxTileCol; |
|
86 |
} |
|
87 |
|
|
88 |
public void setMaxTileCol(int maxTileCol) { |
|
89 |
this.maxTileCol = maxTileCol; |
|
90 |
} |
|
91 |
|
|
92 |
public void print() { |
|
93 |
System.out.println(" *****TileMatrixLimits******"); |
|
94 |
System.out.println(" MaxTileCol:" + getMaxTileCol()); |
|
95 |
System.out.println(" MaxTileRow:" + getMaxTileRow()); |
|
96 |
System.out.println(" MinTileCol:" + getMinTileCol()); |
|
97 |
System.out.println(" MinTileRow:" + getMinTileRow()); |
|
98 |
if(tileMatrix != null) |
|
99 |
tileMatrix.print(); |
|
100 |
} |
|
101 |
} |
|
0 | 102 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.69/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/DefaultCacheStruct.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.cache.tile.impl.provider; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.raster.cache.tile.Tile; |
|
30 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
31 |
import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy; |
|
32 |
import org.gvsig.raster.cache.tile.exception.TileBuildException; |
|
33 |
import org.gvsig.raster.cache.tile.impl.TileImpl; |
|
34 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
35 |
|
|
36 |
/** |
|
37 |
* Implementation for a structure of a cache |
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
39 |
*/ |
|
40 |
public class DefaultCacheStruct implements CacheStruct { |
|
41 |
private TileMatrixSet tileMatrixSet = null; |
|
42 |
private ArrayList<TileMatrixLimits> limits = null; |
|
43 |
private String layerName = null; |
|
44 |
private String uri = null; |
|
45 |
private Rectangle2D worldExtent = null; |
|
46 |
private String fileSuffix = null; |
|
47 |
private String epsg = null; |
|
48 |
private long fileSize = 0; |
|
49 |
private double realPixelSize = 0; |
|
50 |
private Rectangle2D layerExtent = null; |
|
51 |
|
|
52 |
public DefaultCacheStruct(int typeOfCoords, |
|
53 |
int levels, |
Also available in: Unified diff