Revision 839

View differences:

org.gvsig.jgdal/trunk/org.gvsig.jgdal/CMakeLists.txt
30 30

  
31 31
SET(JGDAL_VERSION_MAJOR "2")
32 32
SET(JGDAL_VERSION_MINOR "0")
33
SET(JGDAL_VERSION_PATCH "3")
33
SET(JGDAL_VERSION_PATCH "4")
34 34

  
35 35
SET(VERSION "${JGDAL_VERSION_MAJOR}.${JGDAL_VERSION_MINOR}.${JGDAL_VERSION_PATCH}")
36 36

  
org.gvsig.jgdal/trunk/org.gvsig.jgdal/depman.xml
2 2
	<package>
3 3
		<group>org.gvsig</group>
4 4
		<artifact>org.gvsig.jgdal</artifact>
5
		<version>2.0.3-SNAPSHOT</version>
5
		<version>2.0.4-SNAPSHOT</version>
6 6
		<libraryType>dynamic</libraryType>
7 7
	</package>
8 8
 	<dependencies platform="win,mac">
9 9
    	<dependency>
10 10
	    	<group>org.gdal</group>
11 11
		   	<artifact>gdal</artifact>
12
	    	<version>1.7.1</version>
12
	    	<version>1.8.1</version>
13 13
    		<type>dynamic</type>
14 14
   		</dependency>
15 15
	</dependencies>
......
17 17
    	<dependency>
18 18
	    	<group>org.gdal</group>
19 19
		   	<artifact>gdal</artifact>
20
	    	<version>1.6.3</version>
20
	    	<version>1.8.1</version>
21 21
    		<type>dynamic</type>
22 22
   		</dependency>
23 23
	</dependencies>
org.gvsig.jgdal/trunk/org.gvsig.jgdal/src/test/java/TestReadBand.java
1

  
2
import java.io.IOException;
3
import org.gvsig.jgdal.*;
4

  
5
/**
6
 * Test de acceso a datos de las bandas de una imagen.
7
 * javac -classpath ./:/.../org.gvsig.jgdal/target/org.gvsig.jgdal-2.0.3-SNAPSHOT.jar TestReadBand.java
8
 * 
9
 * java -classpath ./:/.../org.gvsig.jgdal/target/org.gvsig.jgdal-2.0.3-SNAPSHOT.jar -Djava.library.path=/... TestReadBand
10
 * @author Nacho Brodin <nachobrodin@gmail.com>
11
 *
12
 */
13
public class TestReadBand {
14
	private Gdal gdal = null;
15
	private GdalRasterBand band = null;
16
	private String baseDir = "../../../test-images/";
17
	private String file1 = baseDir + "testGdal.tif";
18
	
19

  
20
	public static void main(String[] args) {
21
		TestReadBand t = new TestReadBand();
22
		try {
23
		t.testStack();	
24
		} catch(Exception e) {
25
		}
26
	}
27
	public void testStack() throws GdalException, IOException {
28

  
29
		gdal = new Gdal();
30
		gdal.open(file1, Gdal.GA_Update);
31
		//Llamada sin dominio
32
		String[] metadata = gdal.getMetadata();
33

  
34
		for (int i = 0 ; i < metadata.length; i++) { 
35
			System.out.println("Metadato: " + metadata[i]);
36
		}
37
		
38
		//Llamada con dominio "Image Structure Metadata"
39
		metadata = gdal.getMetadata("Image Structure Metadata");
40
		for (int i = 0 ; i < metadata.length; i++) {
41
			System.out.println("Metadato: " + metadata[i]);
42
		}
43
		
44
		//Comprobaci?n del tama?o de la imagen
45
		System.out.println(gdal.getRasterXSize());
46
		System.out.println(gdal.getRasterYSize());
47
		
48
		//Comprobaci?n del n?mero de bandas
49
		System.out.println("Bands: " + gdal.getRasterCount());
50
		
51
		//Comprobaci?n del driver de la imagen
52
		System.out.println("Driver: " + gdal.getDriverShortName());
53
		
54
		//Comprobaci?n del acceso a las bandas
55
		for (int i = 0 ; i < gdal.getRasterCount() ; i++) {
56
			GdalRasterBand b = gdal.getRasterBand(i+1);
57
			System.out.println("Band:" + i + "  X:" + b.getRasterBandXSize());
58
			System.out.println("Band:" + i + "  Y:" + b.getRasterBandYSize());
59
			System.out.println("Overviews Band:" + i + " " + b.getOverviewCount());
60
			for (int j = 0 ; j < b.getOverviewCount() ; j++) {
61
				GdalRasterBand ov = b.getOverview(j);
62
				System.out.println("    " + ov.getRasterBandXSize() + " x " + ov.getRasterBandYSize());
63
			}
64
		}
65
	}
66
}
0 67

  
org.gvsig.jgdal/trunk/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/JNIBase.java
84 84
		if (os.toLowerCase().startsWith("windows"))
