Revision 33044

View differences:

tags/tmp_build/libraries/libjni-gdal/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src/main/java"/>
4
	<classpathentry kind="src" path="src/test/java"/>
5
	<classpathentry kind="src" path="src/main/resources"/>
6
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
7
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
8
	<classpathentry kind="output" path="bin"/>
9
</classpath>
tags/tmp_build/libraries/libjni-gdal/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>libjni-gdal</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
tags/tmp_build/libraries/libjni-gdal/src/test/java/es/gva/cit/jgdal/TestWarpDataset.java
1
package es.gva.cit.jgdal;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import junit.framework.TestCase;
7

  
8
public class TestWarpDataset extends TestCase {
9
	private GdalWarp warp    = null;
10
	private String   baseDir = "./test-images/";
11
	private String   src     = baseDir + "testGdalWarp.tif";
12
	private String   dst     = baseDir + "warpedImage.tif";
13
	private String   frm     = "GTiff";
14
	private String   t_srs   = "EPSG:23030";
15

  
16
	public void start() {
17
		setUp();
18
		testStack();
19
	}
20

  
21
	public void setUp() {
22
		warp = new GdalWarp();
23
		File f = new File(src);
24
		Gdal dataset = new Gdal();
25

  
26
		try {
27
			assertTrue("El fichero no existe", f.exists());
28
			assertTrue("El fichero no se puede leer", f.canRead());
29
			dataset.open(src, Gdal.GA_ReadOnly);
30
			GdalRasterBand band = dataset.getRasterBand(1);
31
			band.readRaster(0, 0, 10, 10, 10, 10, Gdal.GDT_Byte);
32
		} catch (GdalException e) {
33
			new AssertionError("Fallo en gdal al acceder al fichero fuente");
34
		} catch (IOException e) {
35
			new AssertionError("Fallo en gdal al acceder al fichero fuente");
36
			e.printStackTrace();
37
		}
38
	}
39

  
40
	public void testStack() {
41
		assertNotNull(t_srs);
42
		
43
		warp.warp(t_srs, src, dst, frm);
44
		System.err.println("Proceso completado al " + warp.getPercent() + " %");
45
		
46
		File f = new File(dst);
47

  
48
		assertTrue("El fichero destino no existe", f.exists());
49
		assertTrue("El fichero destino no se puede leer", f.canRead());
50
	}
51
}
tags/tmp_build/libraries/libjni-gdal/src/test/java/es/gva/cit/jgdal/TestReadData.java
1
package es.gva.cit.jgdal;
2

  
3
import java.io.IOException;
4

  
5
import junit.framework.TestCase;
6

  
7
/**
8
 * Test de acceso a datos de la imagen. 
9
 * @author Miguel ?ngel Qierol Carratal? <miguelangel.querol@iver.es>
10
 *
11
 */
