Revision 9167

View differences:

org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/buildNumber.properties
1
#Tue Jan 15 10:01:58 CET 2019
2
buildNumber=130
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77/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.77/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.77/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.77/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.77</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>
0 86

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77/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.77</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.77/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.77</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.234</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.59</org.gvsig.gdal.version>
21
		<org.gvsig.raster.version>2.2.88</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.77</connection>
44
		<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77</developerConnection>
45
		<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77</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.77</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.77/org.gvsig.raster.gdal.io/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.raster.gdal.io</artifactId>
5
    <packaging>jar</packaging>
6
    <name>${project.artifactId}</name>
7
    <parent>
8
        <groupId>org.gvsig</groupId>
9
        <artifactId>org.gvsig.raster.gdal</artifactId>
10
        <version>2.2.77</version>
11
    </parent>
12
	
13
    <dependencies>
14
        <dependency>
15
            <groupId>org.gdal</groupId>
16
            <artifactId>gdal</artifactId>
17
            <scope>compile</scope>
18
        </dependency>
19
        <dependency>
20
            <groupId>org.gvsig</groupId>
21
            <artifactId>org.gvsig.raster.cache.lib.api</artifactId>
22
            <scope>compile</scope>
23
        </dependency>
24
        <dependency>
25
            <groupId>org.gvsig</groupId>
26
            <artifactId>org.gvsig.raster.lib.api</artifactId>
27
            <scope>compile</scope>
28
        </dependency>
29
        <dependency>
30
            <groupId>org.gvsig</groupId>
31
            <artifactId>org.gvsig.raster.lib.impl</artifactId>
32
            <scope>compile</scope>
33
        </dependency>
34
        <dependency>
35
            <groupId>org.gvsig</groupId>
36
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
37
            <scope>compile</scope>
38
        </dependency>
39
        <dependency>
40
            <groupId>org.gvsig</groupId>
41
            <artifactId>org.gvsig.remoteclient</artifactId>
42
            <scope>compile</scope>
43
        </dependency>
44
        <dependency>
45
            <groupId>org.gvsig</groupId>
46
            <artifactId>org.gvsig.tools.lib</artifactId>
47
            <scope>compile</scope>
48
        </dependency>
49
        <dependency>
50
            <groupId>org.gvsig</groupId>
51
            <artifactId>org.gvsig.projection.api</artifactId>
52
            <scope>compile</scope>
53
        </dependency>
54
        <dependency>
55
            <groupId>org.gvsig</groupId>
56
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
57
            <scope>runtime</scope>
58
        </dependency>
59
        <dependency>
60
            <groupId>org.gvsig</groupId>
61
            <artifactId>org.gvsig.compat.api</artifactId>
62
            <scope>compile</scope>
63
        </dependency>
64
        <dependency>
65
            <groupId>org.gvsig</groupId>
66
            <artifactId>org.gvsig.compat.se</artifactId>
67
            <scope>runtime</scope>
68
        </dependency>
69
        <dependency>
70
            <groupId>org.gvsig</groupId>
71
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
72
            <scope>compile</scope>
73
        </dependency>
74
        <dependency>
75
            <groupId>org.gvsig</groupId>
76
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
77
            <scope>runtime</scope>
78
        </dependency>
79
        <dependency>
80
            <groupId>org.gvsig</groupId>
81
            <artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
82
            <scope>compile</scope>
83
        </dependency>
84
        <dependency>
85
            <groupId>org.gvsig</groupId>
86
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
87
            <scope>compile</scope>
88
        </dependency>
89
        <dependency>
90
            <groupId>org.gvsig</groupId>
91
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
92
            <scope>compile</scope>
93
        </dependency>
94

  
95
    </dependencies>
96

  
97

  
98
</project>
0 99

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

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

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

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

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

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

  
25
import org.gdal.gdal.Dataset;
26
import org.gdal.gdal.gdal;
27

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

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

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

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

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

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

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

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

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

  
32

  
33
public class WritingException extends Exception {
34

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

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalNewRasterStoreParameters.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.io;
23

  
24
import org.gvsig.raster.impl.store.AbstractNewRasterStoreParameters;
25

  
26
/**
27
 * Parameters for creating a Gdal store
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public class GdalNewRasterStoreParameters extends AbstractNewRasterStoreParameters {
31

  
32
	public String getDataStoreName() {
33
		return GdalProvider.NAME;
34
	}
35

  
36
	public String getDescription() {
37
		return GdalProvider.DESCRIPTION;
38
	}
39

  
40
}
0 41

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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.raster.gdal.io;
29

  
30
import java.awt.geom.AffineTransform;
31
import java.io.File;
32
import java.io.FileInputStream;
33
import java.io.IOException;
34

  
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataManager;
37
import org.gvsig.fmap.dal.DataServerExplorer;
38
import org.gvsig.fmap.dal.DataStoreParameters;
39
import org.gvsig.fmap.dal.NewDataStoreParameters;
40
import org.gvsig.fmap.dal.coverage.RasterLocator;
41
import org.gvsig.fmap.dal.coverage.datastruct.Params;
42
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
43
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
44
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
45
import org.gvsig.fmap.dal.coverage.store.DataServerWriter;
46
import org.gvsig.fmap.dal.coverage.store.RasterWriter;
47
import org.gvsig.fmap.dal.coverage.store.parameter.NewRasterStoreParameters;
48
import org.gvsig.fmap.dal.exception.CreateException;
49
import org.gvsig.fmap.dal.exception.DataException;
50
import org.gvsig.fmap.dal.exception.RemoveException;
51
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
52
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
53
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
54
import org.gvsig.tools.locator.LocatorException;
55

  
56
public class GdalFilesystemServerExplorer extends AbstractFilesystemServerExplorerProvider {
57
	
58
	public boolean canCreate() {
59
		return false;
60
	}
61

  
62
	public boolean canCreate(NewDataStoreParameters parameters) {
63
		return false;
64
	}
65

  
66
	public void create(NewDataStoreParameters parameters, boolean overwrite)
67
			throws CreateException {
68
		NewRasterStoreParameters p = null;
69
		if(parameters instanceof NewRasterStoreParameters)
70
			 p = (NewRasterStoreParameters)parameters;
71
		
72
		DataServerWriter dataWriter = p.getDataServer();
73
		if(dataWriter == null)
74
			dataWriter = RasterLocator.getManager().createDataServerWriter();
75
		
76
		dataWriter.setBuffer(p.getBuffer(), p.getBand());
77
		Params params;
78
		try {
79
			if(p.getDriverParams() != null)
80
				params = p.getDriverParams();
81
			else
82
				params = RasterLocator.getManager().createWriter(p.getFileName()).getParams();
83
			
84
			AffineTransform affineTransform = p.getAffineTransform();
85
			if(affineTransform == null) {
86
				if(p.getBuffer().getDataExtent() != null) {
87
					double x = p.getBuffer().getDataExtent().getMinX();
88
					double y = p.getBuffer().getDataExtent().getMaxY();
89
					double pixelSizeX = p.getBuffer().getDataExtent().getWidth() / p.getBuffer().getWidth();
90
					double pixelSizeY = p.getBuffer().getDataExtent().getHeight() / p.getBuffer().getHeight();
91
					affineTransform = new AffineTransform(pixelSizeX, 0, 0, -pixelSizeY, x, y);
92
				} else {
93
					affineTransform = new AffineTransform();
94
				}
95
			}
96
			
97
			RasterWriter writer = RasterLocator.getManager().createWriter(
98
					dataWriter, 
99
					p.getPath() + File.separator + p.getFileName(),
100
					p.getBand() < 0 ? p.getBuffer().getBandCount() : 1, 
101
					affineTransform, 
102
					p.getBuffer().getWidth(),
103
					p.getBuffer().getHeight(), 
104
					p.getBuffer().getDataType(), 
105
					params, 
106
					null);
107
			if(p.getColorInterpretation() != null)
108
				writer.setColorBandsInterpretation(p.getColorInterpretation());
109
			writer.setWkt(p.getWktProjection());
110
			
111
			writer.dataWrite();
112
			writer.writeClose();
113
		} catch (LocatorException e) {
114
			throw new CreateException("", e);
115
		} catch (NotSupportedExtensionException e) {
116
			throw new CreateException("", e);
117
		} catch (RasterDriverException e) {
118
			throw new CreateException("", e);
119
		} catch (ProcessInterruptedException e) {
120
			//Fin del proceso
121
		} catch (IOException e) {
122
			throw new CreateException("", e);
123
		}
124
	}
125

  
126
	public NewDataStoreParameters getCreateParameters() throws DataException {
127
		return new GdalNewRasterStoreParameters();
128
	}
129

  
130
	public void initialize(FilesystemServerExplorerProviderServices serverExplorer) {
131
	}
132
	
133
	public void remove(DataStoreParameters parameters) throws RemoveException {
134
		throw new UnsupportedOperationException();
135
	}
136

  
137
	public String getDataStoreProviderName() {
138
		return GdalProvider.NAME;
139
	}
140

  
141
	public boolean accept(File pathname) {
142
		if (pathname.getParentFile() != null && 
143
			pathname.getParentFile().getName().equals("cellhd")) {
144
			if (pathname.getName().endsWith(".rmf")
145
					|| pathname.getName().endsWith(".rmf~")) {
146
				return false;
147
			}
148
			return true;
149
		}
150

  
151
		// Comprobamos que no sea un rmf propio, osea, que contenga xml
152
		if (pathname.getName().toLowerCase().endsWith(".rmf")) {
153
			FileInputStream reader = null;
154
			try {
155
				reader = new FileInputStream(pathname);
156
				String xml = "";
157
				for (int i = 0; i < 6; i++) {
158
					xml += (char) reader.read();
159
				}
160
				if (xml.equals("<?xml ")) {
161
					return false;
162
				}
163
			} catch (Exception e) {
164
			} finally {
165
				try {
166
					reader.close();
167
				} catch (Exception e) {
168
				}
169
			}
170
		}
171
		return RasterLocator.getManager().getProviderServices().isExtensionSupported(
172
				pathname.getAbsolutePath(), 
173
				GdalProvider.class);
174
	}
175

  
176
	public String getDescription() {
177
		return GdalProvider.DESCRIPTION;
178
	}
179

  
180
	public DataStoreParameters getParameters(File file) throws DataException {
181
		DataManager manager = DALLocator.getDataManager();
182
		AbstractRasterFileDataParameters params = (AbstractRasterFileDataParameters) manager
183
				.createStoreParameters(this.getDataStoreProviderName());
184
		params.setFile(file);
185
		return params;
186
	}
187
	
188
	public int getMode() {
189
		return DataServerExplorer.MODE_RASTER;
190
	}
191

  
192
}
0 193

  
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.77/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalWriter.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.io;
23

  
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.Point2D;
26
import java.io.File;
27
import java.io.IOException;
28
import java.sql.Savepoint;
29
import java.util.ArrayList;
30

  
31
import org.apache.commons.io.FileUtils;
32
import org.apache.commons.io.FilenameUtils;
33
import org.cresques.cts.ICRSFactory;
34
import org.cresques.cts.IProjection;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
import org.gvsig.fmap.dal.coverage.RasterLibrary;
39
import org.gvsig.fmap.dal.coverage.RasterLocator;
40
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
41
import org.gvsig.fmap.dal.coverage.datastruct.Params;
42
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
43
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
44
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
45
import org.gvsig.fmap.dal.coverage.store.DataServerWriter;
46
import org.gvsig.jgdal.GdalBuffer;
47
import org.gvsig.jgdal.GdalDataset;
48
import org.gvsig.jgdal.GdalDriver;
49
import org.gvsig.jgdal.GdalException;
50
import org.gvsig.jgdal.GdalRasterBand;
51
import org.gvsig.jgdal.GeoTransform;
52
import org.gvsig.raster.gdal.io.features.BMPFeatures;
53
import org.gvsig.raster.gdal.io.features.GTiffFeatures;
54
import org.gvsig.raster.gdal.io.features.HFAFeatures;
55
import org.gvsig.raster.gdal.io.features.IDRISIFeatures;
56
import org.gvsig.raster.gdal.io.features.ILWIS_MprFeatures;
57
import org.gvsig.raster.gdal.io.features.Jpeg2000Features;
58
import org.gvsig.raster.gdal.io.features.PNM_PgmFeatures;
59
import org.gvsig.raster.gdal.io.features.PNM_PpmFeatures;
60
import org.gvsig.raster.impl.buffer.DefaultDataServerWriter;
61
import org.gvsig.raster.impl.buffer.RasterBuffer;
62
import org.gvsig.raster.impl.process.RasterTask;
63
import org.gvsig.raster.impl.process.RasterTaskQueue;
64
import org.gvsig.raster.impl.store.ParamImpl;
65
import org.gvsig.raster.impl.store.ParamsImpl;
66
import org.gvsig.raster.impl.store.WriteFileFormatFeatures;
67
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
68
import org.gvsig.raster.impl.store.writer.DefaultRasterWriter;
69
import org.gvsig.raster.util.DefaultProviderServices;
70
import org.gvsig.tools.ToolsLocator;
71
import org.gvsig.tools.extensionpoint.ExtensionPoint;
72
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
73

  
74

  
75
/**
76
 * Driver para la escritura a trav?s de Gdal.
77
 * Puede exportar un fichero de un formato a otro desde un GeoRasterFile
78
 * en cualquier formato soportado por la lectura a un formato que este incluido
79
 * en la lista supportedDrv.
80
 *
81
 * Puede salvar a disco en un formato que este incluido en la lista supportedDrv
82
 * obteniendo los datos que van siendo servidos desde el cliente. Este cliente
83
 * debe implementar un DataServerWriter o tener un objeto que lo implemente. Inicialmente
84
 * le pasar? los par?metros de la imagen de salida y cuando el driver comience a
85
 * escribir le ir? solicitando m?s a trav?s del m?todo readData de DataServerWriter.
86
 * El cliente ser? el que lleve el control de lo que va sirviendo y lo que le queda
87
 * por servir.
88
 * @author Nacho Brodin (nachobrodin@gmail.com)
89
 */
90
public class GdalWriter extends DefaultRasterWriter {
91

  
92
    private static final Logger logger = LoggerFactory.getLogger(GdalWriter.class);
93

  
94
	/**
95
	 *
96
	 */
97
	public static void register() {
98
		DefaultProviderServices pInfo = (DefaultProviderServices)RasterLocator.getManager().getProviderServices();
99
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
100
		ExtensionPoint point = extensionPoints.get("RasterWriter");
101

  
102
		point.append("tif", "", GdalWriter.class);
103
		pInfo.getFileFeature().put("tif", new GTiffFeatures());
104

  
105
		point.append("img", "", GdalWriter.class);
106
		pInfo.getFileFeature().put("img", new HFAFeatures());
107

  
108
		point.append("bmp", "", GdalWriter.class);
109
		pInfo.getFileFeature().put("bmp", new BMPFeatures());
110

  
111
		point.append("pgm", "", GdalWriter.class);
112
		pInfo.getFileFeature().put("pgm", new PNM_PgmFeatures());
113

  
114
		point.append("ppm", "", GdalWriter.class);
115
		pInfo.getFileFeature().put("ppm", new PNM_PpmFeatures());
116

  
117
		point.append("mpl", "", GdalWriter.class);
118
		pInfo.getFileFeature().put("mpl", new ILWIS_MprFeatures());
119

  
120
		point.append("rst", "", GdalWriter.class);
121
		pInfo.getFileFeature().put("rst", new IDRISIFeatures());
122

  
123
		point.append("jp2", "", GdalWriter.class);
124
		pInfo.getFileFeature().put("jp2", new Jpeg2000Features());
125

  
126
		//La exportaci?n no es correcta del todo
127
//		point.append("rmf", "", GdalWriter.class);
128
//		pInfo.getFileFeature().put("rmf", new RMFFeatures());
129

  
130
		//No salva datos. Siempre sale negra la imagen
131
		//point.register("aux", GdalWriter.class);
132
		//fileFeature.put("aux", new PAuxFeatures());
133
	}
134

  
135
	private GdalDriver	                 	drv;
136
	private GdalDataset 							dstDataset = null;
137
	private GdalRasterBand 					rband = null;
138
	private GeoTransform 					geot = null; //Datos de georeferenciaci?n
139
	//private OGRSpatialReference 			oSRS; //Datos de proyecci?n
140
	private GdalBuffer[]					bufBands = null;
141
	private int 							nBlocks = 0; //N?mero de bloques en Y en el que se divide la imagen para escribir
142
	private int 							anchoResto = 0; //Tama?o del ?ltimo bloque de la imagen.
143
	private boolean							write = true; //Cuando est? a true se puede escribir en la imagen de salida. Si est? a false el proceso es interrumpido
144
	private int 							dataType = RasterBuffer.TYPE_UNDEFINED;
145

  
146
	/**
147
	 * Carga los par?metros de este driver.
148
	 * @param ident
149
	 */
150
	public void loadParams(String ident) {
151
		WriteFileFormatFeatures wfff = (WriteFileFormatFeatures)pInfo.getFileFeature().get(ident);
152
		wfff.loadParams();
153
		driverParams = (ParamsImpl)wfff.getParams();
154
	}
155

  
156
	public String getProviderName() {
157
		return GdalProvider.NAME;
158
	}
159

  
160
	/**
161
	 * Constructor para la obtenci?n de par?metros del driver
162
	 * @param fileName
163
	 */
164
	public GdalWriter(String fileName) {
165
		ident = fileUtil.getExtensionFromFileName(fileName);
166
		driver = ((WriteFileFormatFeatures)pInfo.getFileFeature().get(ident)).getDriverName();
167

  
168
		loadParams(ident);
169
	}
170

  
171
	/**
172
	 * Constructor para salvar datos servidos por el cliente
173
	 * @param dataWriter       	Objeto servidor de datos para el driver de escritura
174
	 * @param outFileName      	Fichero de salida
175
	 * @param nBands            N?mero de bandas
176
	 * @param at                Transformaci?n afin
177
	 * @param outSizeX		  	Tama?o de salida en X
178
	 * @param outSizeY			Tama?o de salida en Y
179
	 * @param dataType			Tipo de dato
180
	 * @param params
181
	 * @param proj
182
	 * @throws GdalException
183
	 * @throws IOException
184
	 */
185
	public GdalWriter(	DataServerWriter dataWriter,
186
			String outFileName,
187
			Integer nBands,
188
			AffineTransform at,
189
			Integer outSizeX,
190
			Integer outSizeY,
191
			Integer dataType,
192
			Params params,
193
			IProjection proj) throws GdalException, IOException {
194
		this(dataWriter, outFileName, nBands, at, outSizeX, outSizeY, dataType, params, proj, new Boolean(true));
195
	}
196

  
197
	/**
198
	 * Constructor para salvar datos servidos por el cliente
199
	 * @param dataWriter       	Objeto servidor de datos para el driver de escritura
200
	 * @param outFileName
201
	 * @param nBands
202
	 * @param at
203
	 * @param outFilename      	Fichero de salida
204
	 * @param outSizeX		  	Tama?o de salida en X
205
	 * @param outSizeY			Tama?o de salida en Y
206
	 * @param dataType			Tipo de dato
207
	 * @param params
208
	 * @param proj
209
	 * @param geo				Flag que dice si se salva con georreferenciaci?n o sin ella
210
	 * @throws GdalException
211
	 * @throws IOException
212
	 */
213
	public GdalWriter(	DataServerWriter dataWriter,
214
			String outFileName,
215
			Integer nBands,
216
			AffineTransform at,
217
			Integer outSizeX,
218
			Integer outSizeY,
219
			Integer dataType,
220
			Params params,
221
			IProjection proj,
222
			Boolean geo)throws GdalException, IOException {
223

  
224
		this.proj = proj;
225
		ident = outFileName.toLowerCase().substring(outFileName.lastIndexOf(".") + 1);
226
		driver = ((WriteFileFormatFeatures)pInfo.getFileFeature().get(ident)).getDriverName();
227
		this.dataType = dataType.intValue();
228
		this.at = at;
229
		percent = 0;
230

  
231
		this.dataWriter = dataWriter;
232
		this.outFileName = outFileName;
233

  
234
		this.sizeWindowX = outSizeX.intValue();
235
		this.sizeWindowY = outSizeY.intValue();
236

  
237
		if ((sizeWindowX < 0) || (sizeWindowY < 0))
238
			throw new IOException("Tama?o del fichero de salida erroneo.");
239

  
240
		this.nBands = nBands.intValue();
241

  
242
		//Calculamos la georeferenciaci?n a partir del extend pasado por el cliente.
243

  
244
		geot = new GeoTransform();
245
		geot.adfgeotransform[0] = at.getTranslateX();
246
		geot.adfgeotransform[3] = at.getTranslateY();
247
		geot.adfgeotransform[1] = at.getScaleX();
248
		geot.adfgeotransform[5] = at.getScaleY();
249
		geot.adfgeotransform[2] = at.getShearX();
250
		geot.adfgeotransform[4] = at.getShearY();
251

  
252
		String outRmf = outFileName.substring(0, outFileName.lastIndexOf("."));
253
		if(geo.booleanValue())
254
			rasterUtil.saveGeoInfo(outRmf, at, new Point2D.Double(sizeWindowX, sizeWindowY));
255

  
256
		if(params == null)
257
			loadParams(ident);
258
		else
259
			if(params instanceof ParamsImpl)
260
				this.driverParams = (ParamsImpl)params;
261

  
262
		init();
263
	}
264

  
265
	/**
266
	 * A?ade la proyecci?n Wkt con la que salvar.
267
	 * @param wkt
268
	 * @throws GdalException
269
	 */
270
	public void setWkt(String wkt) {
271
		if(dstDataset != null && wkt != null && wkt.compareTo("unknown") != 0)
272
			try {
273
				dstDataset.setProjection(wkt);
274
			} catch (GdalException e) {
275
				System.err.println("Proyecci?n Wkt no asignada en GdalWriter");
276
				return;
277
			}
278
	}
279

  
280
	/**
281
	 * Asigna el tipo de driver con el que se salvar? la imagen
282
	 * @param drvType        Tipo de driver
283
	 */
284
	public void setDriverType(String drvType) {
285
		this.driver = drvType;
286
	}
287

  
288
	/**
289
	 * Creaci?n del dataset de destino.
290
	 * @throws EcwException
291
	 */
292
	private void init() throws GdalException {
293
		//Controlamos que el tipo de driver sea correcto
294
		if (driver == null)
295
			throw new GdalException("Tipo de driver sin especificar.");
296

  
297
		boolean okdrvtype = false;
298

  
299
		String[] types = pInfo.getWriteDriversType();
300
		for (int i = 0; i < pInfo.getWriteNTypes(); i++)
301
			if (driver.equals(types[i]))
302
				okdrvtype = true;
303

  
304
		if (okdrvtype == false)
305
			throw new GdalException("El tipo de driver " + driver + " no est? soportado por GdalWriter.");
306

  
307
		//Obtenemos el driver y creamos el dataset del destino
308
		drv = GdalDataset.getDriverByName(driver);
309

  
310
		if (dstDataset != null) {
311
			dstDataset.close();
312
			dstDataset = null;
313
		}
314

  
315
		dstDataset = drv.create(outFileName, sizeWindowX, sizeWindowY,
316
				nBands, GdalDataSource.getGdalTypeFromRasterBufType(dataType), gdalParamsFromRasterParams(driverParams));
317

  
318
		dstDataset.setGeoTransform(geot);
319

  
320
		int blockSize = RasterLibrary.blockHeight;
321
		if(dataWriter.getBuffer() != null && dataWriter.getBuffer().isCached())
322
			blockSize = dataWriter.getBuffer().getBlockHeight();
323

  
324
		nBlocks = (sizeWindowY / blockSize);
325
		anchoResto = sizeWindowY - (nBlocks * blockSize);
326
	}
327

  
328
	/**
329
	 * @param fileName
330
	 * @throws GdalException
331
	 */
332
	public void anotherFile(String fileName) throws GdalException {
333
		dstDataset = drv.create(fileName, sizeWindowX, sizeWindowY,
334
				nBands, GdalDataSource.getGdalTypeFromRasterBufType(dataType), gdalParamsFromRasterParams(driverParams));
335
	}
336

  
337
	/**
338
	 * Convierte los par?metros obtenidos desde el objeto params a parametros
339
	 * comprensibles por la librer?a gdal
340
	 * @param p Params
341
	 * @return Array de par?metros
342
	 */
343
	public String[] gdalParamsFromRasterParams(Params p) {
344
		if (p == null)
345
			return null;
346
		ArrayList<String> paramList = new ArrayList<String>();
347
		ParamImpl phot = (ParamImpl)p.getParamById("photometric");
348
		if (phot != null)
349
			paramList.add("PHOTOMETRIC=" + phot.getList()[((Integer) phot.getDefaultValue()).intValue()]);
350
		ParamImpl inter = (ParamImpl)p.getParamById("interleave");
351
		if (inter != null)
352
			paramList.add("INTERLEAVE=" + inter.getList()[((Integer) inter.getDefaultValue()).intValue()]);
353
		ParamImpl comp = (ParamImpl)p.getParamById("compression");// GIF LZW, ...
354
		if (comp != null)
355
			paramList.add("COMPRESS=" + comp.getList()[((Integer) comp.getDefaultValue()).intValue()]);
356
		ParamImpl comp1 = (ParamImpl)p.getParamById("compress"); // HFA (YES, NO)
357
		if (comp1 != null)
358
			paramList.add("COMPRESS=" + comp1.getList()[((Integer) comp1.getDefaultValue()).intValue()]);
359
		ParamImpl rrd = (ParamImpl)p.getParamById("rrd");
360
		if (rrd != null)
361
			paramList.add("HFA_USE_RRD=" + rrd.getList()[((Integer) rrd.getDefaultValue()).intValue()]);
362
		ParamImpl mtw = (ParamImpl)p.getParamById("Mtw");
363
		if (mtw != null)
364
			paramList.add("MTW=" + mtw.getList()[((Integer) mtw.getDefaultValue()).intValue()]);
365
		ParamImpl tw = (ParamImpl)p.getParamById("Tile Width");
366
		if (tw != null)
367
			paramList.add("BLOCKXSIZE=" + tw.getList()[((Integer) tw.getDefaultValue()).intValue()]);
368
		ParamImpl th = (ParamImpl)p.getParamById("Tile Height");
369
		if (th != null)
370
			paramList.add("BLOCKYSIZE=" + th.getList()[((Integer) th.getDefaultValue()).intValue()]);
371
		ParamImpl qt = (ParamImpl)p.getParamById("quality");
372
		if (qt != null)
373
			paramList.add("QUALITY=" + qt.getDefaultValue());
374
		ParamImpl prog = (ParamImpl)p.getParamById("progressive");
375
		if (prog != null)
376
			paramList.add("PROGRESSIVE=" + prog.getDefaultValue());
377

  
378
		if (paramList.size() == 0)
379
			return null;
380

  
381
		String[] result = new String[paramList.size()];
382
		for (int i = 0; i < result.length; i++)
383
			result[i] = (String) paramList.get(i);
384
		return result;
385
	}
386

  
387
	/**
388
	 * Escritura de datos tipo Byte.
389
	 * @param sizeY Alto del bloque que se escribe.
390
	 * @param posicionY Posici?ny a partir desde donde se comienza.
391
	 */
392
	public void writeByteBand(int sizeY, int posicionY) {
393
		byte[][] buftmp = dataWriter.readByteData(sizeWindowX, sizeY);
394
		for(int iBand = 0; iBand < nBands; iBand ++)
395
			bufBands[iBand].buffByte = new byte[buftmp[iBand].length];
396

  
397
		//Escribimos el bloque destino
398
		for (int iBand = 0; iBand < buftmp.length; iBand++)
399
			for (int i = 0; i < buftmp[iBand].length; i++)
400
				bufBands[iBand].buffByte[i] = buftmp[iBand][i];
401

  
402
		for (int iBand = 0; iBand < buftmp.length; iBand++)
403
			try {
404
				rband = dstDataset.getRasterBand(iBand + 1);
405
				rband.writeRaster(0, posicionY, sizeWindowX, sizeY, bufBands[iBand], GdalDataset.GDT_Byte);
406
				bufBands[iBand].buffByte = null;
407
			} catch (GdalException e) {
408
				//No se est? escribiendo ...
409
			}
410
		buftmp = null;
411

  
412
	}
413

  
414
	/**
415
	 * Escritura de datos tipo Short.
416
	 * @param sizeY Alto del bloque que se escribe.
417
	 * @param posicionY Posici?ny a partir desde donde se comienza.
418
	 */
419
	public void writeShortBand(int sizeY, int posicionY) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff