Revision 1292
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuración general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
|
0 | 152 |
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/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" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
4 |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
5 |
|
|
6 |
<modelVersion>4.0.0</modelVersion> |
|
7 |
<artifactId>org.gvsig.raster.cache</artifactId> |
|
8 |
<packaging>pom</packaging> |
|
9 |
<name>org.gvsig.raster.cache</name> |
|
10 |
<description>Cache management for raster files</description> |
|
11 |
<version>2.0.0-SNAPSHOT</version> |
|
12 |
<scm> |
|
13 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/trunk/org.gvsig.raster.cache</connection> |
|
14 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/trunk/org.gvsig.raster.cache</developerConnection> |
|
15 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.cache/trunk/org.gvsig.raster.cache</url> |
|
16 |
</scm> |
|
17 |
<parent> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>gvsig-base-library-pom</artifactId> |
|
20 |
<version>2.0-SNAPSHOT</version> |
|
21 |
</parent> |
|
22 |
<developers> |
|
23 |
<developer> |
|
24 |
<id>nbrodin</id> |
|
25 |
<name>Nacho Brodin</name> |
|
26 |
<email>nachobrodin@gmail.com</email> |
|
27 |
<roles> |
|
28 |
<role>Architect</role> |
|
29 |
<role>Developer</role> |
|
30 |
</roles> |
|
31 |
</developer> |
|
32 |
</developers> |
|
33 |
<dependencyManagement> |
|
34 |
<dependencies> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.core.maven.dependencies</artifactId> |
|
38 |
<version>2.0.1-SNAPSHOT</version> |
|
39 |
<type>pom</type> |
|
40 |
<scope>import</scope> |
|
41 |
</dependency> |
|
42 |
</dependencies> |
|
43 |
</dependencyManagement> |
|
44 |
<dependencies> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
48 |
<scope>compile</scope> |
|
49 |
</dependency> |
|
50 |
</dependencies> |
|
51 |
<build> |
|
52 |
<plugins> |
|
53 |
<plugin> |
|
54 |
<groupId>org.apache.maven.plugins</groupId> |
|
55 |
<artifactId>maven-release-plugin</artifactId> |
|
56 |
<configuration> |
|
57 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/</tagBase> |
|
58 |
</configuration> |
|
59 |
</plugin> |
|
60 |
<plugin> |
|
61 |
<groupId>org.apache.maven.plugins</groupId> |
|
62 |
<artifactId>maven-compiler-plugin</artifactId> |
|
63 |
<configuration> |
|
64 |
<source>1.5</source> |
|
65 |
<target>1.5</target> |
|
66 |
</configuration> |
|
67 |
</plugin> |
|
68 |
</plugins> |
|
69 |
</build> |
|
70 |
<modules> |
|
71 |
<module>org.gvsig.raster.cache.lib.api</module> |
|
72 |
<module>org.gvsig.raster.cache.lib.impl</module> |
|
73 |
</modules> |
|
74 |
<properties> |
|
75 |
<build-dir>${basedir}/../build</build-dir> |
|
76 |
</properties> |
|
77 |
</project> |
|
0 | 78 |
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/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/buildNumber_28/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/buffer/impl/TestInterpolationBSplineIncrease.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
9 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
11 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
14 |
|
|
15 |
/** |
|
16 |
* Copy the band 0 from a buffer over the band 2 in the same buffer using the |
|
17 |
* method getBandCopy. |
|
18 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
19 |
*/ |
|
20 |
public class TestInterpolationBSplineIncrease extends TestCase { |
|
21 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
22 |
private String rasterOut = "/tmp/out-interpBSpline.tif"; |
|
23 |
private static int REL = 2; |
|
24 |
|
|
25 |
public void start() { |
|
26 |
this.setUp(); |
|
27 |
this.testStack(); |
|
28 |
} |
|
29 |
|
|
30 |
public void setUp() { |
|
31 |
System.err.println("TestInterpolationBSpline running..."); |
|
32 |
} |
|
33 |
|
|
34 |
public void testStack() { |
|
35 |
long t1 = System.currentTimeMillis(); |
|
36 |
GdalRead input = null; |
|
37 |
GdalWrite out = null; |
|
38 |
try { |
|
39 |
//Read input data |
|
40 |
input = new GdalRead(rasterIn); |
|
41 |
int readSize = 10; |
|
42 |
Object dataIn = input.readBlock(0, 0, readSize, readSize); |
|
43 |
|
|
44 |
//Create Buffer |
|
45 |
Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
46 |
readSize, |
|
47 |
readSize, |
|
48 |
input.getBandCount(), |
|
49 |
true); |
|
50 |
|
|
51 |
//Set data to buffer |
|
52 |
setLines(dataIn, buf1); |
|
53 |
Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_BSpline); |
|
54 |
|
|
55 |
//Write output file |
|
56 |
out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB); |
|
57 |
out.writeBands(buf.getBands()); |
|
58 |
out.close(); |
|
59 |
|
|
60 |
buf1.free(); |
|
61 |
} catch (GdalException e) { |
|
62 |
e.printStackTrace(); |
|
63 |
} catch (IOException e) { |
|
64 |
e.printStackTrace(); |
|
65 |
} catch (ProcessInterruptedException e) { |
|
66 |
e.printStackTrace(); |
|
67 |
} catch (OperationNotSupportedException e) { |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 |
long t2 = System.currentTimeMillis(); |
|
71 |
System.out.println("Tiempo TestInterpolationBSpline: " + (t2 - t1) + " milisegundos"); |
|
72 |
} |
|
73 |
|
|
74 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
75 |
if(dataIn instanceof byte[][][]) { |
|
76 |
byte[][][] d = (byte[][][])dataIn; |
|
77 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
78 |
for (int row = 0; row < d[iBand].length; row++) { |
|
79 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
} |
|
86 |
|
|
0 | 87 |
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/buffer/impl/TestInterpolationBSplineReduction.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
9 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
11 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
14 |
|
|
15 |
/** |
|
16 |
* Copy the band 0 from a buffer over the band 2 in the same buffer using the |
|
17 |
* method getBandCopy. |
|
18 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
19 |
*/ |
|
20 |
public class TestInterpolationBSplineReduction extends TestCase { |
|
21 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
22 |
private String rasterOut = "/tmp/out-interpBSplineReduction.tif"; |
|
23 |
private static int REL = 5; |
|
24 |
|
|
25 |
public void start() { |
|
26 |
this.setUp(); |
|
27 |
this.testStack(); |
|
28 |
} |
|
29 |
|
|
30 |
public void setUp() { |
|
31 |
System.err.println("TestInterpolationBSplineReduction running..."); |
|
32 |
} |
|
33 |
|
|
34 |
public void testStack() { |
|
35 |
long t1 = System.currentTimeMillis(); |
|
36 |
GdalRead input = null; |
|
37 |
GdalWrite out = null; |
|
38 |
try { |
|
39 |
//Read input data |
|
40 |
input = new GdalRead(rasterIn); |
|
41 |
Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight()); |
|
42 |
|
|
43 |
//Create Buffer |
|
44 |
Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
45 |
input.getWidth(), |
|
46 |
input.getHeight(), |
|
47 |
input.getBandCount(), |
|
48 |
true); |
|
49 |
|
|
50 |
//Set data to buffer |
|
51 |
setLines(dataIn, buf1); |
|
52 |
Buffer buf = buf1.getAdjustedWindow(input.getWidth() / REL, input.getHeight() / REL, BufferInterpolationImpl.INTERPOLATION_BSpline); |
|
53 |
|
|
54 |
//Write output file |
|
55 |
out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB); |
|
56 |
out.writeBands(buf.getBands()); |
|
57 |
out.close(); |
|
58 |
|
|
59 |
buf1.free(); |
|
60 |
} catch (GdalException e) { |
|
61 |
e.printStackTrace(); |
|
62 |
} catch (IOException e) { |
|
63 |
e.printStackTrace(); |
|
64 |
} catch (ProcessInterruptedException e) { |
|
65 |
e.printStackTrace(); |
|
66 |
} catch (OperationNotSupportedException e) { |
|
67 |
e.printStackTrace(); |
|
68 |
} |
|
69 |
long t2 = System.currentTimeMillis(); |
|
70 |
System.out.println("Tiempo TestInterpolationBSplineReduction: " + (t2 - t1) + " milisegundos"); |
|
71 |
} |
|
72 |
|
|
73 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
74 |
if(dataIn instanceof byte[][][]) { |
|
75 |
byte[][][] d = (byte[][][])dataIn; |
|
76 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
77 |
for (int row = 0; row < d[iBand].length; row++) { |
|
78 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
85 |
|
|
0 | 86 |
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/buffer/impl/TestInterpolationBicubicIncrease.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
9 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
11 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
14 |
|
|
15 |
/** |
|
16 |
* Copy the band 0 from a buffer over the band 2 in the same buffer using the |
|
17 |
* method getBandCopy. |
|
18 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
19 |
*/ |
|
20 |
public class TestInterpolationBicubicIncrease extends TestCase { |
|
21 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
22 |
private String rasterOut = "/tmp/out-interpBicubic.tif"; |
|
23 |
private static int REL = 2; |
|
24 |
|
|
25 |
public void start() { |
|
26 |
this.setUp(); |
|
27 |
this.testStack(); |
|
28 |
} |
|
29 |
|
|
30 |
public void setUp() { |
|
31 |
System.err.println("TestInterpolationBicubic running..."); |
|
32 |
} |
|
33 |
|
|
34 |
public void testStack() { |
|
35 |
long t1 = System.currentTimeMillis(); |
|
36 |
GdalRead input = null; |
|
37 |
GdalWrite out = null; |
|
38 |
try { |
|
39 |
//Read input data |
|
40 |
input = new GdalRead(rasterIn); |
|
41 |
int readSize = 10; |
|
42 |
Object dataIn = input.readBlock(0, 0, readSize, readSize); |
|
43 |
|
|
44 |
//Create Buffer |
|
45 |
Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
46 |
readSize, |
|
47 |
readSize, |
|
48 |
input.getBandCount(), |
|
49 |
true); |
|
50 |
|
|
51 |
//Set data to buffer |
|
52 |
setLines(dataIn, buf1); |
|
53 |
Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_Bicubic); |
|
54 |
|
|
55 |
//Write output file |
|
56 |
out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB); |
|
57 |
out.writeBands(buf.getBands()); |
|
58 |
out.close(); |
|
59 |
|
|
60 |
buf1.free(); |
|
61 |
} catch (GdalException e) { |
|
62 |
e.printStackTrace(); |
|
63 |
} catch (IOException e) { |
|
64 |
e.printStackTrace(); |
|
65 |
} catch (ProcessInterruptedException e) { |
|
66 |
e.printStackTrace(); |
|
67 |
} catch (OperationNotSupportedException e) { |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 |
long t2 = System.currentTimeMillis(); |
|
71 |
System.out.println("Tiempo TestInterpolationBicubic: " + (t2 - t1) + " milisegundos"); |
|
72 |
} |
|
73 |
|
|
74 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
75 |
if(dataIn instanceof byte[][][]) { |
|
76 |
byte[][][] d = (byte[][][])dataIn; |
|
77 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
78 |
for (int row = 0; row < d[iBand].length; row++) { |
|
79 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
} |
|
86 |
|
|
0 | 87 |
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/buffer/impl/TestInterpolationNearestIncrease.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
9 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
11 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
14 |
|
|
15 |
/** |
|
16 |
* Copy the band 0 from a buffer over the band 2 in the same buffer using the |
|
17 |
* method getBandCopy. |
|
18 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
19 |
*/ |
|
20 |
public class TestInterpolationNearestIncrease extends TestCase { |
|
21 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
22 |
private String rasterOut = "/tmp/out-interpNearest.tif"; |
|
23 |
private static int REL = 2; |
|
24 |
|
|
25 |
public void start() { |
|
26 |
this.setUp(); |
|
27 |
this.testStack(); |
|
28 |
} |
|
29 |
|
|
30 |
public void setUp() { |
|
31 |
System.err.println("MemoryBuffer TestCopyBand running..."); |
|
32 |
} |
|
33 |
|
|
34 |
public void testStack() { |
|
35 |
long t1 = System.currentTimeMillis(); |
|
36 |
GdalRead input = null; |
|
37 |
GdalWrite out = null; |
|
38 |
try { |
|
39 |
//Read input data |
|
40 |
input = new GdalRead(rasterIn); |
|
41 |
int readSize = 10; |
|
42 |
Object dataIn = input.readBlock(0, 0, readSize, readSize); |
|
43 |
|
|
44 |
//Create Buffer |
|
45 |
Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
46 |
readSize, |
|
47 |
readSize, |
|
48 |
input.getBandCount(), |
|
49 |
true); |
|
50 |
|
|
51 |
//Set data to buffer |
|
52 |
setLines(dataIn, buf1); |
|
53 |
Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_NearestNeighbour); |
|
54 |
|
|
55 |
//Write output file |
|
56 |
out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB); |
|
57 |
out.writeBands(buf.getBands()); |
|
58 |
out.close(); |
|
59 |
|
|
60 |
buf1.free(); |
|
61 |
} catch (GdalException e) { |
|
62 |
e.printStackTrace(); |
|
63 |
} catch (IOException e) { |
|
64 |
e.printStackTrace(); |
|
65 |
} catch (ProcessInterruptedException e) { |
|
66 |
e.printStackTrace(); |
|
67 |
} catch (OperationNotSupportedException e) { |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 |
long t2 = System.currentTimeMillis(); |
|
71 |
System.out.println("Tiempo MemoryBuffer TestCopyBand: " + (t2 - t1) + " milisegundos"); |
|
72 |
} |
|
73 |
|
|
74 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
75 |
if(dataIn instanceof byte[][][]) { |
|
76 |
byte[][][] d = (byte[][][])dataIn; |
|
77 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
78 |
for (int row = 0; row < d[iBand].length; row++) { |
|
79 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
} |
|
86 |
|
|
0 | 87 |
org.gvsig.raster.cache/tags/buildNumber_28/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/buffer/impl/others/TestCacheVsMemory.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.others; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
import org.gvsig.jgdal.GdalException; |
|
8 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
9 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
11 |
import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer; |
|
15 |
|
|
16 |
/** |
|
17 |
* Performance Test: It loads a complete image of 65MB in a cached buffer and after read the |
|
18 |
* same image in a memory buffer. For this test we use a small size of cache (2MB) and a size of |
|
19 |
* one page of 0.2MB |
|
20 |
* |
|
21 |
* REPEAT = 1 |
|
22 |
* Using setValues |
|
23 |
* Time cached: 1538 ms |
|
24 |
* Time memory: 1163 ms |
|
25 |
* |
|
26 |
* REPEAT = 1 |
|
27 |
* Using setLines |
|
28 |
* Time cached: 198 ms |
|
29 |
* Time memory: 171 ms |
|
30 |
* |
|
31 |
* REPEAT = 10 |
|
32 |
* Using setValues |
|
33 |
* Time cached: 14317 ms |
|
34 |
* Time memory: 11168 ms |
|
35 |
* |
|
36 |
* REPEAT = 10 |
|
37 |
* Using setLines |
|
38 |
* Time cached: 1944 ms |
|
39 |
* Time memory: 1209 ms |
|
40 |
* |
|
41 |
* Intel(R) Core(TM)2 CPU E8400 @ 3.00GHz |
|
42 |
* 2GB RAM DDR3 1066 |
|
43 |
* HDD ATA 133 |
|
44 |
* Linux Ubuntu 10.04 kernel 2.6.24 |
|
45 |
* |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class TestCacheVsMemory extends TestCase { |
|
49 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
50 |
private static int REPEAT = 10; |
|
51 |
|
|
52 |
public void start() { |
|
53 |
this.setUp(); |
|
54 |
this.testStack(); |
|
55 |
} |
|
56 |
|
|
57 |
public void setUp() { |
|
58 |
System.err.println("CacheVsMemory running..."); |
|
59 |
} |
|
60 |
|
|
61 |
public void testStack() { |
|
62 |
|
|
63 |
try { |
|
64 |
GdalRead input = null; |
|
65 |
//Read input data |
|
66 |
input = new GdalRead(rasterIn); |
Also available in: Unified diff