Revision 819

View differences:

org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/CMakeLists.txt
1
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
2

  
3
IF(WIN32)
4
    CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
5
ELSE(WIN32)
6
    IF(APPLE)
7
        CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
8
    ELSE(APPLE)
9
        CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
10
    ENDIF(APPLE)
11
ENDIF(WIN32)
12

  
13
if(COMMAND cmake_policy)
14
    # Works around warnings libraries linked against that don't
15
    # have absolute paths (e.g. -lpthreads)
16
    cmake_policy(SET CMP0003 NEW)
17

  
18
    # Works around warnings about escaped quotes in ADD_DEFINITIONS
19
    # statements.
20
    cmake_policy(SET CMP0005 NEW)
21

  
22
    # cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names
23
    # quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below."
24
    if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0)
25
        cmake_policy(SET CMP0008 OLD)
26
    endif()
27
endif()
28

  
29
PROJECT(org.gvsig.jgdal)
30

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

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

  
37
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../build/CMakeModules;${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
38

  
39
FIND_PACKAGE(DepMan REQUIRED) 
40
INCLUDE(GeneralMacros) 
41

  
42
CONFIGURE_DEFAULTS()
43

  
44
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
45
  SET(CMAKE_INSTALL_PREFIX
46
    ${DEPMAN_PATH} CACHE PATH "depman path install prefix" FORCE
47
    )
48
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
49

  
50
FIND_PACKAGE(JNI REQUIRED) 
51
FIND_PACKAGE(GDAL REQUIRED) 
52

  
53
ADD_SUBDIRECTORY(src/main/native)
54

  
55
CONFIGURE_END()
56

  
57

  
0 58

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/depman.xml
1
<depman>
2
	<package>
3
		<group>org.gvsig</group>
4
		<artifact>org.gvsig.jgdal</artifact>
5
		<version>2.0.3-SNAPSHOT</version>
6
		<libraryType>dynamic</libraryType>
7
	</package>
8
 	<dependencies platform="win,mac">
9
    	<dependency>
10
	    	<group>org.gdal</group>
11
		   	<artifact>gdal</artifact>
12
	    	<version>1.7.1</version>
13
    		<type>dynamic</type>
14
   		</dependency>
15
	</dependencies>
16
	<dependencies platform="lin">
17
    	<dependency>
18
	    	<group>org.gdal</group>
19
		   	<artifact>gdal</artifact>
20
	    	<version>1.6.3</version>
21
    		<type>dynamic</type>
22
   		</dependency>
23
	</dependencies>
24
</depman>
25

  
0 26

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.jgdal</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
	</buildSpec>
9
	<natures>
10
	</natures>
11
</projectDescription>
0 12

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/addo/WritingException.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.addo;
23

  
24
/**
25
 * Es generada no se puede escribir las overviews
26
 * 
27
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
28
 * @version 0.0
29
 * @link http://www.gvsig.org
30
 */
31

  
32

  
33
public class WritingException extends Exception {
34

  
35
	public WritingException(String msg){
36
		super(msg);
37
	}
38
	
39
	
40
}
0 41

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/addo/IOverviewIncrement.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.addo;
23

  
24
/**
25
 * Interfaz para la asignacion y recuperacion del incremento
26
 * de la tarea.
27
 *
28
 * 17-nov-2007
29
 * @author Nacho Brodin (nachobrodin@gmail.com)
30
 */
31
public interface IOverviewIncrement {
32
	/**
33
	 * Devuelve el porcentaje del incremento
34
	 * @return int
35
	 */
36
	public int getPercent();
37
	
38
	/**
39
	 * Asigna el porcentaje de incremento de la construccion de overview.
40
	 * Esto se hace automaticamente desde el callback que asigna el porcentaje. 
41
	 */
42
	public void setPercent(int value);
43
}
0 44

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/addo/BuildingOverviewsException.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.addo;
23

  
24
/**
25
 * Es generada cuando hay algun problema en la construccion de 
26
 * las overviews y la funcion nativa devuelve 0
27
 * 
28
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
29
 * @version 0.0
30
 * @link http://www.gvsig.org
31
 */
32
public class BuildingOverviewsException extends Exception {
33

  
34
	public BuildingOverviewsException(String msg) {
35
		super(msg);
36
	}
37
	
38
}
0 39

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/addo/Jaddo.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.addo;
23
import java.io.File;
24

  
25
import org.gvsig.jgdal.JNIBase;
26

  
27
/**
28
 * Clase para la construccion de overviews de un raster.
29
 *
30
 * 15-nov-2007
31
 * @author Nacho Brodin (nachobrodin@gmail.com)
32
 */
33
public class Jaddo extends JNIBase implements IOverviewIncrement{
34
	public final static int NEAREST = 0;
35
	public final static int AVERAGE = 1;
36
	public final static int AVERAGE_MP = 2;
37
	public final static int AVERAGE_MAGPHASE = 3;
38
	public final static int MODE = 4;
39

  
40
	private IOverviewIncrement  incrementListener = null;
41
	private int value = 0;
42

  
43
	private native int buildOverviewsNative(int resamplingAlg, String file, int[] overviews);
44

  
45
	/**
46
	 * Construccion de overviews
47
	 */
48
	public void buildOverviews(int resamplingAlg, String file, int[] overviews)
49
		throws BuildingOverviewsException, WritingException {
50
		File f = new File(file);
51
		if(!f.exists() || !f.isFile())
52
			throw new BuildingOverviewsException("File does not exist.");
53
		if(!f.canWrite())
54
			throw new WritingException("File is not writeable");
55
		if(buildOverviewsNative(resamplingAlg, file, overviews) >= 0)
56
			throw new BuildingOverviewsException("Problems building overviews");
57
	}
58

  
59
	/**
60
	 * Devuelve el porcentaje del incremento.
61
	 * @return int
62
	 */
63
	public int getPercent() {
64
		return value;
65
	}
66

  
67
	/**
68
	 * Asigna el porcentaje de incremento de la construccion de overview.
69
	 * Esto se hace automaticamente desde el callback que asigna el porcentaje.
70
	 */
71
	public void setPercent(int value) {
72
		this.value = value;
73
		if(incrementListener != null)
74
			incrementListener.setPercent(value);
75
	}
76

  
77
	/**
78
	 * Asigna el listener para la asignacion del incremento
79
	 * @param incr IOverviewIncrement
80
	 */
81
	public void setIncrementListener(IOverviewIncrement incr) {
82
		this.incrementListener = incr;
83
	}
84
}
0 85

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GdalException.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
 
23
package org.gvsig.jgdal;
24

  
25
/**
26
 * Es generada cuando los c?digos de retorno de las funciones de Gdal significan que algo ha ido mal.
27
 * 
28
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
29
 * @version 0.0
30
 * @link http://www.gvsig.gva.es
31
 */
32

  
33

  
34
public class GdalException extends Exception{
35

  
36
	public GdalException(String msg){
37
		super(msg);
38
	}
39
	
40
	
41
}
0 42

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GeoTransform.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.jgdal;
23

  
24

  
25
/**
26
 * Buffer para el almacenamiento de los datos de georeferenciaci?n.
27
 * 
28
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
29
 * @version 0.0
30
 * @see http://www.gvsig.gva.es
31
 * @link http://www.gvsig.gva.es
32
 */
33

  
34
public class GeoTransform{
35
	
36
   public double adfgeotransform[]=new double[6];   
37
   
38
}
0 39

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/Gdal.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.jgdal;
23

  
24
import java.io.File;
25
import java.io.IOException;
26
/**
27
 * Contiene las funcionalidades necesarias para el acceso a los elementos de un
28
 * dataset de gdal correspondiente a una imagen
29
 * 
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 */
32
public class Gdal extends JNIBase {
33
	// CONSTANTES
34

  
35
	// GDALAccess
36
	public static int GA_ReadOnly   = 0;
37
	public static int GA_Update     = 1;
38

  
39
	// GDALDataType
40
	public static int GDT_Unknown   = 0;
41
	public static int GDT_Byte      = 1; // Buffer byte (8)
42
	public static int GDT_UInt16    = 2; // Buffer short (16)
43
	public static int GDT_Int16     = 3; // Buffer short (16)
44
	public static int GDT_UInt32    = 4; // Buffer int (32)
45
	public static int GDT_Int32     = 5; // Buffer int (32)
46
	public static int GDT_Float32   = 6; // Buffer float (32)
47
	public static int GDT_Float64   = 7; // Buffer double (64)
48
	public static int GDT_CInt16    = 8; // Buffer short (16)
49
	public static int GDT_CInt32    = 9; // Buffer int (32)
50
	public static int GDT_CFloat32  = 10; // Buffer float (32)
51
	public static int GDT_CFloat64  = 11; // Buffer double (64)
52
	public static int GDT_TypeCount = 12;
53

  
54
	private String    pszFilename   = "";
55

  
56
	private native long openNat(String pszFilename, int access);
57
	private native long openArrayNat(byte[] pszFilename, int access);
58
	private native int getGeoTransformNat(long cPtr, GeoTransform adfgeotransform);
59
	private native int setGeoTransformNat(long cPtr, GeoTransform adfgeotransform);
60
	private native String[] getMetadataNat(long cPtr, String pszDomain);
61
	private native String getProjectionRefNat(long cPtr);
62
	private native void closeNat(long cPtr);
63
	private native long getRasterBandNat(long cPtr, int hBand);
64
	private native int setProjectionNat(long cPtr, String proj);
65
	private native String getDriverShortNameNat(long cPtr);
66
	
67
	//private static native long getGDALDriverManagerNat(); 
68
	private static native long getDriverByNameNat(String name);
69
	private native String getColorInterpretationNameNat(long cPtr, int colorInterp);
70
	
71
	/**
72
	 *Constructor a partir de la direcci?n de memoria 
73
	 */
74
	public Gdal(long cPtr){
75
		this.cPtr=cPtr;
76
	}
77
	
78
	/**
79
	 *Constructor generico
80
	 */
81
	public Gdal(){}
82
	
83
	/**
84
	 * Devuelve la direcci?n de memoria del objeto dataset en C.
85
	 */
86
	public long getPtro(){return cPtr;}
87
	
88
	/**
89
	 * Abre el fichero de imagen.
90
	 *
91
	 * @param pszFilename	Nombre del fichero.
92
	 * @param access	Apertura en solo lectura o escritura.
93
	 * @throws GdalException
94
	 */
95
	public void open(String pszFilename, int access)throws GdalException, IOException {
96
		if ((access < 0) || (access > 1))
97
			throw new GdalException("Tipo de acceso al dataset incorrecto");
98

  
99
		cPtr = openArrayNat(pszFilename.getBytes(), access);
100

  
101
		if (cPtr == 0)
102
			throw new GdalException("No se ha podido acceder al archivo.");
103
	}
104
	
105
	/**
106
	 * Obtiene un array de Strings con los metadatos
107
	 * 
108
	 * @throws GdalException
109
	 * @return Array de Strings que corresponden a los metadatos que ofrece la imagen
110
	 */
111
	public String[] getMetadata()throws GdalException {
112
		return getMetadata(null);
113
		
114
	}
115
	
116
	
117
	/**
118
	 * Obtiene un array de Strings con los metadatos
119
	 * 
120
	 * @throws GdalException
121
	 * @return Array de Strings que corresponden a los metadatos que ofrece la imagen
122
	 */
123
	public String[] getMetadata(String domain)throws GdalException {
124
		String[] res = getMetadataNat(cPtr, domain);
125
		if(res == null)
126
			return new String[0];
127
		else return res;
128
		
129
	}
130
	
131
	/**
132
	 * Obtiene el n?mero de bandas de la imagen
133
	 * 
134
	 * @throws GdalException
135
	 * @param hBand	Entero que corresponde al n?mero de banda que se quiere recuperar
136
	 * @return Objeto GdalRasterBand que representa la banda recuperada	
137
	 */
138
	
139
	public GdalRasterBand getRasterBand(int hBand)throws GdalException {
140
		long cPtr_rb;
141
			
142
		if ((hBand < 1) || (hBand > getRasterCount()))
143
			throw new GdalException("Banda seleccionada incorrecta");
144
		
145
		if (cPtr == 0)
146
				throw new GdalException("No se ha podido acceder al archivo.");
147
		
148
		cPtr_rb = getRasterBandNat(cPtr,hBand);
149
		
150
		return new GdalRasterBand(cPtr_rb);	
151
	}
152
	
153
		
154
	
155
	/**
156
	 * Obtiene la dimensi?n del raster en el eje X.
157
	 * 
158
	 * @return	Devuelve un entero con la longitud de la imagen en el eje X en pixels.
159
	 * @throws GdalException 
160
	 */
161
	public int getRasterXSize()throws GdalException {
162
		String msg1="Error en GDALGetRasterXSize. La llamada GDALOpen no tuvo ?xito";
163
		String msg2="Error en tama?o X";
164
		return baseSimpleFunctions(5,msg1,msg2);
165
	}
166
		
167
	
168
	/**
169
	 * Obtiene la dimensi?n del raster en el eje Y.
170
	 * 
171
	 * @return	Devuelve un entero con la longitud de la imagen en el eje Y en pixels.
172
	 * @throws GdalException 
173
	 */
174
	public int getRasterYSize()throws GdalException {
175
		String msg1="Error en GDALGetRasterYSize. La llamada GDALOpen no tuvo ?xito";
176
		String msg2="Error en tama?o Y";
177
		return baseSimpleFunctions(6,msg1,msg2);
178
	}
179
	
180
	
181
	/**
182
	 * Obtiene el n?mero de bandas de la imagen
183
	 * 
184
	 * @return	Devuelve un entero con el n?mero de bandas que contiene la imagen.
185
	 * @throws GdalException
186
	 */
187
	public int getRasterCount()throws GdalException {
188
		String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito";
189
		String msg2="Error en el conteo de n?mero de bandas";
190
		return baseSimpleFunctions(7,msg1,msg2);
191
	}
192
	
193
	
194
	/**
195
	 * Obtiene el vector geoTransform de la imagen que contiene los valores Origen y pixelSize
196
	 * 
197
	 * @return	Devuelve un vector de doubles que contiene los valores de coordenadas de origen y pixelSize.
198
	 * @throws GdalException
199
	 */
200
	public GeoTransform getGeoTransform()throws GdalException {
201
		GeoTransform gt=new GeoTransform();
202
				
203
		if (cPtr == 0)
204
				throw new GdalException("No se ha podido acceder al archivo.");
205
		
206
		if(getGeoTransformNat(cPtr,gt) < 0)
207
			throw new GdalException("Error en getGeoTransform(). No se han obtenido valores para geoTransform.");
208
		else{
209
			return gt;
210
		}
211
	}
212
	
213
	/**
214
	 * Obtiene el Nombre corto asociado al driver del dataset
215
	 * 
216
	 * @return	Cadena con el nombre del driver
217
	 * @throws GdalException
218
	 */
219
	public String getDriverShortName()throws GdalException {
220
		if (cPtr == 0)
221
				throw new GdalException("No se ha podido acceder al archivo.");
222
		
223
		String shortName = getDriverShortNameNat(cPtr);
224
		
225
		if(shortName == null)
226
			throw new GdalException("Error en getDriverShortName(). No ha podido obtenerse el driver");
227
		else 
228
			return shortName;
229
	}
230
	
231
	/**
232
	 * A?ade el vector geoTransform a la imagen que contiene los valores Origen y pixelSize
233
	 * 
234
	 * @return	Devuelve un vector de doubles que contiene los valores de coordenadas de origen y pixelSize.
235
	 * @throws GdalException
236
	 */
237
	public void setGeoTransform(GeoTransform gt)throws GdalException {
238
		if (cPtr == 0)
239
				throw new GdalException("No se ha podido acceder al archivo.");
240
		if (gt == null)
241
			throw new GdalException("el objeto " + gt.getClass().getName() + " es null");
242
		
243
		int res = setGeoTransformNat(cPtr,gt);
244
	}
245
	
246
	/**
247
	 * Obtiene el sistema de coordenadas de referencia de la imagen.
248
	 * 
249
	 * @return	Devuelve un String con los datos del sistema de coordenadas de referencia.
250
	 * @throws GdalException
251
	 */
252
	public String getProjectionRef()throws GdalException {
253
		if (cPtr == 0)
254
				throw new GdalException("No se ha podido acceder al archivo.");
255
		
256
		String res = getProjectionRefNat(cPtr);
257
		
258
		if(res == null)return new String("");
259
		else return res;
260
	}
261
	
262
	/**
263
	 * Cierra el fichero de imagen.
264
	 *
265
	 * @throws GdalException 
266
	 */
267
	public void close()throws GdalException {
268
		if (cPtr == 0)
269
				throw new GdalException("No se ha podido acceder al archivo.");
270
		
271
		closeNat(cPtr);	
272
	}
273
	
274
	/**
275
	 * Obtiene un driver a trav?s de su nombre
276
	 * 
277
	 * @param name	Nombre del driver
278
	 */
279
	public static GdalDriver getDriverByName(String name)throws GdalException {
280
		long ptrdrv = -1;
281
		
282
		if (name == null)
283
			throw new GdalException("El nombre del driver es null");
284
		
285
		ptrdrv = getDriverByNameNat(name);
286
		
287
		return (new GdalDriver(ptrdrv));
288
	}
289
	
290
	
291
	/**
292
	 * Obtiene el numero de bandas de la imagen
293
	 * 
294
	 * @return	Devuelve un entero con el numero de bandas que contiene la imagen.
295
	 * @throws GdalException
296
	 */
297
	public int getGCPCount()throws GdalException {
298
		String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito";
299
		String msg2="Error en el conteo de n?mero de bandas";
300
		return baseSimpleFunctions(8,msg1,msg2);
301
	}
302
	
303
	/**
304
	 *Asigna la proyecci?n especificada en la cadena que se le pasa por par?metro.
305
	 *@param proj	proyecci?n
306
	 *@throws GdalException 
307
	 */
308
	public void setProjection(String proj)throws GdalException {
309
		if (cPtr == 0)
310
				throw new GdalException("No se ha podido acceder al archivo.");
311
		if (proj == null)
312
				throw new GdalException("La proyeccion es null");
313
		
314
		int res = setProjectionNat(cPtr, proj);
315
		
316
		if(res < 0)
317
			throw new GdalException("Error en setProjection(). No se ha podido asignar la proyecci?n.");
318
	}
319
	
320
	/**
321
	 * Obtiene la cadena que representa el tipo de banda de color. Los tipos posibles son:
322
	 * <UL>
323
	 *  <LI>0 = "Undefined" </LI>
324
	 *  <LI>1 = "Gray";</LI>
325
	 *  <LI>2 = "Palette";</LI>
326
	 *  <LI>3 = "Red";</LI>
327
	 *  <LI>4 = "Green";</LI>
328
	 *  <LI>5 = "Blue";</LI>
329
	 *  <LI>6 = "Alpha";</LI>
330
	 *  <LI>7 = "Hue";</LI>
331
	 *  <LI>8 = "Saturation";</LI>
332
	 *  <LI>9 = "Lightness";</LI>
333
	 *  <LI>10 = "Cyan";</LI>
334
	 *  <LI>11 = "Magenta";</LI>
335
	 *  <LI>12 = "Yellow";</LI>
336
	 *  <LI>13 = "Black";</LI>
337
	 *  <LI>14 = "YCbCr_Y";</LI>
338
	 *  <LI>15 = "YCbCr_Cb";</LI>
339
	 *  <LI>16 = "YCbCr_Cr";</LI>
340
	 * </UL>
341
	 * @return	Cadena con el nombre del tipo de banda de color
342
	 * @throws GdalException
343
	 */
344
	public String getColorInterpretationName(int colorInterp)throws GdalException {
345
		if ((colorInterp < 0) || (colorInterp > 16))
346
			throw new GdalException("Valor de interpretacion de color fuera de rango");
347
		
348
		String bandTypeName = getColorInterpretationNameNat(cPtr, colorInterp);
349
		
350
		if(bandTypeName == null)
351
			throw new GdalException("Error en getColorInterpretationName(). No ha podido obtenerse el tipo de banda de color");
352
		else 
353
			return bandTypeName;
354
	}	
355
	
356
}
0 357

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GdalColorEntry.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.jgdal;
23

  
24
/**
25
 * Clase que representa una entrada de la tabla de color.
26
 * @author Nacho Brodin (nachobrodin@gmail.com)
27
 *
28
 */
29
public class GdalColorEntry{
30
	 /*! gray, red, cyan or hue */
31
    public short      c1;      
32

  
33
    /*! green, magenta, or lightness */    
34
    public short      c2;      
35

  
36
    /*! blue, yellow, or saturation */
37
    public short      c3;      
38

  
39
    /*! alpha or blackband */
40
    public short      c4;      
41
}
0 42

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GdalTools.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

  
23
package org.gvsig.jgdal;
24

  
25
public class GdalTools {
26
	
27
	static public int CSLFindString(String[] lista, String target) {
28
		
29
		if(lista==null || lista.length==0)return -1;
30
		
31
		for( int i = 0; i<lista.length; i++ ) {
32
	        if( lista[i].equals(target) )
33
	            return i;
34
	    }
35
	    return -1;
36
		
37
	}
38
	
39
}
0 40

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/JNIBase.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

  
23

  
24
/**
25
 * @author Nacho Brodin <nachobrodin@gmail.com>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
26
 * @version 0.0
27
 * @link http://www.gvsig.gva.es
28
 */
29

  
30
package org.gvsig.jgdal;
31

  
32
public class JNIBase{
33
	
34
	protected long cPtr;
35
	
36
	private native int getRasterBandXSizeNat(long cPtr);
37
	private native int getRasterBandYSizeNat(long cPtr);
38
	private native int getOverviewCountNat(long cPtr);
39
	private native int getBlockXSizeNat(long cPtr);
40
	private native int getBlockYSizeNat(long cPtr);
41
	private native int getRasterXSizeNat(long cPtr);
42
	private native int getRasterYSizeNat(long cPtr);
43
	private native int getRasterCountNat(long cPtr);
44
	private native int getGCPCountNat(long cPtr);
45
	private native int getRasterDataTypeNat(long cPtr);
46
	private native int getDriverCountNat(long cPtr);
47
	private native int getLayerCountNat(long cPtr);
48
	
49
	
50
	 /**
51
	 * Funci?n que sirve como base para funcionalidades de gdal que admiten como par?metro un entero y devuelven un entero.
52
	 * 
53
	 * @throws GdalException.
54
	 * @param msg1	Mensaje de error que se muestra cuando el puntero a objeto pasado es vacio.
55
	 * @param msg2	Mensaje de error que se muestra cuando el resultado de la llamada a la funci�n de gdal es menor o igual que 0.
56
	 */
57
	 
58
	 
59
	protected int baseSimpleFunctions(int n,String msg1,String msg2)throws GdalException{
60
			
61
		int res = 0;
62
			
63
		switch(n){
64
			case 0: res = getRasterBandXSizeNat(cPtr);break;
65
			case 1: res = getRasterBandYSizeNat(cPtr);break;
66
			case 2: res = getOverviewCountNat(cPtr);break;
67
			case 3: res = getBlockXSizeNat(cPtr);break;
68
			case 4: res = getBlockYSizeNat(cPtr);break;
69
			case 5: res = getRasterXSizeNat(cPtr);break;
70
			case 6: res = getRasterYSizeNat(cPtr);break;
71
			case 7: res = getRasterCountNat(cPtr);break;
72
			case 8: res = getGCPCountNat(cPtr);break;
73
			case 9: res = getRasterDataTypeNat(cPtr);break;
74
		}
75

  
76
		if (res < 0)
77
			throw new GdalException(msg2);
78
		else
79
			return res;
80
	}
81
	
82
	static {
83
		/*String os = System.getProperty("os.name");
84
		if (os.toLowerCase().startsWith("windows"))
85
			System.loadLibrary("jgdal201");
86
		else*/
87
			System.loadLibrary("jgdal2.0.3");
88
	}
89
}
0 90

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/Options.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

  
23
package org.gvsig.jgdal;
24

  
25

  
26
public class Options {
27
	String[] vars;
28
	String[] datos;
29
	int longitud;
30
	int nopc;
31
	
32
   	public Options(int nopciones) {
33
   		vars=new String[nopciones];
34
   		datos=new String[nopciones];
35
   		longitud=nopciones;
36
   		nopc=0;
37
   	}
38
	
39
   	public void addOption(String var, String dato) {
40
   		vars[nopc]=var;
41
		datos[nopc]=dato;
42
		nopc++;
43
   	}
44
   	
45
   	public int getSize() {
46
   		return longitud;
47
   	}
48
 }
0 49

  
org.gvsig.jgdal/branches/goto-jgdal2.0.4/org.gvsig.jgdal/src/main/java/org/gvsig/jgdal/GdalRasterBand.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

  
23
package org.gvsig.jgdal;
24

  
25
/**
26
 * Representa a una banda simple de la im�gen o canal.
27
 * 
28
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
29
 * @version 0.0
30
 * @link http://www.gvsig.gva.es
31
 */
32

  
33
public class GdalRasterBand extends JNIBase{
34

  
35

  
36
	private native long getOverviewNat(long cPtr,int i);
37
	private native long getRasterColorTableNat(long cPtr);
38
	private native GdalBuffer readRasterNat(long cPtr, 
39
			int nXOff, int nYOff, int nXSize, int nYSize,
40
			int BufXSize, int BufYSize,
41
			int eBufType);
42
	private native GdalBuffer readRasterWithPaletteNat(long cPtr, 
43
			int nXOff, int nYOff, int nXSize, int nYSize,
44
			int BufXSize, int BufYSize,
45
			int eBufType);
46
	private native void writeRasterNat(	long cPtr, 
47
			int nXOff, int nYOff, int nXSize, int nYSize,
48
			GdalBuffer buffer,
49
			int eBufType);
50
	private native double getRasterNoDataValueNat(long cPtr);
51
	private native int existsNoDataValueNat(long cPtr);
52
	private native String[] getMetadataNat(long cPtr,String pszDomain);
53
	private native int getRasterColorInterpretationNat(long cPtr);
54
	private native int setRasterColorInterpretationNat(long cPtr, int bandType);
55

  
56

  
57
	/**
58
	 * Asigna el identificador de la banda
59
	 */
60

  
61
	 public GdalRasterBand(long cPtr) {
62
		 this.cPtr=cPtr;
63
	 }
64

  
65

  
66
	 /**
67
	  * Lee datos de la banda de la im�gen
68
	  * 
69
	  * @return	Devuelve un vector de bytes con el trozo de raster le�do.
70
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
71
	  * de la banda accedida.  
72
	  * @param nYOff	El desplazamiento de l�nea desde la esquina superior derecha
73
	  * de la banda accedida. 	
74
	  * @param nXSize	Ancho de la regi�n en pixels de la banda que ser� accedida
75
	  * @param nYSize	Altura de la regi�n en l�neas de la banda que ser� accedida
76
	  * @param bufXSize	Ancho del buffer donde la regi�n de la im�gen ser� guardada
77
	  * @param bufYSize	Altura del buffer donde la regi�n de la im�gen ser� guardada
78
	  * En caso de que bufXSize o bufYSize sean menores que 1, pasan a tener el mismo valor que
79
	  * nXSize y nYSize respectivamente para evitar buffers con tama?o 0. 
80
	  * @param eBufType		
81
	  */
82

  
83
	 public GdalBuffer readRaster(int nXOff, int nYOff, int nXSize, int nYSize,
84
			 int bufXSize, int bufYSize,
85
			 int eBufType)throws GdalException {
86
		 
87
		 if (cPtr == 0)
88
			 throw new GdalException("No se ha podido acceder al archivo.");
89

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

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

  
96
		 if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", ""))))
97
			 throw new GdalException("Posicion de la ventana incorrecta.");
98
		 
99
		 if ((eBufType < 1) || (eBufType > 11))
100
			 throw new GdalException("Tipo de datos incorrecto.");
101
		 
102
		 if (bufXSize < 1)
103
			 bufXSize = nXSize;
104
		 
105
		 if (bufYSize < 1)
106
			 bufYSize = nYSize;
107
		 
108
		 GdalBuffer buffer = readRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType);
109
		 if(buffer!=null)
110
			 return buffer;
111
		 else 
112
			 return null;
113
	 }
114

  
115
	 /**
116
	  * Escribe datos en la banda de la im�gen
117
	  * 
118
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
119
	  * de la banda accedida.  
120
	  * @param nYOff	El desplazamiento de l�nea desde la esquina superior derecha
121
	  * de la banda accedida. 	
122
	  * @param nXSize	Ancho de la regi�n en pixels de la banda que ser� accedida
123
	  * @param nYSize	Altura de la regi�n en l�neas de la banda que ser� accedida
124
	  * @param BufXSize	Ancho del buffer donde la regi�n de la im�gen ser� guardada
125
	  * @param BufYSize	Altura del buffer donde la regi�n de la im�gen ser� guardada
126
	  * @param eBufType
127
	  */
128

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

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

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

  
175
		 writeRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, buffer, eBufType); 	 	
