Revision 12379

View differences:

org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.app/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3

  
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.raster.gdal.app</artifactId>
6
	<packaging>pom</packaging>
7
	<name>${project.artifactId}</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.raster.gdal</artifactId>
11
		<version>2.2.118</version>
12
	</parent>
13

  
14
	<modules>
15
		<module>org.gvsig.raster.gdal.app.mainplugin</module>
16
	</modules>
17

  
18
</project>
19

  
0 20

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
    <id>gvsig-plugin-package</id>
28
    <formats>
29
        <format>zip</format>
30
    </formats>
31
    <baseDirectory>${project.artifactId}</baseDirectory>
32
    <includeBaseDirectory>true</includeBaseDirectory>
33
    <files>
34
        <file>
35
            <source>target/${project.artifactId}-${project.version}.jar</source>
36
            <outputDirectory>lib</outputDirectory>
37
        </file>
38
        <file>
39
            <source>target/package.info</source>
40
        </file>
41
    </files>
42

  
43
    <fileSets>
44
        <fileSet>
45
            <directory>src/main/resources-plugin</directory>
46
            <outputDirectory>.</outputDirectory>
47
        </fileSet>
48
    </fileSets>
49

  
50

  
51
    <dependencySets>
52
        <dependencySet>
53
            <useProjectArtifact>false</useProjectArtifact>
54
            <useTransitiveDependencies>false</useTransitiveDependencies>
55
            <outputDirectory>lib</outputDirectory>
56
            <includes>
57
                <include>org.gvsig:org.gvsig.raster.gdal.io:jar</include>
58
            </includes>
59
        </dependencySet>
60
    </dependencySets>