85 85
			System.loadLibrary("jgdal201");
86 86
		else*/
87
			System.loadLibrary("jgdal2.0.3");
87
			System.loadLibrary("jgdal2.0.4");
88 88
	}
89 89
}
org.gvsig.jgdal/trunk/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GdalRasterBand.java
64 64

  
65 65

  
66 66
	 /**
67
	  * Lee datos de la banda de la imgen
67
	  * Lee datos de la banda de la imagen
68 68
	  * 
69 69
	  * @return	Devuelve un vector de bytes con el trozo de raster le�do.
70 70
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
......
87 87
		 if (cPtr == 0)
88 88
			 throw new GdalException("No se ha podido acceder al archivo.");
89 89

  
90
		 if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", "")))
90
		 if ((nXOff<0) || (nXOff > getRasterBandXSize()) || (nYOff < 0) || (nYOff > getRasterBandYSize()))
91 91
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
92 92

  
93
		 if ((nXSize < 1) || (nXSize > baseSimpleFunctions(5, "", "")) || (nYSize<1) || (nYSize > baseSimpleFunctions(6, "", "")))
93
		 if ((nXSize < 1) || (nXSize > getRasterBandXSize()) || (nYSize<1) || (nYSize > getRasterBandYSize()))
94 94
			 throw new GdalException("Tama?o de ventana incorrecto.");
95 95

  
96
		 if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", ""))))
96
		 if (((nXSize + nXOff) > (getRasterBandXSize())) || ((nYSize + nYOff) > (getRasterBandYSize())))
97 97
			 throw new GdalException("Posicion de la ventana incorrecta.");
98 98
		 
99 99
		 if ((eBufType < 1) || (eBufType > 11))
......
113 113
	 }
114 114

  
115 115
	 /**
116
	  * Escribe datos en la banda de la imgen
116
	  * Escribe datos en la banda de la imagen
117 117
	  * 
118 118
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
119 119
	  * de la banda accedida.  
......
126 126
	  * @param eBufType
127 127
	  */
128 128

  
129
	 public void writeRaster(int nXOff, int nYOff, int nXSize, int nYSize, GdalBuffer buf, int eBufType)throws GdalException{
130
		 GdalBuffer buffer=new GdalBuffer();
129
	 public void writeRaster(int nXOff, int nYOff, int nXSize, int nYSize, GdalBuffer buf, int eBufType)throws GdalException {
130
		 GdalBuffer buffer = new GdalBuffer();
131 131
		 
132
		 if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", "")))
132
		 if ((nXOff < 0) || (nXOff > getRasterBandXSize()) || (nYOff < 0) || (nYOff > getRasterBandYSize()))
133 133
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
134 134

  
135
		 if ((nXSize < 1) || (nXSize > baseSimpleFunctions(5, "", "")) || (nYSize<1) || (nYSize > baseSimpleFunctions(6, "", "")))
135
		 if ((nXSize < 1) || (nXSize > getRasterBandXSize()) || (nYSize < 1) || (nYSize > getRasterBandYSize()))
136 136
			 throw new GdalException("Tama?o de ventana incorrecto.");
137 137

  
138
		 if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", ""))))
138
		 if (((nXSize + nXOff) > (getRasterBandXSize())) || ((nYSize + nYOff) > (getRasterBandYSize())))
139 139
			 throw new GdalException("Posicion de la ventana incorrecta.");
140 140
		 
141 141
		 if ((eBufType < 1) || (eBufType > 11))
......
144 144
		 if (buf == null)
145 145
			 throw new GdalException("Buffer incorrecto");
146 146
		 
147
		 switch(eBufType){
147
		 switch(eBufType) {
148 148
		 case 0:
149 149
			 return;
150 150
		 case 1:
151
			 buffer.buffByte=buf.buffByte;
151
			 buffer.buffByte = buf.buffByte;
152 152
			 break;
153 153
		 case 2:
154 154
		 case 3:
155 155
		 case 8:
156
			 buffer.buffShort=buf.buffShort;
156
			 buffer.buffShort = buf.buffShort;
157 157
			 break;
158 158
		 case 4:
159 159
		 case 5:
160 160
		 case 9:
161
			 buffer.buffInt=buf.buffInt;
161
			 buffer.buffInt = buf.buffInt;
162 162
			 break;
163 163
		 case 6:
164 164
		 case 10:
165
			 buffer.buffFloat=buf.buffFloat;
165
			 buffer.buffFloat = buf.buffFloat;
166 166
			 break;
167 167
		 case 7:
168 168
		 case 11:
169
			 buffer.buffDouble=buf.buffDouble;
169
			 buffer.buffDouble = buf.buffDouble;
170 170
			 break; 		
171 171
		 case 12:
172 172
			 return;
......
183 183

  
184 184
	 public int getRasterBandXSize()throws GdalException {
185 185
		 String msg1="Error en getRasterBandXSize(). La llamada getRasterBand no tuvo exito";
186
		 String msg2="Tamao de banda erroneo devuelto por GetRasterBandXSize";
186
		 String msg2="Tama?o de banda erroneo devuelto por GetRasterBandXSize";
187 187

  
188 188
		 return baseSimpleFunctions(0,msg1,msg2);
189 189
	 }
190 190

  
191 191
	 /**
192
	  *Obtiene el tama�o en pixeles de la im�gen en el eje de las Y
192
	  *Obtiene el tama?o en pixeles de la im?gen en el eje de las Y
193 193
	  *@return Tama�o en pixeles del eje Y
194 194
	  *@throws GdalException 
195 195
	  */
196 196

  
197 197
	 public int getRasterBandYSize()throws GdalException {
198 198
		 String msg1="Error en getRasterBandYSize(). La llamada getRasterBand no tuvo exito";
199
		 String msg2="Tamao de banda erroneo devuelto por GetRasterBandYSize";
199
		 String msg2="Tama?o de banda erroneo devuelto por GetRasterBandYSize";
200 200

  
201 201
		 return baseSimpleFunctions(1,msg1,msg2);
202 202
	 }
......
247 247

  
248 248
	 public int getBlockXSize()throws GdalException {
249 249
		 String msg1="Error en getBlockXSize(). La llamada getRasterBand no tuvo exito";
250
		 String msg2="Tamao de bloque erroneo devuelto por GetBlockXSize";
250
		 String msg2="Tama?o de bloque erroneo devuelto por GetBlockXSize";
251 251

  
252 252
		 return baseSimpleFunctions(3,msg1,msg2);
253 253
	 }
......
322 322
		 if (cPtr == 0)
323 323
			 throw new GdalException("No se ha podido acceder al archivo.");
324 324
		 
325
		 if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", "")))
325
		 if ((nXOff<0) || (nXOff > getRasterBandXSize()) || (nYOff < 0) || (nYOff > getRasterBandYSize()))
326 326
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
327 327

  
328
		 if ((nXSize < 1) || (nXSize > baseSimpleFunctions(5, "", "")) || (nYSize<1) || (nYSize > baseSimpleFunctions(6, "", "")))
328
		 if ((nXSize < 1) || (nXSize > getRasterBandXSize()) || (nYSize < 1) || (nYSize > getRasterBandYSize()))
329 329
			 throw new GdalException("Tama?o de ventana incorrecto.");
330 330

  
331
		 if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", ""))))
331
		 if (((nXSize + nXOff) > (getRasterBandXSize())) || ((nYSize + nYOff) > (getRasterBandYSize())))
332 332
			 throw new GdalException("Posicion de la ventana incorrecta.");
333 333
		 
334 334
		 if ((eBufType < 1) || (eBufType > 11))
......
444 444
		 
445 445
	 }
446 446

  
447
}
447
}
org.gvsig.jgdal/trunk/org.gvsig.jgdal/pom.xml
4 4
	<groupId>org.gvsig</groupId>
5 5
	<artifactId>org.gvsig.jgdal</artifactId>
6 6
	<packaging>jar</packaging>
7
	<version>2.0.3-SNAPSHOT</version>
7
	<version>2.0.4-SNAPSHOT</version>
8 8
	<name>org.gvsig.jgdal</name>
9 9
	<parent>
10 10
		<groupId>org.gvsig</groupId>
......
44 44
				<dependency>
45 45
					<groupId>org.gdal</groupId>
46 46
					<artifactId>gdal</artifactId>
47
					<version>1.7.1</version>
47
					<version>1.8.1</version>
48 48
					<classifier>${native-classifier}</classifier>
49 49
					<type>tar.gz</type>
50 50
				</dependency>
......
69 69
				<dependency>
70 70
					<groupId>org.gdal</groupId>
71 71
					<artifactId>gdal</artifactId>
72
					<version>1.6.3</version>
72
					<version>1.8.1</version>
73 73
					<classifier>${native-classifier}</classifier>
74 74
					<type>tar.gz</type>
75 75
				</dependency>

Also available in: Unified diff