176
	 }
177

  
178
	 /**
179
	  *Obtiene el tama�o en pixeles de la im�gen en el eje de las X
180
	  *@return Tama�o en pixeles del eje X
181
	  *@throws GdalException 
182
	  */
183

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

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

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

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

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

  
204

  
205
	 /**
206
	  * Devuelve el n�mero de overviews que contiene la banda.
207
	  * @return N�mero de overviews
208
	  * @throws GdalException 
209
	  */
210

  
211
	 public int getOverviewCount()throws GdalException {
212
		 String msg1="Error en getOverviewCount(). La llamada getRasterBand no tuvo exito";		
213
		 String msg2="Error al obtener el n�mero de overviews";
214

  
215
		 return baseSimpleFunctions(2,msg1,msg2);
216
	 }
217

  
218

  
219
	 /**
220
	  * Obtiene el overview indicado por el �ndice "i".
221
	  * 
222
	  * @param i	indice del overview que se quiere recuperar.
223
	  * @return GdalRasterBand	Banda correspondiente al overview selecccionado
224
	  * @throws GdalException 
225
	  */
226

  
227
	 public GdalRasterBand getOverview(int i)throws GdalException {
228
		 long cPtr_ov;
229

  
230
		 if((i < 0) || (i >= getOverviewCount()))
231
			 throw new GdalException("El overview seleccionado no existe");
232

  
233
		 cPtr_ov = getOverviewNat(cPtr,i);
234
		 
235
		 if (cPtr_ov == 0)
236
			 throw new GdalException("No se ha podido obtener el overview");
237

  
238
		 return new GdalRasterBand(cPtr_ov);
239
	 }