61

  
62
</assembly>
63

  
64

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/src/main/java/org/gvsig/raster/gdal/app/GdalExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.gdal.app;
23

  
24
import org.gvsig.andami.plugins.Extension;
25
import org.gvsig.fmap.dal.coverage.RasterLocator;
26
import org.gvsig.fmap.dal.coverage.util.ProviderServices;
27
import org.gvsig.installer.lib.api.InstallerLocator;
28
import org.gvsig.installer.lib.api.InstallerManager;
29
import org.gvsig.installer.lib.api.PackageInfo;
30
import org.gvsig.raster.gdal.io.GdalProvider;
31
import org.slf4j.LoggerFactory;
32

  
33
/**
34
 * Extension to add Gdal library support
35
 *
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class GdalExtension extends Extension {
39

  
40
        private static final org.slf4j.Logger logger = LoggerFactory.getLogger(GdalExtension.class);
41
        
42
        @Override
43
	public void execute(String actionCommand) {
44
	}
45

  
46
        @Override
47
        public void postInitialize() {
48
            try {
49
                InstallerManager installerManager = InstallerLocator.getInstallerManager();
50
                PackageInfo[] pkgs = installerManager.getInstalledPackages();
51
                boolean needECW = true;
52
                boolean needMrSID = true;
53
                for (PackageInfo pkg : pkgs) {
54
                    if( "org.gvsig.raster.ermapper.app".equalsIgnoreCase(pkg.getCode() )) {
55
                        needECW = false;
56
                    }
57
                    if( "org.gvsig.raster.lizardtech.app".equalsIgnoreCase(pkg.getCode() )) {
58
                        needMrSID = false;
59
                    }
60
                }
61
                ProviderServices providerServices = RasterLocator.getManager().getProviderServices();
62
                if( needECW ) {
63
                    providerServices.addFormat("ecw", GdalProvider.class);
64
                    providerServices.addFormat("jp2", GdalProvider.class);
65
                }
66
                if( needMrSID ) {
67
                    providerServices.addFormat("mrsid", GdalProvider.class);
68
                }
69
            } catch (Exception ex) {
70
                logger.warn("Can't determine the use of gdal drivers for ecw, jp2 and mrsid",ex);
71
            }
72
        }
73

  
74

  
75

  
76
        @Override
77
	public void initialize() {
78
	}
79
	
80
        @Override
81
	public boolean isEnabled() {
82
		return false;
83
	}
84

  
85
        @Override
86
	public boolean isVisible() {
87
		return false;
88
	}
89

  
90
}
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
    <depends plugin-name="org.gvsig.gdal.app.mainplugin" />
4
    <depends plugin-name="org.gvsig.raster.mainplugin" />
5
    <depends plugin-name="org.gvsig.raster.tilecache.app" optional="true" />
6
    <libraries library-dir="lib"/>
7
    <resourceBundle name="text"/>
8
    <extensions>
9
        <extension class-name="org.gvsig.raster.gdal.app.GdalExtension"
10
                           description=""
11
                           active="true"
12
                           priority="1">
13
        </extension>
14
    </extensions>
15
</plugin-config>
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.raster.gdal.app.mainplugin</artifactId>
6
    <packaging>jar</packaging>
7
    <name>${project.artifactId}</name>
8
    <description>GDAL raster data provider for gvSIG: jpeg, tiff, png, gif.</description>
9
    <parent>
10
        <groupId>org.gvsig</groupId>
11
        <artifactId>org.gvsig.raster.gdal.app</artifactId>
12
        <version>2.2.118</version>
13
    </parent>
14

  
15
    <dependencies>
16
        <dependency>
17
            <groupId>org.gvsig</groupId>
18
            <artifactId>org.gvsig.andami</artifactId>
19
            <scope>compile</scope>
20
        </dependency>
21
        <dependency>
22
            <groupId>org.gvsig</groupId>
23
            <artifactId>org.gvsig.raster.gdal.io</artifactId>
24
            <scope>compile</scope>
25
        </dependency>
26
        <dependency>
27
            <groupId>org.gvsig</groupId>
28
            <artifactId>org.gvsig.raster.lib.api</artifactId>
29
            <scope>compile</scope>
30
        </dependency>
31
    </dependencies>
32

  
33
    <properties>
34
        <svn.tags.folder>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/</svn.tags.folder>
35

  
36
        <gvsig.package.info.name>Formats: GDAL raster file formats support</gvsig.package.info.name>     
37
        <gvsig.package.info.state>testing</gvsig.package.info.state>
38
        <gvsig.package.info.official>true</gvsig.package.info.official>
39
        <gvsig.package.info.operatingSystem>all</gvsig.package.info.operatingSystem>
40
        <gvsig.package.info.architecture>all</gvsig.package.info.architecture>
41
        <gvsig.package.info.categories>Raster, Formats</gvsig.package.info.categories>
42
        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/Raster/pool/</gvsig.package.info.poolURL>
43
        <gvsig.package.info.codealias>org.gvsig.raster.gdal.app</gvsig.package.info.codealias>
44
        <gvsig.package.info.description>${project.parent.description}</gvsig.package.info.description>
45
        <gvsig.package.info.dependencies>required: org.gvsig.gdal.app.mainplugin -ge 1, required: org.gvsig.raster.tilecache.app -ge 2</gvsig.package.info.dependencies>
46

  
47
        <gvsig.install.plugin>true</gvsig.install.plugin>
48
        <gvsig.install.plugin.package>true</gvsig.install.plugin.package>
49

  
50
    </properties>
51

  
52
    <build>
53
        <plugins>
54

  
55
            <plugin>
56
                <!-- Skip compilation tests -->
57
                <groupId>org.apache.maven.plugins</groupId>
58
                <artifactId>maven-compiler-plugin</artifactId>
59
                <executions>
60
                    <execution>
61
                        <id>default-testCompile</id>
62
                        <phase>process-test-sources</phase>
63
                        <goals>
64
                            <goal>testCompile</goal>
65
                        </goals>
66
                        <configuration>
67
                            <skip>true</skip>
68
                        </configuration>
69
                    </execution>
70
                </executions>
71
            </plugin>
72

  
73
            <plugin>
74
                <!-- Skip test execution -->
75
                <groupId>org.apache.maven.plugins</groupId>
76
                <artifactId>maven-surefire-plugin</artifactId>
77
                <configuration>
78
                    <skipTests>true</skipTests>
79
                </configuration>
80
            </plugin>
81
 
82
        </plugins>
83
    </build>
84

  
85
</project>
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/buildNumber.properties
1
#Thu Sep 10 17:20:19 CEST 2020
2
buildNumber=171
0 3

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.raster.gdal</artifactId>
5
	<packaging>pom</packaging>
6
	<version>2.2.118</version>
7
	<name>${project.artifactId}</name>
8
	<description>GDAL raster data provider for gvSIG</description>
9
	<inceptionYear>2011</inceptionYear>
10

  
11
	<parent>
12
		<groupId>org.gvsig</groupId>
13
		<artifactId>org.gvsig.desktop</artifactId>
14
		<version>2.0.293</version>
15
	</parent>
16

  
17
	<properties>
18
		<!-- El plugin versions:use-latest-versions falla con scope import -->
19
		<!-- asi que toca usar el versions:update-properties que si que funciona -->
20
		<org.gvsig.gdal.version>1.0.102</org.gvsig.gdal.version>
21
		<org.gvsig.raster.version>2.2.130</org.gvsig.raster.version>
22
	</properties>
23

  
24
	<repositories>
25
		<repository>
26
			<id>gvsig-public-http-repository</id>
27
			<name>gvSIG maven public HTTP repository</name>
28
			<url>http://devel.gvsig.org/m2repo/j2se</url>
29
			<releases>
30
				<enabled>true</enabled>
31
				<updatePolicy>daily</updatePolicy>
32
				<checksumPolicy>warn</checksumPolicy>
33
			</releases>
34
			<snapshots>
35
				<enabled>true</enabled>
36
				<updatePolicy>daily</updatePolicy>
37
				<checksumPolicy>warn</checksumPolicy>
38
			</snapshots>
39
		</repository>
40
	</repositories>
41

  
42
	<scm>
43
		<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118</connection>
44
		<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118</developerConnection>
45
		<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118</url>
46
	</scm>
47

  
48
	<build>
49
		<plugins>
50
			<plugin>
51
				<groupId>org.apache.maven.plugins</groupId>
52
				<artifactId>maven-release-plugin</artifactId>
53
				<configuration>
54
					<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/</tagBase>
55
					<goals>deploy</goals>
56
				</configuration>
57
			</plugin>
58
		</plugins>
59
	</build>
60

  
61
	<developers>
62
		<developer>
63
			<id>nbrodin</id>
64
			<name>Nacho Brodin</name>
65
			<email>nachobrodin@gmail.com</email>
66
			<roles>
67
				<role>Architect</role>
68
				<role>Developer</role>
69
			</roles>
70
		</developer>
71
	</developers>
72

  
73
	<dependencyManagement>
74
		<dependencies>
75
			<dependency>
76
				<groupId>org.gvsig</groupId>
77
				<artifactId>org.gvsig.raster</artifactId>
78
				<version>${org.gvsig.raster.version}</version>
79
				<type>pom</type>
80
				<scope>import</scope>
81
			</dependency>
82

  
83
			<dependency>
84
				<groupId>org.gvsig</groupId>
85
				<artifactId>org.gvsig.gdal</artifactId>
86
				<version>${org.gvsig.gdal.version}</version>
87
				<type>pom</type>
88
				<scope>import</scope>
89
			</dependency>
90

  
91
                        <dependency>
92
				<groupId>org.gvsig</groupId>
93
				<artifactId>org.gvsig.raster.gdal.app.common</artifactId>
94
				<version>2.2.14-SNAPSHOT</version>
95
				<type>zip</type>
96
			</dependency>
97

  
98
			<dependency>
99
				<groupId>org.gvsig</groupId>
100
				<artifactId>org.gvsig.raster.gdal.io</artifactId>
101
				<version>2.2.118</version>
102
			</dependency>
103

  
104
		</dependencies>
105
	</dependencyManagement>
106

  
107
	<modules>
108
		<module>org.gvsig.raster.gdal.io</module>
109
		<module>org.gvsig.raster.gdal.app</module>
110
	</modules>
111

  
112
</project>
113

  
0 114

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.io/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.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/GdalDataset.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.IOException;
25
import java.util.Arrays;
26
import java.util.Vector;
27

  
28
import org.gdal.gdal.Band;
29
import org.gdal.gdal.Dataset;
30
import org.gdal.gdal.Driver;
31
import org.gdal.gdal.gdal;
32
import org.gdal.ogr.ogr;
33
import org.gvsig.jgdal.GeoTransform.GeoTransformException;
34

  
35
import org.gvsig.jogr.OGRTools;
36
/**
37
 * Contiene las funcionalidades necesarias para el acceso a los elementos de un
38
 * dataset de gdal correspondiente a una imagen
39
 *
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
public class GdalDataset  {
43
	// CONSTANTES
44

  
45
	// GDALAccess
46
	public static int GA_ReadOnly   = 0;
47
	public static int GA_Update     = 1;
48

  
49
	// GDALDataType
50
	public static int GDT_Unknown   = 0;
51
	public static int GDT_Byte      = 1; // Buffer byte (8)
52
	public static int GDT_UInt16    = 2; // Buffer short (16)
53
	public static int GDT_Int16     = 3; // Buffer short (16)
54
	public static int GDT_UInt32    = 4; // Buffer int (32)
55
	public static int GDT_Int32     = 5; // Buffer int (32)
56
	public static int GDT_Float32   = 6; // Buffer float (32)
57
	public static int GDT_Float64   = 7; // Buffer double (64)
58
	public static int GDT_CInt16    = 8; // Buffer short (16)
59
	public static int GDT_CInt32    = 9; // Buffer int (32)
60
	public static int GDT_CFloat32  = 10; // Buffer float (32)
61
	public static int GDT_CFloat64  = 11; // Buffer double (64)
62
	public static int GDT_TypeCount = 12;
63

  
64
//	private String    pszFilename ;
65
	private Dataset dataset;
66

  
67
	/**
68
	 *Constructor generico
69
	 */
70
	public GdalDataset(){
71
		super();
72
	}
73

  
74
	public GdalDataset(Dataset dataset){
75
		super();
76
		this.dataset = dataset;
77
	}
78

  
79

  
80

  
81
	/**
82
	 * Abre el fichero de imagen.
83
	 *
84
	 * @param filename	Nombre del fichero.
85
	 * @param access	Apertura en solo lectura o escritura.
86
	 * @throws GdalException
87
            */
88
        public void open(String filename, int access) throws GdalException, IOException {
89
            if (filename == null) {
90
                throw new IllegalArgumentException("filename is null");
91
            }
92
            if ((access < 0) || (access > 1)) {
93
                throw new GdalException("Access type mistmatch (access="+access+").");
94
            }
95
            this.dataset = gdal.Open(filename, access);
96
            if (this.dataset == null) {
97
                throw new GdalException("Can't open file '" + filename + "'.");
98
            }
99
        }
100

  
101
	/**
102
	 * Obtiene un array de Strings con los metadatos
103
	 *
104
	 * @throws GdalException
105
	 * @return Array de Strings que corresponden a los metadatos que ofrece la imagen
106
	 */
107
	public String[] getMetadata()throws GdalException {
108
		return getMetadata(null);
109

  
110
	}
111

  
112

  
113
	/**
114
	 * Obtiene un array de Strings con los metadatos
115
	 *
116
	 * @throws GdalException
117
	 * @return Array de Strings que corresponden a los metadatos que ofrece la imagen
118
	 */
119
	@SuppressWarnings("unchecked")
120
    public String[] getMetadata(String domain)throws GdalException {
121
		@SuppressWarnings("rawtypes")
122
        Vector res = this.dataset.GetMetadata_List(domain);
123
		if(res == null)
124
			return new String[0];
125
		else
126
		    return OGRTools.safeVectorToStringArray(res);
127

  
128
	}
129

  
130
	/**
131
	 * Obtiene el n?mero de bandas de la imagen
132
	 *
133
	 * @throws GdalException
134
	 * @param hBand	Entero que corresponde al n?mero de banda que se quiere recuperar
135
	 * @return Objeto GdalRasterBand que representa la banda recuperada
136
	 */