12
public class TestReadData extends TestCase{
13

  
14
	private Gdal gdal = null;
15
	private String baseDir = "./test-images/";
16
	private String file1 = baseDir + "testGdal.tif";
17
	private String[] metadata = null;
18
	
19
	public void start(){
20
		try {
21
			setUp();
22
			testStack();
23
		} catch (GdalException e) {
24
			e.printStackTrace();
25
		} catch (IOException e) {
26
			e.printStackTrace();
27
		}
28
		
29
	}
30
	
31
	public void setUp() throws GdalException, IOException{
32
		gdal = new Gdal();
33
		gdal.open(file1, Gdal.GA_Update);
34
	}
35
	
36
	public void testStack() throws GdalException, IOException{
37
		//Llamada sin dominio
38
		metadata = gdal.getMetadata();
39
		assertNotNull("No se han devuelto metadatos", metadata);
40
		for (int i = 0 ; i<metadata.length ; i++){
41
			System.out.println("Metadato: " + metadata[i]);
42
		}
43
		
44
		//Llamada con dominio "Image Structure Metadata"
45
		metadata = gdal.getMetadata("Image Structure Metadata");
46
		assertNotNull("No se han devuelto metadatos", metadata);
47
		for (int i = 0 ; i<metadata.length ; i++){
48
			System.out.println("Metadato: " + metadata[i]);
49
		}
50
		
51
		//Comprobaci?n del tama?o de la imagen
52
		assertEquals(842, gdal.getRasterXSize());
53
		assertEquals(1023, gdal.getRasterYSize());
54
		
55
		//Comprobaci?n del n?mero de bandas
56
		assertEquals(4, gdal.getRasterCount());
57
		
58
		//Comprobaci?n del driver de la imagen
59
		assertEquals("GTiff", gdal.getDriverShortName());
60
		
61
		//Comprobaci?n del acceso a las bandas
62
		for (int i = 0 ; i < gdal.getRasterCount() ; i++){
63
			assertNotNull(gdal.getRasterBand(i+1));
64
		}
65
		
66
		gdal.close();
67
		gdal = null;
68
		System.gc();
69
	}
70
}
tags/tmp_build/libraries/libjni-gdal/src/test/java/es/gva/cit/jgdal/TestReadBandData.java
1
package es.gva.cit.jgdal;
2

  
3
import java.io.IOException;
4

  
5
import junit.framework.TestCase;
6

  
7
/**
8
 * Test de acceso a datos de las bandas de una imagen.
9
 * @author Miguel ?ngel Querol Carratal? <miguelangel.querol@iver.es>
10
 *
11
 */
12
public class TestReadBandData extends TestCase{
13
	private Gdal gdal = null;
14
	private GdalRasterBand band = null;
15
	private String baseDir = "./test-images/";
16
	private String file1 = baseDir + "testGdal.tif";
17
	
18
	public void start(){
19
		try {
20
			setUp();
21
			testStack();
22
		} catch (GdalException e) {
23
			e.printStackTrace();
24
		} catch (IOException e) {
25
			e.printStackTrace();
26
		}
27
		
28
	}
29
	
30
	public void setUp() throws GdalException, IOException{
31
		gdal = new Gdal();
32
		gdal.open(file1, Gdal.GA_Update);
33
	}
34
	
35
	public void testStack() throws GdalException, IOException{
36
		//Llamada sin dominio
37
		String[] metadata = gdal.getMetadata();
38
		assertNotNull("No se han devuelto metadatos", metadata);
39
		for (int i = 0 ; i<metadata.length ; i++){
40
			System.out.println("Metadato: " + metadata[i]);
41
		}
42
		
43
		//Llamada con dominio "Image Structure Metadata"
44
		metadata = gdal.getMetadata("Image Structure Metadata");
45
		assertNotNull("No se han devuelto metadatos", metadata);
46
		for (int i = 0 ; i<metadata.length ; i++){
47
			System.out.println("Metadato: " + metadata[i]);
48
		}
49
		
50
		//Comprobaci?n del tama?o de la imagen
51
		assertEquals(842, gdal.getRasterXSize());
52
		assertEquals(1023, gdal.getRasterYSize());
53
		
54
		//Comprobaci?n del n?mero de bandas
55
		assertEquals(4, gdal.getRasterCount());
56
		
57
		//Comprobaci?n del driver de la imagen
58
		assertEquals("GTiff", gdal.getDriverShortName());
59
		
60
		//Comprobaci?n del acceso a las bandas
61
		for (int i = 0 ; i < gdal.getRasterCount() ; i++){
62
			assertNotNull(gdal.getRasterBand(i+1));
63
		}
64
	}
65
}
tags/tmp_build/libraries/libjni-gdal/src/test/java/org/gvsig/addo/TestBuildOverviews.java
1
package org.gvsig.addo;
2

  
3
import java.io.IOException;
4

  
5
import junit.framework.TestCase;
6
import es.gva.cit.jgdal.Gdal;
7
import es.gva.cit.jgdal.GdalException;
8

  
9
/**
10
 * Test para la generacion de overviews sobre una imagen raster.
11
 * Registra un listener para mostrar el incremento de la tarea.
12
 *
13
 * 18-nov-2007
14
 * @author Nacho Brodin (nachobrodin@gmail.com)
15
 */