240

  
241

  
242
	 /**
243
	  * Devuelve el tama�o en X del bloque para esa banda
244
	  * @return Tama�o en pixeles del bloque en el eje X
245
	  * @throws GdalException 
246
	  */
247

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

  
252
		 return baseSimpleFunctions(3,msg1,msg2);
253
	 }
254

  
255

  
256
	 /**
257
	  * Devuelve el tama�o en Y del bloque para esa banda
258
	  * @return Tama�o en pixeles del bloque en el eje Y
259
	  * @throws GdalException 
260
	  */
261

  
262
	 public int getBlockYSize()throws GdalException {
263
		 String msg1="Error en getBlockXSize(). La llamada getRasterBand no tuvo exito";
264
		 String msg2="Tama�o de bloque erroneo devuelto por GetBlockYSize";
265

  
266
		 return baseSimpleFunctions(4,msg1,msg2);
267
	 }
268

  
269
	 /**
270
	  * Devuelve el tipo de datos de la banda
271
	  * @return Tama�o en pixeles del bloque en el eje Y
272
	  * @throws GdalException 
273
	  */
274

  
275
	 public int getRasterDataType()throws GdalException {
276
		 String msg1="Error en getRasterDataType(). La llamada getRasterBand no tuvo exito";
277
		 String msg2="Tipo de dato devuelto por GetRasterDataType erroneo";
278

  
279
		 return baseSimpleFunctions(9,msg1,msg2);
280
	 }