137

  
138
	public GdalRasterBand getRasterBand(int hBand)throws GdalException {
139
		Band rb;
140

  
141
		if ((hBand < 1) || (hBand > getRasterCount()))
142
			throw new GdalException("Banda seleccionada incorrecta");
143

  
144
		if (this.dataset == null)
145
				throw new GdalException("No se ha podido acceder al archivo.");
146

  
147
		rb = this.dataset.GetRasterBand(hBand);
148

  
149
		return new GdalRasterBand(rb);
150
	}
151

  
152

  
153

  
154
	/**
155
	 * Obtiene la dimensi?n del raster en el eje X.
156
	 *
157
	 * @return	Devuelve un entero con la longitud de la imagen en el eje X en pixels.
158
	 */
159
	public int getRasterXSize() {
160
		return this.dataset.getRasterXSize();
161
	}
162

  
163

  
164
	/**
165
	 * Obtiene la dimensi?n del raster en el eje Y.
166
	 *
167
	 * @return	Devuelve un entero con la longitud de la imagen en el eje Y en pixels.
168
	 */
169
	public int getRasterYSize() {
170
		return this.dataset.getRasterYSize();
171
	}
172

  
173

  
174
	/**
175
	 * Obtiene el n?mero de bandas de la imagen
176
	 *
177
	 * @return	Devuelve un entero con el n?mero de bandas que contiene la imagen.
178
	 */
179
	public int getRasterCount() {
180
		return this.dataset.getRasterCount();
181
	}
182

  
183

  
184
	/**
185
	 * Obtiene el vector geoTransform de la imagen que contiene los valores Origen y pixelSize
186
	 *
187
	 * @return	Devuelve un vector de doubles que contiene los valores de coordenadas de origen y pixelSize.
188
	 * @throws GdalException
189
	 */
190
        public GeoTransform getGeoTransform() throws GdalException {
191
            GeoTransform gt = new GeoTransform();
192

  
193
            if (this.dataset == null) {
194
                throw new GdalException("No se ha podido acceder al archivo.");
195
            }
196

  
197
            this.dataset.GetGeoTransform(gt.adfgeotransform);
198
            if (gt.isIdentity()) {
199
                // The default transform is (0,1,0,0,0,1) and should be returned even when an error occurs,
200
                // such as for formats that don't support transformation to projection coordinates.
201
                // http://gdal.org/java/org/gdal/gdal/Dataset.html#GetGeoTransform%28double[]%29
202
                throw new GeoTransformException("Error en getGeoTransform(). No se han obtenido valores para geoTransform.");
203
            }
204

  
205
            return gt;
206
        }
207

  
208
	/**
209
	 * Obtiene el Nombre corto asociado al driver del dataset
210
	 *
211
	 * @return	Cadena con el nombre del driver
212
	 * @throws GdalException
213
	 */
214
	public String getDriverShortName()throws GdalException {
215
		if (this.dataset == null)
216
				throw new GdalException("No se ha podido acceder al archivo.");
217

  
218
		String shortName =this.dataset.GetDriver().getShortName();
219

  
220
		if(shortName == null)
221
			throw new GdalException("Error en getDriverShortName(). No ha podido obtenerse el driver");
222
		else
223
			return shortName;
224
	}
225

  
226
	/**
227
	 * A?ade el vector geoTransform a la imagen que contiene los valores Origen y pixelSize
228
	 *
229
	 * @return	Devuelve un vector de doubles que contiene los valores de coordenadas de origen y pixelSize.
230
	 * @throws GdalException
231
	 */
232
	public void setGeoTransform(GeoTransform gt)throws GdalException {
233
		if (this.dataset == null)
234
				throw new GdalException("No se ha podido acceder al archivo.");
235
		if (gt == null)
236
			throw new GdalException("el objeto es null");
237

  
238
		@SuppressWarnings("unused")
239
        int res = this.dataset.SetGeoTransform(gt.adfgeotransform);
240
	}
241

  
242
	/**
243
	 * Obtiene el sistema de coordenadas de referencia de la imagen.
244
	 *
245
	 * @return	Devuelve un String con los datos del sistema de coordenadas de referencia.
246
	 * @throws GdalException
247
	 */
248
	public String getProjectionRef()throws GdalException {
249
		if (this.dataset == null)
250
				throw new GdalException("No se ha podido acceder al archivo.");
251

  
252
		String res = this.dataset.GetProjectionRef();
253

  
254
		if(res == null)return new String("");
255
		else return res;
256
	}
257

  
258
	/**
259
	 * Cierra el fichero de imagen.
260
	 *
261
	 * @throws GdalException
262
	 */
263
	public void close()throws GdalException {
264
//		if (cPtr == 0)
265
//				throw new GdalException("No se ha podido acceder al archivo.");
266
//
267
//		closeNat(cPtr);
268
		this.dataset.delete();
269
	}
270

  
271
	/**
272
	 * Obtiene un driver a trav?s de su nombre
273
	 *
274
	 * @param name	Nombre del driver
275
	 */
276
	public static GdalDriver getDriverByName(String name)throws GdalException {
277

  
278
		if (name == null)
279
			throw new GdalException("El nombre del driver es null");
280
		gdal.AllRegister();
281
		ogr.RegisterAll();
282
		Driver ptrdrv = gdal.GetDriverByName(name);
283

  
284
		return new GdalDriver(ptrdrv);
285
	}
286

  
287

  
288
	/**
289
	 * Obtiene el numero de bandas de la imagen
290
	 *
291
	 * @return	Devuelve un entero con el numero de bandas que contiene la imagen.
292
	 * @throws GdalException
293
	 */
294
	public int getGCPCount()throws GdalException {
295
//		String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito";
296
//		String msg2="Error en el conteo de n?mero de bandas";
297
		return this.dataset.GetGCPCount();
298
	}
299

  
300
	public Dataset getDataset(){
301
		return this.dataset;
302
	}
303

  
304
	/**
305
	 *Asigna la proyecci?n especificada en la cadena que se le pasa por par?metro.
306
	 *@param proj	proyecci?n
307
	 *@throws GdalException
308
	 */
309
	public void setProjection(String proj)throws GdalException {
310
		if (this.dataset == null)
311
				throw new GdalException("No se ha podido acceder al archivo.");
312
		if (proj == null)
313
				throw new GdalException("La proyeccion es null");
314

  
315
		int res = this.dataset.SetProjection(proj);
316

  
317
		if(res < 0)
318
			throw new GdalException("Error en setProjection(). No se ha podido asignar la proyecci?n.");
319
	}
320

  
321
	/**
322
	 * Obtiene la cadena que representa el tipo de banda de color. Los tipos posibles son:
323
	 * <UL>
324
	 *  <LI>0 = "Undefined" </LI>
325
	 *  <LI>1 = "Gray";</LI>
326
	 *  <LI>2 = "Palette";</LI>
327
	 *  <LI>3 = "Red";</LI>
328
	 *  <LI>4 = "Green";</LI>
329
	 *  <LI>5 = "Blue";</LI>
330
	 *  <LI>6 = "Alpha";</LI>
331
	 *  <LI>7 = "Hue";</LI>
332
	 *  <LI>8 = "Saturation";</LI>
333
	 *  <LI>9 = "Lightness";</LI>
334
	 *  <LI>10 = "Cyan";</LI>
335
	 *  <LI>11 = "Magenta";</LI>
336
	 *  <LI>12 = "Yellow";</LI>
337
	 *  <LI>13 = "Black";</LI>
338
	 *  <LI>14 = "YCbCr_Y";</LI>
339
	 *  <LI>15 = "YCbCr_Cb";</LI>
340
	 *  <LI>16 = "YCbCr_Cr";</LI>
341
	 * </UL>
342
	 * @return	Cadena con el nombre del tipo de banda de color
343
	 * @throws GdalException
344
	 */
345
	public String getColorInterpretationName(int colorInterp)throws GdalException {
346
		if ((colorInterp < 0) || (colorInterp > 16))
347
			throw new GdalException("Valor de interpretacion de color fuera de rango");
348

  
349
		String bandTypeName = gdal.GetColorInterpretationName(colorInterp);
350

  
351
		if(bandTypeName == null)
352
			throw new GdalException("Error en getColorInterpretationName(). No ha podido obtenerse el tipo de banda de color");
353
		else
354
			return bandTypeName;
355
	}
356

  
357
}
0 358

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.io/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
import java.util.Vector;
26

  
27
import org.gdal.gdal.Band;
28
import org.gdal.gdal.ColorTable;
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

  
32
/**
33
 * Representa a una banda simple de la im�gen o canal.
34
 *
35
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
36
 * @version 0.0
37
 * @link http://www.gvsig.gva.es
38
 */
39

  
40
public class GdalRasterBand {
41

  
42
	public static final Logger logger = LoggerFactory.getLogger(GdalRasterBand.class);
43

  
44
	private boolean hasNoDataValue = false;
45

  
46
    private Band band;
47

  
48
	 public GdalRasterBand(Band band) {
49
		 this.band = band;
50
	 }
51

  
52
	 /**
53
	  * Lee datos de la banda de la imagen
54
	  *
55
	  * @return	Devuelve un vector de bytes con el trozo de raster le�do.
56
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
57
	  * de la banda accedida.
58
	  * @param nYOff	El desplazamiento de l�nea desde la esquina superior derecha
59
	  * de la banda accedida.
60
	  * @param nXSize	Ancho de la regi�n en pixels de la banda que ser� accedida
61
	  * @param nYSize	Altura de la regi�n en l�neas de la banda que ser� accedida
62
	  * @param bufXSize	Ancho del buffer donde la regi�n de la im�gen ser� guardada
63
	  * @param bufYSize	Altura del buffer donde la regi�n de la im�gen ser� guardada
64
	  * En caso de que bufXSize o bufYSize sean menores que 1, pasan a tener el mismo valor que
65
	  * nXSize y nYSize respectivamente para evitar buffers con tama?o 0.
66
	  * @param eBufType
67
	  */
68

  
69
	 public GdalBuffer readRaster(int nXOff, int nYOff, int nXSize, int nYSize,
70
			 int bufXSize, int bufYSize,
71
			 int eBufType)throws GdalException {
72

  
73
		 if ((nXOff<0) || (nXOff > getRasterBandXSize()) || (nYOff < 0) || (nYOff > getRasterBandYSize()))
74
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
75

  
76
		 if ((nXSize < 1) || (nXSize > getRasterBandXSize()) || (nYSize<1) || (nYSize > getRasterBandYSize()))
77
			 throw new GdalException("Tama?o de ventana incorrecto.");
78

  
79
		 if (((nXSize + nXOff) > (getRasterBandXSize())) || ((nYSize + nYOff) > (getRasterBandYSize()))){
80
			 throw new GdalException("Posicion de la ventana incorrecta.");
81
		 }
82

  
83
		 if ((eBufType < 1) || (eBufType > 11))
84
			 throw new GdalException("Tipo de datos incorrecto.");
85

  
86
		 if (bufXSize < 1)
87
			 bufXSize = nXSize;
88

  
89
		 if (bufYSize < 1)
90
			 bufYSize = nYSize;
91

  
92
		 GdalBuffer buf = new GdalBuffer();
93
		 int i = 0;
94

  
95
		 switch(eBufType) {
96
		 case 0:
97
			 i = 0;
98
			 break;
99
		 case 1:
100
			 buf.reservaByte(bufXSize * bufYSize);
101
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffByte);
102
			 break;
103
		 case 2:
104
		 case 3:
105
		 case 8:
106
			 buf.reservaShort(bufXSize * bufYSize);
107
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffShort);
108
			 break;
109
		 case 4:
110
		 case 5:
111
		 case 9:
112
			 buf.reservaInt(bufXSize * bufYSize);
113
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffInt);
114
			 break;