16
public class TestBuildOverviews extends TestCase implements IOverviewIncrement {
17
	private int value = 0;
18

  
19
	private Jaddo addo = null;
20
	private Gdal gdal = null;
21
	private String path = "./test-images/testGdalWarp.tif";
22
	
23
	public void start(){
24
		setUp();
25
		testStack();
26
	}
27
	
28
	
29
	public void setUp(){
30
		addo = new Jaddo();
31
		addo.setIncrementListener(this);
32
		gdal = new Gdal();
33
	}
34
	
35
	
36
	public void testStack(){
37
		try {
38
			addo.buildOverviews(Jaddo.AVERAGE, path, new int[]{2, 4, 8, 16});
39
			gdal.open(path, Gdal.GA_ReadOnly);
40
			assertTrue("No hay overviews!!", gdal.getRasterBand(1).getOverviewCount()>0);
41
		} catch (BuildingOverviewsException e) {
42
			System.err.println(e);
43
		} catch (WritingException e) {
44
			System.err.println(e);
45
		} catch (GdalException e) {
46
			e.printStackTrace();
47
		} catch (IOException e) {
48
			e.printStackTrace();
49
		}
50
		
51
	}
52

  
53
	public int getPercent() {
54
		return value;
55
	}
56

  
57
	public void setPercent(int value) {
58
		this.value = value;
59
		System.out.println("Increment:" + value);
60
	}
61
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/DiagSignalHandler.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package es.gva.cit.jgdal;
20
import java.awt.BorderLayout;
21
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionListener;
23

  
24
import javax.swing.JButton;
25
import javax.swing.JFrame;
26
import javax.swing.JLabel;
27
import javax.swing.JPanel;
28

  
29
import sun.misc.Signal;
30
import sun.misc.SignalHandler;
31

  
32
class DiagSignalHandler implements SignalHandler {
33
			 
34
		private SignalHandler oldHandler;
35
		private static boolean active = false;
36

  
37
		//Static method to install the signal handler
38
		public static DiagSignalHandler install(String signalName) {
39
			Signal diagSignal = new Signal(signalName);
40
				DiagSignalHandler diagHandler = new DiagSignalHandler();
41
			diagHandler.oldHandler = Signal.handle(diagSignal,diagHandler);
42
				return diagHandler;
43
		}
44
		// Signal handler method
45
		public void handle(Signal sig) {
46
	if(active)
47
		return;
48
	active = true;
49
	JFrame frame = new JFrame();
50
	frame.setSize(400, 150);
51
	JPanel p = new JPanel();
52
	JLabel l = new JLabel("SIGSEGV signal handler. Signal: " + sig);
53
	p.setLayout(new BorderLayout());
54
	JButton b = new JButton("Close");
55
	b.addActionListener(new ActionListener() {
56
		public void actionPerformed(ActionEvent e) {
57
			System.out.println("Handler test");
58
		}
59
	});
60
	p.add(l, BorderLayout.NORTH);
61
	p.add(b, BorderLayout.SOUTH);
62

  
63
	frame.getContentPane().add(p);
64
	frame.show();
65
		 }
66
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GdalBuffer.java
1
/**********************************************************************
2
 * $Id: GdalBuffer.java 7765 2006-10-03 07:05:18Z nacho $
3
 *
4
 * Name:     GdalBuffer.java
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:  Buffer to store image data. 
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
*
12
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
*
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
*
28
* For more information, contact:
29
*
30
*  Generalitat Valenciana
31
*   Conselleria d'Infraestructures i Transport
32
*   Av. Blasco Ib??ez, 50
33
*   46010 VALENCIA
34
*   SPAIN
35
*
36
*      +34 963862235
37
*   gvsig@gva.es
38
*      www.gvsig.gva.es
39
*
40
*    or
41
*
42
*   IVER T.I. S.A
43
*   Salamanca 50
44
*   46005 Valencia
45
*   Spain
46
*
47
*   +34 963163400
48
*   dac@iver.es
49
*/
50

  
51
package es.gva.cit.jgdal;
52

  
53

  
54
/**  
55
 * Buffer para el almacenamiento de l?neas de la im?g?n. Esta clase es instanciada desde C para que se pueda acceder a sus datos desde el cliente java.
56
 * 
57
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
58
 * @version 0.0
59
 * @link http://www.gvsig.gva.es
60
 */
61

  
62
public class GdalBuffer{
63
	
64
    public byte[] buffByte;			//8 bits
65
    public short[] buffShort;		//16 bits
66
    public int[] buffInt;			//32 bits
67
    public float[] buffFloat;		//32 bits
68
    public double[] buffDouble;		//64 bits
69
    
70
    public byte[] buffAPalette;
71
    public byte[] buffRPalette;
72
    public byte[] buffGPalette;
73
    public byte[] buffBPalette;
74
    
75
    public void reservaByte(int r){
76
    	buffByte = new byte[r];
77
    }
78
    
79
    public void reservaShort(int r){
80
    	buffShort = new short[r];
81
    }
82
    
83
    public void reservaInt(int r){
84
    	buffInt = new int[r];
85
    }
86
    
87
    public void reservaFloat(int r){
88
    	buffFloat = new float[r];
89
    }
90
    
91
    public void reservaDouble(int r){
92
    	buffDouble = new double[r];
93
    }
94
    
95
    public void reservaPalette(int r){
96
    	buffAPalette = new byte[r];
97
    	buffRPalette = new byte[r];
98
        buffGPalette = new byte[r];
99
        buffBPalette = new byte[r];
100
    }
101
    
102
    public int getSize(){
103
      for(int i=0;i<5;i++){
104
      	if(buffByte!=null)return buffByte.length;
105
    	if(buffShort!=null)return buffShort.length;
106
    	if(buffInt!=null)return buffInt.length;
107
    	if(buffFloat!=null)return buffFloat.length;
108
    	if(buffDouble!=null)return buffDouble.length;
109
    	if(buffRPalette!=null)return buffRPalette.length;
110
      }
111
      return 0;
112
    }
113
  
114
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GdalGCP.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package es.gva.cit.jgdal;
20
/**
21
 * Contiene las funcionalidades necesarias para el acceso a los
22
 * elementos de un dataset de gdal correspondiente a una im?gen 
23
 * 
24
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
25
 * @link http://www.gvsig.gva.es
26
 */
27
public class GdalGCP extends JNIBase{
28

  
29
	private native long GdalGCPNat();
30
	private native long GdalGCPPointsNat(	double pixelXGCP, 
31
											double pixelYGCP,
32
											double mapXGCP,
33
											double mapYGCP,
34
											double mapZGCP);
35
	private native void FreeGdalGCPNat();
36
	
37
	private String id; 			//identificador 
38
	private String info;		//informaci?n
39
	private double pixelXGCP;	/** Pixel (x) location of GCP on raster */
40
	private double pixelYGCP;	/** Line (y) location of GCP on raster */
41
	private double mapXGCP;		/** X position of GCP in georeferenced space */
42
	private double mapYGCP; 	/** Y position of GCP in georeferenced space */
43
	private double mapZGCP;		/** Elevation of GCP, or zero if not known */
44
		
45
	/**
46
	 * Constructor
47
	 */
48
	public GdalGCP(){
49
		cPtr = this.GdalGCPNat();
50
	}
51
	
52
	/**
53
	 * Constructor
54
	 * @param pixelXGCP
55
	 * @param pixelYGCP
56
	 * @param mapXGCP
57
	 * @param mapYGCP
58
	 * @param mapZGCP
59
	 */
60
	public GdalGCP(	double pixelXGCP, 
61
					double pixelYGCP,
62
					double mapXGCP,
63
					double mapYGCP,
64
					double mapZGCP){
65
		this.pixelXGCP = pixelXGCP;  
66
		this.pixelYGCP = pixelYGCP;
67
		this.mapXGCP = mapXGCP; 
68
		this.mapYGCP = mapYGCP;
69
		this.mapZGCP = mapYGCP;
70
	}
71
	
72
	protected void finalize(){
73
		
74
	}
75
	
76
	/**
77
	 * @return Returns the mapXGCP.
78
	 */
79
	public double getMapXGCP() {
80
		return mapXGCP;
81
	}
82
	/**
83
	 * @param mapXGCP The mapXGCP to set.
84
	 */
85
	public void setMapXGCP(double mapXGCP) {
86
		this.mapXGCP = mapXGCP;
87
	}
88
	/**
89
	 * @return Returns the mapYGCP.
90
	 */
91
	public double getMapYGCP() {
92
		return mapYGCP;
93
	}
94
	/**
95
	 * @param mapYGCP The mapYGCP to set.
96
	 */
97
	public void setMapYGCP(double mapYGCP) {
98
		this.mapYGCP = mapYGCP;
99
	}
100
	/**
101
	 * @return Returns the mapZGCP.
102
	 */
103
	public double getMapZGCP() {
104
		return mapZGCP;
105
	}
106
	/**
107
	 * @param mapZGCP The mapZGCP to set.
108
	 */
109
	public void setMapZGCP(double mapZGCP) {
110
		this.mapZGCP = mapZGCP;
111
	}
112
	/**
113
	 * @return Returns the pixelXGCP.
114
	 */
115
	public double getPixelXGCP() {
116
		return pixelXGCP;
117
	}
118
	/**
119
	 * @param pixelXGCP The pixelXGCP to set.
120
	 */
121
	public void setPixelXGCP(double pixelXGCP) {
122
		this.pixelXGCP = pixelXGCP;
123
	}
124
	/**
125
	 * @return Returns the pixelYGCP.
126
	 */
127
	public double getPixelYGCP() {
128
		return pixelYGCP;
129
	}
130
	/**
131
	 * @param pixelYGCP The pixelYGCP to set.
132
	 */
133
	public void setPixelYGCP(double pixelYGCP) {
134
		this.pixelYGCP = pixelYGCP;
135
	}
136
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GdalWarp.java
1
package es.gva.cit.jgdal;
2

  
3
import java.util.ArrayList;
4

  
5
/**
6
 * Clase que recubre la funci?n de reproyecci?n de gdal.
7
 *  
8
 * @author Miguel ?ngel Querol Carratal?
9
 */
10
public class GdalWarp extends JNIBase {
11
	private int    porcentaje;
12

  
13
	/**
14
	 * Par?metros de la operaci?n de reproyecci?n
15
	 */
16
	private String s_srs = null;
17

  
18
	/**
19
	 * M?todo nativo para el warp desde gdal.
20
	 */
21
	private native int warpDataset(String s_srs, String t_srs, String source, String dest, String format);
22

  
23
	/**
24
	 * Constructor generico.
25
	 */
26
	public GdalWarp() {}
27

  
28
	/**
29
	 * Reproyecta una imagen raster, creando una imagen de salida
30
	 * @param proj EPSG:code o proj4
31
	 * @param source Ruta del fichero fuente
32
	 * @param dest Ruta del fichero destino
33
	 * @param format
34
	 * @return 0 si ha ocurrido algun error o 1 si la ejecuci?n ha sido correcta.
35
	 * @throws GdalException
36
	 */
37
	public int warp(String t_srs, String source, String dest, String format) {
38

  
39
		int stat = warpDataset(s_srs, t_srs, source, dest, format);
40
		
41
		return stat;
42
	}
43

  
44
	/**
45
	 * Indica la proyecci?n del dataset origen
46
	 * @param s_srs
47
	 */
48
	public void setSsrs(String s_srs) {
49
		this.s_srs = s_srs;
50
	}
51

  
52
	/**
53
	 * Obtiene el porcentaje de proceso que se ha completado
54
	 */
55
	public int getPercent() {
56
		return porcentaje;
57
	}
58
	
59
	/**
60
	 * Devuelve la lista de drivers que usa GdalWarp para reproyectar
61
	 * @return
62
	 */
63
	static public ArrayList getDrivers() {
64
		ArrayList list = new ArrayList();
65
		list.add("GTiff");
66
		list.add("VRT");
67
		list.add("NITF");
68
		list.add("HFA");
69
		list.add("ELAS");
70
		list.add("MEM");
71
		list.add("BMP");
72
		list.add("PCIDSK");
73
		list.add("ILWIS");
74
		String os = System.getProperty("os.name");
75
		if (!os.toLowerCase().startsWith("windows"))
76
			list.add("HDF4Image");
77
		list.add("PNM");
78
		list.add("ENVI");
79
		list.add("EHdr");
80
		list.add("PAux");
81
		list.add("MFF");
82
		list.add("MFF2");
83
		list.add("BT");
84
		list.add("IDA");
85
		list.add("RMF");
86
		list.add("RST");
87
		list.add("Leveller");
88
		list.add("Terragen");
89
		list.add("ERS");
90
		list.add("INGR");
91
		list.add("GSAG");
92
		list.add("GSBG");
93
		list.add("ADRG");
94
		return list;
95
	}
96
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GdalDriver.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package es.gva.cit.jgdal;
20

  
21
import java.io.File;
22
import java.util.StringTokenizer;
23
/**
24
 * Representa un driver de un tipo de im?gen 
25
 * 
26
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
27
 * @version 0.0
28
 * @link http://www.gvsig.gva.es
29
 */
30
public class GdalDriver extends JNIBase {
31
	private native long createCopyNat(long cPtr, String file, long src, int bstrict);
32
	private native long createCopyParamsNat(long cPtr, String file, long src, int bstrict, Options opc);
33
	private native long createNat(long cPtr, String filename, int nXSize, int nYSize, int nBands, int nType, Options opc);
34
	
35
	/**
36
	 * Constructor de Driver pasandole como par?metro la referencia al objeto 
37
	 * GdalDriver en C
38
	 * 
39
	 * @param cPtr	direcci?n de memoria del objeto 
40
	 */
41
	public GdalDriver(long cPtr) {
42
		this.cPtr=cPtr;
43
	}
44

  
45
	/**
46
	 * Crea una copia de una im?gen a partir de un dataset de origen especificado.
47
	 * @param file	Nombre del fichero sobre el cual se guardar? la copia
48
	 * @param src	Dataset fuente a copiar
49
	 * @param bstrict	TRUE si la copia debe ser estrictamente equivalente y FALSE indica que la copia puede
50
	 * adaptarse a las necesidades del formato de salida
51
	 * @return Gdal	Dataset de la im?gen de salida
52
	 * @throws GdalException
53
	 */
54
	public Gdal createCopy(String file, Gdal src, boolean bstrict) throws GdalException {
55
		String path = file.substring(0, file.lastIndexOf(File.separator));
56
		File f = new File(path);
57
		if (!f.canWrite())
58
			throw new GdalException("Ruta de archivo incorrecta.");
59
		f = null;
60

  
61
		if (src == null)
62
			throw new GdalException("El objeto Gdal es null");
63

  
64
		if (cPtr == 0)
65
			throw new GdalException("No se ha podido acceder al archivo.");
66

  
67
		long ptr = createCopyNat(cPtr, file, src.getPtro(), bstrict ? 1 : 0);
68
	
69
//		if (ptr == 0)
70
//			throw new GdalException("No se ha podido crear la copia");
71

  
72
		return (new Gdal(ptr));
73
	}
74
	
75
	
76
	/**
77
	 * A partir de las opciones en forma de vector de Strings pasadas por el usuario donde cada
78
	 * elemento del vector tiene la forma VARIABLE=VALOR crea el objeto Options para que sea accesible
79
	 * a las funciones JNI desde C.
80
	 * @param params	Vector de strigs con las opciones
81
	 * @return Options	Objeto de opciones
82
	 */
83
	private Options selectOptions(String[] params) {
84
		if (params == null)
85
			return null;
86

  
87
		Options opc = new Options(params.length);
88
		StringTokenizer st;
89
		for (int i = 0; i < params.length; i++) {
90
			st = new StringTokenizer(params[i], "=");
91
			String var = st.nextToken();
92
			String dato = st.nextToken();
93
			opc.addOption(var, dato);
94
		}
95
		return opc;
96
	}
97
	
98
	/**
99
	 * Crea una copia de una im?gen a partir de un dataset de origen especificado y unos par?metros dados.
100
	 * @param file	Nombre del fichero sobre el cual se guardar? la copia
101
	 * @param src	Dataset fuente a copiar
102
	 * @param bstrict	TRUE si la copia debe ser estrictamente equivalente y FALSE indica que la copia puede
103
	 * adaptarse a las necesidades del formato de salida
104
	 * @param params	Vector de strigs con las opciones de la copia
105
	 * @return Gdal	Dataset de la im?gen de salida
106
	 * @throws GdalException
107
	 */
108
	public Gdal createCopy(String file, Gdal src, boolean bstrict, String[] params) throws GdalException {
109
		String path = file.substring(0, file.lastIndexOf(File.separator));
110
		File f = new File(path);
111
		if (!f.canWrite())
112
			throw new GdalException("Ruta de archivo incorrecta.");
113
		f = null;
114

  
115
		if (cPtr == 0)
116
			throw new GdalException("No se ha podido acceder al archivo.");
117

  
118
		if (src == null)
119
			throw new GdalException("El objeto Gdal es null");
120

  
121
		long ptr = createCopyParamsNat(cPtr, file, src.getPtro(), bstrict ? 1 : 0, selectOptions(params));
122

  
123
		if (ptr == 0)
124
			throw new GdalException("No se ha podido crear la copia");
125

  
126
		return (new Gdal(ptr));
127
	}
128
	
129
	
130
	/**
131
	 * Crea un nuevo dataset con el driver actual
132
	 * 
133
	 * @param filename	Nombre del dataset a crear
134
	 * @param nXSize	Ancho en pixels
135
	 * @param nYSize	Alto en pixels
136
	 * @param nBands	N?mero de bandas
137
	 * @param nType	Tipo de raster
138
	 * @param params	lista de par?metros especificos del driver
139
	 */
140
	public Gdal create(String filename, int nXSize, int nYSize, int nBands, int nType, String[] params) throws GdalException {
141
		if (cPtr == 0)
142
			throw new GdalException("No se ha podido acceder al archivo.");
143

  
144
		long ptr = createNat(cPtr, filename, nXSize, nYSize, nBands, nType, selectOptions(params));
145

  
146
		return (new Gdal(ptr));
147
	}
148
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GdalException.java
1
/**********************************************************************
2
 * $Id: GdalException.java 7765 2006-10-03 07:05:18Z nacho $
3
 *
4
 * Name:     GdalException.java
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:  Class for exceptions produced into gdal. 
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
*
12
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
*
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
*
28
* For more information, contact:
29
*
30
*  Generalitat Valenciana
31
*   Conselleria d'Infraestructures i Transport
32
*   Av. Blasco Ib??ez, 50
33
*   46010 VALENCIA
34
*   SPAIN
35
*
36
*      +34 963862235
37
*   gvsig@gva.es
38
*      www.gvsig.gva.es
39
*
40
*    or
41
*
42
*   IVER T.I. S.A
43
*   Salamanca 50
44
*   46005 Valencia
45
*   Spain
46
*
47
*   +34 963163400
48
*   dac@iver.es
49
*/
50
 
51
package es.gva.cit.jgdal;
52

  
53
/**
54
 * Es generada cuando los c?digos de retorno de las funciones de Gdal significan que algo ha ido mal.
55
 * 
56
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
57
 * @version 0.0
58
 * @link http://www.gvsig.gva.es
59
 */
60

  
61

  
62
public class GdalException extends Exception{
63

  
64
	public GdalException(String msg){
65
		super(msg);
66
	}
67
	
68
	
69
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GeoTransform.java
1
/**********************************************************************
2
 * $Id: GeoTransform.java 7765 2006-10-03 07:05:18Z nacho $
3
 *
4
 * Name:     GeoTransform.java
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:  Georeferencing data. 
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
*
12
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
*
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
*
28
* For more information, contact:
29
*
30
*  Generalitat Valenciana
31
*   Conselleria d'Infraestructures i Transport
32
*   Av. Blasco Ib??ez, 50
33
*   46010 VALENCIA
34
*   SPAIN
35
*
36
*      +34 963862235
37
*   gvsig@gva.es
38
*      www.gvsig.gva.es
39
*
40
*    or
41
*
42
*   IVER T.I. S.A
43
*   Salamanca 50
44
*   46005 Valencia
45
*   Spain
46
*
47
*   +34 963163400
48
*   dac@iver.es
49
*/
50

  
51
package es.gva.cit.jgdal;
52

  
53

  
54
/**
55
 * Buffer para el almacenamiento de los datos de georeferenciaci?n.
56
 * 
57
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
58
 * @version 0.0
59
 * @see http://www.gvsig.gva.es
60
 * @link http://www.gvsig.gva.es
61
 */
62

  
63
public class GeoTransform{
64
	
65
   public double adfgeotransform[]=new double[6];   
66
   
67
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/Gdal.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 * 
19
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
20
 */
21
package es.gva.cit.jgdal;
22

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

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

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

  
53
	private String    pszFilename   = "";
54

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

  
3
/**
4
 * Clase que representa una entrada de la tabla de color.
5
 * @author Nacho Brodin (brodin_ign@gva.es)
6
 *
7
 */
8
public class GdalColorEntry{
9
	 /*! gray, red, cyan or hue */
10
    public short      c1;      
11

  
12
    /*! green, magenta, or lightness */    
13
    public short      c2;      
14

  
15
    /*! blue, yellow, or saturation */
16
    public short      c3;      
17

  
18
    /*! alpha or blackband */
19
    public short      c4;      
20
}
tags/tmp_build/libraries/libjni-gdal/src/main/java/es/gva/cit/jgdal/GdalTools.java
1
/**********************************************************************
2
 * $Id: GdalTools.java 7765 2006-10-03 07:05:18Z nacho $
3
 *
4
 * Name:     GdalTools.java
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:   
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
*
12
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
*
14
* This program is free software; you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License
16
* as published by the Free Software Foundation; either version 2
17
* of the License, or (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
*
28
* For more information, contact:
29
*
30
*  Generalitat Valenciana
31
*   Conselleria d'Infraestructures i Transport
32
*   Av. Blasco Ib??ez, 50
33
*   46010 VALENCIA
34
*   SPAIN
35
*
36
*      +34 963862235
37
*   gvsig@gva.es
38
*      www.gvsig.gva.es
39
*
40
*    or
41
*
42
*   IVER T.I. S.A
43
*   Salamanca 50
44
*   46005 Valencia
45
*   Spain
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff