Revision 15128
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155/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.155</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.155/org.gvsig.raster.gdal.app/org.gvsig.raster.gdal.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Thu Oct 21 09:20:45 CEST 2021 |
|
2 |
buildNumber=208 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155/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.155/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.155/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.155/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.155</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.155/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.155</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.337</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.141</org.gvsig.gdal.version> |
|
21 |
<org.gvsig.raster.version>2.2.167</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.155</connection> |
|
44 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155</developerConnection> |
|
45 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155</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.155</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.155/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.155/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/memory/io/MemoryRasterProvider.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.memory.io; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.io.File; |
|
28 |
|
|
29 |
import org.cresques.cts.ICoordTrans; |
|
30 |
|
|
31 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
32 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
33 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
39 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
40 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
41 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
42 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
43 |
import org.gvsig.metadata.MetadataLocator; |
|
44 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
45 |
import org.gvsig.raster.impl.buffer.SpiRasterQuery; |
|
46 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
47 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
|
48 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
49 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
50 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
51 |
import org.gvsig.tools.ToolsLocator; |
|
52 |
import org.gvsig.tools.task.TaskStatus; |
|
53 |
|
|
54 |
/** |
|
55 |
* Driver para datos cargados en un objeto IBuffer |
|
56 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
57 |
* |
|
58 |
*/ |
|
59 |
public class MemoryRasterProvider extends AbstractRasterProvider { |
|
60 |
public static String NAME = "Gdal Store"; |
|
61 |
public static String DESCRIPTION = "Gdal Raster file"; |
|
62 |
public static final String METADATA_DEFINITION_NAME = "GdalStore"; |
|
63 |
|
|
64 |
private Extent v = null; |
|
65 |
protected Buffer buffer = null; |
|
66 |
private Extent extent = null; |
|
67 |
private boolean open = false; |
|
68 |
|
|
69 |
public static void register() { |
|
70 |
} |
|
71 |
|
|
72 |
public void registerTileProviderFormats(Class<RasterProvider> c) { |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Mandatory constructor to instantiate an empty provider |
|
78 |
*/ |
|
79 |
public MemoryRasterProvider() {} |
|
80 |
|
|
81 |
/** |
|
82 |
* Constructor. Asigna el buffer de datos y la extensi?n |
|
83 |
* @param proj Proyecci?n |
|
84 |
* @param buf Buffer |
|
85 |
* @throws NotSupportedExtensionException |
|
86 |
*/ |
|
87 |
public MemoryRasterProvider(AbstractRasterDataParameters params, |
|
88 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException { |
|
89 |
super(params, storeServices, ToolsLocator.getDynObjectManager() |
|
90 |
.createDynObject( |
|
91 |
MetadataLocator.getMetadataManager().getDefinition( |
|
92 |
METADATA_DEFINITION_NAME))); |
|
93 |
setParam(storeServices, params); |
|
94 |
if(!(params instanceof MemoryDataParameters)) |
|
95 |
throw new NotSupportedExtensionException("Buffer not supported"); |
|
96 |
|
|
97 |
extent = ((MemoryDataParameters)params).getExtent(); |
|
98 |
this.buffer = ((MemoryDataParameters)params).getBuffer(); |
|
99 |
|
|
100 |
if(extent != null) { |
|
101 |
double psX = (extent.maxX() - extent.minX()) / buffer.getWidth(); |
|
102 |
double psY = (extent.minY() - extent.maxY()) / buffer.getHeight(); |
|
103 |
ownTransformation = new AffineTransform(psX, 0, 0, psY, extent.minX(), extent.maxY()); |
|
104 |
} else |
|
105 |
ownTransformation = new AffineTransform(1, 0, 0, -1, 0, buffer.getHeight()); |
|
106 |
|
|
107 |
if(buffer == null) |
|
108 |
throw new NotSupportedExtensionException("Buffer invalid"); |
|
109 |
|
|
110 |
load(); |
|
111 |
bandCount = buffer.getBandCount(); |
|
112 |
|
|
113 |
//Obtenemos el tipo de dato de gdal y lo convertimos el de RasterBuf |
|
114 |
int[] dt = new int[buffer.getBandCount()]; |
|
115 |
for (int i = 0; i < dt.length; i++) |
|
116 |
dt[i] = buffer.getDataType(); |
|
117 |
setDataType(dt); |
|
118 |
open = true; |
|
119 |
} |
|
120 |
|
|
121 |
public RasterProvider load() { |
|
122 |
return this; |
|
123 |
} |
|
124 |
|
|
125 |
public boolean isOpen() { |
|
126 |
return open; |
|
127 |
} |
|
128 |
|
|
129 |
public void close() { |
|
130 |
buffer = null; |
|
131 |
open = false; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Asigna el extent de la vista actual. |
|
136 |
*/ |
|
137 |
public void setView(Extent e) { |
|
138 |
v = e; |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* Obtiene extent de la vista actual |
|
143 |
*/ |
|
144 |
public Extent getView() { |
|
145 |
return v; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Obtiene la anchura del fichero |
|
150 |
*/ |
|
151 |
public double getWidth() { |
|
152 |
return buffer.getWidth(); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* Obtiene la altura del fichero |
|
157 |
*/ |
|
158 |
public double getHeight() { |
|
159 |
return buffer.getHeight(); |
|
160 |
} |
|
161 |
|
|
162 |
public void reProject(ICoordTrans rp) { |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Obtiene la orientaci?n de la imagen a partir del signo del tama?o de pixel para poder |
|
167 |
* asignarlo en el setView. Esto es util para poder conocer como debe leerse la image, |
|
168 |
* de abajo a arriba, de arriba a abajo, de izquierda a derecha o de derecha a izquierda. |
|
169 |
* La posici?n habitual es la que el pixel size en X es positivo y en Y negativo leyendose |
|
170 |
* en este caso las X de menor a mayor y las Y de mayor a menor. Los casos posibles son: |
|
171 |
* <UL> |
|
172 |
* <LI><B>X > 0; Y < 0;</B> {true, false}</LI> |
|
173 |
* <LI><B>X > 0; Y > 0;</B> {true, true}</LI> |
|
174 |
* <LI><B>X < 0; Y > 0;</B> {false, true}</LI> |
|
175 |
* <LI><B>X < 0; Y < 0;</B> {false, false}</LI> |
|
176 |
* </UL> |
|
177 |
* |
|
178 |
* @return |
|
179 |
*/ |
|
180 |
/*private boolean[] getOrientation(){ |
|
181 |
boolean[] orientation = {true, false}; |
|
182 |
return orientation; |
|
183 |
}*/ |
|
184 |
|
|
185 |
public Object getData(int x, int y, int band) { |
|
186 |
if(buffer.getDataType() == Buffer.TYPE_BYTE){ |
|
187 |
return new Integer(buffer.getElemByte(y, x, band)); |
|
188 |
}else if(buffer.getDataType() == Buffer.TYPE_SHORT){ |
|
189 |
return new Integer(buffer.getElemShort(y, x, band)); |
|
190 |
}else if(buffer.getDataType() == Buffer.TYPE_INT){ |
|
191 |
return new Integer(buffer.getElemInt(y, x, band)); |
|
192 |
}else if(buffer.getDataType() == Buffer.TYPE_FLOAT){ |
|
193 |
return new Float(buffer.getElemFloat(y, x, band)); |
|
194 |
}else if(buffer.getDataType() == Buffer.TYPE_DOUBLE){ |
|
195 |
return new Double(buffer.getElemDouble(y, x, band)); |
|
196 |
} |
|
197 |
return null; |
|
198 |
} |
|
199 |
|
|
200 |
|
|
201 |
/** |
|
202 |
* Devuelve el tama?o de bloque |
|
203 |
* @return Tama?o de bloque |
|
204 |
*/ |
|
205 |
public int getBlockSize(){ |
|
206 |
return 0; |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Obtiene el flag que dice si la imagen est? o no georreferenciada |
|
211 |
* @return true si est? georreferenciada y false si no lo est?. |
|
212 |
*/ |
|
213 |
public boolean isGeoreferenced() { |
|
214 |
return (this.extent != null); |
|
215 |
} |
|
216 |
|
|
217 |
/** |
|
218 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar? |
|
219 |
* el valor de esta variable cada vez que dibuja. |
|
220 |
* @return true si se ha supersampleado y false si no se ha hecho. |
|
221 |
*/ |
|
222 |
public boolean isSupersampling() { |
|
223 |
return false; |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* @return Returns the dataType. |
|
228 |
*/ |
|
229 |
public int[] getDataType() { |
|
230 |
int[] dt = new int[buffer.getBandCount()]; |
|
231 |
for (int i = 0; i < dt.length; i++) |
|
232 |
dt[i] = buffer.getDataType(); |
|
233 |
return dt; |
|
234 |
} |
|
235 |
|
|
236 |
/** |
|
237 |
* Ajusta los puntos pasados por par?metro a los l?mites del buffer. Es decir si alguno excede |
|
238 |
* los l?mites por arriba o por abajo los ajusta. |
|
239 |
* @param begin Punto inicial |
|
240 |
* @param end Punto final |
|
241 |
*/ |
|
242 |
private void adjustPointsToBufferLimits(Point2D begin, Point2D end) { |
|
243 |
if(begin.getX() < 0) |
|
244 |
begin.setLocation(0, begin.getY()); |
|
245 |
if(begin.getY() > buffer.getHeight()) |
|
246 |
begin.setLocation(begin.getX(), buffer.getHeight()); |
|
247 |
if(end.getY() < 0) |
|
248 |
end.setLocation(begin.getX(), 0); |
|
249 |
if(end.getX() > buffer.getWidth()) |
|
250 |
begin.setLocation(buffer.getWidth(), begin.getY()); |
|
251 |
} |
|
252 |
|
|
253 |
public void loadBuffer(SpiRasterQuery q) |
|
254 |
throws ProcessInterruptedException, RasterDriverException { |
|
255 |
getWindow(q.getAdjustedRequestBoundingBox(), q.getBandList(), q.getBufferForProviders(), q.getTaskStatus()); |
|
256 |
} |
|
257 |
|
|
258 |
public Buffer getWindow(Extent ex, BandList bandList, Buffer rasterBuf, TaskStatus status) { |
|
259 |
Point2D begin = worldToRaster(new Point2D.Double(ex.getULX(), ex.getULY())); |
|
260 |
Point2D end = worldToRaster(new Point2D.Double(ex.getLRX(), ex.getLRY())); |
|
261 |
setView(ex); |
|
262 |
|
|
263 |
adjustPointsToBufferLimits(begin, end); |
|
264 |
|
|
265 |
switch(buffer.getDataType()){ |
|
266 |
case Buffer.TYPE_BYTE: writeByteBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
267 |
case Buffer.TYPE_SHORT: writeShortBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
268 |
case Buffer.TYPE_INT: writeIntBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
269 |
case Buffer.TYPE_FLOAT: writeFloatBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
270 |
case Buffer.TYPE_DOUBLE: writeDoubleBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
271 |
} |
|
272 |
return rasterBuf; |
|
273 |
} |
|
274 |
|
|
275 |
public Buffer getWindow(double x, double y, double w, double h, |
|
276 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) { |
|
277 |
Point2D begin = worldToRaster(new Point2D.Double(x, y)); |
|
278 |
Point2D end = worldToRaster(new Point2D.Double(x + w, y - h)); |
|
279 |
setView(new ExtentImpl(x, y, x + w, y - h)); |
|
280 |
|
|
281 |
adjustPointsToBufferLimits(begin, end); |
|
282 |
|
|
283 |
switch(buffer.getDataType()){ |
|
284 |
case Buffer.TYPE_BYTE: writeByteBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
285 |
case Buffer.TYPE_SHORT: writeShortBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
286 |
case Buffer.TYPE_INT: writeIntBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
287 |
case Buffer.TYPE_FLOAT: writeFloatBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
288 |
case Buffer.TYPE_DOUBLE: writeDoubleBuffer(rasterBuf, 1, 1, begin, bandList); break; |
|
289 |
} |
|
290 |
return rasterBuf; |
|
291 |
} |
|
292 |
|
|
293 |
public Buffer getWindow(Extent extent, int bufWidth, int bufHeight, |
|
294 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) { |
|
295 |
Point2D begin = worldToRaster(new Point2D.Double(extent.getMin().getX(), extent.getMax().getY())); |
|
296 |
Point2D end = worldToRaster(new Point2D.Double(extent.getMax().getX(), extent.getMin().getY())); |
|
297 |
setView(extent); |
|
298 |
|
|
299 |
adjustPointsToBufferLimits(begin, end); |
|
300 |
|
|
301 |
//Ancho y alto en pixels (double) del area seleccionada. |
|
302 |
double w = Math.abs(end.getX() - begin.getX()); |
|
303 |
double h = Math.abs(end.getY() - begin.getY()); |
|
304 |
|
|
305 |
//Relaci?n entre el n?mero de pixels del buffer origen (area seleccionada) y el destino |
|
306 |
double stepX = w / ((double)bufWidth); |
|
307 |
double stepY = h / ((double)bufHeight); |
|
308 |
|
|
309 |
//Escritura separada en 5 llamadas para mejorar el rendimiento |
|
310 |
switch(buffer.getDataType()){ |
|
311 |
case Buffer.TYPE_BYTE: writeByteBuffer(rasterBuf, stepX, stepY, begin, bandList); break; |
|
312 |
case Buffer.TYPE_SHORT: writeShortBuffer(rasterBuf, stepX, stepY, begin, bandList); break; |
|
313 |
case Buffer.TYPE_INT: writeIntBuffer(rasterBuf, stepX, stepY, begin, bandList); break; |
|
314 |
case Buffer.TYPE_FLOAT: writeFloatBuffer(rasterBuf, stepX, stepY, begin, bandList); break; |
|
315 |
case Buffer.TYPE_DOUBLE: writeDoubleBuffer(rasterBuf, stepX, stepY, begin, bandList); break; |
|
316 |
} |
|
317 |
|
|
318 |
/*int xPx = 0, yPx = 0; |
|
319 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) { |
|
320 |
yPx = 0; |
|
321 |
for(double row = begin.getY(); yPx < bufHeight; row += stepY) { |
|
322 |
xPx = 0; |
|
323 |
for(double col = begin.getX(); xPx < bufWidth; col += stepX) { |
|
324 |
switch(buffer.getDataType()){ |
|
325 |
case Buffer.TYPE_BYTE: rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemByte((int)row, (int)col, iBand)); break; |
|
326 |
case Buffer.TYPE_SHORT: rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemShort((int)row, (int)col, iBand)); break; |
|
327 |
case Buffer.TYPE_INT: rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemInt((int)row, (int)col, iBand)); break; |
|
328 |
case Buffer.TYPE_FLOAT: rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemFloat((int)row, (int)col, iBand)); break; |
|
329 |
case Buffer.TYPE_DOUBLE: rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemDouble((int)row, (int)col, iBand)); break; |
|
330 |
} |
|
331 |
xPx ++; |
|
332 |
} |
|
333 |
yPx ++; |
|
334 |
} |
|
335 |
}*/ |
|
336 |
return rasterBuf; |
|
337 |
} |
|
338 |
|
|
339 |
/** |
|
340 |
* Escribe sobre el buffer pasado por par?metro los valores solicitados, desde el buffer de la clase. Los valores |
|
341 |
* se solicitan a trav?s de los par?metros. En ellos se especifica el tama?o del buffer de destino, las bandas a |
|
342 |
* escribir, el punto inicial en coordenadas pixel (double) y el incremento. |
|
343 |
* @param rasterBuf Buffer donde se escriben los datos |
|
344 |
* @param stepX Incremento en X. Cada vez que se escribe un pixel en X se incrementa el contador en stepX pixels. Esto es necesario |
|
345 |
* ya que el buffer destino no tiene porque tener el mismo ancho que el de origen. Este valor suele ser ancho_buffer_origen / ancho_buffer_destino. |
|
346 |
* @param stepY Incremento en Y. Cada vez que se escribe un pixel en Y se incrementa el contador en stepY pixels. Esto es necesario |
|
347 |
* ya que el buffer destino no tiene porque tener el mismo alto que el de origen. Este valor suele ser alto_buffer_origen / alto_buffer_destino. |
|
348 |
* @param begin pixel donde se comienza a leer en el buffer de origen. Este valor es decimal ya que no tiene porque empezar a leerse al principio |
|
349 |
* del pixel. Esto es util cuando se supersamplea. |
|
350 |
*/ |
|
351 |
private void writeByteBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) { |
|
352 |
int xPx = 0, yPx = 0; |
|
353 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
354 |
int[] drawableBands = bandList.getBufferBandToDraw(new File(this.getURIOfFirstProvider()).getAbsolutePath(), iBand); |
|
355 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
356 |
continue; |
|
357 |
for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) { |
|
358 |
yPx = 0; |
|
359 |
for(double row = begin.getY(); (yPx < rasterBuf.getHeight() && row < buffer.getHeight()); row += stepY) { |
|
360 |
xPx = 0; |
|
361 |
for(double col = begin.getX(); (xPx < rasterBuf.getWidth() && col < buffer.getWidth()); col += stepX) { |
|
362 |
rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemByte((int)row, (int)col, iBand)); |
|
363 |
xPx ++; |
|
364 |
} |
|
365 |
yPx ++; |
|
366 |
} |
|
367 |
} |
|
368 |
} |
|
369 |
} |
|
370 |
|
|
371 |
/** |
|
372 |
* Escribe sobre el buffer pasado por par?metro los valores solicitados, desde el buffer de la clase. Los valores |
|
373 |
* se solicitan a trav?s de los par?metros. En ellos se especifica el tama?o del buffer de destino, las bandas a |
|
374 |
* escribir, el punto inicial en coordenadas pixel (double) y el incremento. |
|
375 |
* @param rasterBuf Buffer donde se escriben los datos |
|
376 |
* @param stepX Incremento en X. Cada vez que se escribe un pixel en X se incrementa el contador en stepX pixels. Esto es necesario |
|
377 |
* ya que el buffer destino no tiene porque tener el mismo ancho que el de origen. Este valor suele ser ancho_buffer_origen / ancho_buffer_destino. |
|
378 |
* @param stepY Incremento en Y. Cada vez que se escribe un pixel en Y se incrementa el contador en stepY pixels. Esto es necesario |
|
379 |
* ya que el buffer destino no tiene porque tener el mismo alto que el de origen. Este valor suele ser alto_buffer_origen / alto_buffer_destino. |
|
380 |
* @param begin pixel donde se comienza a leer en el buffer de origen. Este valor es decimal ya que no tiene porque empezar a leerse al principio |
|
381 |
* del pixel. Esto es util cuando se supersamplea. |
|
382 |
*/ |
|
383 |
private void writeShortBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) { |
|
384 |
int xPx = 0, yPx = 0; |
|
385 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
386 |
int[] drawableBands = bandList.getBufferBandToDraw(new File(this.getURIOfFirstProvider()).getAbsolutePath(), iBand); |
|
387 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
388 |
continue; |
|
389 |
for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) { |
|
390 |
yPx = 0; |
|
391 |
for(double row = begin.getY(); yPx < rasterBuf.getHeight(); row += stepY) { |
|
392 |
xPx = 0; |
|
393 |
for(double col = begin.getX(); xPx < rasterBuf.getWidth(); col += stepX) { |
|
394 |
rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemShort((int)row, (int)col, iBand)); |
|
395 |
xPx ++; |
|
396 |
} |
|
397 |
yPx ++; |
|
398 |
} |
|
399 |
} |
|
400 |
} |
|
401 |
} |
|
402 |
|
|
403 |
/** |
|
404 |
* Escribe sobre el buffer pasado por par?metro los valores solicitados, desde el buffer de la clase. Los valores |
|
405 |
* se solicitan a trav?s de los par?metros. En ellos se especifica el tama?o del buffer de destino, las bandas a |
|
406 |
* escribir, el punto inicial en coordenadas pixel (double) y el incremento. |
|
407 |
* @param rasterBuf Buffer donde se escriben los datos |
|
408 |
* @param stepX Incremento en X. Cada vez que se escribe un pixel en X se incrementa el contador en stepX pixels. Esto es necesario |
|
409 |
* ya que el buffer destino no tiene porque tener el mismo ancho que el de origen. Este valor suele ser ancho_buffer_origen / ancho_buffer_destino. |
|
410 |
* @param stepY Incremento en Y. Cada vez que se escribe un pixel en Y se incrementa el contador en stepY pixels. Esto es necesario |
|
411 |
* ya que el buffer destino no tiene porque tener el mismo alto que el de origen. Este valor suele ser alto_buffer_origen / alto_buffer_destino. |
|
412 |
* @param begin pixel donde se comienza a leer en el buffer de origen. Este valor es decimal ya que no tiene porque empezar a leerse al principio |
|
413 |
* del pixel. Esto es util cuando se supersamplea. |
|
414 |
*/ |
|
415 |
private void writeIntBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) { |
|
416 |
int xPx = 0, yPx = 0; |
|
417 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
418 |
int[] drawableBands = bandList.getBufferBandToDraw(new File(this.getURIOfFirstProvider()).getAbsolutePath(), iBand); |
|
419 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
420 |
continue; |
|
421 |
for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) { |
|
422 |
yPx = 0; |
|
423 |
for(double row = begin.getY(); yPx < rasterBuf.getHeight(); row += stepY) { |
|
424 |
xPx = 0; |
|
425 |
for(double col = begin.getX(); xPx < rasterBuf.getWidth(); col += stepX) { |
|
426 |
rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemInt((int)row, (int)col, iBand)); |
|
427 |
xPx ++; |
|
428 |
} |
|
429 |
yPx ++; |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
|
|
435 |
/** |
|
436 |
* Escribe sobre el buffer pasado por par?metro los valores solicitados, desde el buffer de la clase. Los valores |
|
437 |
* se solicitan a trav?s de los par?metros. En ellos se especifica el tama?o del buffer de destino, las bandas a |
|
438 |
* escribir, el punto inicial en coordenadas pixel (double) y el incremento. |
|
439 |
* @param rasterBuf Buffer donde se escriben los datos |
|
440 |
* @param stepX Incremento en X. Cada vez que se escribe un pixel en X se incrementa el contador en stepX pixels. Esto es necesario |
|
441 |
* ya que el buffer destino no tiene porque tener el mismo ancho que el de origen. Este valor suele ser ancho_buffer_origen / ancho_buffer_destino. |
|
442 |
* @param stepY Incremento en Y. Cada vez que se escribe un pixel en Y se incrementa el contador en stepY pixels. Esto es necesario |
|
443 |
* ya que el buffer destino no tiene porque tener el mismo alto que el de origen. Este valor suele ser alto_buffer_origen / alto_buffer_destino. |
|
444 |
* @param begin pixel donde se comienza a leer en el buffer de origen. Este valor es decimal ya que no tiene porque empezar a leerse al principio |
|
445 |
* del pixel. Esto es util cuando se supersamplea. |
|
446 |
*/ |
|
447 |
private void writeFloatBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) { |
|
448 |
int xPx = 0, yPx = 0; |
|
449 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
450 |
int[] drawableBands = bandList.getBufferBandToDraw(new File(this.getURIOfFirstProvider()).getAbsolutePath(), iBand); |
|
451 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
452 |
continue; |
|
453 |
for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) { |
|
454 |
yPx = 0; |
|
455 |
for(double row = begin.getY(); yPx < rasterBuf.getHeight(); row += stepY) { |
|
456 |
xPx = 0; |
|
457 |
for(double col = begin.getX(); xPx < rasterBuf.getWidth(); col += stepX) { |
|
458 |
rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemFloat((int)row, (int)col, iBand)); |
|
459 |
xPx ++; |
|
460 |
} |
|
461 |
yPx ++; |
|
462 |
} |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
|
|
467 |
/** |
|
468 |
* Escribe sobre el buffer pasado por par?metro los valores solicitados, desde el buffer de la clase. Los valores |
|
469 |
* se solicitan a trav?s de los par?metros. En ellos se especifica el tama?o del buffer de destino, las bandas a |
|
470 |
* escribir, el punto inicial en coordenadas pixel (double) y el incremento. |
|
471 |
* @param rasterBuf Buffer donde se escriben los datos |
|
472 |
* @param stepX Incremento en X. Cada vez que se escribe un pixel en X se incrementa el contador en stepX pixels. Esto es necesario |
|
473 |
* ya que el buffer destino no tiene porque tener el mismo ancho que el de origen. Este valor suele ser ancho_buffer_origen / ancho_buffer_destino. |
|
474 |
* @param stepY Incremento en Y. Cada vez que se escribe un pixel en Y se incrementa el contador en stepY pixels. Esto es necesario |
|
475 |
* ya que el buffer destino no tiene porque tener el mismo alto que el de origen. Este valor suele ser alto_buffer_origen / alto_buffer_destino. |
|
476 |
* @param begin pixel donde se comienza a leer en el buffer de origen. Este valor es decimal ya que no tiene porque empezar a leerse al principio |
|
477 |
* del pixel. Esto es util cuando se supersamplea. |
|
478 |
*/ |
|
479 |
private void writeDoubleBuffer(Buffer rasterBuf, double stepX, double stepY, Point2D begin, BandList bandList) { |
|
480 |
int xPx = 0, yPx = 0; |
|
481 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
482 |
int[] drawableBands = bandList.getBufferBandToDraw(new File(this.getURIOfFirstProvider()).getAbsolutePath(), iBand); |
|
483 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
484 |
continue; |
|
485 |
for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) { |
|
486 |
yPx = 0; |
|
487 |
for(double row = begin.getY(); yPx < rasterBuf.getHeight(); row += stepY) { |
|
488 |
xPx = 0; |
|
489 |
for(double col = begin.getX(); xPx < rasterBuf.getWidth(); col += stepX) { |
|
490 |
rasterBuf.setElem(yPx, xPx, iBand, buffer.getElemDouble((int)row, (int)col, iBand)); |
|
491 |
xPx ++; |
|
492 |
} |
|
493 |
yPx ++; |
|
494 |
} |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
|
|
499 |
/* |
|
500 |
* (non-Javadoc) |
|
501 |
* @see org.gvsig.raster.dataset.RasterDataset#getWindowRaster(int, int, org.gvsig.raster.dataset.BandList, org.gvsig.raster.dataset.Buffer) |
|
502 |
*/ |
|
503 |
// public Buffer getWindow(int x, int y, BandList bandList, Buffer rasterBuf) { |
|
504 |
// int w = rasterBuf.getWidth(); |
|
505 |
// int h = rasterBuf.getHeight(); |
|
506 |
// setView( |
|
507 |
// new ExtentImpl( rasterUtil.getMapRectFromPxRect(getExtent().toRectangle2D(), |
|
508 |
// getWidth(), |
|
509 |
// getHeight(), |
|
510 |
// new Rectangle2D.Double(x, y, w, h))) |
|
511 |
// ); |
|
512 |
// |
|
513 |
// for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++){ |
|
514 |
// int[] drawableBands = bandList.getBufferBandToDraw(this.getURIOfFirstProvider(), iBand); |
|
515 |
// if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
516 |
// continue; |
|
517 |
// if(buffer.getDataType() == Buffer.TYPE_BYTE) { |
|
518 |
// for(int drawBands = 0; drawBands < drawableBands.length; drawBands++) { |
|
519 |
// for(int line = y; line < (y + h); line ++) |
|
520 |
// for(int col = x; col < (x + w); col ++) |
|
521 |
// rasterBuf.setElem((line - y), (col - x), drawableBands[drawBands], buffer.getElemByte(line, col, drawableBands[drawBands])); |
|
522 |
// } |
|
523 |
// }else if(buffer.getDataType() == Buffer.TYPE_SHORT){ |
|
524 |
// for(int drawBands = 0; drawBands < drawableBands.length; drawBands++){ |
|
525 |
// for(int line = y; line < (y + h); line ++) |
|
526 |
// for(int col = x; col < (x + w); col ++) |
|
527 |
// rasterBuf.setElem((line - y), (col - x), drawableBands[drawBands], buffer.getElemShort(line, col, drawableBands[drawBands])); |
|
528 |
// } |
|
529 |
// }else if(buffer.getDataType() == Buffer.TYPE_INT){ |
|
530 |
// for(int drawBands = 0; drawBands < drawableBands.length; drawBands++){ |
|
531 |
// for(int line = y; line < (y + h); line ++) |
|
532 |
// for(int col = x; col < (x + w); col ++) |
|
533 |
// rasterBuf.setElem((line - y), (col - x), drawableBands[drawBands], buffer.getElemInt(line, col, drawableBands[drawBands])); |
|
534 |
// } |
|
535 |
// }else if(buffer.getDataType() == Buffer.TYPE_FLOAT){ |
|
536 |
// for(int drawBands = 0; drawBands < drawableBands.length; drawBands++){ |
|
537 |
// for(int line = y; line < (y + h); line ++) |
|
538 |
// for(int col = x; col < (x + w); col ++) |
|
539 |
// rasterBuf.setElem((line - y), (col - x), drawableBands[drawBands], buffer.getElemFloat(line, col, drawableBands[drawBands])); |
|
540 |
// } |
|
541 |
// }else if(buffer.getDataType() == Buffer.TYPE_DOUBLE){ |
|
542 |
// for(int drawBands = 0; drawBands < drawableBands.length; drawBands++){ |
|
543 |
// for(int line = y; line < (y + h); line ++) |
|
544 |
// for(int col = x; col < (x + w); col ++) |
|
545 |
// rasterBuf.setElem((line - y), (col - x), drawableBands[drawBands], buffer.getElemDouble(line, col, drawableBands[drawBands])); |
|
546 |
// } |
|
547 |
// } |
|
548 |
// } |
|
549 |
// return rasterBuf; |
|
550 |
// } |
|
551 |
|
|
552 |
public Buffer getWindow(int x, int y, int w, int h, |
|
553 |
BandList bandList, Buffer rasterBuf, TaskStatus status) { |
|
554 |
setView( |
|
555 |
new ExtentImpl( rasterUtil.getMapRectFromPxRect(getExtent().toRectangle2D(), |
|
556 |
getWidth(), |
|
557 |
getHeight(), |
|
558 |
new Rectangle2D.Double(x, y, w, h))) |
|
559 |
); |
|
560 |
|
|
561 |
//Relaci?n entre el n?mero de pixels del buffer origen (area seleccionada) y el destino |
|
562 |
double stepX = w / ((double)rasterBuf.getWidth()); |
|
563 |
double stepY = h / ((double)rasterBuf.getHeight()); |
|
564 |
switch(buffer.getDataType()){ |
|
565 |
case Buffer.TYPE_BYTE: writeByteBuffer(rasterBuf, stepX, stepY, new Point2D.Double(x, y), bandList); break; |
|
566 |
case Buffer.TYPE_SHORT: writeShortBuffer(rasterBuf, stepX, stepY, new Point2D.Double(x, y), bandList); break; |
|
567 |
case Buffer.TYPE_INT: writeIntBuffer(rasterBuf, stepX, stepY, new Point2D.Double(x, y), bandList); break; |
|
568 |
case Buffer.TYPE_FLOAT: writeFloatBuffer(rasterBuf, stepX, stepY, new Point2D.Double(x, y), bandList); break; |
|
569 |
case Buffer.TYPE_DOUBLE: writeDoubleBuffer(rasterBuf, stepX, stepY, new Point2D.Double(x, y), bandList); break; |
|
570 |
} |
|
571 |
return rasterBuf; |
|
572 |
} |
|
573 |
|
|
574 |
public Object readCompleteLine(int line, int band) throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
575 |
switch(buffer.getDataType()){ |
|
576 |
case Buffer.TYPE_BYTE: return buffer.getLineFromBandByte(line, band); |
|
577 |
case Buffer.TYPE_SHORT: return buffer.getLineFromBandShort(line, band); |
|
578 |
case Buffer.TYPE_INT: return buffer.getLineFromBandInt(line, band); |
|
579 |
case Buffer.TYPE_FLOAT: return buffer.getLineFromBandFloat(line, band); |
|
580 |
case Buffer.TYPE_DOUBLE: return buffer.getLineFromBandDouble(line, band); |
|
581 |
} |
|
582 |
return null; |
|
583 |
} |
|
584 |
|
|
585 |
public Object readBlock(int pos, int blockHeight, double scale) throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
586 |
if(pos < 0) |
|
587 |
throw new InvalidSetViewException("Request out of grid"); |
|
588 |
|
|
589 |
if((pos + blockHeight) > buffer.getHeight()) |
|
590 |
blockHeight = Math.abs(buffer.getHeight() - pos); |
|
591 |
|
|
592 |
switch(buffer.getDataType()){ |
|
593 |
case Buffer.TYPE_BYTE: |
|
594 |
byte[][][] bufb = new byte[getBandCount()][][]; |
|
595 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
596 |
for (int row = 0; row < blockHeight; row++) { |
|
597 |
bufb[iBand][row] = buffer.getLineFromBandByte(row, iBand); |
|
598 |
} |
|
599 |
} |
|
600 |
return bufb; |
|
601 |
case Buffer.TYPE_SHORT: |
|
602 |
short[][][] bufs = new short[getBandCount()][][]; |
|
603 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
604 |
for (int row = 0; row < blockHeight; row++) { |
|
605 |
bufs[iBand][row] = buffer.getLineFromBandShort(row, iBand); |
|
606 |
} |
|
607 |
} |
|
608 |
return bufs; |
|
609 |
case Buffer.TYPE_INT: |
|
610 |
int[][][] bufi = new int[getBandCount()][][]; |
|
611 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
612 |
for (int row = 0; row < blockHeight; row++) { |
|
613 |
bufi[iBand][row] = buffer.getLineFromBandInt(row, iBand); |
|
614 |
} |
|
615 |
} |
|
616 |
return bufi; |
|
617 |
case Buffer.TYPE_FLOAT: |
|
618 |
float[][][] buff = new float[getBandCount()][][]; |
|
619 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
620 |
for (int row = 0; row < blockHeight; row++) { |
|
621 |
buff[iBand][row] = buffer.getLineFromBandFloat(row, iBand); |
|
622 |
} |
|
623 |
} |
|
624 |
return buff; |
|
625 |
case Buffer.TYPE_DOUBLE: |
|
626 |
double[][][] bufd = new double[getBandCount()][][]; |
|
627 |
for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) { |
|
628 |
for (int row = 0; row < blockHeight; row++) { |
|
629 |
bufd[iBand][row] = buffer.getLineFromBandDouble(row, iBand); |
|
630 |
} |
|
631 |
} |
|
632 |
return bufd; |
|
633 |
} |
|
634 |
return null; |
|
635 |
} |
|
636 |
|
|
637 |
/** |
|
638 |
* Obtiene el objeto que contiene el estado de la transparencia |
|
639 |
*/ |
|
640 |
public Transparency getTransparency() { |
|
641 |
if(transparency == null) |
|
642 |
transparency = new DataStoreTransparency(getColorInterpretation()); |
|
643 |
return transparency; |
|
644 |
} |
|
645 |
|
|
646 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
|
647 |
if(band >= getBandCount()) |
|
648 |
throw new BandAccessException("Wrong band"); |
|
649 |
return 0; |
|
650 |
} |
|
651 |
|
|
652 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
|
653 |
if (band >= getBandCount()) |
|
654 |
throw new BandAccessException("Wrong band"); |
|
655 |
return 0; |
|
656 |
} |
|
657 |
|
|
658 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
|
659 |
if (band >= getBandCount()) |
|
660 |
throw new BandAccessException("Wrong band"); |
|
661 |
return 0; |
|
662 |
} |
|
663 |
|
|
664 |
public boolean isOverviewsSupported() { |
|
665 |
return false; |
|
666 |
} |
|
667 |
|
|
668 |
public String getProviderName() { |
|
669 |
return NAME; |
|
670 |
} |
|
671 |
|
|
672 |
public String getName() { |
|
673 |
return "buffer"+this.hashCode(); |
|
674 |
} |
|
675 |
|
|
676 |
public String getFullName() { |
|
677 |
return this.getName(); |
|
678 |
} |
|
679 |
|
|
680 |
public void setStatus(RasterProvider provider) { |
|
681 |
if(provider instanceof MemoryRasterProvider) { |
|
682 |
//Not implemented yet |
|
683 |
} |
|
684 |
} |
|
685 |
|
|
686 |
public TileServer getTileServer() { |
|
687 |
return null; |
|
688 |
} |
|
689 |
|
|
690 |
public void addFile(File file) throws InvalidSourceException { |
|
691 |
// Do nothing |
|
692 |
} |
|
693 |
|
|
694 |
public void removeFile(File file) { |
|
695 |
// Do nothing |
|
696 |
} |
|
697 |
|
|
698 |
} |
|
0 | 699 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/memory/io/MemoryDataParameters.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.memory.io; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
31 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
32 |
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters; |
|
33 |
|
|
34 |
/** |
|
35 |
* Parameters for the memory provider |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public class MemoryDataParameters extends AbstractRasterFileDataParameters { |
|
39 |
private final String id = "memory"; |
|
40 |
private Buffer buffer = null; |
|
41 |
private Extent extent = null; |
|
42 |
|
|
43 |
/** |
|
44 |
* Constructor vacio |
|
45 |
*/ |
|
46 |
public MemoryDataParameters() { |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Contructor |
|
51 |
* @param buf buffer del driver |
|
52 |
* @param ext extensi?n del buffer |
|
53 |
*/ |
|
54 |
public MemoryDataParameters(Buffer buf, Extent ext) { |
|
55 |
this.buffer = buf; |
|
56 |
this.extent = ext; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Obtiene el buffer de datos |
|
61 |
* @return Buffer |
|
62 |
*/ |
|
63 |
public Buffer getBuffer() { |
|
64 |
return buffer; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Asigna el buffer de datos |
|
69 |
* @param buffer Buffer |
|
70 |
*/ |
|
71 |
public void setBuffer(Buffer buffer) { |
|
72 |
this.buffer = buffer; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Obtiene la extensi?n del buffer de datos |
|
77 |
* @return Extent |
|
78 |
*/ |
|
79 |
public Extent getExtent() { |
|
80 |
return extent; |
|
81 |
} |
|
82 |
|
|
83 |
/**O |
|
84 |
* Asigna la extensi?n del buffer de datos |
|
85 |
* @param extent |
|
86 |
*/ |
|
87 |
public void setExtent(Extent extent) { |
|
88 |
this.extent = extent; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Obtiene el identificador del driver |
|
93 |
* @return String |
|
94 |
*/ |
|
95 |
public String getFormatID() { |
|
96 |
return id; |
|
97 |
} |
|
98 |
|
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName() |
|
102 |
*/ |
|
103 |
public String getDataStoreName() { |
|
104 |
return MemoryRasterProvider.NAME; |
|
105 |
} |
|
106 |
|
|
107 |
/* |
|
108 |
* (non-Javadoc) |
|
109 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDescription() |
|
110 |
*/ |
|
111 |
public String getDescription() { |
|
112 |
return MemoryRasterProvider.DESCRIPTION; |
|
113 |
} |
|
114 |
} |
|
0 | 115 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/util/DefaultCRSUtils.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.util; |
|
23 |
|
|
24 |
import org.cresques.cts.ICRSFactory; |
|
25 |
import org.cresques.cts.IProjection; |
|
26 |
import org.gdal.osr.SpatialReference; |
|
27 |
|
|
28 |
import org.gvsig.fmap.crs.CRSFactory; |
|
29 |
import org.gvsig.fmap.dal.coverage.util.CRSUtils; |
|
30 |
|
|
31 |
/** |
|
32 |
* Esta clase se encarga de hacer la conversion entre Wkt e IProjection. |
|
33 |
* |
|
34 |
* El uso se hace mediante dos llamadas estaticas que son: |
|
35 |
* convertIProjectionToWkt y |
|
36 |
* convertWktToIProjection. |
|
37 |
* |
|
38 |
* Antes de usarlos, hay que saber si tenemos acceso a gvSIG e intentar coger el |
|
39 |
* factory desde all?. |
|
40 |
* Ya que su uso consume tiempo y espacio de memoria y es preferible |
|
41 |
* reaprovechar ese objeto ya |
|
42 |
* creado. Esto se hace con setCRSFactory. |
|
43 |
* |
|
44 |
* En caso de no asignarse el ya existente, el crear? uno interno y lo dejara en |
|
45 |
* una variable estatica. |
|
46 |
* |
|
47 |
* @version 11/07/2008 |
|
48 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
49 |
*/ |
|
50 |
public class DefaultCRSUtils implements CRSUtils { |
|
51 |
|
|
52 |
private ICRSFactory factory = null; |
|
53 |
|
|
54 |
public void setCRSFactory(ICRSFactory factory) { |
|
55 |
this.factory = factory; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Devuelve el CRSFactory asignado desde fuera o creado desde dentro, todo |
|
60 |
* depende de como se haya |
|
61 |
* usado. |
|
62 |
* |
|
63 |
* @param code |
|
64 |
* @return |
|
65 |
*/ |
|
66 |
private IProjection getCRS(String code) { |
|
67 |
if (factory == null) |
|
68 |
factory = CRSFactory.getCRSFactory(); // new ProjectionPool(); |
|
69 |
return factory.get(code); |
|
70 |
} |
|
71 |
|
|
72 |
public IProjection convertWktToIProjection(String wkt) { |
|
73 |
if (wkt == null || wkt.equals("")) |
|
74 |
return null; |
|
75 |
|
|
76 |
String code = null; |
|
77 |
String name = null; |
|
78 |
|
|
79 |
SpatialReference oSRSSource = new SpatialReference(); |
|
80 |
|
|
81 |
oSRSSource.ImportFromWkt(wkt); |
|
82 |
|
|
83 |
code = oSRSSource.GetAuthorityCode("PROJCS"); |
|
84 |
if (code == null) |
|
85 |
code = oSRSSource.GetAuthorityCode("GEOGCS"); |
|
86 |
name = oSRSSource.GetAuthorityName("PROJCS"); |
|
87 |
if (name == null) |
|
88 |
name = oSRSSource.GetAuthorityName("GEOGCS"); |
|
89 |
try { |
|
90 |
if (name != null && code != null) |
|
91 |
return getCRS(name + ":" + code); |
|
92 |
} catch (NumberFormatException ex) { |
|
93 |
return null; |
|
94 |
} |
|
95 |
|
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
99 |
public String convertIProjectionToWkt(IProjection projection) { |
|
100 |
if (projection == null) |
|
101 |
return null; |
|
102 |
return projection.export(ICRSFactory.FORMAT_WKT); |
|
103 |
} |
|
104 |
} |
|
0 | 105 |
org.gvsig.raster.gdal/tags/org.gvsig.raster.gdal-2.2.155/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 |
*/ |
Also available in: Unified diff