281

  
282
	 /**
283
	  * Obtiene la tabla de color asociada a la imagen
284
	  */
285
	 public GdalColorTable getRasterColorTable()throws GdalException {
286
		 GdalColorTable gct = null;
287
		 
288
		 if (cPtr == 0)
289
			 throw new GdalException("No se ha podido acceder al archivo.");
290
		 
291
		 long cPtr_ct = getRasterColorTableNat(cPtr);
292
		 
293
		 if ((cPtr_ct == 0) || (cPtr_ct == -1))
294
			 return null;
295
		 
296
		 gct = new GdalColorTable(cPtr_ct);
297

  
298
		 return gct;
299
	 }
300

  
301
	 /**
302
	  * Lee datos de la banda de la im�gen con una paleta asociada
303
	  * 
304
	  * @return	Devuelve un vector de bytes con el trozo de raster le�do.
305
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
306
	  * de la banda accedida.  
307
	  * @param nYOff	El desplazamiento de l�nea desde la esquina superior derecha
308
	  * de la banda accedida. 	
309
	  * @param nXSize	Ancho de la regi�n en pixels de la banda que ser� accedida
310
	  * @param nYSize	Altura de la regi�n en l�neas de la banda que ser� accedida
311
	  * @param BufXSize	Ancho del buffer donde la regi�n de la im�gen ser� guardada
312
	  * @param BufYSize	Altura del buffer donde la regi�n de la im�gen ser� guardada
313
	  * En caso de que bufXSize o bufYSize sean menores que 1, pasan a tener el mismo valor que
314
	  * nXSize y nYSize respectivamente para evitar buffers con tama?o 0. 
315
	  * @param eBufType		
316
	  */
