Revision 21932
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247/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.247</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.247/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.247</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.247/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Sun Dec 17 18:18:22 CET 2023 |
|
2 |
buildNumber=300 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247/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.247/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.247/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> |
|
0 | 16 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247/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.247</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.439</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.234</org.gvsig.gdal.version> |
|
21 |
<org.gvsig.raster.version>2.2.260</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.247</connection> |
|
44 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247</developerConnection> |
|
45 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247</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.247</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.247/org.gvsig.raster.gdal.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.gdal.io.DefaultGdalIOLibrary |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247/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.247/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.247/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.247/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.247/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/overview/GdalOverviewBuilder.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.overview; |
|
23 |
|
|
24 |
import org.gvsig.addo.BuildingOverviewsException; |
|
25 |
import org.gvsig.addo.IOverviewIncrement; |
|
26 |
import org.gvsig.addo.Jaddo; |
|
27 |
import org.gvsig.addo.WritingException; |
|
28 |
import org.gvsig.fmap.dal.coverage.exception.OverviewException; |
|
29 |
import org.gvsig.fmap.dal.coverage.process.BaseIncrementableTask; |
|
30 |
import org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder; |
|
31 |
|
|
32 |
/** |
|
33 |
* Servicios ofrecidos por el proceso de construcci?n de overviews. Esta |
|
34 |
* implementaci?n usa gdal para construir las overviews. |
|
35 |
* |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public class GdalOverviewBuilder implements OverviewBuilder { |
|
39 |
private Jaddo build = new Jaddo(); |
|
40 |
private int value = 0; |
|
41 |
|
|
42 |
/** |
|
43 |
* Bindings between an IOverviewIncrement and a BaseIncrementableTask |
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
45 |
*/ |
|
46 |
class ProcessBinding implements IOverviewIncrement { |
|
47 |
private BaseIncrementableTask task = null; |
|
48 |
|
|
49 |
public ProcessBinding(BaseIncrementableTask task) { |
|
50 |
this.task = task; |
|
51 |
} |
|
52 |
|
|
53 |
public int getPercent() { |
|
54 |
return task.getPercent(); |
|
55 |
} |
|
56 |
|
|
57 |
public void setPercent(int value) { |
|
58 |
task.setPercent(value); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* @see org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder#buildOverviews(int, java.lang.String, int[]) |
|
65 |
*/ |
|
66 |
public void buildOverviews(int resamplingAlg, String file, int[] overviews) |
|
67 |
throws OverviewException { |
|
68 |
try { |
|
69 |
build.buildOverviews(resamplingAlg, file, overviews); |
|
70 |
} catch (BuildingOverviewsException e) { |
|
71 |
throw new OverviewException("Error building overviews", e); |
|
72 |
} catch (WritingException e) { |
|
73 |
throw new OverviewException("Error writing overviews", e); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
/* |
|
78 |
* (non-Javadoc) |
|
79 |
* @see org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder#getPercent() |
|
80 |
*/ |
|
81 |
public int getPercent() { |
|
82 |
return value; |
|
83 |
} |
|
84 |
|
|
85 |
/* |
|
86 |
* (non-Javadoc) |
|
87 |
* @see org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder#setIncrementListener(org.gvsig.addo.IOverviewIncrement) |
|
88 |
*/ |
|
89 |
public void setIncrementListener(BaseIncrementableTask incr) { |
|
90 |
build.setIncrementListener(new ProcessBinding(incr)); |
|
91 |
} |
|
92 |
|
|
93 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* @see org.gvsig.fmap.dal.coverage.process.overview.OverviewBuilder#setPercent(int) |
|
96 |
*/ |
|
97 |
public void setPercent(int value) { |
|
98 |
this.value = value; |
|
99 |
} |
|
100 |
} |
|
0 | 101 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/PngWriter.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.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
|
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
30 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
31 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
32 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
|
33 |
import org.gvsig.jgdal.GdalDataset; |
|
34 |
import org.gvsig.jgdal.GdalDriver; |
|
35 |
import org.gvsig.jgdal.GdalException; |
|
36 |
import org.gvsig.raster.gdal.io.features.PngFeatures; |
|
37 |
import org.gvsig.raster.impl.store.WriteFileFormatFeatures; |
|
38 |
import org.gvsig.raster.impl.store.writer.DefaultRasterWriter; |
|
39 |
import org.gvsig.raster.util.DefaultProviderServices; |
|
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
42 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
43 |
/** |
|
44 |
* Driver para la escritura de Png. |
|
45 |
* Este driver utiliza GdalWriter para salvar Png. |
|
46 |
* La escritura de un png no es posible utilizando un servidor de datos |
|
47 |
* como el que usan los drivers comunes por lo que ser? necesario salvar antes |
|
48 |
* a Tif con el driver de Gdal para posteriormente convertir la imagen completa |
|
49 |
* a png. El problema que tiene es el mismo del jpg y es que el dataset solo soporta la |
|
50 |
* escritura rw y no rw+. |
|
51 |
* |
|
52 |
* @version 22/07/2008 |
|
53 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
54 |
*/ |
|
55 |
public class PngWriter extends DefaultRasterWriter { |
|
56 |
|
|
57 |
// Datos de registro de drivers |
|
58 |
public static void register() { |
|
59 |
DefaultProviderServices pInfo = (DefaultProviderServices)RasterLocator.getManager().getProviderServices(); |
|
60 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
|
61 |
ExtensionPoint point=extensionPoints.get("RasterWriter"); |
|
62 |
point.append("png", "", PngWriter.class); |
|
63 |
pInfo.getFileFeature().put("png", new PngFeatures()); |
|
64 |
} |
|
65 |
|
|
66 |
private GdalWriter gdalWriter = null; |
|
67 |
private String outTif = null; |
|
68 |
private String outPng = null; |
|
69 |
|
|
70 |
/** |
|
71 |
* Carga los par?metros de este driver. |
|
72 |
*/ |
|
73 |
public void loadParams(String ident) { |
|
74 |
WriteFileFormatFeatures wfff = (WriteFileFormatFeatures) pInfo.getFileFeature().get(ident); |
|
75 |
wfff.loadParams(); |
|
76 |
driverParams = wfff.getParams(); |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see org.gvsig.fmap.dal.coverage.store.RasterWriter#getProviderName() |
|
82 |
*/ |
|
83 |
public String getProviderName() { |
|
84 |
return GdalProvider.NAME; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Constructor para la obtenci?n de par?metros del driver |
|
89 |
* @param drvType Tipo de driver |
|
90 |
*/ |
|
91 |
public PngWriter(String fileName) { |
|
92 |
ident = fileUtil.getExtensionFromFileName(fileName); |
|
93 |
driver = ((WriteFileFormatFeatures) pInfo.getFileFeature().get(ident)).getDriverName(); |
|
94 |
gdalWriter = new GdalWriter(fileName); |
|
95 |
|
|
96 |
loadParams(ident); |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Constructor para salvar datos servidos por el cliente |
|
101 |
* @param dataWriter Objeto servidor de datos para el driver de escritura |
|
102 |
* @param outSizeX N?mero de pixels en X de la imagen de salida |
|
103 |
* @param outSizeY N?mero de pixels en Y de la imagen de salida |
|
104 |
* @param outFilename Fichero de salida |
|
105 |
* @param extentMaxX Posici?n en X m?xima del extent |
|
106 |
* @param extentMinX Posici?n en X m?nima del extent |
|
107 |
* @param extentMaxY Posici?n en Y m?xima del extent |
|
108 |
* @param extentMinY Posici?n en Y m?nima del extent |
|
109 |
* @param nBands N?mero de bandas |
|
110 |
* @param drvType Tipo de driver |
|
111 |
* @throws GdalException |
|
112 |
* @throws IOException |
|
113 |
*/ |
|
114 |
public PngWriter(DataServerWriter dataWriter, |
|
115 |
String outFileName, |
|
116 |
Integer nBands, |
|
117 |
AffineTransform at, |
|
118 |
Integer outSizeX, |
|
119 |
Integer outSizeY, |
|
120 |
Integer dataType, |
|
121 |
Params params, |
|
122 |
IProjection proj, |
|
123 |
Boolean geo)throws GdalException, IOException { |
|
124 |
ident = fileUtil.getExtensionFromFileName(outFileName); |
|
125 |
driver = ((WriteFileFormatFeatures) pInfo.getFileFeature().get(ident)).getDriverName(); |
|
126 |
outPng = outFileName; |
|
127 |
outTif = outFileName.substring(0, outFileName.lastIndexOf(".")); |
|
128 |
outTif += ".tif"; |
|
129 |
this.at = at; |
|
130 |
|
|
131 |
gdalWriter = new GdalWriter(dataWriter, outTif, nBands, at, outSizeX, outSizeY, dataType, params, proj, geo); |
|
132 |
if (params == null) |
|
133 |
loadParams(ident); |
|
134 |
else |
|
135 |
this.driverParams = params; |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* Asigna el tipo de driver con el que se salvar? la imagen |
|
140 |
* @param drvType Tipo de driver |
|
141 |
*/ |
|
142 |
public void setDriverType(String drvType) { |
|
143 |
gdalWriter.setDriverType(drvType); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Realiza la funci?n de compresi?n a partir de un GeoRasterFile. |
|
148 |
* @throws IOException |
|
149 |
*/ |
|
150 |
public void fileWrite() throws IOException, ProcessInterruptedException { |
|
151 |
gdalWriter.fileWrite(); |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* Realiza una copia en el formato especificado. |
|
156 |
* @throws IOException |
|
157 |
*/ |
|
158 |
public static void createCopy(GdalDriver driverDst, String dst, String src, |
|
159 |
boolean bstrict, String[] params) throws IOException, GdalException { |
|
160 |
GdalWriter.createCopy(driverDst, dst, src, bstrict, params); |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* Realiza la escritura de datos con los datos que le pasa el cliente. |
|
165 |
* @throws IOException |
|
166 |
*/ |
|
167 |
public void dataWrite() throws IOException, ProcessInterruptedException { |
|
168 |
if(colorInterp != null) |
|
169 |
gdalWriter.setColorBandsInterpretation(colorInterp.getValues()); |
|
170 |
gdalWriter.dataWrite(); |
|
171 |
if (gdalWriter.isWrite()) { |
|
172 |
gdalWriter.writeClose(); |
|
173 |
if (outTif != null) { |
|
174 |
GdalDriver driver = null; |
|
175 |
try { |
|
176 |
driver = GdalDataset.getDriverByName("PNG"); |
|
177 |
GdalWriter.createCopy(driver, outPng, outTif, false, gdalWriter.gdalParamsFromRasterParams(driverParams)); |
|
178 |
} catch (GdalException exc) { |
|
179 |
throw new IOException("No se ha podido obtener el driver."); |
|
180 |
} |
|
181 |
File file = new File(outTif); |
|
182 |
file.delete(); |
|
183 |
} |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* Cancela el salvado de datos. |
|
189 |
*/ |
|
190 |
public void writeCancel() { |
|
191 |
gdalWriter.setWrite(false); |
|
192 |
} |
|
193 |
|
|
194 |
/* |
|
195 |
* (non-Javadoc) |
|
196 |
* @see org.gvsig.raster.dataset.GeoRasterWriter#setParams(org.gvsig.raster.dataset.Params) |
|
197 |
*/ |
|
198 |
public void setParams(Params params) { |
|
199 |
driverParams = params; |
|
200 |
if (gdalWriter != null) |
|
201 |
gdalWriter.setParams(params); |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* Cierra el compresor ecw. |
|
206 |
* @throws GdalException |
|
207 |
*/ |
|
208 |
public void writeClose() { |
|
209 |
// El close del tif se hizo en dataWrite |
|
210 |
} |
|
211 |
|
|
212 |
public void setWkt(String wkt) {} |
|
213 |
} |
|
0 | 214 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.247/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalDataSource.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.Color; |
|
25 |
import java.awt.Rectangle; |
|
26 |
import java.awt.geom.AffineTransform; |
|
27 |
import java.awt.geom.NoninvertibleTransformException; |
|
28 |
import java.awt.geom.Point2D; |
|
29 |
import java.io.IOException; |
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.gdal.gdal.gdal; |
|
34 |
import org.gdal.ogr.ogr; |
|
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.BandList; |
|
42 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem; |
|
43 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
44 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
45 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
46 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
47 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
48 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
|
49 |
import org.gvsig.jgdal.GdalBuffer; |
|
50 |
import org.gvsig.jgdal.GdalColorEntry; |
|
51 |
import org.gvsig.jgdal.GdalColorTable; |
|
52 |
import org.gvsig.jgdal.GdalDataset; |
|
53 |
import org.gvsig.jgdal.GdalException; |
|
54 |
import org.gvsig.jgdal.GdalRasterBand; |
|
55 |
import org.gvsig.jgdal.GeoTransform; |
|
56 |
import org.gvsig.jgdal.GeoTransform.GeoTransformException; |
|
57 |
import org.gvsig.raster.impl.datastruct.ColorItemImpl; |
|
58 |
import org.gvsig.raster.impl.datastruct.DefaultNoData; |
|
59 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
60 |
import org.gvsig.raster.impl.process.RasterTask; |
|
61 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
|
62 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
63 |
import org.gvsig.raster.impl.store.properties.DataStoreColorTable; |
|
64 |
import org.gvsig.raster.impl.store.properties.DataStoreMetadata; |
|
65 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
66 |
import org.gvsig.tools.dispose.Disposable; |
|
67 |
import org.gvsig.tools.task.TaskStatus; |
|
68 |
/** |
|
69 |
* Soporte 'nativo' para ficheros desde GDAL. |
|
70 |
*/ |
|
71 |
public class GdalDataSource extends GdalDataset implements Disposable { |
|
72 |
private String fileName = null; |
|
73 |
private String shortName = ""; |
|
74 |
public GeoTransform trans = null; |
|
75 |
public int width = 0, height = 0; |
|
76 |
public double originX = 0D, originY = 0D; |
|
77 |
public String version = ""; |
|
78 |
protected int rBandNr = 1, gBandNr = 2, bBandNr = 3, aBandNr = 4; |
|
79 |
private int[] dataType = null; |
|
80 |
DataStoreMetadata metadata = null; |
|
81 |
protected boolean georeferenced = true; |
|
82 |
|
|
83 |
private static final Logger logger = LoggerFactory.getLogger(GdalDataSource.class); |
|
84 |
|
|
85 |
/** |
|
86 |
* Vectores que contiene los desplazamientos de un pixel cuando hay supersampling. |
|
87 |
* , es decir el n?mero de pixels de pantalla que tiene un pixel de imagen. Como todos |
|
88 |
* los pixeles no tienen el mismo ancho y alto ha de meterse en un array y no puede ser |
|
89 |
* una variable. Adem?s hay que tener en cuenta que el primer y ?ltimo pixel son de |
|
90 |
* distinto tama?o que el resto. |
|
91 |
*/ |
|
92 |
public int[] stepArrayX = null; |
|
93 |
public int[] stepArrayY = null; |
|
94 |
protected GdalRasterBand[] gdalBands = null; |
|
95 |
private double lastReadLine = -1; |
|
96 |
private int overviewWidth = -1; |
|
97 |
private int overviewHeight = -1; |
|
98 |
private int currentViewWidth = -1; |
|
99 |
private int currentViewHeight = -1; |
|
100 |
private double currentViewX = 0D; |
|
101 |
private double viewportScaleX = 0D; |
|
102 |
private double viewportScaleY = 0D; |
|
103 |
private double stepX = 0D; |
|
104 |
private double stepY = 0D; |
|
105 |
public boolean isSupersampling = false; |
|
106 |
private boolean open = false; |
|
107 |
/** |
|
108 |
* Estado de transparencia del raster. |
|
109 |
*/ |
|
110 |
protected DataStoreTransparency fileTransparency = null; |
|
111 |
protected DataStoreColorTable palette = null; |
|
112 |
protected DataStoreColorInterpretation colorInterpr = null; |
|
113 |
protected AffineTransform ownTransformation = null; |
|
114 |
protected AffineTransform externalTransformation = new AffineTransform(); |
|
115 |
|
|
116 |
public static int getGdalTypeFromRasterBufType(int rasterBufType) { |
|
117 |
switch (rasterBufType) { |
|
118 |
case Buffer.TYPE_BYTE: return GdalDataset.GDT_Byte; |
|
119 |
case Buffer.TYPE_USHORT: return GdalDataset.GDT_UInt16; |
|
120 |
case Buffer.TYPE_SHORT: return GdalDataset.GDT_Int16; |
|
121 |
case Buffer.TYPE_INT: return GdalDataset.GDT_Int32; |
|
122 |
case Buffer.TYPE_FLOAT: return GdalDataset.GDT_Float32; |
|
123 |
case Buffer.TYPE_DOUBLE: return GdalDataset.GDT_Float64; |
|
124 |
case Buffer.TYPE_UNDEFINED: return GdalDataset.GDT_Unknown; |
|
125 |
case Buffer.TYPE_IMAGE: return GdalDataset.GDT_Byte; |
|
126 |
} |
|
127 |
return GdalDataset.GDT_Unknown; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Conversi?n de los tipos de datos de gdal a los tipos de datos de RasterBuf |
|
132 |
* @param gdalType Tipo de dato de gdal |
|
133 |
* @return Tipo de dato de RasterBuf |
|
134 |
*/ |
|
135 |
public static int getRasterBufTypeFromGdalType(int gdalType) { |
|
136 |
switch (gdalType) { |
|
137 |
case 1:// Eight bit unsigned integer GDT_Byte = 1 |
|
138 |
return Buffer.TYPE_BYTE; |
|
139 |
|
|
140 |
case 3:// Sixteen bit signed integer GDT_Int16 = 3, |
|
141 |
return Buffer.TYPE_SHORT; |
|
142 |
|
|
143 |
case 2:// Sixteen bit unsigned integer GDT_UInt16 = 2 |
|
144 |
//return RasterBuffer.TYPE_USHORT; |
|
145 |
return Buffer.TYPE_SHORT; //Apa?o para usar los tipos de datos que soportamos |
|
146 |
|
|
147 |
case 5:// Thirty two bit signed integer GDT_Int32 = 5 |
|
148 |
return Buffer.TYPE_INT; |
|
149 |
|
|
150 |
case 6:// Thirty two bit floating point GDT_Float32 = 6 |
|
151 |
return Buffer.TYPE_FLOAT; |
|
152 |
|
|
153 |
case 7:// Sixty four bit floating point GDT_Float64 = 7 |
|
154 |
return Buffer.TYPE_DOUBLE; |
|
155 |
|
|
156 |
// TODO:Estos tipos de datos no podemos gestionarlos. Habria que definir |
|
157 |
// el tipo complejo y usar el tipo long que de momento no se gasta. |
|
158 |
case 4:// Thirty two bit unsigned integer GDT_UInt32 = 4, |
|
159 |
return Buffer.TYPE_INT; |
|
160 |
//return RasterBuffer.TYPE_UNDEFINED; // Deberia devolver un Long |
|
161 |
|
|
162 |
case 8:// Complex Int16 GDT_CInt16 = 8 |
|
163 |
case 9:// Complex Int32 GDT_CInt32 = 9 |
|
164 |
case 10:// Complex Float32 GDT_CFloat32 = 10 |
|
165 |
case 11:// Complex Float64 GDT_CFloat64 = 11 |
|
166 |
return Buffer.TYPE_UNDEFINED; |
|
167 |
} |
|
168 |
return Buffer.TYPE_UNDEFINED; |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* Overview usada en el ?ltimo setView |
|
173 |
*/ |
|
174 |
int currentOverview = -1; |
|
175 |
|
|
176 |
public GdalDataSource(String fName) throws GdalException, IOException { |
|
177 |
super(); |
|
178 |
init(fName); |
|
179 |
} |
|
180 |
|
|
181 |
// private static Dataset initializeGdal(String fName) throws GdalException { |
|
182 |
// gdal.AllRegister(); |
|
183 |
// ogr.RegisterAll(); |
|
184 |
// Dataset data = gdal.Open(fName, 1); |
|
185 |
// if (data == null) |
|
186 |
// throw new GdalException("Error en la apertura del fichero. El fichero no tiene un formato v?lido."); |
|
187 |
// |
|
188 |
// return data; |
|
189 |
// } |
|
190 |
|
|
191 |
private void init(String fName) throws GdalException, IOException { |
|
192 |
gdal.AllRegister(); |
|
193 |
ogr.RegisterAll(); |
|
194 |
fileName = fName; |
|
195 |
open(fName, GA_ReadOnly); |
|
196 |
open = true; |
|
197 |
if (getDataset() == null) |
|
198 |
throw new GdalException("Error en la apertura del fichero. El fichero no tiene un formato v?lido."); |
|
199 |
width = getRasterXSize(); |
|
200 |
height = getRasterYSize(); |
|
201 |
|
|
202 |
int[] dt = new int[getRasterCount()]; |
|
203 |
for (int i = 0; i < getRasterCount(); i++) |
|
204 |
dt[i] = this.getRasterBand(i + 1).getRasterDataType(); |
|
205 |
setDataType(dt); |
|
206 |
shortName = getDriverShortName(); |
|
207 |
colorInterpr = new DataStoreColorInterpretation(getRasterCount()); |
|
208 |
fileTransparency = new DataStoreTransparency(colorInterpr); |
|
209 |
metadata = new DataStoreMetadata(getMetadata(), colorInterpr); |
|
210 |
|
|
211 |
// Asignamos la interpretaci?n de color leida por gdal a cada banda. Esto |
|
212 |
// nos sirve para saber que banda de la imagen va asignada a cada banda de |
|
213 |
// visualizaci?n (ARGB) |
|
214 |
metadata.initNoDataByBand(getRasterCount()); |
|
215 |
for (int i = 0; i < getRasterCount(); i++) { |
|
216 |
GdalRasterBand rb = getRasterBand(i + 1); |
|
217 |
String colorInt = getColorInterpretationName(rb.getRasterColorInterpretation()); |
|
218 |
metadata.setNoDataEnabled(rb.existsNoDataValue()); |
|
219 |
if(rb.existsNoDataValue()) { |
|
220 |
metadata.setNoDataValue(i, rb.getRasterNoDataValue()); |
|
221 |
metadata.setNoDataEnabled(rb.existsNoDataValue()); |
|
222 |
} |
|
223 |
colorInterpr.setColorInterpValue(i, colorInt); |
|
224 |
if (colorInt.equals("Alpha")) |
|
225 |
fileTransparency.setTransparencyBand(i); |
|
226 |
|
|
227 |
if (rb.getRasterColorTable() != null && palette == null) { |
|
228 |
palette = new DataStoreColorTable(gdalColorTable2ColorItems(rb.getRasterColorTable()), false); |
|
229 |
// fileTransparency.setTransparencyRangeList(palette.getTransparencyRange()); |
|
230 |
} |
|
231 |
} |
|
232 |
fileTransparency.setTransparencyByPixelFromMetadata(metadata); |
|
233 |
|
|
234 |
try { |
|
235 |
trans = getGeoTransform(); |
|
236 |
if( !trans.isValid() ) { |
|
237 |
throw new GeoTransformException(); |
|
238 |
} |
|
239 |
|
|
240 |
double psX = trans.adfgeotransform[1]; |
|
241 |
double psY = trans.adfgeotransform[5]; |
|
242 |
double rotX = trans.adfgeotransform[4]; |
|
243 |
double rotY = trans.adfgeotransform[2]; |
|
244 |
double offX = trans.adfgeotransform[0]; |
|
245 |
double offY = trans.adfgeotransform[3]; |
|
246 |
|
|
247 |
ownTransformation = new AffineTransform(psX, rotX, rotY, psY, offX, offY); |
|
248 |
//trans.adfgeotransform[1], trans.adfgeotransform[4], trans.adfgeotransform[2], trans.adfgeotransform[5], trans.adfgeotransform[0], trans.adfgeotransform[3]); |
|
249 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
|
250 |
overviewWidth = width; |
|
251 |
overviewHeight = height; |
|
252 |
|
|
253 |
this.georeferenced = true; |
|
254 |
} catch (GeoTransformException exc) { |
|
255 |
// Transformaci?n para ficheros sin georreferenciaci?n. Se invierte la Y |
|
256 |
// ya que las WC decrecen de |
|
257 |
// arriba a abajo y los pixeles crecen de arriba a abajo |
|
258 |
logger.warn("Can't retrieve transformation from file '"+fName+"' use default."); |
|
259 |
ownTransformation = new AffineTransform(1, 0, 0, -1, 0, height); |
|
260 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
|
261 |
overviewWidth = width; |
|
262 |
overviewHeight = height; |
|
263 |
this.georeferenced = false; |
|
264 |
|
|
265 |
} catch (Exception exc) { |
|
266 |
// Transformaci?n para ficheros sin georreferenciaci?n. Se invierte la Y |
|
267 |
// ya que las WC decrecen de |
|
268 |
// arriba a abajo y los pixeles crecen de arriba a abajo |
|
269 |
logger.warn("Can't retrieve transformation from file '"+fName+"' use default.", exc); |
|
270 |
ownTransformation = new AffineTransform(1, 0, 0, -1, 0, height); |
|
271 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
|
272 |
overviewWidth = width; |
|
273 |
overviewHeight = height; |
|
274 |
this.georeferenced = false; |
|
275 |
|
|
276 |
} |
|
277 |
} |
|
278 |
|
|
279 |
/** |
|
280 |
* Returns true if this provider is open and false if don't |
|
281 |
* @return |
|
282 |
*/ |
|
283 |
public boolean isOpen() { |
|
284 |
return open; |
|
285 |
} |
|
286 |
|
|
287 |
/** |
|
288 |
* Obtiene el flag que informa de si el raster tiene valor no data o no. |
|
289 |
* Consultar? todas las bandas del mismo y si alguna tiene valor no data |
|
290 |
* devuelve true sino devolver? false. |
|
291 |
* @return true si tiene valor no data y false si no lo tiene |
|
292 |
* @throws GdalException |
|
293 |
*/ |
|
294 |
public boolean existsNoDataValue() throws GdalException { |
|
295 |
for (int i = 0; i < getRasterCount(); i++) { |
|
296 |
GdalRasterBand rb = getRasterBand(i + 1); |
|
297 |
if (rb.existsNoDataValue()) |
|
298 |
return true; |
|
299 |
} |
|
300 |
return false; |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* Obtiene el flag que informa de si el raster tiene valor no data o no |
|
305 |
* en una banda concreta. |
|
306 |
* @return true si tiene valor no data en esa banda y false si no lo tiene |
|
307 |
* @param band Posici?n de la banda a consultar (0..n) |
|
308 |
* @throws GdalException |
|
309 |
*/ |
|
310 |
public boolean existsNoDataValue(int band) throws GdalException { |
|
311 |
GdalRasterBand rb = getRasterBand(band + 1); |
|
312 |
return rb.existsNoDataValue(); |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* Gets nodata value |
|
317 |
* @return |
|
318 |
*/ |
|
319 |
public NoData getNoDataValue() { |
|
320 |
Number value = null; |
|
321 |
int type = getRasterBufTypeFromGdalType(getDataType()[0]); |
|
322 |
if (metadata != null && metadata.isNoDataEnabled() && metadata.getNoDataValue().length > 0) { |
|
323 |
switch (type) { |
|
324 |
case Buffer.TYPE_BYTE: |
|
325 |
if (metadata == null || metadata.getNoDataValue().length == 0) |
|
326 |
value = new Byte(RasterLibrary.defaultByteNoDataValue); |
|
327 |
else |
|
328 |
value = new Byte((byte)metadata.getNoDataValue()[0]); |
|
329 |
break; |
|
330 |
case Buffer.TYPE_SHORT: |
|
331 |
if (metadata == null || metadata.getNoDataValue().length == 0) |
|
332 |
value = new Short(RasterLibrary.defaultShortNoDataValue); |
|
333 |
else |
|
334 |
value = new Short((short)metadata.getNoDataValue()[0]); |
|
335 |
break; |
|
336 |
case Buffer.TYPE_INT: |
|
337 |
if (metadata == null || metadata.getNoDataValue().length == 0) |
|
338 |
value = new Integer((int)RasterLibrary.defaultIntegerNoDataValue); |
|
339 |
else |
|
340 |
value = new Integer((int)metadata.getNoDataValue()[0]); |
|
341 |
break; |
|
342 |
case Buffer.TYPE_FLOAT: |
|
343 |
if (metadata == null || metadata.getNoDataValue().length == 0) |
|
344 |
value = new Float(RasterLibrary.defaultFloatNoDataValue); |
|
345 |
else |
|
346 |
value = new Float(metadata.getNoDataValue()[0]); |
|
347 |
break; |
|
348 |
case Buffer.TYPE_DOUBLE: |
|
349 |
if (metadata == null || metadata.getNoDataValue().length == 0) |
|
350 |
value = new Double(RasterLibrary.defaultFloatNoDataValue); |
|
351 |
else |
|
352 |
value = new Double(metadata.getNoDataValue()[0]); |
|
353 |
break; |
|
354 |
} |
|
355 |
} |
|
356 |
|
|
357 |
NoData nodata = new DefaultNoData(value, value, fileName); |
|
358 |
nodata.setNoDataTransparent(false); |
|
359 |
return nodata; |
|
360 |
} |
|
361 |
|
|
362 |
/** |
|
363 |
* Asigna el tipo de dato |
|
364 |
* @param dt entero que representa el tipo de dato |
|
365 |
*/ |
|
366 |
public void setDataType(int[] dt) { |
|
367 |
dataType = dt; |
|
368 |
} |
|
369 |
|
|
370 |
/** |
|
371 |
* Obtiene el tipo de dato |
|
372 |
* @return entero que representa el tipo de dato |
|
373 |
*/ |
|
374 |
public int[] getDataType() { |
|
375 |
return dataType; |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* Gets the color interpretation |
|
380 |
* @return |
|
381 |
*/ |
|
382 |
public ColorInterpretation getColorInterpretation() { |
|
383 |
return colorInterpr; |
|
384 |
} |
|
385 |
|
|
386 |
/** |
|
387 |
* Gets the color table |
|
388 |
* @return |
|
389 |
*/ |
|
390 |
public ColorTable getColorTable() { |
|
391 |
return palette; |
|
392 |
} |
|
393 |
|
|
394 |
/** |
|
395 |
* Obtiene un punto 2D con las coordenadas del raster a partir de uno en coordenadas |
|
396 |
* del punto real. |
|
397 |
* Supone rasters no girados |
|
398 |
* @param pt punto en coordenadas del punto real |
|
399 |
* @return punto en coordenadas del raster |
|
400 |
*/ |
|
401 |
public Point2D worldToRasterWithoutRot(Point2D pt) { |
|
402 |
Point2D p = new Point2D.Double(); |
|
403 |
AffineTransform at = new AffineTransform( externalTransformation.getScaleX(), 0, |
|
404 |
0, externalTransformation.getScaleY(), |
|
405 |
externalTransformation.getTranslateX(), externalTransformation.getTranslateY()); |
|
406 |
try { |
|
407 |
at.inverseTransform(pt, p); |
|
408 |
} catch (NoninvertibleTransformException e) { |
|
409 |
return pt; |
|
410 |
} |
|
411 |
return p; |
|
412 |
} |
|
413 |
|
|
414 |
/** |
|
415 |
* Obtiene un punto 2D con las coordenadas del raster a partir de uno en coordenadas |
|
416 |
* del punto real. |
|
417 |
* Supone rasters no girados |
|
418 |
* @param pt punto en coordenadas del punto real |
|
419 |
* @return punto en coordenadas del raster |
|
420 |
*/ |
|
421 |
public Point2D worldToRaster(Point2D pt) { |
|
422 |
Point2D p = new Point2D.Double(); |
|
423 |
try { |
|
424 |
externalTransformation.inverseTransform(pt, p); |
|
425 |
} catch (NoninvertibleTransformException e) { |
|
426 |
return pt; |
|
427 |
} |
|
428 |
return p; |
|
429 |
} |
|
430 |
|
|
431 |
/** |
|
432 |
* Obtiene un punto del raster en coordenadas pixel a partir de un punto en coordenadas |
|
433 |
* reales. |
|
434 |
* @param pt Punto en coordenadas reales |
|
435 |
* @return Punto en coordenadas pixel. |
|
436 |
*/ |
|
437 |
public Point2D rasterToWorld(Point2D pt) { |
|
438 |
Point2D p = new Point2D.Double(); |
|
439 |
externalTransformation.transform(pt, p); |
|
440 |
return p; |
|
441 |
} |
Also available in: Unified diff