115
		 case 6:
116
		 case 10:
117
			 buf.reservaFloat(bufXSize * bufYSize);
118
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffFloat);
119
			 break;
120
		 case 7:
121
		 case 11:
122
			 buf.reservaDouble(bufXSize * bufYSize);
123
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffDouble);
124
			 break;
125
		 case 12:
126
			 i = 0;
127
			 break;
128
		 }
129

  
130

  
131
		 if(i>=0)
132
			 return buf;
133
		 else
134
			 return null;
135
	 }
136

  
137
	 /**
138
	  * Escribe datos en la banda de la imagen
139
	  *
140
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
141
	  * de la banda accedida.
142
	  * @param nYOff	El desplazamiento de l�nea desde la esquina superior derecha
143
	  * de la banda accedida.
144
	  * @param nXSize	Ancho de la regi�n en pixels de la banda que ser� accedida
145
	  * @param nYSize	Altura de la regi�n en l�neas de la banda que ser� accedida
146
	  * @param BufXSize	Ancho del buffer donde la regi�n de la im�gen ser� guardada
147
	  * @param BufYSize	Altura del buffer donde la regi�n de la im�gen ser� guardada
148
	  * @param eBufType
149
	  */
150

  
151
	 public void writeRaster(int nXOff, int nYOff, int nXSize, int nYSize, GdalBuffer buf, int eBufType)throws GdalException {
152
		 GdalBuffer buffer = new GdalBuffer();
153

  
154
		 if ((nXOff < 0) || (nXOff > getRasterBandXSize()) || (nYOff < 0) || (nYOff > getRasterBandYSize()))
155
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
156

  
157
		 if ((nXSize < 1) || (nXSize > getRasterBandXSize()) || (nYSize < 1) || (nYSize > getRasterBandYSize()))
158
			 throw new GdalException("Tama?o de ventana incorrecto.");
159

  
160
		 if (((nXSize + nXOff) > (getRasterBandXSize())) || ((nYSize + nYOff) > (getRasterBandYSize())))
161
			 throw new GdalException("Posicion de la ventana incorrecta.");
162

  
163
		 if ((eBufType < 1) || (eBufType > 11))
164
			 throw new GdalException("Tipo de datos incorrecto.");
165

  
166
		 if (buf == null)
167
			 throw new GdalException("Buffer incorrecto");
168

  
169
		 switch(eBufType) {
170
		 case 0:
171
			 return;
172
		 case 1:
173
			 buffer.buffByte = buf.buffByte;
174
			 break;
175
		 case 2:
176
		 case 3:
177
		 case 8:
178
			 buffer.buffShort = buf.buffShort;
179
			 break;
180
		 case 4:
181
		 case 5:
182
		 case 9:
183
			 buffer.buffInt = buf.buffInt;
184
			 break;
185
		 case 6:
186
		 case 10:
187
			 buffer.buffFloat = buf.buffFloat;
188
			 break;
189
		 case 7:
190
		 case 11:
191
			 buffer.buffDouble = buf.buffDouble;
192
			 break;
193
		 case 12:
194
			 return;
195
		 }
196

  
197

  
198

  
199
		 switch(eBufType) {
200
		 case 0:
201
			 break;
202
		 case 1:
203
			 this.band.WriteRaster(nXOff, nYOff, nXSize, nYSize, eBufType, buffer.buffByte);
204
			 break;
205
		 case 2:
206
		 case 3:
207
		 case 8:
208
			 this.band.WriteRaster(nXOff, nYOff, nXSize, nYSize, eBufType, buffer.buffShort);
209
			 break;
210
		 case 4:
211
		 case 5:
212
		 case 9:
213
			 this.band.WriteRaster(nXOff, nYOff, nXSize, nYSize, eBufType, buffer.buffInt);
214
			 break;
215
		 case 6:
216
		 case 10:
217
			 this.band.WriteRaster(nXOff, nYOff, nXSize, nYSize, eBufType, buffer.buffFloat);
218
			 break;
219
		 case 7:
220
		 case 11:
221
			 this.band.WriteRaster(nXOff, nYOff, nXSize, nYSize, eBufType, buffer.buffDouble);
222
			 break;
223
		 case 12:
224
			 break;
225
		 }
226
	 }
227

  
228
	 /**
229
	  *Obtiene el tama�o en pixeles de la im�gen en el eje de las X
230
	  *@return Tama�o en pixeles del eje X
231
	  *@throws GdalException
232
	  */
233

  
234
	 public int getRasterBandXSize()throws GdalException {
235
		 return this.band.GetXSize();
236
	 }
237

  
238
	 /**
239
	  *Obtiene el tama?o en pixeles de la im?gen en el eje de las Y
240
	  *@return Tama�o en pixeles del eje Y
241
	  *@throws GdalException
242
	  */
243

  
244
	 public int getRasterBandYSize()throws GdalException {
245
		 return this.band.GetYSize();
246
	 }
247

  
248

  
249
	 /**
250
	  * Devuelve el n�mero de overviews que contiene la banda.
251
	  * @return N�mero de overviews
252
	  * @throws GdalException
253
	  */
254

  
255
	 public int getOverviewCount()throws GdalException {
256
		 return this.band.GetOverviewCount();
257
	 }
258

  
259

  
260
	 /**
261
	  * Obtiene el overview indicado por el �ndice "i".
262
	  *
263
	  * @param i	indice del overview que se quiere recuperar.
264
	  * @return GdalRasterBand	Banda correspondiente al overview selecccionado
265
	  * @throws GdalException
266
	  */
267

  
268
	 public GdalRasterBand getOverview(int i)throws GdalException {
269
		 Band band_ov;
270

  
271
		 if((i < 0) || (i >= getOverviewCount()))
272
			 throw new GdalException("El overview seleccionado no existe");
273

  
274
		 band_ov = this.band.GetOverview(i);
275

  
276
		 if (band_ov == null || !(band_ov instanceof Band))
277
			 throw new GdalException("No se ha podido obtener el overview");
278

  
279
		 return new GdalRasterBand(band_ov);
280
	 }
281

  
282

  
283
	 /**
284
	  * Devuelve el tama�o en X del bloque para esa banda
285
	  * @return Tama�o en pixeles del bloque en el eje X
286
	  * @throws GdalException
287
	  */
288

  
289
	 public int getBlockXSize()throws GdalException {
290
		 return this.band.GetBlockXSize();
291
	 }
292

  
293

  
294
	 /**
295
	  * Devuelve el tama�o en Y del bloque para esa banda
296
	  * @return Tama�o en pixeles del bloque en el eje Y
297
	  * @throws GdalException
298
	  */
299

  
300
	 public int getBlockYSize()throws GdalException {
301
		 return this.band.GetBlockYSize();
302
	 }
303

  
304
	 /**
305
	  * Devuelve el tipo de datos de la banda
306
	  * @return Tama�o en pixeles del bloque en el eje Y
307
	  * @throws GdalException
308
	  */
309

  
310
	 public int getRasterDataType()throws GdalException {
311
		 return this.band.getDataType();
312
	 }
313

  
314
	 /**
315
	  * Obtiene la tabla de color asociada a la imagen
316
	  */
317
	 public GdalColorTable getRasterColorTable()throws GdalException {
318
		 ColorTable ct = this.band.GetColorTable();
319

  
320
		 if ((ct == null)) {
321
			 return null;
322
		 }
323

  
324
		 return new GdalColorTable(ct);
325
	 }
326

  
327
	 /**
328
	  * Lee datos de la banda de la im�gen con una paleta asociada
329
	  *
330
	  * @return	Devuelve un vector de bytes con el trozo de raster le�do.
331
	  * @param nXOff	El desplazamiento del pixel desde la esquina superior derecha
332
	  * de la banda accedida.
333
	  * @param nYOff	El desplazamiento de l�nea desde la esquina superior derecha
334
	  * de la banda accedida.
335
	  * @param nXSize	Ancho de la regi�n en pixels de la banda que ser� accedida
336
	  * @param nYSize	Altura de la regi�n en l�neas de la banda que ser� accedida
337
	  * @param BufXSize	Ancho del buffer donde la regi�n de la im�gen ser� guardada
338
	  * @param BufYSize	Altura del buffer donde la regi�n de la im�gen ser� guardada
339
	  * En caso de que bufXSize o bufYSize sean menores que 1, pasan a tener el mismo valor que
340
	  * nXSize y nYSize respectivamente para evitar buffers con tama?o 0.
341
	  * @param eBufType
342
	  */
343

  
344
	 public GdalBuffer readRasterWithPalette(int nXOff, int nYOff, int nXSize, int nYSize,
345
			 int bufXSize, int bufYSize,
346
			 int eBufType)throws GdalException {
347

  
348
		 if ((nXOff<0) || (nXOff > getRasterBandXSize()) || (nYOff < 0) || (nYOff > getRasterBandYSize()))
349
			 throw new GdalException("Desplazamiento de la ventana fuera de rango.");
350

  
351
		 if ((nXSize < 1) || (nXSize > getRasterBandXSize()) || (nYSize < 1) || (nYSize > getRasterBandYSize()))
352
			 throw new GdalException("Tama?o de ventana incorrecto.");
353

  
354
		 if (((nXSize + nXOff) > (getRasterBandXSize())) || ((nYSize + nYOff) > (getRasterBandYSize())))
355
			 throw new GdalException("Posicion de la ventana incorrecta.");
356

  
357
		 if ((eBufType < 1) || (eBufType > 11))
358
			 throw new GdalException("Tipo de datos incorrecto.");
359

  
360
		 if (bufXSize < 1)
361
			 bufXSize = nXSize;
362

  
363
		 if (bufYSize < 1)
364
			 bufYSize = nYSize;
365

  
366

  
367
		 GdalBuffer buf = new GdalBuffer();
368
		 int i = 0;
369

  
370
		 switch(eBufType) {
371
		 case 0:
372
			 i = 0;
373
			 break;
374
		 case 1:
375
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffByte);
376
			 break;
377
		 case 2:
378
		 case 3:
379
		 case 8:
380
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffShort);
381
			 break;
382
		 case 4:
383
		 case 5:
384
		 case 9:
385
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffInt);
386
			 break;
387
		 case 6:
388
		 case 10:
389
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffFloat);
390
			 break;
391
		 case 7:
392
		 case 11:
393
			 i = this.band.ReadRaster(nXOff, nYOff, nXSize, nYSize, bufXSize, bufYSize, eBufType, buf.buffDouble);
394
			 break;
395
		 case 12:
396
			 i = 0;
397
			 break;
398
		 }
399

  
400

  
401
		 if(i>0)
402
			 return buf;
403
		 else
404
			 return null;
405
	 }
406

  
407
	 /**
408
	  *Devuelve el valor de NoData
409
	  */
410
	 public double getRasterNoDataValue()throws GdalException {
411

  
412
		 Double[] aux = new Double[1];
413
		 this.band.GetNoDataValue(aux);
414
		 return aux[0];
415
	 }
416

  
417
	 /**
418
	  * Obtiene el valorDevuelve el valor de NoData
419
	  */
420
	 public boolean existsNoDataValue()throws GdalException {
421
			 return this.hasNoDataValue  ;
422
	 }
423

  
424
	 public void setRasterNoDataValue(double val){
425
		 this.hasNoDataValue = true;
426

  
427
		 this.band.SetNoDataValue(val);
428
	 }
429

  
430
	 /**
431
	  * Obtiene un array de Strings con los metadatos
432
	  *
433
	  * @throws GdalException
434
	  * @return Array de Strings que corresponden a los metadatos que ofrece la im�gen
435
	  */
436

  
437
	 public String[] getMetadata()throws GdalException {
438

  
439
		 @SuppressWarnings("unchecked")
440
         Vector<String> aux = this.band.GetMetadata_List();
441
		 String[] res =  aux.toArray(new String[0]);
442
		 if(res == null)
443
			 return new String[0];
444
		 else return res;
445
	 }
446

  
447
	 /**
448
	  * Obtiene identificador que representa el tipo de banda de color.
449
	  * @return	identificador del tipo de banda de color
450
	  * @throws GdalException
451
	  */
452

  
453
	 public int getRasterColorInterpretation()throws GdalException {
454

  
455
		 int bandType = this.band.GetColorInterpretation();
456
		 return bandType;
457
	 }
458

  
459

  
460
	 /**
461
	  * Asigna la interpretaci?n de color de la banda.
462
	  * Con algunos formatos no es posible modificar la interpretaci?n de color,
463
	  * tales como tiff y jpg. En el caso de tif, no hay error pero tampoco se
464
	  * produce el cambio en la interpretaci?n. En el caso de jpg, gdal lanza un error.
465
	  * 0 = "Undefined"
466
	  * 1 = "Gray";
467
	  * 2 = "Palette";
468
	  * 3 = "Red";
469
	  * 4 = "Green";
470
	  * 5 = "Blue";
471
	  * 6 = "Alpha";
472
	  * 7 = "Hue";
473
	  * 8 = "Saturation";
474
	  * 9 = "Lightness";
475
	  * 10 = "Cyan";
476
	  * 11 = "Magenta";
477
	  * 12 = "Yellow";
478
	  * 13 = "Black";
479
	  * 14 = "YCbCr_Y";
480
	  * 15 = "YCbCr_Cb";
481
	  * 16 = "YCbCr_Cr";
482
	  * @param bandType
483
	  * @throws GdalException
484
	  */
485
	 public void setRasterColorInterpretation(int bandType) throws GdalException{
486

  
487
		 if ((bandType < 0) || (bandType > 16)){
488
			 throw new GdalException("Tipo de banda incorrecto");
489
		 }
490

  
491
		 @SuppressWarnings("unused")
492
         int err = this.band.SetColorInterpretation(bandType);
493

  
494
	 }
495

  
496
}
0 497

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/GdalColorTable.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.awt.Color;
25

  
26
import org.gdal.gdal.ColorTable;
27

  
28
public class GdalColorTable {
29

  
30

  
31
    private ColorTable ct;
32

  
33
    /**
34
     *
35
     */
36
    public GdalColorTable(ColorTable ct) {
37
        this.ct = ct;
38
    }
39

  
40
	public int getColorEntryCount() throws GdalException{
41
		return this.ct.GetCount();
42
	}
43

  
44
	public GdalColorEntry getColorEntryAsRGB(int pos) throws GdalException{
45

  
46
		if ((pos < 0) || (pos >= getColorEntryCount()))
47
			throw new GdalException("Entrada de la tabla de color fuera de rango");
48

  
49
		GdalColorEntry entry = new GdalColorEntry();
50
		Color values =  this.ct.GetColorEntry(pos);
51
		if(values == null)
52
		    throw new GdalException("Error en getColorEntryAsRGB(). Posici?n de la tabla de color inexistente.");
53
		entry.c1 =  (short) values.getRed();
54
		entry.c2 =  (short) values.getGreen();
55
		entry.c3 =  (short) values.getBlue();
56
		entry.c4 =  (short) values.getAlpha();
57
		return entry;
58
	}
59

  
60
}
0 61

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.118/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/GdalBuffer.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
/**  
27
 * 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.
28
 * 
29
 * @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff