Revision 2046
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuración general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
|
0 | 152 |
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/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.netcdf</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.1.0-SNAPSHOT</version> |
|
7 |
<name>org.gvsig.raster.netcdf</name> |
|
8 |
<description>NetCDF adapter</description> |
|
9 |
<inceptionYear>2011</inceptionYear> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop</artifactId> |
|
13 |
<version>2.0.16-SNAPSHOT</version> |
|
14 |
</parent> |
|
15 |
<scm> |
|
16 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.netcdf/trunk/org.gvsig.raster.netcdf</connection> |
|
17 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.netcdf/trunk/org.gvsig.raster.netcdf</developerConnection> |
|
18 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.netcdf/trunk/org.gvsig.raster.netcdf</url> |
|
19 |
</scm> |
|
20 |
<build> |
|
21 |
<plugins> |
|
22 |
<plugin> |
|
23 |
<groupId>org.apache.maven.plugins</groupId> |
|
24 |
<artifactId>maven-release-plugin</artifactId> |
|
25 |
<configuration> |
|
26 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.netcdf/tags/</tagBase> |
|
27 |
<goals>deploy</goals> |
|
28 |
</configuration> |
|
29 |
</plugin> |
|
30 |
</plugins> |
|
31 |
</build> |
|
32 |
<dependencyManagement> |
|
33 |
<dependencies> |
|
34 |
<dependency> |
|
35 |
<groupId>essi-unidata</groupId> |
|
36 |
<artifactId>netcdf-java</artifactId> |
|
37 |
<version>4.2</version> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.gvsig</groupId> |
|
41 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
42 |
<version>2.1.0-SNAPSHOT</version> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>org.gvsig</groupId> |
|
46 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
47 |
<version>2.1.0-SNAPSHOT</version> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>org.gvsig</groupId> |
|
51 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
52 |
<version>2.1.0-SNAPSHOT</version> |
|
53 |
</dependency> |
|
54 |
<!--<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.jproj</artifactId> |
|
57 |
<version>2.0.1-SNAPSHOT</version> |
|
58 |
<classifier>${native_classifier}</classifier> |
|
59 |
<type>tar.gz</type> |
|
60 |
</dependency>--> |
|
61 |
<dependency> |
|
62 |
<groupId>org.gvsig</groupId> |
|
63 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
64 |
<version>2.1.0-SNAPSHOT</version> |
|
65 |
</dependency> |
|
66 |
<dependency> |
|
67 |
<groupId>org.gvsig</groupId> |
|
68 |
<artifactId>org.gvsig.raster.netcdf.io</artifactId> |
|
69 |
<version>2.1.0-SNAPSHOT</version> |
|
70 |
</dependency> |
|
71 |
<dependency> |
|
72 |
<groupId>org.gvsig</groupId> |
|
73 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
74 |
<version>2.0.12-SNAPSHOT</version> |
|
75 |
<scope>compile</scope> |
|
76 |
</dependency> |
|
77 |
</dependencies> |
|
78 |
</dependencyManagement> |
|
79 |
<modules> |
|
80 |
<module>org.gvsig.raster.netcdf.io</module> |
|
81 |
<module>org.gvsig.raster.netcdf.app.netcdfclient</module> |
|
82 |
</modules> |
|
83 |
</project> |
|
0 | 84 |
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.netcdf.io.DefaultNetCDFIOLibrary |
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.io/src/main/java/org/gvsig/raster/netcdf/io/NetCDFProvider.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.netcdf.io; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.io.IOException; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
30 |
import org.gvsig.fmap.dal.DALLocator; |
|
31 |
import org.gvsig.fmap.dal.DataStore; |
|
32 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
33 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
34 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
35 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
39 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
40 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
|
41 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
42 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterFileStoreParameters; |
|
44 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
45 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
46 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
47 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
48 |
import org.gvsig.metadata.MetadataLocator; |
|
49 |
import org.gvsig.raster.cache.tile.provider.TileListener; |
|
50 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
51 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
52 |
import org.gvsig.raster.impl.datastruct.DefaultNoData; |
|
53 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
54 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
|
55 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
56 |
import org.gvsig.raster.impl.provider.tile.FileTileServer; |
|
57 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
|
58 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
59 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
60 |
import org.gvsig.tools.ToolsLocator; |
|
61 |
import org.gvsig.tools.task.TaskStatus; |
|
62 |
import org.slf4j.Logger; |
|
63 |
import org.slf4j.LoggerFactory; |
|
64 |
|
|
65 |
import ucar.ma2.Array; |
|
66 |
import ucar.ma2.DataType; |
|
67 |
import ucar.ma2.InvalidRangeException; |
|
68 |
import ucar.ma2.Range; |
|
69 |
import ucar.nc2.dt.GridDatatype; |
|
70 |
import ucar.nc2.dt.grid.GridDataset; |
|
71 |
import ucar.unidata.geoloc.ProjectionRect; |
|
72 |
/** |
|
73 |
* Data provider for NetCDF files with raster data |
|
74 |
* |
|
75 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
76 |
*/ |
|
77 |
public class NetCDFProvider extends DefaultRasterProvider { |
|
78 |
public static String NAME = "NetCDF Raster"; |
|
79 |
public static String DESCRIPTION = "NetCDF Raster file"; |
|
80 |
public final String METADATA_DEFINITION_NAME = NAME; |
|
81 |
private Extent viewRequest = null; |
|
82 |
private TileServer tileServer = null; |
|
83 |
private boolean open = false; |
|
84 |
|
|
85 |
private GridDataset gridNetCDF = null; |
|
86 |
private List<GridDatatype> gridList = null; |
|
87 |
private GridDatatype selectedGridDataType = null; |
|
88 |
private DataStoreTransparency fileTransparency = null; |
|
89 |
private static final Logger logger = LoggerFactory.getLogger(NetCDFProvider.class); |
|
90 |
protected static String[] formatList = null; |
|
91 |
|
|
92 |
public static void register() { |
|
93 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
94 |
RasterLocator.getManager().getProviderServices().registerFileProvidersTiled(NetCDFProvider.class); |
|
95 |
registerFormats(); |
|
96 |
|
|
97 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
|
98 |
dataman.registerStoreProvider(NAME, |
|
99 |
NetCDFProvider.class, NetCDFDataParametersImpl.class); |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 |
/*if (!dataman.getExplorerProviders().contains(NetCDFFilesystemServerExplorer.NAME)) { |
|
104 |
dataman.registerExplorerProvider(NetCDFFilesystemServerExplorer.NAME, NetCDFFilesystemServerExplorer.class, NetCDFServerExplorerParameters.class); |
|
105 |
}*/ |
|
106 |
|
|
107 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
|
108 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
|
109 |
NAME, DESCRIPTION, |
|
110 |
NetCDFFilesystemServerExplorer.class); |
|
111 |
|
|
112 |
|
|
113 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
|
114 |
} |
|
115 |
|
|
116 |
private static void registerFormats() { |
|
117 |
formatList = new String[] {"nc"}; |
|
118 |
for (int i = 0; i < formatList.length; i++) |
|
119 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i], NetCDFProvider.class); |
|
120 |
} |
|
121 |
|
|
122 |
/* |
|
123 |
* (non-Javadoc) |
|
124 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getFormatList() |
|
125 |
*/ |
|
126 |
public String[] getFormatList() { |
|
127 |
return formatList; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Returns true if the extension is supported and false if doesn't |
|
132 |
* @param ext |
|
133 |
* @return |
|
134 |
*/ |
|
135 |
public boolean isExtensionSupported(String ext) { |
|
136 |
if(ext.indexOf(".") != -1) |
|
137 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length()); |
|
138 |
for (int i = 0; i < formatList.length; i++) { |
|
139 |
if(formatList[i].compareTo(ext) == 0) |
|
140 |
return true; |
|
141 |
} |
|
142 |
return false; |
|
143 |
} |
|
144 |
|
|
145 |
public NetCDFProvider() { |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Opens the dataset. |
|
150 |
* @param proj Projection |
|
151 |
* @param fName File name |
|
152 |
* @throws NotSupportedExtensionException |
|
153 |
*/ |
|
154 |
public NetCDFProvider(String params) throws NotSupportedExtensionException, OpenException { |
|
155 |
super(params); |
|
156 |
if(params instanceof String) { |
|
157 |
NetCDFDataParameters p = new NetCDFDataParametersImpl(); |
|
158 |
p.setURI((String)params); |
|
159 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
|
160 |
.createDynObject( |
|
161 |
MetadataLocator.getMetadataManager().getDefinition( |
|
162 |
DataStore.METADATA_DEFINITION_NAME))); |
|
163 |
init(p, null); |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
public NetCDFProvider (NetCDFDataParameters params, |
|
168 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException { |
|
169 |
super(params, storeServices, ToolsLocator.getDynObjectManager() |
|
170 |
.createDynObject( |
|
171 |
MetadataLocator.getMetadataManager().getDefinition( |
|
172 |
DataStore.METADATA_DEFINITION_NAME))); |
|
173 |
init(params, storeServices); |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* Build file references |
|
178 |
* @param proj Projection |
|
179 |
* @param param Load parameters |
|
180 |
* @throws NotSupportedExtensionException |
|
181 |
*/ |
|
182 |
public void init (NetCDFDataParameters params, |
|
183 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException { |
|
184 |
|
|
185 |
if(((RasterFileStoreParameters)params).getFile().exists()) { |
|
186 |
String fileName = ((RasterFileStoreParameters)params).getFile().getAbsolutePath(); |
|
187 |
try { |
|
188 |
gridNetCDF = GridDataset.open(fileName); |
|
189 |
gridList = gridNetCDF.getGrids(); |
|
190 |
if(gridList.size() == 0) |
|
191 |
throw new OpenException("There is not a grid variable", null); |
|
192 |
selectedGridDataType = gridList.get(0); |
|
193 |
//netCDFFile = NetcdfFile.open(((RasterFileStoreParameters)params).getFile().getAbsolutePath()); |
|
194 |
} catch (IOException e) { |
|
195 |
throw new OpenException("Imposible to read the file", e); |
|
196 |
} |
|
197 |
|
|
198 |
/*List<Variable> variableList = netCDFFile.getVariables(); |
|
199 |
Iterator<Variable> it = variableList.iterator(); |
|
200 |
while(it.hasNext()) { |
|
201 |
Variable var = it.next(); |
|
202 |
System.out.println("===>>" + var.getName()); |
|
203 |
}*/ |
|
204 |
|
|
205 |
setParam(storeServices, params); |
|
206 |
reloadMetadataFromGrid(); |
|
207 |
|
|
208 |
noData = new DefaultNoData(Double.NaN, Double.NaN, fileName); |
|
209 |
load(); |
|
210 |
} else |
|
211 |
setParam(storeServices, params); |
|
212 |
|
|
213 |
super.init(); |
|
214 |
selectSubdataset(getId(0, 0, 0)); |
|
215 |
try { |
|
216 |
loadFromRmf(getRmfBlocksManager()); |
|
217 |
} catch (ParsingException e) { |
|
218 |
//No lee desde rmf |
|
219 |
} |
|
220 |
open = true; |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Reloads metadata using the selected grid |
|
225 |
*/ |
|
226 |
private void reloadMetadataFromGrid() { |
|
227 |
//wktProjection = null; |
|
228 |
//CrsWkt crs = new CrsWkt(wktProjection); |
|
229 |
//IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
230 |
|
|
231 |
/*LatLonRect gcs = selectedGridDataType.getCoordinateSystem().getLatLonBoundingBox(); |
|
232 |
getColorInterpretation(); |
|
233 |
double scaleX = gcs.getWidth() / selectedGridDataType.getXDimension().getLength(); |
|
234 |
double scaleY = gcs.getHeight() / selectedGridDataType.getYDimension().getLength(); |
|
235 |
ownTransformation = new AffineTransform( |
|
236 |
scaleX, 0, |
|
237 |
0, -scaleY, |
|
238 |
gcs.getLonMin(), |
|
239 |
gcs.getLatMax());*/ |
|
240 |
|
|
241 |
ProjectionRect pRect = selectedGridDataType.getCoordinateSystem().getBoundingBox(); |
|
242 |
double scaleX = pRect.getWidth() / selectedGridDataType.getXDimension().getLength(); |
|
243 |
double scaleY = pRect.getHeight() / selectedGridDataType.getYDimension().getLength(); |
|
244 |
ownTransformation = new AffineTransform( |
|
245 |
scaleX, 0, |
|
246 |
0, -scaleY, |
|
247 |
pRect.getMinX(), |
|
248 |
pRect.getMaxY()); |
|
249 |
externalTransformation = (AffineTransform)ownTransformation.clone(); |
|
250 |
bandCount = 1; //One variable is always shown |
|
251 |
setDataType(); |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* @param dataType The dataType to set. |
|
256 |
*/ |
|
257 |
private void setDataType() { |
|
258 |
DataType dt = selectedGridDataType.getDataType(); |
|
259 |
int type = Buffer.TYPE_UNDEFINED; |
|
260 |
if(dt.name() == DataType.BYTE.name()) { |
|
261 |
type = Buffer.TYPE_BYTE; |
|
262 |
} |
|
263 |
if(dt.name() == DataType.SHORT.name()) { |
|
264 |
type = Buffer.TYPE_SHORT; |
|
265 |
} |
|
266 |
if(dt.name() == DataType.INT.name()) { |
|
267 |
type = Buffer.TYPE_INT; |
|
268 |
} |
|
269 |
if(dt.name() == DataType.DOUBLE.name()) { |
|
270 |
type = Buffer.TYPE_DOUBLE; |
|
271 |
} |
|
272 |
if(dt.name() == DataType.FLOAT.name()) { |
|
273 |
type = Buffer.TYPE_FLOAT; |
|
274 |
} |
|
275 |
if(dt.name() == DataType.LONG.name()) { |
|
276 |
type = Buffer.TYPE_DOUBLE; |
|
277 |
} |
|
278 |
|
|
279 |
int[] dtype = new int[getBandCount()]; |
|
280 |
for (int i = 0; i < dtype.length; i++) |
|
281 |
dtype[i] = type; |
|
282 |
setDataType(dtype); |
|
283 |
} |
|
284 |
|
|
285 |
/* |
|
286 |
* (non-Javadoc) |
|
287 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#load() |
|
288 |
*/ |
|
289 |
public RasterProvider load() { |
|
290 |
return this; |
|
291 |
} |
|
292 |
|
|
293 |
/* |
|
294 |
* (non-Javadoc) |
|
295 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isOpen() |
|
296 |
*/ |
|
297 |
public boolean isOpen() { |
|
298 |
return open; |
|
299 |
} |
|
300 |
|
|
301 |
/* |
|
302 |
* (non-Javadoc) |
|
303 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#close() |
|
304 |
*/ |
|
305 |
public void close() { |
|
306 |
try { |
|
307 |
gridNetCDF.close(); |
|
308 |
} catch (IOException e) { |
|
309 |
logger.error("Error closing file", e); |
|
310 |
} |
|
311 |
} |
|
312 |
|
|
313 |
/* |
|
314 |
* (non-Javadoc) |
|
315 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#translateFileName(java.lang.String) |
|
316 |
*/ |
|
317 |
public String translateFileName(String fileName) { |
|
318 |
return fileName; |
|
319 |
} |
|
320 |
|
|
321 |
/** |
|
322 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci�n |
|
323 |
* de la vista asignada ya que la petici�n viene en coordenadas del fichero .rmf y la vista (v) |
|
324 |
* ha de estar en coordenadas del fichero. |
|
325 |
*/ |
|
326 |
public void setView(Extent e) { |
|
327 |
viewRequest = new ExtentImpl(e); |
|
328 |
} |
|
329 |
|
|
330 |
/* |
|
331 |
* (non-Javadoc) |
|
332 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getView() |
|
333 |
*/ |
|
334 |
public Extent getView() { |
|
335 |
return viewRequest; |
|
336 |
} |
|
337 |
|
|
338 |
/* |
|
339 |
* (non-Javadoc) |
|
340 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWidth() |
|
341 |
*/ |
|
342 |
public double getWidth() { |
|
343 |
return selectedGridDataType.getXDimension().getLength(); |
|
344 |
} |
|
345 |
|
|
346 |
/* |
|
347 |
* (non-Javadoc) |
|
348 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getHeight() |
|
349 |
*/ |
|
350 |
public double getHeight() { |
|
351 |
return selectedGridDataType.getYDimension().getLength(); |
|
352 |
} |
|
353 |
|
|
354 |
/* |
|
355 |
* (non-Javadoc) |
|
356 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int, double) |
|
357 |
*/ |
|
358 |
public Object readBlock(int pos, int blockHeight, double scale) |
|
359 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException { |
|
360 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
361 |
if(pos < 0) |
|
362 |
throw new InvalidSetViewException("Request out of grid"); |
|
363 |
|
|
364 |
if((pos + blockHeight) > getHeight()) |
|
365 |
blockHeight = Math.abs(((int)getHeight()) - pos); |
|
366 |
|
|
367 |
Buffer buf = DefaultRasterManager.getInstance().createBuffer(getDataType()[0], (int)getWidth(), blockHeight, 1, true); |
|
368 |
try { |
|
369 |
int time = p.getFieldTime(); |
|
370 |
int level = getLevelValue(); |
|
371 |
Range rangeY = new Range(pos, pos + blockHeight - 1, 1); |
|
372 |
Range rangeX = new Range(0, (int)(getWidth() - 1), 1); |
|
373 |
GridDatatype dt = selectedGridDataType.makeSubset(null, null, null, null /*getTime(1), getLevel(1)*/, rangeY, rangeX); |
|
374 |
Array values = dt.readDataSlice(time, level, -1, -1); |
|
375 |
return arrayValuesToBuffer(values, buf, rangeX.length(), rangeY.length(), null); |
|
376 |
} catch (IOException e) { |
|
377 |
throw new RasterDriverException("Error reading a slice", e); |
|
378 |
} catch (InvalidRangeException e) { |
|
379 |
throw new RasterDriverException("Error reading a slice", e); |
|
380 |
} |
|
381 |
} |
|
382 |
|
|
383 |
/* |
|
384 |
* (non-Javadoc) |
|
385 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getData(int, int, int) |
|
386 |
*/ |
|
387 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
388 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
389 |
if(x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) |
|
390 |
throw new InvalidSetViewException("Request out of grid"); |
|
391 |
try { |
|
392 |
int strideX = 1; |
|
393 |
int strideY = 1; |
|
394 |
Range rangeY = new Range((int)(getHeight() - y), (int)(getHeight() - y), strideY); |
|
395 |
Range rangeX = new Range(x, x, strideX); |
|
396 |
|
|
397 |
selectSubdataset(); |
|
398 |
int time = p.getFieldTime(); |
|
399 |
int level = getLevelValue(); |
|
400 |
GridDatatype dt = selectedGridDataType.makeSubset(null, null, null, null, rangeY, rangeX); |
|
401 |
Array values = dt.readDataSlice(time, level, -1, -1); |
|
402 |
Object data = null; |
|
403 |
|
|
404 |
if(getDataType()[0] == Buffer.TYPE_BYTE) { |
|
405 |
data = new java.lang.Integer(values.getByte(0)); |
|
406 |
} |
|
407 |
|
|
408 |
if(getDataType()[0] == Buffer.TYPE_SHORT) { |
|
409 |
data = new java.lang.Integer(values.getShort(0)); |
|
410 |
} |
|
411 |
|
|
412 |
if(getDataType()[0] == Buffer.TYPE_INT) { |
|
413 |
data = new java.lang.Integer(values.getInt(0)); |
|
414 |
} |
|
415 |
|
|
416 |
if(getDataType()[0] == Buffer.TYPE_FLOAT) { |
|
417 |
data = new java.lang.Float(values.getFloat(0)); |
|
418 |
} |
|
419 |
if(getDataType()[0] == Buffer.TYPE_DOUBLE) { |
|
420 |
data = new java.lang.Double(values.getDouble(0)); |
|
421 |
} |
|
422 |
return data; |
|
423 |
} catch (IOException e) { |
|
424 |
throw new RasterDriverException("Error reading a slice", e); |
|
425 |
} catch (InvalidRangeException e) { |
|
426 |
throw new RasterDriverException("Error reading a slice", e); |
|
427 |
} |
|
428 |
} |
|
429 |
|
|
430 |
/* |
|
431 |
* (non-Javadoc) |
|
432 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.raster.cache.tile.provider.TileListener) |
|
433 |
*/ |
|
434 |
public void getWindow(Extent ex, int bufWidth, int bufHeight, |
|
435 |
BandList bandList, TileListener listener, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
436 |
} |
|
437 |
|
|
438 |
/* |
|
439 |
* (non-Javadoc) |
|
440 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(org.gvsig.fmap.dal.coverage.datastruct.Extent, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer) |
|
441 |
*/ |
|
442 |
public Buffer getWindow(Extent extent, BandList bandList, Buffer rasterBuf, TaskStatus status) |
|
443 |
throws ProcessInterruptedException, RasterDriverException { |
|
444 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
445 |
setView(extent); |
|
446 |
|
|
447 |
Point2D ul = new Point2D.Double(viewRequest.getULX(), viewRequest.getULY()); |
|
448 |
Point2D lr = new Point2D.Double(viewRequest.getLRX(), viewRequest.getLRY()); |
|
449 |
ul = worldToRaster(ul); |
|
450 |
lr = worldToRaster(lr); |
|
451 |
ul.setLocation(ul.getX() < 0 ? 0 : ul.getX(), ul.getY() < 0 ? 0 : ul.getY()); |
|
452 |
lr.setLocation(lr.getX() < 0 ? 0 : lr.getX(), lr.getY() < 0 ? 0 : lr.getY()); |
|
453 |
ul.setLocation(ul.getX() > getWidth() ? getWidth() : ul.getX(), ul.getY() > getHeight() ? getHeight() : ul.getY()); |
|
454 |
lr.setLocation(lr.getX() > getWidth() ? getWidth() : lr.getX(), lr.getY() > getHeight() ? getHeight() : lr.getY()); |
|
455 |
|
|
456 |
adjustPoints(ul, lr); |
|
457 |
|
|
458 |
try { |
|
459 |
int strideX = 1; |
|
460 |
int strideY = 1; |
|
461 |
Range rangeY = new Range((int)(getHeight() - lr.getY()), (int)(getHeight() - ul.getY() - 1), strideY); |
|
462 |
Range rangeX = new Range((int)ul.getX(), (int)(lr.getX() - 1), strideX); |
|
463 |
|
|
464 |
selectSubdataset(); |
|
465 |
int time = p.getFieldTime(); |
|
466 |
int level = getLevelValue(); |
|
467 |
GridDatatype dt = selectedGridDataType.makeSubset(null, null, null, null /*getTime(strideX), getLevel(strideX)*/, rangeY, rangeX); |
|
468 |
Array values = dt.readDataSlice(time, level, -1, -1); |
|
469 |
rasterBuf = arrayValuesToBuffer(values, rasterBuf, rangeX.length(), rangeY.length(), bandList); |
|
470 |
} catch (IOException e) { |
|
471 |
throw new RasterDriverException("Error reading a slice", e); |
|
472 |
} catch (InvalidRangeException e) { |
|
473 |
throw new RasterDriverException("Error reading a slice", e); |
|
474 |
} |
|
475 |
|
|
476 |
return rasterBuf; |
|
477 |
} |
|
478 |
|
|
479 |
/** |
|
480 |
* Gets the Range of the selected time or null if there is not a selected time |
|
481 |
* @param strideX |
|
482 |
* @return |
|
483 |
* @throws InvalidRangeException |
|
484 |
*/ |
|
485 |
@SuppressWarnings("unused") |
|
486 |
private Range getTime(int strideX) throws InvalidRangeException { |
|
487 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
488 |
int time = p.getFieldTime(); |
|
489 |
return new Range(time, time, strideX); |
|
490 |
} |
|
491 |
|
|
492 |
/*private int getTimeValue() { |
|
493 |
int time = 0; |
|
494 |
if(param.hasDynValue(NetCDFDataParameters.FIELD_TIME)) |
|
495 |
time = ((Integer)param.getDynValue(NetCDFDataParameters.FIELD_TIME)).intValue(); |
|
496 |
return time; |
|
497 |
}*/ |
|
498 |
|
|
499 |
/** |
|
500 |
* Gets the Range of the selected level or null if there is not a selected level |
|
501 |
* @param strideX |
|
502 |
* @return |
|
503 |
* @throws InvalidRangeException |
|
504 |
*/ |
|
505 |
@SuppressWarnings("unused") |
|
506 |
private Range getLevel(int strideX) throws InvalidRangeException { |
|
507 |
int level = getLevelValue(); |
|
508 |
return new Range(level, level, strideX); |
|
509 |
} |
|
510 |
|
|
511 |
private int getLevelValue() { |
|
512 |
int level = 0; |
|
513 |
if(param.hasDynValue(NetCDFDataParameters.FIELD_LEVEL)) |
|
514 |
level = ((Integer)param.getDynValue(NetCDFDataParameters.FIELD_LEVEL)).intValue(); |
|
515 |
return level; |
|
516 |
} |
|
517 |
|
|
518 |
|
|
519 |
/** |
|
520 |
* Selects the GridDataType using the selected variable in the parameters |
|
521 |
*/ |
|
522 |
public void selectSubdataset() { |
|
523 |
if(param.hasDynValue(NetCDFDataParameters.FIELD_VARIABLE)) { |
|
524 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
525 |
String variable = (String)param.getDynValue(NetCDFDataParameters.FIELD_VARIABLE); |
|
526 |
if(variable != null) { |
|
527 |
for (int j = 0; j < gridList.size(); j++) { |
|
528 |
if(gridList.get(j).getName().compareTo(variable) == 0) { |
|
529 |
selectedGridDataType = gridList.get(j); |
|
530 |
reloadMetadataFromGrid(); |
|
531 |
super.selectSubdataset(getId(j, getLevelValue(), p.getFieldTime())); |
|
532 |
} |
|
533 |
} |
|
534 |
} |
|
535 |
} |
|
536 |
} |
|
537 |
|
|
538 |
/** |
|
539 |
* Gets the identifier of a subdataset |
|
540 |
* @param grid |
|
541 |
* @param level |
|
542 |
* @param time |
|
543 |
* @return |
|
544 |
*/ |
|
545 |
private String getId(int grid, int level, int time) { |
|
546 |
return grid + "-" + level + "-" + time; |
|
547 |
} |
|
548 |
|
|
549 |
/** |
|
550 |
* Loads a Buffer object from an netCDF Array. |
|
551 |
* @param values |
|
552 |
* @param rasterBuf |
|
553 |
* @param w |
|
554 |
* @param h |
|
555 |
* @return |
|
556 |
*/ |
|
557 |
private Buffer arrayValuesToBuffer(Array values, Buffer rasterBuf, int w, int h, BandList bandList) { |
|
558 |
Buffer buf = null; |
|
559 |
boolean resampling = false; |
|
560 |
|
|
561 |
if((rasterBuf.getWidth() * rasterBuf.getHeight()) != values.getSize()) { |
|
562 |
buf = DefaultRasterManager.getInstance().createBuffer(getDataType()[0], w, h, rasterBuf.getBandCount(), true); |
|
563 |
resampling = true; |
|
564 |
} else |
|
565 |
buf = rasterBuf; |
|
566 |
|
|
567 |
int[] drawableBands = bandList != null ? bandList.getBufferBandToDraw(getURIOfFirstProvider(), 0) : new int[1]; |
|
568 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
569 |
return rasterBuf; |
|
570 |
|
|
571 |
if(getDataType()[0] == Buffer.TYPE_BYTE) { |
|
572 |
for (int i = 0; i < values.getSize(); i++) { |
|
573 |
int[] rc = getColAndRow(i, buf); |
|
574 |
for (int iBands = 0; iBands < drawableBands.length; iBands++) |
|
575 |
buf.setElem(rc[0], rc[1], drawableBands[iBands], values.getByte(i)); |
|
576 |
} |
|
577 |
} |
|
578 |
|
|
579 |
if(getDataType()[0] == Buffer.TYPE_SHORT) { |
|
580 |
for (int i = 0; i < values.getSize(); i++) { |
|
581 |
int[] rc = getColAndRow(i, buf); |
|
582 |
for (int iBands = 0; iBands < drawableBands.length; iBands++) |
|
583 |
buf.setElem(rc[0], rc[1], drawableBands[iBands], values.getShort(i)); |
|
584 |
} |
|
585 |
} |
|
586 |
|
|
587 |
if(getDataType()[0] == Buffer.TYPE_INT) { |
|
588 |
for (int i = 0; i < values.getSize(); i++) { |
|
589 |
int[] rc = getColAndRow(i, buf); |
|
590 |
for (int iBands = 0; iBands < drawableBands.length; iBands++) |
|
591 |
buf.setElem(rc[0], rc[1], drawableBands[iBands], values.getInt(i)); |
|
592 |
} |
|
593 |
} |
|
594 |
|
|
595 |
if(getDataType()[0] == Buffer.TYPE_FLOAT) { |
|
596 |
for (int i = 0; i < values.getSize(); i++) { |
|
597 |
int[] rc = getColAndRow(i, buf); |
|
598 |
for (int iBands = 0; iBands < drawableBands.length; iBands++) |
|
599 |
buf.setElem(rc[0], rc[1], drawableBands[iBands], values.getFloat(i)); |
|
600 |
} |
|
601 |
} |
|
602 |
|
|
603 |
if(getDataType()[0] == Buffer.TYPE_DOUBLE) { |
|
604 |
for (int i = 0; i < values.getSize(); i++) { |
|
605 |
int[] rc = getColAndRow(i, buf); |
|
606 |
for (int iBands = 0; iBands < drawableBands.length; iBands++) |
|
607 |
buf.setElem(rc[0], rc[1], drawableBands[iBands], values.getDouble(i)); |
|
608 |
} |
|
609 |
} |
|
610 |
if(resampling) { |
|
611 |
try { |
|
612 |
Buffer result = null; |
|
613 |
result = buf.getAdjustedWindow(rasterBuf.getWidth(), rasterBuf.getHeight(), Buffer.INTERPOLATION_NearestNeighbour); |
|
614 |
if(result != buf) |
|
615 |
buf.dispose(); |
|
616 |
return result; |
|
617 |
} catch (ProcessInterruptedException e) { |
|
618 |
return buf; |
|
619 |
} |
|
620 |
} |
|
621 |
return buf; |
|
622 |
} |
|
623 |
|
|
624 |
/** |
|
625 |
* Calculates the row and column number for the position i in the |
|
626 |
* array of data |
|
627 |
* @param i |
|
628 |
* @param buf |
|
629 |
* @return |
|
630 |
*/ |
|
631 |
private int[] getColAndRow(int i, Buffer buf) { |
|
632 |
int auxRow = (int)(i / buf.getWidth()); |
|
633 |
return new int[]{ |
|
634 |
(int)buf.getHeight() - auxRow - 1, |
|
635 |
i - (auxRow * buf.getWidth()) |
|
636 |
}; |
|
637 |
} |
|
638 |
|
|
639 |
/* |
|
640 |
* (non-Javadoc) |
|
641 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean) |
|
642 |
*/ |
|
643 |
public Buffer getWindow(double ulx, double uly, double w, double h, |
|
644 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
645 |
return rasterBuf; |
|
646 |
} |
|
647 |
|
|
648 |
/* |
|
649 |
* (non-Javadoc) |
|
650 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean) |
|
651 |
*/ |
|
652 |
public Buffer getWindow(Extent extent, int bufWidth, int bufHeight, |
|
653 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
654 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
655 |
setView(extent); |
|
656 |
|
|
657 |
Point2D ul = new Point2D.Double(viewRequest.getULX(), viewRequest.getULY()); |
|
658 |
Point2D lr = new Point2D.Double(viewRequest.getLRX(), viewRequest.getLRY()); |
|
659 |
ul = worldToRaster(ul); |
|
660 |
lr = worldToRaster(lr); |
|
661 |
ul.setLocation(ul.getX() < 0 ? 0 : ul.getX(), ul.getY() < 0 ? 0 : ul.getY()); |
|
662 |
lr.setLocation(lr.getX() < 0 ? 0 : lr.getX(), lr.getY() < 0 ? 0 : lr.getY()); |
|
663 |
ul.setLocation(ul.getX() >= getWidth() ? getWidth() - 1 : ul.getX(), ul.getY() >= getHeight() ? getHeight() - 1 : ul.getY()); |
|
664 |
lr.setLocation(lr.getX() >= getWidth() ? getWidth() - 1 : lr.getX(), lr.getY() >= getHeight() ? getHeight() - 1 : lr.getY()); |
|
665 |
|
|
666 |
adjustPoints(ul, lr); |
|
667 |
|
|
668 |
int width = Math.abs(((int)lr.getX()) - ((int)ul.getX())); |
|
669 |
int height = Math.abs(((int)lr.getY()) - ((int)ul.getY())); |
|
670 |
|
|
671 |
try { |
|
672 |
int strideX = width / rasterBuf.getWidth(); |
|
673 |
int strideY = height / rasterBuf.getHeight(); |
|
674 |
Range rangeY = new Range((int)(getHeight() - lr.getY()), (int)(getHeight() - ul.getY() - 1), strideY <= 0 ? 1 : strideY); |
|
675 |
Range rangeX = new Range((int)ul.getX(), (int)(lr.getX() - 1), strideX <= 0 ? 1 : strideX); |
|
676 |
|
|
677 |
selectSubdataset(); |
|
678 |
int time = p.getFieldTime(); |
|
679 |
int level = getLevelValue(); |
|
680 |
GridDatatype dt = selectedGridDataType.makeSubset(null, null, null, null /*getTime(strideX), getLevel(strideX)*/, rangeY, rangeX); |
|
681 |
Array values = dt.readDataSlice(time, level, -1, -1); |
|
682 |
rasterBuf = arrayValuesToBuffer(values, rasterBuf, rangeX.length(), rangeY.length(), bandList); |
|
683 |
} catch (IOException e) { |
|
684 |
throw new RasterDriverException("Error reading a slice", e); |
|
685 |
} catch (InvalidRangeException e) { |
|
686 |
throw new RasterDriverException("Error reading a slice", e); |
|
687 |
} |
|
688 |
|
|
689 |
return rasterBuf; |
|
690 |
} |
|
691 |
|
|
692 |
private void adjustPoints(Point2D ul, Point2D lr) { |
|
693 |
double a = (ul.getX() - (int)ul.getX()); |
|
694 |
double b = (ul.getY() - (int)ul.getY()); |
|
695 |
ul.setLocation( (a > 0.95 || a < 0.05) ? Math.round(ul.getX()) : ul.getX(), |
|
696 |
(b > 0.95 || b < 0.05) ? Math.round(ul.getY()) : ul.getY()); |
|
697 |
lr.setLocation( (a > 0.95 || a < 0.05) ? Math.round(lr.getX()) : lr.getX(), |
|
698 |
(b > 0.95 || b < 0.05) ? Math.round(lr.getY()) : lr.getY()); |
|
699 |
} |
|
700 |
|
|
701 |
/* |
|
702 |
* (non-Javadoc) |
|
703 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(int, int, int, int, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer) |
|
704 |
*/ |
|
705 |
public Buffer getWindow(int x, int y, int w, int h, |
|
706 |
BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
707 |
try { |
|
708 |
NetCDFDataParameters p = (NetCDFDataParameters)param; |
|
709 |
int strideX = 1; |
|
710 |
int strideY = 1; |
|
711 |
Range rangeY = new Range((int)(h - y), (int)(h - y - 1), strideY); |
|
712 |
Range rangeX = new Range((int)x, (int)(x + w - 1), strideX); |
|
713 |
|
|
714 |
selectSubdataset(); |
|
715 |
int time = p.getFieldTime(); |
|
716 |
int level = getLevelValue(); |
|
717 |
GridDatatype dt = selectedGridDataType.makeSubset(null, null, null, null, rangeY, rangeX); |
|
718 |
Array values = dt.readDataSlice(time, level, -1, -1); |
|
719 |
rasterBuf = arrayValuesToBuffer(values, rasterBuf, rangeX.length(), rangeY.length(), bandList); |
|
720 |
} catch (IOException e) { |
|
721 |
throw new RasterDriverException("Error reading a slice", e); |
|
722 |
} catch (InvalidRangeException e) { |
|
723 |
throw new RasterDriverException("Error reading a slice", e); |
|
724 |
} |
|
725 |
|
|
726 |
return rasterBuf; |
|
727 |
} |
|
728 |
|
|
729 |
/* |
|
730 |
* (non-Javadoc) |
|
731 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getBlockSize() |
|
732 |
*/ |
|
733 |
public int getBlockSize(){ |
|
734 |
return 0; |
|
735 |
} |
|
736 |
|
|
737 |
/* |
|
738 |
* (non-Javadoc) |
|
739 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getColorInterpretation() |
|
740 |
*/ |
|
741 |
public ColorInterpretation getColorInterpretation() { |
|
742 |
if(super.getColorInterpretation() == null) { |
|
743 |
setColorInterpretation(new DataStoreColorInterpretation(new String[]{ColorInterpretation.GRAY_BAND})); |
|
744 |
} |
|
745 |
return super.getColorInterpretation(); |
|
746 |
} |
|
747 |
|
|
748 |
/* |
|
749 |
* (non-Javadoc) |
|
750 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getTransparency() |
|
751 |
*/ |
|
752 |
public DataStoreTransparency getTransparency() { |
|
753 |
if(fileTransparency == null) |
|
754 |
fileTransparency = new DataStoreTransparency(); |
|
755 |
return fileTransparency; |
|
756 |
} |
|
757 |
|
|
758 |
/** |
|
759 |
* Informa de si el driver ha supersampleado en el �ltimo dibujado. Es el driver el que colocar� |
|
760 |
* el valor de esta variable cada vez que dibuja. |
|
761 |
* @return true si se ha supersampleado y false si no se ha hecho. |
|
762 |
*/ |
|
763 |
public boolean isSupersampling() { |
|
764 |
return false; |
|
765 |
} |
|
766 |
|
|
767 |
/* |
|
768 |
* (non-Javadoc) |
|
769 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setAffineTransform(java.awt.geom.AffineTransform) |
|
770 |
*/ |
|
771 |
public void setAffineTransform(AffineTransform t){ |
|
772 |
super.setAffineTransform(t); |
|
773 |
} |
|
774 |
|
|
775 |
/* |
|
776 |
* (non-Javadoc) |
|
777 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewCount(int) |
|
778 |
*/ |
|
779 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
|
780 |
if(band >= getBandCount()) |
|
781 |
throw new BandAccessException("Wrong band"); |
|
782 |
return 0; |
|
783 |
} |
|
784 |
|
|
785 |
/* |
|
786 |
* (non-Javadoc) |
|
787 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewWidth(int, int) |
|
788 |
*/ |
|
789 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
|
790 |
if (band >= getBandCount()) |
|
791 |
throw new BandAccessException("Wrong band"); |
|
792 |
return 0; |
|
793 |
} |
|
794 |
|
|
795 |
/* |
|
796 |
* (non-Javadoc) |
|
797 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewHeight(int, int) |
|
798 |
*/ |
|
799 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
|
800 |
if (band >= getBandCount()) |
|
801 |
throw new BandAccessException("Wrong band"); |
|
802 |
return 0; |
|
803 |
} |
|
804 |
|
|
805 |
/* |
|
806 |
* (non-Javadoc) |
|
807 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isOverviewsSupported() |
|
808 |
*/ |
|
809 |
public boolean isOverviewsSupported() { |
|
810 |
return true; |
|
811 |
} |
|
812 |
|
|
813 |
/* |
|
814 |
* (non-Javadoc) |
|
815 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isReproyectable() |
|
816 |
*/ |
|
817 |
public boolean isReproyectable() { |
|
818 |
return true; |
|
819 |
} |
|
820 |
|
|
821 |
/* |
|
822 |
* (non-Javadoc) |
|
823 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getName() |
|
824 |
*/ |
|
825 |
public String getName() { |
|
826 |
return NAME; |
|
827 |
} |
|
828 |
|
|
829 |
/* |
|
830 |
* (non-Javadoc) |
|
831 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setStatus(org.gvsig.raster.impl.provider.RasterProvider) |
|
832 |
*/ |
|
833 |
public void setStatus(RasterProvider provider) { |
|
834 |
if(provider instanceof NetCDFProvider) { |
|
835 |
//Not implemented yet |
|
836 |
} |
|
837 |
} |
|
838 |
|
|
839 |
/* |
|
840 |
* (non-Javadoc) |
|
841 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isTimeSupported() |
|
842 |
*/ |
|
843 |
public boolean isTimeSupported() { |
|
844 |
return true; |
|
845 |
} |
|
846 |
|
|
847 |
/* |
|
848 |
* (non-Javadoc) |
|
849 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getTileServer() |
|
850 |
*/ |
|
851 |
public TileServer getTileServer() { |
|
852 |
if(tileServer == null) |
|
853 |
tileServer = new FileTileServer(this); |
|
854 |
return tileServer; |
|
855 |
} |
|
856 |
} |
|
0 | 857 |
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.io/src/main/java/org/gvsig/raster/netcdf/io/NetCDFServerExplorerParameters.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.netcdf.io; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
34 |
import org.gvsig.tools.dynobject.DynClass; |
|
35 |
import org.gvsig.tools.dynobject.DynField; |
|
36 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
37 |
|
|
38 |
|
|
39 |
/** |
|
40 |
* Parameters for the NetCDF explorer |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class NetCDFServerExplorerParameters extends FilesystemServerExplorerParameters |
|
44 |
implements DataServerExplorerParameters { |
|
45 |
public static final String PARAMS_NAME = "NetCDFRasterServerExplorerParameters"; |
|
46 |
protected static DynClass DYNCLASS = null; |
|
47 |
private static final String FIELD_ROOT = "root"; |
|
48 |
private static DelegatedDynObject delegatedDynObject = null; |
|
49 |
|
|
50 |
public NetCDFServerExplorerParameters() { |
|
51 |
super(); |
|
52 |
initialize(); |
|
53 |
} |
|
54 |
|
|
55 |
protected void initialize() { |
|
56 |
delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
57 |
.getDynObjectManager().createDynObject( |
|
58 |
DYNCLASS); |
|
59 |
} |
|
60 |
|
|
61 |
public static DynClass registerDynClass() { |
|
62 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
63 |
DynClass dynClass = dynman.get(PARAMS_NAME); |
|
64 |
DynField field; |
|
65 |
if (dynClass == null) { |
|
66 |
dynClass = dynman.add(PARAMS_NAME); |
|
67 |
|
|
68 |
field = dynClass.addDynFieldString(FIELD_ROOT); |
|
69 |
field.setDescription("Root directory path of the explorer"); |
|
70 |
field.setMandatory(false); |
|
71 |
field.setClassOfValue(String.class); |
|
72 |
|
|
73 |
field = dynClass.addDynFieldString("initialpath"); |
|
74 |
field.setDescription("Initial path of the explorer"); |
|
75 |
field.setMandatory(false); |
|
76 |
field.setClassOfValue(String.class); |
|
77 |
DYNCLASS = dynClass; |
|
78 |
} |
|
79 |
return dynClass; |
|
80 |
} |
|
81 |
|
|
82 |
public void setRoot(String path) { |
|
83 |
this.setDynValue(FIELD_ROOT, path); |
|
84 |
} |
|
85 |
|
|
86 |
public String getRoot() { |
|
87 |
return (String) this.getDynValue(FIELD_ROOT); |
|
88 |
} |
|
89 |
|
|
90 |
public void setInitialpath(String path) { |
|
91 |
this.setDynValue("initialpath", path); |
|
92 |
} |
|
93 |
|
|
94 |
public String getInitialpath() { |
|
95 |
return (String) this.getDynValue("initialpath"); |
|
96 |
} |
|
97 |
|
|
98 |
public String getExplorerName() { |
|
99 |
return NetCDFFilesystemServerExplorer.NAME; |
|
100 |
} |
|
101 |
|
|
102 |
public String getDataStoreName() { |
|
103 |
return NetCDFProvider.NAME; |
|
104 |
} |
|
105 |
|
|
106 |
public String getDescription() { |
|
107 |
return NetCDFProvider.DESCRIPTION; |
|
108 |
} |
|
109 |
|
|
110 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
111 |
return delegatedDynObject; |
|
112 |
} |
|
113 |
} |
|
0 | 114 |
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.io/src/main/java/org/gvsig/raster/netcdf/io/NetCDFFilesystemServerExplorer.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.netcdf.io; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.gvsig.fmap.dal.DALLocator; |
|
34 |
import org.gvsig.fmap.dal.DataManager; |
|
35 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
36 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
37 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
38 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
39 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
40 |
import org.gvsig.fmap.dal.exception.CreateException; |
|
41 |
import org.gvsig.fmap.dal.exception.DataException; |
|
42 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
43 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
|
44 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
45 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
46 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
47 |
|
|
48 |
public class NetCDFFilesystemServerExplorer extends AbstractFilesystemServerExplorerProvider implements FilesystemServerExplorerProvider { |
|
49 |
public static final String NAME = NetCDFProvider.NAME; |
|
50 |
|
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#canCreate() |
|
54 |
*/ |
|
55 |
public boolean canCreate() { |
|
56 |
return false; |
|
57 |
} |
|
58 |
|
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#canCreate(org.gvsig.fmap.dal.NewDataStoreParameters) |
|
62 |
*/ |
|
63 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
64 |
return false; |
|
65 |
} |
|
66 |
|
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#create(org.gvsig.fmap.dal.NewDataStoreParameters, boolean) |
|
70 |
*/ |
|
71 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
|
72 |
throws CreateException { |
|
73 |
throw new UnsupportedOperationException(); |
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#getCreateParameters() |
|
79 |
*/ |
|
80 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
81 |
return null; |
|
82 |
} |
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#initialize(org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices) |
|
87 |
*/ |
|
88 |
public void initialize(FilesystemServerExplorerProviderServices serverExplorer) { |
|
89 |
} |
|
90 |
|
|
91 |
/* |
|
92 |
* (non-Javadoc) |
|
93 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#remove(org.gvsig.fmap.dal.DataStoreParameters) |
|
94 |
*/ |
|
95 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
96 |
throw new UnsupportedOperationException(); |
|
97 |
} |
|
98 |
|
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter#getDataStoreProviderName() |
|
102 |
*/ |
|
103 |
public String getDataStoreProviderName() { |
|
104 |
return NetCDFProvider.NAME; |
|
105 |
} |
|
106 |
|
|
107 |
/* |
|
108 |
* (non-Javadoc) |
|
109 |
* @see java.io.FileFilter#accept(java.io.File) |
|
110 |
*/ |
|
111 |
public boolean accept(File pathname) { |
|
112 |
return RasterLocator.getManager().getProviderServices().isExtensionSupported( |
|
113 |
pathname.getAbsolutePath(), |
|
114 |
NetCDFProvider.class); |
|
115 |
} |
|
116 |
|
|
117 |
/* |
|
118 |
* (non-Javadoc) |
|
119 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter#getDescription() |
|
120 |
*/ |
|
121 |
public String getDescription() { |
|
122 |
return NetCDFProvider.DESCRIPTION; |
|
123 |
} |
|
124 |
|
|
125 |
public DataStoreParameters getParameters(File file) throws DataException { |
|
126 |
DataManager manager = DALLocator.getDataManager(); |
|
127 |
NetCDFDataParameters params = (NetCDFDataParameters) manager |
|
128 |
.createStoreParameters(this.getDataStoreProviderName()); |
|
129 |
params.setFile(file); |
|
130 |
return params; |
|
131 |
} |
|
132 |
|
|
133 |
public int getMode() { |
|
134 |
return DataServerExplorer.MODE_RASTER; |
|
135 |
} |
|
136 |
|
|
137 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() { |
|
138 |
// TODO Auto-generated method stub |
|
139 |
return null; |
|
140 |
} |
|
141 |
|
|
142 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
143 |
boolean overwrite) throws DataException { |
|
144 |
// TODO Auto-generated method stub |
|
145 |
return false; |
|
146 |
} |
|
147 |
|
|
148 |
/* |
|
149 |
* (non-Javadoc) |
|
150 |
* @see org.gvsig.fmap.dal.DataServerExplorer#canAdd() |
|
151 |
*/ |
|
152 |
public boolean canAdd() { |
|
153 |
return false; |
|
154 |
} |
|
155 |
|
|
156 |
/* |
|
157 |
* (non-Javadoc) |
|
158 |
* @see org.gvsig.fmap.dal.DataServerExplorer#canAdd(java.lang.String) |
|
159 |
*/ |
|
160 |
public boolean canAdd(String storeName) throws DataException { |
|
161 |
return false; |
|
162 |
} |
|
163 |
|
|
164 |
/* |
|
165 |
* (non-Javadoc) |
|
166 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getAddParameters(java.lang.String) |
|
167 |
*/ |
|
168 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
169 |
throws DataException { |
|
170 |
return null; |
|
171 |
} |
|
172 |
|
|
173 |
/* |
|
174 |
* (non-Javadoc) |
|
175 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getDataStoreProviderNames() |
|
176 |
*/ |
|
177 |
@SuppressWarnings("unchecked") |
|
178 |
public List getDataStoreProviderNames() { |
|
179 |
return null; |
|
180 |
} |
|
181 |
|
|
182 |
public DataServerExplorerParameters getParameters() { |
|
183 |
// TODO Auto-generated method stub |
|
184 |
return null; |
|
185 |
} |
|
186 |
|
|
187 |
public String getProviderName() { |
|
188 |
return NetCDFProvider.NAME; |
|
189 |
} |
|
190 |
|
|
191 |
@SuppressWarnings("unchecked") |
|
192 |
public List list() throws DataException { |
|
193 |
return null; |
|
194 |
} |
|
195 |
|
|
196 |
@SuppressWarnings("unchecked") |
|
197 |
public List list(int mode) throws DataException { |
|
198 |
return null; |
|
199 |
} |
|
200 |
|
|
201 |
public void dispose() { |
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
} |
|
0 | 206 |
org.gvsig.raster.netcdf/tags/tagdate_29082013/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.io/src/main/java/org/gvsig/raster/netcdf/io/NetCDFWriter.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.netcdf.io; |
|
23 |
|
|
24 |
|
|
25 |
|
Also available in: Unified diff