Revision 11504
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/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.54</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.54</connection> |
|
12 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54</developerConnection> |
|
13 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54</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.281</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.54</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.raster.cache.lib.impl</artifactId> |
|
67 |
<version>2.2.54</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.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/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/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/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/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/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/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/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/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/ArrayVsArrayList.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.others; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import org.gvsig.raster.cache.buffer.PxTile; |
|
6 |
import org.gvsig.raster.cache.buffer.impl.PxTileImpl; |
|
7 |
import org.gvsig.raster.cache.buffer.impl.rocache.ByteBand; |
|
8 |
import org.gvsig.raster.cache.buffer.impl.rocache.ReadOnlyCacheBand; |
|
9 |
|
|
10 |
/** |
|
11 |
* This test compare the access time of an element in two cases. The first |
|
12 |
* case is the access to an element in a simple array of objects. The second |
|
13 |
* case is the access to an element in an ArrayList. |
|
14 |
* |
|
15 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class ArrayVsArrayList { |
|
19 |
public static int N = 500000; |
|
20 |
/** |
|
21 |
* @param args |
|
22 |
*/ |
|
23 |
public static void main(String[] args) { |
|
24 |
ArrayVsArrayList p = new ArrayVsArrayList(); |
|
25 |
p.array(); |
|
26 |
p.arrayList(); |
|
27 |
} |
|
28 |
|
|
29 |
private void array() { |
|
30 |
long t1 = System.currentTimeMillis(); |
|
31 |
ArrayList<PxTile> stripeList = new ArrayList<PxTile>(); |
|
32 |
for (int i = 0; i < 1; i++) |
|
33 |
stripeList.add(new PxTileImpl(0, 0, 0, 0)); |
|
34 |
|
|
35 |
ReadOnlyCacheBand[] l = new ReadOnlyCacheBand[N]; |
|
36 |
for (int i = 0; i < N; i++) { |
|
37 |
ByteBand b = new ByteBand(stripeList, null, 15, 15, 15, 2345, 3244); |
|
38 |
l[i] = b; |
|
39 |
} |
|
40 |
int z = 0; |
|
41 |
for (int i = 0; i < N; i++) { |
|
42 |
int y = l[i].getBandNumber(); |
|
43 |
z += y; |
|
44 |
} |
|
45 |
long t2 = System.currentTimeMillis(); |
|
46 |
System.out.println("Time Array with " + N + " elements: " + (t2 - t1) + " milisegundos" + z); |
|
47 |
|
|
48 |
} |
|
49 |
|
|
50 |
private void arrayList() { |
|
51 |
long t1 = System.currentTimeMillis(); |
|
52 |
ArrayList<PxTile> stripeList = new ArrayList<PxTile>(); |
|
53 |
for (int i = 0; i < 1; i++) |
|
54 |
stripeList.add(new PxTileImpl(0, 0, 0, 0)); |
|
55 |
|
|
56 |
ArrayList<ReadOnlyCacheBand> l = new ArrayList<ReadOnlyCacheBand>(); |
|
57 |
for (int i = 0; i < N; i++) { |
|
58 |
ByteBand b = new ByteBand(stripeList, null, 15, 15, 15, 2345, 3244); |
|
59 |
l.add(b); |
|
60 |
} |
|
61 |
int z = 0; |
|
62 |
for (int i = 0; i < N; i++) { |
|
63 |
int y = l.get(i).getBandNumber(); |
|
64 |
z += y; |
|
65 |
} |
|
66 |
long t2 = System.currentTimeMillis(); |
|
67 |
System.out.println("Time ArrayList with " + N + " elements: " + (t2 - t1) + " milisegundos" + z); |
|
68 |
} |
|
69 |
|
|
70 |
} |
|
0 | 71 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/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); |
|
67 |
Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight()); |
|
68 |
|
|
69 |
|
|
70 |
//Reducimos el tama?o de la cache para una prueba con menos datos |
|
71 |
BufferCacheManagerImpl.cacheSize = 25; |
|
72 |
BufferCacheManagerImpl.pageSize = 2; |
|
73 |
|
|
74 |
//****************CACHE********************** |
|
75 |
long t1 = System.currentTimeMillis(); |
|
76 |
for (int iTimes = 0; iTimes < REPEAT; iTimes++) { |
|
77 |
|
|
78 |
//Create Buffer |
|
79 |
Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
80 |
input.getWidth(), |
|
81 |
input.getHeight(), |
|
82 |
input.getBandCount()); |
|
83 |
|
|
84 |
//Set data to buffer |
|
85 |
setValues(dataIn, buf1); |
|
86 |
buf1.free(); |
|
87 |
} |
|
88 |
|
|
89 |
long t2 = System.currentTimeMillis(); |
|
90 |
System.out.println("Tiempo StripeCache : " + (t2 - t1) + " milisegundos"); |
|
91 |
//****************FIN CACHE****************** |
|
92 |
|
|
93 |
//****************MEMO*********************** |
|
94 |
t1 = System.currentTimeMillis(); |
|
95 |
for (int iTimes = 0; iTimes < REPEAT; iTimes++) { |
|
96 |
|
|
97 |
//Create Buffer |
|
98 |
Buffer buf2 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
99 |
input.getWidth(), |
|
100 |
input.getHeight(), |
|
101 |
input.getBandCount(), |
|
102 |
true); |
|
103 |
|
|
104 |
//Set data to buffer |
|
105 |
setValues(dataIn, buf2); |
|
106 |
buf2.free(); |
|
107 |
} |
|
108 |
|
|
109 |
t2 = System.currentTimeMillis(); |
|
110 |
System.out.println("Tiempo Memoria : " + (t2 - t1) + " milisegundos"); |
|
111 |
//****************FIN MEMO****************** |
|
112 |
|
|
113 |
input.close(); |
|
114 |
} catch (GdalException e) { |
|
115 |
e.printStackTrace(); |
|
116 |
} catch (IOException e) { |
|
117 |
e.printStackTrace(); |
|
118 |
} catch (ProcessInterruptedException e) { |
|
119 |
e.printStackTrace(); |
|
120 |
} catch (OperationNotSupportedException e) { |
|
121 |
e.printStackTrace(); |
|
122 |
} |
|
123 |
|
|
124 |
|
|
125 |
} |
|
126 |
|
|
127 |
public void setValues(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
128 |
if(dataIn instanceof byte[][][]) { |
|
129 |
byte[][][] d = (byte[][][])dataIn; |
|
130 |
for (int band = 0; band < d.length; band++) { |
|
131 |
for (int row = 0; row < d[band].length; row++) { |
|
132 |
for (int col = 0; col < d[band][row].length; col++) { |
|
133 |
buf.setElem(row, col, band, (byte)d[band][row][col]); |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
public void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
141 |
if(dataIn instanceof byte[][][]) { |
|
142 |
byte[][][] d = (byte[][][])dataIn; |
|
143 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
144 |
for (int row = 0; row < d[iBand].length; row++) { |
|
145 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
146 |
} |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
} |
|
0 | 152 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestRemoveBand.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.BufferDataSource; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
15 |
|
|
16 |
/** |
|
17 |
* This test read a RGB image and remove one band from the read buffer. Then compare |
|
18 |
* the bands that have not been removed with the source bands. As a result of this test a raster |
|
19 |
* of two bands is created and saved in the hard disk |
|
20 |
* |
|
21 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
22 |
*/ |
|
23 |
public class TestRemoveBand extends TestCase { |
|
24 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
25 |
|
|
26 |
public void start() { |
|
27 |
this.setUp(); |
|
28 |
this.testStack(); |
|
29 |
} |
|
30 |
|
|
31 |
public void setUp() { |
|
32 |
System.err.println("ROCache TestRemoveBand running..."); |
|
33 |
} |
|
34 |
|
|
35 |
public void testStack() { |
|
36 |
long t1 = System.currentTimeMillis(); |
|
37 |
GdalRead input = 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 |
|
|
53 |
BufferDataSource ds = null; |
|
54 |
try { |
|
55 |
ds = new BufferDataSourceImpl(rasterIn); |
|
56 |
} catch (IOException e) { |
|
57 |
e.printStackTrace(); |
|
58 |
} |
|
59 |
Buffer buf2 = new RasterReadOnlyBuffer(ds); |
|
60 |
|
|
61 |
//Remove bands |
|
62 |
buf2.removeBand(1); |
|
63 |
buf1.removeBand(1); |
|
64 |
compareIRasterBuffer(buf1, buf2); |
|
65 |
} catch (GdalException e) { |
|
66 |
e.printStackTrace(); |
|
67 |
} catch (IOException e) { |
|
68 |
e.printStackTrace(); |
|
69 |
} catch (ProcessInterruptedException e) { |
|
70 |
e.printStackTrace(); |
|
71 |
} catch (OperationNotSupportedException e) { |
|
72 |
e.printStackTrace(); |
|
73 |
} |
|
74 |
long t2 = System.currentTimeMillis(); |
|
75 |
System.out.println("Tiempo ROCache TestRemoveBand: " + (t2 - t1) + " milisegundos"); |
|
76 |
} |
|
77 |
|
|
78 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
79 |
if(dataIn instanceof byte[][][]) { |
|
80 |
byte[][][] d = (byte[][][])dataIn; |
|
81 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
82 |
for (int row = 0; row < d[iBand].length; row++) { |
|
83 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
public void compareIRasterBuffer(Buffer b1, Buffer b2) { |
|
90 |
for (int iBand = 0; iBand < b1.getBandCount(); iBand++) { |
|
91 |
|
|
92 |
for (int i = 0; i < b1.getHeight(); i++) { |
|
93 |
for (int j = 0; j < b1.getWidth(); j++) { |
|
94 |
byte b = b1.getElemByte(i, j, iBand); |
|
95 |
byte c = b2.getElemByte(i, j, iBand); |
|
96 |
if(b != c) |
|
97 |
System.out.println("B:" + iBand + "" + i + " " + j); |
|
98 |
assertEquals(c, b); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
} |
|
0 | 106 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapBands.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.Band; |
|
9 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
10 |
import org.gvsig.raster.cache.buffer.BufferDataSource; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
12 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
13 |
import org.gvsig.raster.cache.buffer.exception.WrongParameterException; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
|
15 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
16 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
17 |
|
|
18 |
/** |
|
19 |
* This test swap several bands of a raster compare the result with a memory buffer |
|
20 |
* swaped. |
|
21 |
* <P> |
|
22 |
* The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the |
|
23 |
* band one goes to the position zero and the band two goes to the position one. |
|
24 |
* When the swap operation is executed, this test will check comparing the result |
|
25 |
* bands with the input bands |
|
26 |
* </P> |
|
27 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
28 |
*/ |
|
29 |
public class TestSwapBands extends TestCase { |
|
30 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
31 |
|
|
32 |
public void start() { |
|
33 |
this.setUp(); |
|
34 |
this.testStack(); |
|
35 |
} |
|
36 |
|
|
37 |
public void setUp() { |
|
38 |
System.err.println("ROCache TestSwapBands running..."); |
|
39 |
} |
|
40 |
|
|
41 |
public void testStack() { |
|
42 |
long t1 = System.currentTimeMillis(); |
|
43 |
GdalRead input1 = null; |
|
44 |
try { |
|
45 |
//Read input data |
|
46 |
input1 = new GdalRead(rasterIn); |
|
47 |
Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight()); |
|
48 |
|
|
49 |
//Create Buffer |
|
50 |
Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), |
|
51 |
input1.getWidth(), |
|
52 |
input1.getHeight(), |
|
53 |
input1.getBandCount(), |
|
54 |
true); |
|
55 |
|
|
56 |
//Set data to buffer |
|
57 |
setLines(dataIn1, buf2); |
|
58 |
|
|
59 |
BufferDataSource ds = null; |
|
60 |
try { |
|
61 |
ds = new BufferDataSourceImpl(rasterIn); |
|
62 |
} catch (IOException e) { |
|
63 |
e.printStackTrace(); |
|
64 |
} |
|
65 |
RasterReadOnlyBuffer buf1 = new RasterReadOnlyBuffer(ds); |
|
66 |
try { |
|
67 |
buf2.swapBands(new int[]{2, 0, 1}); |
|
68 |
buf1.swapBands(new int[]{2, 0, 1}); |
|
69 |
} catch (WrongParameterException e) { |
|
70 |
e.printStackTrace(); |
|
71 |
} |
|
72 |
|
|
73 |
//Write output file |
|
74 |
|
|
75 |
Band band1 = buf1.getBand(0); |
|
76 |
Band band2 = buf2.getBand(0); |
|
77 |
compareBands(band1, band2); |
|
78 |
|
|
79 |
band1 = buf1.getBand(1); |
|
80 |
band2 = buf2.getBand(1); |
|
81 |
compareBands(band1, band2); |
|
82 |
|
|
83 |
band1 = buf1.getBand(2); |
|
84 |
band2 = buf2.getBand(2); |
|
85 |
compareBands(band1, band2); |
|
86 |
|
|
87 |
buf1.free(); |
|
88 |
buf2.free(); |
|
89 |
} catch (GdalException e) { |
|
90 |
e.printStackTrace(); |
|
91 |
} catch (IOException e) { |
|
92 |
e.printStackTrace(); |
|
93 |
} catch (ProcessInterruptedException e) { |
|
94 |
e.printStackTrace(); |
|
95 |
} catch (OperationNotSupportedException e) { |
|
96 |
e.printStackTrace(); |
|
97 |
} |
|
98 |
long t2 = System.currentTimeMillis(); |
|
99 |
System.out.println("Tiempo ROCache TestSwapBands: " + (t2 - t1) + " milisegundos"); |
|
100 |
} |
|
101 |
|
|
102 |
public void compareBands(Band band1, Band band2) { |
|
103 |
for (int i = 0; i < band1.getHeight(); i++) { |
|
104 |
for (int j = 0; j < band1.getWidth(); j++) { |
|
105 |
byte b1 = band1.getElemByte(i, j); |
|
106 |
byte b2 = band2.getElemByte(i, j); |
|
107 |
if(b1 != b2) |
|
108 |
System.out.println(i + " " + j); |
|
109 |
assertEquals(b1, b2); |
|
110 |
} |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
115 |
if(dataIn instanceof byte[][][]) { |
|
116 |
byte[][][] d = (byte[][][])dataIn; |
|
117 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
118 |
for (int row = 0; row < d[iBand].length; row++) { |
|
119 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
} |
|
0 | 126 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadWindowAndCompareData.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.BufferParam; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.BufferParamImpl; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
15 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
16 |
|
|
17 |
/** |
|
18 |
* Read a number from cache |
|
19 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
20 |
*/ |
|
21 |
public class TestReadWindowAndCompareData extends TestCase { |
|
22 |
private String in = "./src/test/resources/image/001m09_1_0.tif"; |
|
23 |
private int initX = 200; |
|
24 |
private int initY = 200; |
|
25 |
private int w = 400; |
|
26 |
private int h = 400; |
|
27 |
|
|
28 |
public void start() { |
|
29 |
this.setUp(); |
|
30 |
this.testStack(); |
|
31 |
} |
|
32 |
|
|
33 |
public void setUp() { |
|
34 |
System.err.println("ROCache TestReadTiffAndCompareData running..."); |
|
35 |
} |
|
36 |
|
|
37 |
public void testStack() { |
|
38 |
long t1 = System.currentTimeMillis(); |
|
39 |
GdalRead input = null; |
|
40 |
|
|
41 |
BufferCacheManagerImpl.cacheSize = 1; |
|
42 |
BufferCacheManagerImpl.pageSize = 0.2; |
|
43 |
|
|
44 |
Buffer buf1 = null; |
|
45 |
try { |
|
46 |
input = new GdalRead(in); |
|
47 |
|
|
48 |
Object dataIn = input.readBlock(initX, initY, w, h); |
|
49 |
|
|
50 |
//Create Buffer |
|
51 |
buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
52 |
w, |
|
53 |
h, |
|
54 |
input.getBandCount(), |
|
55 |
true); |
|
56 |
|
|
57 |
//Set data to buffer |
|
58 |
setLines(dataIn, buf1); |
|
59 |
} catch (GdalException e1) { |
|
60 |
e1.printStackTrace(); |
|
61 |
} catch (IOException e1) { |
|
62 |
e1.printStackTrace(); |
|
63 |
} catch (ProcessInterruptedException e1) { |
|
64 |
e1.printStackTrace(); |
|
65 |
} catch (OperationNotSupportedException e1) { |
|
66 |
e1.printStackTrace(); |
|
67 |
} |
|
68 |
|
|
69 |
RasterReadOnlyBuffer buf = null; |
|
70 |
try { |
|
71 |
BufferParam p = new BufferParamImpl(in, initX, initY, w, h, new int[]{0, 1, 2}); |
|
72 |
buf = new RasterReadOnlyBuffer(p); |
|
73 |
} catch (IOException e) { |
|
74 |
e.printStackTrace(); |
|
75 |
} |
|
76 |
|
|
77 |
|
|
78 |
for (int iBand = 0; iBand < buf.getBandCount(); iBand++) { |
|
79 |
for (int row = 0; row < buf.getHeight(); row++) { |
|
80 |
for (int col = 0; col < buf.getWidth(); col++) { |
|
81 |
byte n = buf.getElemByte(row, col, iBand); |
|
82 |
byte m = buf1.getElemByte(row, col, iBand); |
|
83 |
if(n != m) |
|
84 |
System.out.println(row + " " + col); |
|
85 |
assertEquals(n, m); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
try { |
|
91 |
buf.free(); |
|
92 |
} catch (IOException e) { |
|
93 |
// TODO Auto-generated catch block |
|
94 |
e.printStackTrace(); |
|
95 |
} |
|
96 |
|
|
97 |
long t2 = System.currentTimeMillis(); |
|
98 |
System.out.println("Tiempo ROCache TestRWOneValue: " + (t2 - t1) + " milisegundos"); |
|
99 |
} |
|
100 |
|
|
101 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
102 |
if(dataIn instanceof byte[][][]) { |
|
103 |
byte[][][] d = (byte[][][])dataIn; |
|
104 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
105 |
for (int row = 0; row < d[iBand].length; row++) { |
|
106 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
0 | 113 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestWindow.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.Band; |
|
9 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
10 |
import org.gvsig.raster.cache.buffer.BufferDataSource; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
12 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.PxTileImpl; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
|
15 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
16 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
17 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
18 |
|
|
19 |
/** |
|
20 |
* |
|
21 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
22 |
*/ |
|
23 |
public class TestWindow extends TestCase { |
|
24 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
25 |
private String rasterOut = "/tmp/window.tif"; |
|
26 |
private String compare = "./src/test/resources/image/clip_test_robufer.tif"; |
|
27 |
|
|
28 |
public void start() { |
|
29 |
this.setUp(); |
|
30 |
this.testStack(); |
|
31 |
} |
|
32 |
|
|
33 |
public void setUp() { |
|
34 |
System.err.println("ROCache TestWindow running..."); |
|
35 |
} |
|
36 |
|
|
37 |
public void testStack() { |
|
38 |
long t1 = System.currentTimeMillis(); |
|
39 |
GdalWrite output = null; |
|
40 |
try { |
|
41 |
|
|
42 |
BufferDataSource ds = null; |
|
43 |
try { |
|
44 |
ds = new BufferDataSourceImpl(rasterIn, new PxTileImpl(100, 100, 500, 400)); |
|
45 |
} catch (IOException e) { |
|
46 |
e.printStackTrace(); |
|
47 |
} |
|
48 |
Buffer buf = new RasterReadOnlyBuffer(ds); |
|
49 |
|
|
50 |
GdalRead input1 = new GdalRead(compare); |
|
51 |
output = new GdalWrite(rasterOut, 3, input1.getGdalTypeFromRasterBufType(ds.getDataType()), ds.getWidth(), ds.getHeight(), GdalWrite.COLOR_INTERP_RGB); |
|
52 |
output.writeBands(buf.getBands()); |
|
53 |
output.close(); |
|
54 |
|
|
55 |
//Read input data |
|
56 |
|
|
57 |
Object dataIn = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight()); |
|
58 |
|
|
59 |
//Create Buffer |
|
60 |
Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), |
|
61 |
input1.getWidth(), |
|
62 |
input1.getHeight(), |
|
63 |
input1.getBandCount(), |
|
64 |
true); |
|
65 |
|
|
66 |
//Set data to buffer |
|
67 |
setLines(dataIn, buf1); |
|
68 |
for (int i = 0; i < buf.getBandCount(); i++) |
|
69 |
compareBands(buf.getBand(i), buf.getBand(i)); |
|
70 |
|
|
71 |
buf.free(); |
|
72 |
buf1.free(); |
|
73 |
} catch (GdalException e) { |
|
74 |
e.printStackTrace(); |
|
75 |
} catch (IOException e) { |
|
76 |
e.printStackTrace(); |
|
77 |
} catch (ProcessInterruptedException e) { |
|
78 |
e.printStackTrace(); |
|
79 |
} catch (OperationNotSupportedException e) { |
|
80 |
e.printStackTrace(); |
|
81 |
} |
|
82 |
long t2 = System.currentTimeMillis(); |
|
83 |
System.out.println("Tiempo ROCache TestWindow: " + (t2 - t1) + " milisegundos"); |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
public void compareBands(Band band1, Band band2) { |
|
88 |
for (int i = 0; i < band1.getHeight(); i++) { |
|
89 |
for (int j = 0; j < band1.getWidth(); j++) { |
|
90 |
byte b1 = band1.getElemByte(i, j); |
|
91 |
byte b2 = band2.getElemByte(i, j); |
|
92 |
assertEquals(b1, b2); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
98 |
if(dataIn instanceof byte[][][]) { |
|
99 |
byte[][][] d = (byte[][][])dataIn; |
|
100 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
101 |
for (int row = 0; row < d[iBand].length; row++) { |
|
102 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
0 | 108 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadTiffAndCompareData.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.BufferDataSource; |
|
10 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
15 |
import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer; |
|
16 |
|
|
17 |
/** |
|
18 |
* Read a number from cache |
|
19 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
20 |
*/ |
|
21 |
public class TestReadTiffAndCompareData extends TestCase { |
|
22 |
private String in = "./src/test/resources/image/001m09_1_0.tif"; |
|
23 |
|
|
24 |
public void start() { |
|
25 |
this.setUp(); |
|
26 |
this.testStack(); |
|
27 |
} |
|
28 |
|
|
29 |
public void setUp() { |
|
30 |
System.err.println("ROCache TestReadTiffAndCompareData running..."); |
|
31 |
} |
|
32 |
|
|
33 |
public void testStack() { |
|
34 |
long t1 = System.currentTimeMillis(); |
|
35 |
GdalRead input = null; |
|
36 |
|
|
37 |
BufferCacheManagerImpl.cacheSize = 1; |
|
38 |
BufferCacheManagerImpl.pageSize = 0.2; |
|
39 |
|
|
40 |
Buffer buf1 = null; |
|
41 |
try { |
|
42 |
input = new GdalRead(in); |
|
43 |
|
|
44 |
Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight()); |
|
45 |
|
|
46 |
//Create Buffer |
|
47 |
buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), |
|
48 |
input.getWidth(), |
|
49 |
input.getHeight(), |
|
50 |
input.getBandCount(), |
|
51 |
true); |
|
52 |
|
|
53 |
//Set data to buffer |
|
54 |
setLines(dataIn, buf1); |
|
55 |
} catch (GdalException e1) { |
|
56 |
e1.printStackTrace(); |
|
57 |
} catch (IOException e1) { |
|
58 |
e1.printStackTrace(); |
|
59 |
} catch (ProcessInterruptedException e1) { |
|
60 |
e1.printStackTrace(); |
|
61 |
} catch (OperationNotSupportedException e1) { |
|
62 |
e1.printStackTrace(); |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
BufferDataSource ds = null; |
|
67 |
try { |
|
68 |
ds = new BufferDataSourceImpl(in); |
|
69 |
} catch (IOException e) { |
|
70 |
e.printStackTrace(); |
|
71 |
} |
|
72 |
RasterReadOnlyBuffer buf = new RasterReadOnlyBuffer(ds); |
|
73 |
|
|
74 |
for (int iBand = 0; iBand < buf.getBandCount(); iBand++) { |
|
75 |
for (int row = 0; row < buf.getHeight(); row++) { |
|
76 |
for (int col = 0; col < buf.getWidth(); col++) { |
|
77 |
byte n = buf.getElemByte(row, col, iBand); |
|
78 |
byte m = buf1.getElemByte(row, col, iBand); |
|
79 |
if(n != m) |
|
80 |
System.out.println(row + " " + col); |
|
81 |
assertEquals(n, m); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
try { |
|
87 |
buf.free(); |
|
88 |
} catch (IOException e) { |
|
89 |
// TODO Auto-generated catch block |
|
90 |
e.printStackTrace(); |
|
91 |
} |
|
92 |
|
|
93 |
long t2 = System.currentTimeMillis(); |
|
94 |
System.out.println("Tiempo ROCache TestRWOneValue: " + (t2 - t1) + " milisegundos"); |
|
95 |
} |
|
96 |
|
|
97 |
private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException { |
|
98 |
if(dataIn instanceof byte[][][]) { |
|
99 |
byte[][][] d = (byte[][][])dataIn; |
|
100 |
for (int iBand = 0; iBand < d.length; iBand++) { |
|
101 |
for (int row = 0; row < d[iBand].length; row++) { |
|
102 |
buf.setLineInBandByte(d[iBand][row], row, iBand); |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
} |
|
0 | 109 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAssignBand.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.Band; |
|
9 |
import org.gvsig.raster.cache.buffer.Buffer; |
|
10 |
import org.gvsig.raster.cache.buffer.BufferDataSource; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
15 |
|
|
16 |
/** |
|
17 |
* Assign by reference a band in a Buffer |
|
18 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
19 |
*/ |
|
20 |
public class TestAssignBand extends TestCase { |
|
21 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
22 |
private String rasterOut = "/tmp/out-4bands.tif"; |
|
23 |
|
|
24 |
public void start() { |
|
25 |
this.setUp(); |
|
26 |
this.testStack(); |
|
27 |
} |
|
28 |
|
|
29 |
public void setUp() { |
|
30 |
System.err.println("ROCache TestAssignBand running..."); |
|
31 |
} |
|
32 |
|
|
33 |
public void testStack() { |
|
34 |
long t1 = System.currentTimeMillis(); |
|
35 |
GdalRead input1 = null; |
|
36 |
|
|
37 |
GdalWrite out = null; |
|
38 |
try { |
|
39 |
|
|
40 |
//Read input data |
|
41 |
input1 = new GdalRead(rasterIn); |
|
42 |
|
|
43 |
BufferDataSource ds = null; |
|
44 |
try { |
|
45 |
ds = new BufferDataSourceImpl(rasterIn); |
|
46 |
} catch (IOException e) { |
|
47 |
e.printStackTrace(); |
|
48 |
} |
|
49 |
Buffer buf1 = new RasterReadOnlyBuffer(ds); |
|
50 |
|
|
51 |
BufferDataSource ds1 = null; |
|
52 |
try { |
|
53 |
ds1 = new BufferDataSourceImpl(rasterIn); |
|
54 |
} catch (IOException e) { |
|
55 |
e.printStackTrace(); |
|
56 |
} |
|
57 |
Buffer buf2 = new RasterReadOnlyBuffer(ds1); |
|
58 |
|
|
59 |
Band rb = buf2.getBand(2); |
|
60 |
try { |
|
61 |
buf1.assignBand(1, rb); |
|
62 |
} catch (BandNotCompatibleException e) { |
|
63 |
e.printStackTrace(); |
|
64 |
} |
|
65 |
|
|
66 |
//Write output file |
|
67 |
out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY); |
|
68 |
out.writeBands(buf1.getBands()); |
|
69 |
out.close(); |
|
70 |
|
|
71 |
Band band1 = buf1.getBand(1); |
|
72 |
Band band2 = buf1.getBand(3); |
|
73 |
for (int i = 0; i < band1.getHeight(); i++) { |
|
74 |
for (int j = 0; j < band1.getWidth(); j++) { |
|
75 |
byte b1 = band1.getElemByte(i, j); |
|
76 |
byte b2 = band2.getElemByte(i, j); |
|
77 |
assertEquals(b1, b2); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
buf1.free(); |
|
82 |
buf2.free(); |
|
83 |
} catch (GdalException e) { |
|
84 |
e.printStackTrace(); |
|
85 |
} catch (IOException e) { |
|
86 |
e.printStackTrace(); |
|
87 |
} |
|
88 |
long t2 = System.currentTimeMillis(); |
|
89 |
System.out.println("Tiempo ROCache TestAssignBand: " + (t2 - t1) + " milisegundos"); |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.54/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestMultifile.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
|
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.BufferDataSource; |
|
10 |
import org.gvsig.raster.cache.buffer.BufferParam; |
|
11 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
12 |
import org.gvsig.raster.cache.buffer.impl.BufferParamImpl; |
|
13 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
|
14 |
import org.gvsig.raster.cache.buffer.impl.io.GdalRead; |
|
15 |
import org.gvsig.raster.cache.buffer.impl.io.GdalWrite; |
|
16 |
|
|
17 |
/** |
|
18 |
* This test gets bands from a raster with the method getBufferWithOneBand() and compare |
|
19 |
* each band from original source with obtained bands |
|
20 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
21 |
*/ |
|
22 |
public class TestMultifile extends TestCase { |
|
23 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
|
24 |
private String rasterOut1 = "/tmp/out-b1.tif"; |
|
25 |
private String rasterOut2 = "/tmp/out-b2.tif"; |
|
26 |
private String rasterOut3 = "/tmp/out-b3.tif"; |
|
27 |
private int x = 200; |
|
28 |
private int y = 200; |
|
29 |
private int w = 800; |
|
30 |
private int h = 800; |
|
31 |
|
|
32 |
public void start() { |
|
33 |
this.setUp(); |
|
34 |
this.testStack(); |
|
35 |
} |
Also available in: Unified diff