317

  
318
	 public GdalBuffer readRasterWithPalette(int nXOff, int nYOff, int nXSize, int nYSize,
319
			 int bufXSize, int bufYSize,
320
			 int eBufType)throws GdalException {
321
		 
322
		 if (cPtr == 0)
323
			 throw new GdalException("No se ha podido acceder al archivo.");
324
		 
325
		 if ((nXOff<0) || (nXOff > baseSimpleFunctions(5, "", "")) || (nYOff < 0) || (nYOff > baseSimpleFunctions(6, "", "")))
326
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
327

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

  
331
		 if (((nXSize + nXOff) > (baseSimpleFunctions(5, "", ""))) || ((nYSize + nYOff) > (baseSimpleFunctions(6, "", ""))))
332
			 throw new GdalException("Posicion de la ventana incorrecta.");
333
		 
334
		 if ((eBufType < 1) || (eBufType > 11))
335
			 throw new GdalException("Tipo de datos incorrecto.");
336
		 
337
		 if (bufXSize < 1)
338
			 bufXSize = nXSize;
339
		 
340
		 if (bufYSize < 1)
341
			 bufYSize = nYSize;
342
		 
343
		 
344
		 GdalBuffer buffer = readRasterWithPaletteNat(cPtr, nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType);
345

  
346

  
347
		 if(buffer!=null)
348
			 return buffer;
349
		 else 
350
			 return null;
351
	 }
352

  
353
	 /**
354
	  *Devuelve el valor de NoData
355
	  */
356
	 public double getRasterNoDataValue()throws GdalException {
357
		 if (cPtr == 0)
358
			 throw new GdalException("No se ha podido acceder al archivo.");
359
		 
360
		 return getRasterNoDataValueNat(cPtr);
361
	 }
362
	 
363
	 /**
364
	  * Obtiene el valorDevuelve el valor de NoData
365
	  */
366
	 public boolean existsNoDataValue()throws GdalException {
367
		 if (cPtr == 0)
368
			 throw new GdalException("No se ha podido acceder al archivo.");
369
		 
370
		 int result = existsNoDataValueNat(cPtr);
371
		 
372
		 if(result == 1)
373
			 return true;
374
		 else 
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff