Revision 2411
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/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.multifile</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.2.0-SNAPSHOT</version> |
|
7 |
<name>Raster multifile support for gvSIG</name> |
|
8 |
<description>Raster multifile support for gvSIG</description> |
|
9 |
<inceptionYear>2013</inceptionYear> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop</artifactId> |
|
13 |
<version>2.0.22</version> |
|
14 |
</parent> |
|
15 |
<scm> |
|
16 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.multifile/trunk/org.gvsig.raster.multifile</connection> |
|
17 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.multifile/trunk/org.gvsig.raster.multifile</developerConnection> |
|
18 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.multifile/trunk/org.gvsig.raster.multifile</url> |
|
19 |
</scm> |
|
20 |
<developers> |
|
21 |
<developer> |
|
22 |
<id>nbrodin</id> |
|
23 |
<name>Nacho Brodin</name> |
|
24 |
<email>nachobrodin@gmail.com</email> |
|
25 |
<roles> |
|
26 |
<role>Architect</role> |
|
27 |
<role>Developer</role> |
|
28 |
</roles> |
|
29 |
</developer> |
|
30 |
</developers> |
|
31 |
<dependencyManagement> |
|
32 |
<dependencies> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.raster.mainplugin</artifactId> |
|
36 |
<version>2.2.0-SNAPSHOT</version> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.raster.algorithm</artifactId> |
|
41 |
<version>2.2.0-SNAPSHOT</version> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.raster.multifile.io</artifactId> |
|
46 |
<version>2.2.0-SNAPSHOT</version> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
51 |
<version>2.2.0-SNAPSHOT</version> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
56 |
<version>2.2.0-SNAPSHOT</version> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>org.gvsig</groupId> |
|
60 |
<artifactId>org.gvsig.raster.swing.api</artifactId> |
|
61 |
<version>2.2.0-SNAPSHOT</version> |
|
62 |
</dependency> |
|
63 |
<dependency> |
|
64 |
<groupId>org.gvsig</groupId> |
|
65 |
<artifactId>org.gvsig.raster.swing.impl</artifactId> |
|
66 |
<version>2.2.0-SNAPSHOT</version> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.gvsig</groupId> |
|
70 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
71 |
<version>2.1.0-SNAPSHOT</version> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.raster.cache.lib.impl</artifactId> |
|
76 |
<version>2.1.0-SNAPSHOT</version> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
81 |
<version>2.2.0-SNAPSHOT</version> |
|
82 |
</dependency> |
|
83 |
</dependencies> |
|
84 |
</dependencyManagement> |
|
85 |
<build> |
|
86 |
<plugins> |
|
87 |
<plugin> |
|
88 |
<groupId>org.apache.maven.plugins</groupId> |
|
89 |
<artifactId>maven-release-plugin</artifactId> |
|
90 |
<configuration> |
|
91 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.multifile/tags/</tagBase> |
|
92 |
<goals>deploy</goals> |
|
93 |
</configuration> |
|
94 |
</plugin> |
|
95 |
</plugins> |
|
96 |
</build> |
|
97 |
<modules> |
|
98 |
<module>org.gvsig.raster.multifile.io</module> |
|
99 |
<module>org.gvsig.raster.multifile.app.multifileclient</module> |
|
100 |
</modules> |
|
101 |
</project> |
|
0 | 102 |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/resources/multifileformat.dtd | ||
---|---|---|
1 |
<!DOCTYPE TimeSeriesFormat [ |
|
2 |
<!ELEMENT TimeSeriesFormat (Name,URIs)> |
|
3 |
<!ELEMENT Name (#PCDATA)> |
|
4 |
<!ELEMENT URIs (URI)+> |
|
5 |
|
|
6 |
<!ELEMENT URI (#PCDATA)> |
|
7 |
]> |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.multifile.io.DefaultMultiFileIOLibrary |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/java/org/gvsig/raster/multifile/io/MultiFileServerExplorer.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.multifile.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.InitializeException; |
|
43 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
44 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
45 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
|
46 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
47 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
48 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
49 |
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters; |
|
50 |
|
|
51 |
/** |
|
52 |
* Explorer for a Multifile |
|
53 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
54 |
*/ |
|
55 |
public class MultiFileServerExplorer extends AbstractFilesystemServerExplorerProvider implements DataServerExplorerProvider { |
|
56 |
|
|
57 |
public MultiFileServerExplorer() { |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
public MultiFileServerExplorer( |
|
62 |
MultiFileServerExplorerParameters parameters, |
|
63 |
DataServerExplorerProviderServices services) |
|
64 |
throws InitializeException { |
|
65 |
System.out.println(); |
|
66 |
} |
|
67 |
|
|
68 |
public String getDataStoreProviderName() { |
|
69 |
return MultiFileProvider.NAME; |
|
70 |
} |
|
71 |
|
|
72 |
public String getDescription() { |
|
73 |
return MultiFileProvider.DESCRIPTION; |
|
74 |
} |
|
75 |
|
|
76 |
public DataStoreParameters getStoreParameters() { |
|
77 |
DataManager manager = DALLocator.getDataManager(); |
|
78 |
try { |
|
79 |
return manager.createStoreParameters(this.getDataStoreProviderName()); |
|
80 |
} catch (InitializeException e) { |
|
81 |
e.printStackTrace(); |
|
82 |
} catch (ProviderNotRegisteredException e) { |
|
83 |
e.printStackTrace(); |
|
84 |
} |
|
85 |
return null; |
|
86 |
} |
|
87 |
|
|
88 |
public List<?> getDataStoreProviderNames() { |
|
89 |
return null; |
|
90 |
} |
|
91 |
|
|
92 |
public String getProviderName() { |
|
93 |
return MultiFileProvider.NAME; |
|
94 |
} |
|
95 |
|
|
96 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() { |
|
97 |
return null; |
|
98 |
} |
|
99 |
|
|
100 |
public boolean canCreate() { |
|
101 |
return false; |
|
102 |
} |
|
103 |
|
|
104 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
105 |
return false; |
|
106 |
} |
|
107 |
|
|
108 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
|
109 |
throws CreateException { |
|
110 |
throw new UnsupportedOperationException(); |
|
111 |
} |
|
112 |
|
|
113 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
114 |
return null; |
|
115 |
} |
|
116 |
|
|
117 |
public void initialize( |
|
118 |
FilesystemServerExplorerProviderServices serverExplorer) { |
|
119 |
} |
|
120 |
|
|
121 |
public boolean accept(File pathname) { |
|
122 |
return RasterLocator.getManager().getProviderServices().isExtensionSupported( |
|
123 |
pathname.getAbsolutePath(), |
|
124 |
MultiFileProvider.class); |
|
125 |
} |
|
126 |
|
|
127 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
128 |
throw new UnsupportedOperationException(); |
|
129 |
} |
|
130 |
|
|
131 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
132 |
boolean overwrite) throws DataException { |
|
133 |
return false; |
|
134 |
} |
|
135 |
|
|
136 |
public boolean canAdd() { |
|
137 |
return false; |
|
138 |
} |
|
139 |
|
|
140 |
public boolean canAdd(String storeName) throws DataException { |
|
141 |
return false; |
|
142 |
} |
|
143 |
|
|
144 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
145 |
throws DataException { |
|
146 |
return null; |
|
147 |
} |
|
148 |
|
|
149 |
public DataStoreParameters getParameters(File file) throws DataException { |
|
150 |
DataManager manager = DALLocator.getDataManager(); |
|
151 |
AbstractRasterFileDataParameters params = (AbstractRasterFileDataParameters) manager |
|
152 |
.createStoreParameters(this.getDataStoreProviderName()); |
|
153 |
params.setFile(file); |
|
154 |
return params; |
|
155 |
} |
|
156 |
|
|
157 |
public DataServerExplorerParameters getParameters() { |
|
158 |
return null; |
|
159 |
} |
|
160 |
|
|
161 |
public List<?> list() throws DataException { |
|
162 |
return null; |
|
163 |
} |
|
164 |
|
|
165 |
public List<?> list(int mode) throws DataException { |
|
166 |
return null; |
|
167 |
} |
|
168 |
|
|
169 |
public void dispose() { |
|
170 |
} |
|
171 |
|
|
172 |
public int getMode() { |
|
173 |
return DataServerExplorer.MODE_RASTER; |
|
174 |
} |
|
175 |
|
|
176 |
} |
|
0 | 177 |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/java/org/gvsig/raster/multifile/io/MultiFileFormat.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.multifile.io; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.util.ArrayList; |
|
27 |
|
|
28 |
/** |
|
29 |
* MultiFileFormat information |
|
30 |
* |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class MultiFileFormat { |
|
34 |
public ArrayList<File> fileList = new ArrayList<File>(); |
|
35 |
private String name = null; |
|
36 |
|
|
37 |
/** |
|
38 |
* Gets the name of this serial |
|
39 |
* @return |
|
40 |
*/ |
|
41 |
public String getName() { |
|
42 |
return name; |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* Sets the name of this serie |
|
47 |
* @param name |
|
48 |
*/ |
|
49 |
public void setName(String name) { |
|
50 |
this.name = name; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Gets the number of files of this serial |
|
55 |
* @return |
|
56 |
*/ |
|
57 |
public int getNumberOfFiles() { |
|
58 |
return fileList.size(); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Gets the path of the file in the selected position |
|
63 |
* @param file |
|
64 |
* @return |
|
65 |
*/ |
|
66 |
public String getPathToFile(int file) { |
|
67 |
return fileList.get(file).getAbsolutePath(); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Adds a file to the list |
|
72 |
* @param file |
|
73 |
*/ |
|
74 |
public void addFile(File file) { |
|
75 |
fileList.add(file); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Cleans the list of files |
|
80 |
*/ |
|
81 |
public void clean() { |
|
82 |
fileList.clear(); |
|
83 |
name = null; |
|
84 |
} |
|
85 |
|
|
86 |
public static String saveMultiFileFormat(String fileName, String path, ArrayList<File> uriList) throws IOException { |
|
87 |
path = path + File.separator + fileName + ".mff"; |
|
88 |
|
|
89 |
MultiFileFormat format = new MultiFileFormat(); |
|
90 |
for (int i = 0; i < uriList.size(); i++) { |
|
91 |
format.addFile(uriList.get(i)); |
|
92 |
} |
|
93 |
format.setName(fileName); |
|
94 |
|
|
95 |
format.write(path); |
|
96 |
return path; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Writes a MultiFileFormat to disk |
|
101 |
* @param file |
|
102 |
* @throws IOException |
|
103 |
*/ |
|
104 |
public void write(String fileName) throws IOException { |
|
105 |
MultiFileFormatSerializer.write(this, fileName); |
|
106 |
} |
|
107 |
} |
|
0 | 108 |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/java/org/gvsig/raster/multifile/io/MultiFileProvider.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.multifile.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 |
import java.io.IOException; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
32 |
import org.gvsig.fmap.dal.DALLocator; |
|
33 |
import org.gvsig.fmap.dal.DataStore; |
|
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
36 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
37 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
|
39 |
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException; |
|
40 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
41 |
import org.gvsig.fmap.dal.coverage.exception.FileNotSupportedException; |
|
42 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
43 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
44 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
45 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
|
46 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
47 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
48 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
49 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
50 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
51 |
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer; |
|
52 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
|
53 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
54 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
55 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
56 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
57 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
58 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
59 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
60 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
61 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
62 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
63 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
64 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
65 |
import org.gvsig.metadata.MetadataLocator; |
|
66 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
67 |
import org.gvsig.raster.impl.buffer.SpiRasterQuery; |
|
68 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
|
69 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl; |
|
70 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
71 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
|
72 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
73 |
import org.gvsig.raster.impl.provider.tile.FileTileServer; |
|
74 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
75 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
|
76 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
77 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
78 |
import org.gvsig.raster.impl.store.properties.MultiProviderHistogramComputer; |
|
79 |
import org.gvsig.raster.impl.store.properties.MultiProviderStatistics; |
|
80 |
import org.gvsig.tools.ToolsLocator; |
|
81 |
import org.gvsig.tools.locator.LocatorException; |
|
82 |
import org.slf4j.Logger; |
|
83 |
import org.slf4j.LoggerFactory; |
|
84 |
/** |
|
85 |
* A data provider for a multiband image readed from different files |
|
86 |
* |
|
87 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
88 |
*/ |
|
89 |
public class MultiFileProvider extends AbstractRasterProvider { |
|
90 |
public static String NAME = "Multifile Raster"; |
|
91 |
public static String DESCRIPTION = "Multifile Raster Support"; |
|
92 |
public final String METADATA_DEFINITION_NAME = NAME; |
|
93 |
private Extent viewRequest = null; |
|
94 |
private TileServer tileServer = null; |
|
95 |
private boolean open = false; |
|
96 |
|
|
97 |
private DataStoreTransparency fileTransparency = null; |
|
98 |
private static final Logger logger = LoggerFactory.getLogger(MultiFileProvider.class); |
|
99 |
protected static String[] formatList = null; |
|
100 |
|
|
101 |
public static void register() { |
|
102 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
103 |
registerFormats(); |
|
104 |
|
|
105 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
|
106 |
dataman.registerStoreProvider(NAME, |
|
107 |
MultiFileProvider.class, MultiFileDataParametersImpl.class); |
|
108 |
} |
|
109 |
|
|
110 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
|
111 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
|
112 |
NAME, DESCRIPTION, |
|
113 |
MultiFileServerExplorer.class); |
|
114 |
|
|
115 |
if (!dataman.getExplorerProviders().contains(NAME)) { |
|
116 |
dataman.registerExplorerProvider(NAME, MultiFileServerExplorer.class, MultiFileServerExplorerParameters.class); |
|
117 |
} |
|
118 |
|
|
119 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
|
120 |
} |
|
121 |
|
|
122 |
private static void registerFormats() { |
|
123 |
formatList = new String[] { |
|
124 |
"mff"}; |
|
125 |
for (int i = 0; i < formatList.length; i++) |
|
126 |
RasterLocator.getManager().getProviderServices().addFormat( |
|
127 |
formatList[i], |
|
128 |
MultiFileProvider.class); |
|
129 |
} |
|
130 |
|
|
131 |
public MultiFileProvider() { |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Opens the dataset. |
|
136 |
* @param proj Projection |
|
137 |
* @param fName File name |
|
138 |
* @throws NotSupportedExtensionException |
|
139 |
*/ |
|
140 |
public MultiFileProvider(String params) throws NotSupportedExtensionException, OpenException { |
|
141 |
super(params); |
|
142 |
if(params instanceof String) { |
|
143 |
MultiFileDataParameters p = new MultiFileDataParametersImpl(); |
|
144 |
p.setURI((String)params); |
|
145 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
|
146 |
.createDynObject( |
|
147 |
MetadataLocator.getMetadataManager().getDefinition( |
|
148 |
DataStore.METADATA_DEFINITION_NAME))); |
|
149 |
init(p, null); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
public MultiFileProvider(MultiFileDataParametersImpl params, |
|
154 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException { |
|
155 |
super(params, storeServices, ToolsLocator.getDynObjectManager() |
|
156 |
.createDynObject( |
|
157 |
MetadataLocator.getMetadataManager().getDefinition( |
|
158 |
DataStore.METADATA_DEFINITION_NAME))); |
|
159 |
init(params, storeServices); |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* Build file references |
|
164 |
* @param proj Projection |
|
165 |
* @param param Load parameters |
|
166 |
* @throws NotSupportedExtensionException |
|
167 |
*/ |
|
168 |
public void init(MultiFileDataParameters params, |
|
169 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException { |
|
170 |
|
|
171 |
openFromMff(); |
|
172 |
|
|
173 |
uri = getParameters().getURI(); |
|
174 |
setParam(storeServices, params); |
|
175 |
|
|
176 |
try { |
|
177 |
setFirstProviderToNotTiled(); |
|
178 |
} catch (InvalidSourceException e1) { |
|
179 |
throw new OpenException(e1.getMessage(), e1); |
|
180 |
} |
|
181 |
|
|
182 |
super.init(); |
|
183 |
|
|
184 |
try { |
|
185 |
loadFromRmf(getRmfBlocksManager()); |
|
186 |
} catch (ParsingException e) { |
|
187 |
logger.debug("Problems reading from RMF", e); |
|
188 |
} |
|
189 |
|
|
190 |
open = true; |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* Open from a .mff file. |
|
195 |
* This method loads all providers and adds these to the parameters |
|
196 |
* @throws OpenException |
|
197 |
*/ |
|
198 |
private void openFromMff() throws OpenException { |
|
199 |
if(getParameters().getURI() != null && new File(getParameters().getURI()).exists()) { |
|
200 |
boolean loadedProviders = true; |
|
201 |
if(getParameters().hasProviders()) { |
|
202 |
//solo se considera que est�n todos los providers cargados si existen y est�n open, |
|
203 |
//sino se leeran de disco |
|
204 |
for (int i = 0; i < getParameters().getProviders().size(); i++) { |
|
205 |
if(!getParameters().getProviders().get(i).isOpen()) |
|
206 |
loadedProviders = false; |
|
207 |
} |
|
208 |
} else |
|
209 |
loadedProviders = false; |
|
210 |
|
|
211 |
if(loadedProviders) |
|
212 |
return; |
|
213 |
|
|
214 |
try { |
|
215 |
if(getParameters().hasProviders()) |
|
216 |
getParameters().removeAllProviders(); |
|
217 |
MultiFileFormat multiFileFormat = new MultiFileFormat(); |
|
218 |
multiFileFormat = MultiFileFormatSerializer.read(multiFileFormat, getParameters().getURI()); |
|
219 |
for (int i = 0; i < multiFileFormat.getNumberOfFiles(); i++) { |
|
220 |
try { |
|
221 |
File file = new File(multiFileFormat.getPathToFile(i)); |
|
222 |
if(file.exists()) { |
|
223 |
RasterProvider prov = loadProvider(multiFileFormat.getPathToFile(i), storeServices); |
|
224 |
getParameters().addProvider(prov); |
|
225 |
} |
|
226 |
} catch (ProviderNotRegisteredException e) { |
|
227 |
throw new OpenException("A provider can't be loaded", e); |
|
228 |
} catch (InitializeException e) { |
|
229 |
throw new OpenException("A provider can't be initialized", e); |
|
230 |
} |
|
231 |
} |
|
232 |
} catch (IOException e1) { |
|
233 |
throw new OpenException("File .mff can't be read", e1); |
|
234 |
} catch (ParsingException e1) { |
|
235 |
throw new OpenException("File .mff can't be parsed", e1); |
|
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Loads the specific provider |
|
242 |
* @param file |
|
243 |
* @return |
|
244 |
* @throws NotSupportedExtensionException |
|
245 |
* @throws FileNotSupportedException |
|
246 |
*/ |
|
247 |
@SuppressWarnings("unchecked") |
|
248 |
private RasterProvider loadProvider(String file, DataStoreProviderServices storeServices) throws ProviderNotRegisteredException, InitializeException { |
|
249 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
250 |
DataStoreProvider prov = null; |
|
251 |
|
|
252 |
if(file != null) { |
|
253 |
//We have to locate a provider's name which manages the selected file |
|
254 |
//A FilesystemServerExplorer will give a getProviderNames service |
|
255 |
FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
256 |
FilesystemServerExplorer serverExplorer = null; |
|
257 |
try { |
|
258 |
paramsExplorer.setRoot(File.separator); |
|
259 |
serverExplorer = (FilesystemServerExplorer)dataManager.openServerExplorer(FilesystemServerExplorer.NAME, paramsExplorer); |
|
260 |
} catch (ValidateDataParametersException e) { |
|
261 |
throw new InitializeException(e); |
|
262 |
} |
|
263 |
File f = new File(file); |
|
264 |
//Gets the list of provider's name to manage the file |
|
265 |
List<String> provName = serverExplorer.getProviderNameList(f); |
|
266 |
if(provName.size() > 0) { |
|
267 |
for (int i = 0; i < provName.size(); i++) { |
|
268 |
//Gets the first provider what is not a TileProvider |
|
269 |
if(provName.get(i).compareTo("Tile Store") != 0) { |
|
270 |
DataStoreParameters newparams = dataManager.createStoreParameters(provName.get(i)); |
|
271 |
((FilesystemStoreParameters)newparams).setFile(f); |
|
272 |
prov = dataManager.createProvider(storeServices, newparams); |
|
273 |
} |
|
274 |
} |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
if(prov != null && prov instanceof RasterProvider) { |
|
279 |
if(((RasterProvider)prov).isRotated()) |
|
280 |
throw new InitializeException("Rotation not supported tiling files", new Throwable()); |
|
281 |
|
|
282 |
return (RasterProvider)prov; |
|
283 |
} |
|
284 |
|
|
285 |
return null; |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* Checks if the new file is compatible with the old one |
|
290 |
* @param file |
|
291 |
* @return |
|
292 |
* @throws LocatorException |
|
293 |
* @throws NotSupportedExtensionException |
|
294 |
* @throws RasterDriverException |
|
295 |
* @throws CloseException |
|
296 |
*/ |
|
297 |
private boolean checkNewProvider(RasterProvider p) { |
|
298 |
Rectangle2D extentOrigin = getExtent().toRectangle2D(); |
|
299 |
|
|
300 |
Extent extentNewFile = p.getExtent(); |
|
301 |
|
|
302 |
// Comprobamos que el extent y tama�o del fichero a�adido sea igual al |
|
303 |
// fichero original. Si no es as� no abrimos la capa y mostramos un aviso |
|
304 |
|
|
305 |
double widthNewFile = (extentNewFile.getMax().getX() - extentNewFile.getMin().getX()); |
|
306 |
double heightNewFile = (extentNewFile.getMax().getY() - extentNewFile.getMin().getY()); |
|
307 |
|
|
308 |
if ((widthNewFile - extentOrigin.getWidth()) > 1.0 || (widthNewFile - extentOrigin.getWidth()) < -1.0 || (heightNewFile - extentOrigin.getHeight()) > 1.0 |
|
309 |
|| (heightNewFile - extentOrigin.getHeight()) < -1.0) { |
|
310 |
return false; |
|
311 |
} |
|
312 |
|
|
313 |
if ((extentNewFile.getMax().getX() - extentNewFile.getMin().getX()) != extentOrigin.getWidth() |
|
314 |
|| (extentNewFile.getMax().getY() - extentNewFile.getMin().getY()) != extentOrigin.getHeight()) { |
|
315 |
return false; |
|
316 |
} |
|
317 |
|
|
318 |
return true; |
|
319 |
} |
|
320 |
|
|
321 |
public MultiFileDataParameters getParameters() { |
|
322 |
try { |
|
323 |
return (MultiFileDataParameters)parameters; |
|
324 |
} catch (ClassCastException e) { |
|
325 |
return null; |
|
326 |
} |
|
327 |
} |
|
328 |
|
|
329 |
public RasterProvider load() { |
|
330 |
return this; |
|
331 |
} |
|
332 |
|
|
333 |
public int getBandCount() { |
|
334 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
335 |
int bandCount = 0; |
|
336 |
for (int i = 0; i < providerList.size(); i++) { |
|
337 |
bandCount += providerList.get(i).getBandCount(); |
|
338 |
} |
|
339 |
return bandCount; |
|
340 |
} |
|
341 |
|
|
342 |
public int[] getDataType() { |
|
343 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
344 |
int[] datatypes = new int[getBandCount()]; |
|
345 |
int k = 0; |
|
346 |
for (int i = 0; i < providerList.size(); i++) { |
|
347 |
int[] dtByProv = providerList.get(i).getDataType(); |
|
348 |
for (int j = 0; j < dtByProv.length; j++) { |
|
349 |
datatypes[k] = dtByProv[j]; |
|
350 |
k++; |
|
351 |
} |
|
352 |
} |
|
353 |
return datatypes; |
|
354 |
} |
|
355 |
|
|
356 |
public String[] getURIByProvider() { |
|
357 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
358 |
String[] uris = new String[providerList.size()]; |
|
359 |
for (int i = 0; i < uris.length; i++) { |
|
360 |
uris[i] = providerList.get(i).getURIOfFirstProvider(); |
|
361 |
} |
|
362 |
return uris; |
|
363 |
} |
|
364 |
|
|
365 |
public int getBandPositionByProvider(int band) { |
|
366 |
return getSubBandByBandNumber(band)[1]; |
|
367 |
} |
|
368 |
|
|
369 |
public String getURIOfFirstProvider() { |
|
370 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
371 |
return providerList.get(0).getURIOfFirstProvider(); |
|
372 |
} |
|
373 |
|
|
374 |
|
|
375 |
public Extent getExtent() { |
|
376 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
377 |
if(providerList != null && providerList.size() > 0) |
|
378 |
return providerList.get(0).getExtent(); |
|
379 |
return null; |
|
380 |
} |
|
381 |
|
|
382 |
public AffineTransform getAffineTransform() { |
|
383 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
384 |
return providerList.get(0).getAffineTransform(); |
|
385 |
} |
|
386 |
|
|
387 |
public void setAffineTransform(AffineTransform t) { |
|
388 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
389 |
for (int i = 0; i < providerList.size(); i++) { |
|
390 |
providerList.get(i).setAffineTransform(t); |
|
391 |
} |
|
392 |
} |
|
393 |
|
|
394 |
public int getInternalProviderCount() { |
|
395 |
return getParameters().getProviders().size(); |
|
396 |
} |
|
397 |
|
|
398 |
public RasterProvider getInternalProvider(int i) { |
|
399 |
return getParameters().getProviders().get(i); |
|
400 |
} |
|
401 |
|
|
402 |
public int[] getBandCountByProvider() { |
|
403 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
404 |
int[] bc = new int[providerList.size()]; |
|
405 |
for (int i = 0; i < bc.length; i++) { |
|
406 |
bc[i] = providerList.get(i).getBandCount(); |
|
407 |
} |
|
408 |
return bc; |
|
409 |
} |
|
410 |
|
|
411 |
public long[] getFileSizeByProvider() { |
|
412 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
413 |
long[] fs = new long[providerList.size()]; |
|
414 |
for (int i = 0; i < fs.length; i++) { |
|
415 |
fs[i] = ((AbstractRasterProvider)providerList.get(i)).getFileSize(); |
|
416 |
} |
|
417 |
return fs; |
|
418 |
} |
|
419 |
|
|
420 |
public Point2D rasterToWorld(Point2D pt) { |
|
421 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
422 |
return providerList.get(0).rasterToWorld(pt); |
|
423 |
} |
|
424 |
|
|
425 |
public Point2D worldToRaster(Point2D pt) { |
|
426 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
427 |
return providerList.get(0).worldToRaster(pt); |
|
428 |
} |
|
429 |
|
|
430 |
public boolean isInside(Point2D p){ |
|
431 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
432 |
return providerList.get(0).isInside(p); |
|
433 |
} |
|
434 |
|
|
435 |
public double getCellSize() { |
|
436 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
437 |
return providerList.get(0).getCellSize(); |
|
438 |
} |
|
439 |
|
|
440 |
public Statistics getStatistics() { |
|
441 |
if(stats == null || (stats instanceof MultiProviderStatistics && |
|
442 |
((MultiProviderStatistics)stats).getNumberOfProviders() != getParameters().getProviders().size())) { |
|
443 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
444 |
stats = new MultiProviderStatistics(providerList, this); |
|
445 |
} |
|
446 |
|
|
447 |
return stats; |
|
448 |
} |
|
449 |
|
|
450 |
public HistogramComputer getHistogramComputer() { |
|
451 |
if(histogram == null || |
|
452 |
(histogram instanceof MultiProviderHistogramComputer && |
|
453 |
((MultiProviderHistogramComputer)histogram).getNumberOfProviders() != getParameters().getProviders().size())) { |
|
454 |
histogram = new MultiProviderHistogramComputer(this); |
|
455 |
} |
|
456 |
|
|
457 |
return histogram; |
|
458 |
} |
|
459 |
|
|
460 |
/** |
|
461 |
* A multiband provider doesn't have a color table because this will have |
|
462 |
* more than one band. |
|
463 |
*/ |
|
464 |
public ColorTable getColorTable() { |
|
465 |
return null; |
|
466 |
} |
|
467 |
|
|
468 |
public boolean isOpen() { |
|
469 |
return open; |
|
470 |
} |
|
471 |
|
|
472 |
public void close() { |
|
473 |
} |
|
474 |
|
|
475 |
public String translateFileName(String fileName) { |
|
476 |
return fileName; |
|
477 |
} |
|
478 |
|
|
479 |
/** |
|
480 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci�n |
|
481 |
* de la vista asignada ya que la petici�n viene en coordenadas del fichero .rmf y la vista (v) |
|
482 |
* ha de estar en coordenadas del fichero. |
|
483 |
*/ |
|
484 |
public void setView(Extent e) { |
|
485 |
viewRequest = new ExtentImpl(e); |
|
486 |
} |
|
487 |
|
|
488 |
public Extent getView() { |
|
489 |
return viewRequest; |
|
490 |
} |
|
491 |
|
|
492 |
public double getWidth() { |
|
493 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
494 |
if(providerList != null && providerList.size() > 0) { |
|
495 |
return providerList.get(0).getWidth(); |
|
496 |
} |
|
497 |
return 0; |
|
498 |
} |
|
499 |
|
|
500 |
public double getHeight() { |
|
501 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
502 |
if(providerList != null && providerList.size() > 0) { |
|
503 |
return providerList.get(0).getHeight(); |
|
504 |
} |
|
505 |
return 0; |
|
506 |
|
|
507 |
} |
|
508 |
|
|
509 |
public Object readBlock(int pos, int blockHeight, double scale) |
|
510 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException { |
|
511 |
return null; |
|
512 |
} |
|
513 |
|
|
514 |
/** |
|
515 |
* Gets a number of provider and the band of this provider |
|
516 |
* @param band |
|
517 |
* @return |
|
518 |
*/ |
|
519 |
private int[] getSubBandByBandNumber(int band) { |
|
520 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
521 |
int[] res = new int[2]; |
|
522 |
int acum = 0; |
|
523 |
for (int i = 0; i < providerList.size(); i++) { |
|
524 |
acum += providerList.get(i).getBandCount(); |
|
525 |
if(acum > band) { |
|
526 |
res[0] = i; |
|
527 |
int aux = (acum - providerList.get(i).getBandCount()); |
|
528 |
res[1] = band - aux; |
|
529 |
return res; |
|
530 |
} |
|
531 |
} |
|
532 |
return res; |
|
533 |
} |
|
534 |
|
|
535 |
@Override |
|
536 |
public void loadBuffer(SpiRasterQuery q) |
|
537 |
throws ProcessInterruptedException, RasterDriverException { |
|
538 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
539 |
|
|
540 |
for (int i = 0; i < providerList.size(); i++) { |
|
541 |
SpiRasterQuery query = (SpiRasterQuery)q.clone(); |
|
542 |
BandList bandListByFile = createBandListByProvider(q.getBandList(), providerList.get(i)); |
|
543 |
query.setBandList(bandListByFile); |
|
544 |
providerList.get(i).getDataSet(q); |
|
545 |
} |
|
546 |
|
|
547 |
/*for (int i = 0; i < providerList.size(); i++) { |
|
548 |
DefaultRasterStore store = new DefaultRasterStore(); |
|
549 |
store.setProvider(providerList.get(i)); |
|
550 |
RasterQuery query = ((DefaultRasterQuery)q).clone(); |
|
551 |
BandList bandListByFile = createBandListByProvider(q.getBandList(), providerList.get(i)); |
|
552 |
query.set |
|
553 |
try { |
|
554 |
store.query((RasterQuery)q); |
|
555 |
} catch (QueryException e) { |
|
556 |
throw new RasterDriverException("Error in query to the provider " + i, e); |
|
557 |
} |
|
558 |
}*/ |
|
559 |
} |
|
560 |
|
|
561 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
562 |
int[] sub = getSubBandByBandNumber(band); |
|
563 |
RasterProvider prov = getParameters().getProviders().get(sub[0]); |
|
564 |
return prov.getData(x, y, sub[1]); |
|
565 |
} |
|
566 |
|
|
567 |
|
|
568 |
/*public Buffer getWindow(Extent extent, BandList bandList, Buffer rasterBuf, TaskStatus status) |
|
569 |
throws ProcessInterruptedException, RasterDriverException { |
|
570 |
providerList = getParameters().getProviders(); |
|
571 |
|
|
572 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
573 |
q.setAreaOfInterest(extent); |
|
574 |
q.setBandList(bandList); |
|
575 |
q.setBuffer(rasterBuf); |
|
576 |
|
|
577 |
for (int i = 0; i < providerList.size(); i++) { |
|
578 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q); |
|
579 |
} |
|
580 |
return rasterBuf; |
|
581 |
}*/ |
|
582 |
|
|
583 |
/*public Buffer getWindow(double ulx, double uly, double w, double h, |
|
584 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
585 |
providerList = getParameters().getProviders(); |
|
586 |
|
|
587 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
588 |
q.setAreaOfInterest(ulx, uly, w, h); |
|
589 |
q.setBandList(bandList); |
|
590 |
q.setBuffer(rasterBuf); |
|
591 |
q.setAdjustToExtent(adjustToExtent); |
|
592 |
|
|
593 |
for (int i = 0; i < providerList.size(); i++) { |
|
594 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q); |
|
595 |
} |
|
596 |
return rasterBuf; |
|
597 |
}*/ |
|
598 |
|
|
599 |
/*public Buffer getWindow(Extent extent, int bufWidth, int bufHeight, |
|
600 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
601 |
providerList = getParameters().getProviders(); |
|
602 |
|
|
603 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
604 |
q.setAreaOfInterest(extent, bufWidth, bufHeight); |
|
605 |
q.setBuffer(rasterBuf); |
|
606 |
q.setAdjustToExtent(adjustToExtent); |
|
607 |
|
|
608 |
for (int i = 0; i < providerList.size(); i++) { |
|
609 |
BandList bandListByFile = createBandListByProvider(bandList, providerList.get(i)); |
|
610 |
if(bandListByFile != null) { |
|
611 |
q.setBandList(bandListByFile); |
|
612 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q); |
|
613 |
} |
|
614 |
} |
|
615 |
return rasterBuf; |
|
616 |
}*/ |
|
617 |
|
|
618 |
/** |
|
619 |
* Creates a <code>BandList</code> for each provider of this <code>MultiFileProvider</code>. |
|
620 |
* When a request is made, the <code>BandList</code> is global for all files. A specific |
|
621 |
* <code>BandList</code> has to be built for each provider. |
|
622 |
* @param globalBandList |
|
623 |
* @param provider |
|
624 |
* @return |
|
625 |
*/ |
|
626 |
private BandList createBandListByProvider(BandList globalBandList, RasterProvider provider) { |
|
627 |
if(provider.isTiled()) { |
|
628 |
//Si los proveedores que hay por debajo son tileados estos crear�n su propio buffer para escribir |
|
629 |
//cada tile. Por ello no usar� el buffer que viene del store. Esto quiere decir que el BandList ha |
|
630 |
//de ser distinto para que escriba bien en su buffer |
|
631 |
|
|
632 |
//TODO: De momento no se permiten MultiFiles con proveedores tileados. Esto es porque |
|
633 |
//los tiles crean su propio buffer y no escriben en el buffer creado en el Store |
|
634 |
|
|
635 |
} else { |
|
636 |
BandList bandListByFile = new BandListImpl(); |
|
637 |
for (int i = 0; i < provider.getBandCount(); i++) { |
|
638 |
try { |
|
639 |
bandListByFile.addBand(new DatasetBandImpl(provider.getURI(), i, provider.getDataType()[0], provider.getBandCount())); |
|
640 |
} catch (BandNotFoundInListException e1) { |
|
641 |
} |
|
642 |
} |
|
643 |
|
|
644 |
boolean areThereBandsToDraw = false; |
|
645 |
for (int i = 0; i < provider.getBandCount(); i++) { |
|
646 |
int[] bandsToDrawByProviderBand = globalBandList.getBufferBandToDraw(provider.getURI(), i); |
|
647 |
if(bandsToDrawByProviderBand != null) { |
|
648 |
areThereBandsToDraw = true; |
|
649 |
for (int j = 0; j < bandsToDrawByProviderBand.length; j++) { |
|
650 |
bandListByFile.getBand(i).addPositionToDrawInBuffer(bandsToDrawByProviderBand[j]); |
|
651 |
} |
|
652 |
} |
|
653 |
} |
|
654 |
|
|
655 |
if(areThereBandsToDraw) |
|
656 |
return bandListByFile; |
|
657 |
} |
|
658 |
return null; |
|
659 |
} |
|
660 |
|
|
661 |
/*public Buffer getWindow(int x, int y, int w, int h, |
|
662 |
BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException { |
|
663 |
providerList = getParameters().getProviders(); |
|
664 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
665 |
q.setAreaOfInterest(x, y, w, h); |
|
666 |
q.setBandList(bandList); |
|
667 |
q.setBuffer(rasterBuf); |
|
668 |
for (int i = 0; i < providerList.size(); i++) { |
|
669 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q); |
|
670 |
} |
|
671 |
return rasterBuf; |
|
672 |
}*/ |
|
673 |
|
|
674 |
public int getBlockSize() { |
|
675 |
return 0; |
|
676 |
} |
|
677 |
|
|
678 |
public ColorInterpretation getColorInterpretation() { |
|
679 |
if(super.getColorInterpretation() == null) { |
|
680 |
String[] cis = new String[getBandCount()]; |
|
681 |
for (int i = 0; i < cis.length; i++) { |
|
682 |
if(i == 0) |
|
683 |
cis[i] = ColorInterpretation.GRAY_BAND; |
|
684 |
else |
|
685 |
cis[i] = ColorInterpretation.UNDEF_BAND; |
|
686 |
} |
|
687 |
setColorInterpretation(new DataStoreColorInterpretation(cis)); |
|
688 |
} |
|
689 |
return super.getColorInterpretation(); |
|
690 |
} |
|
691 |
|
|
692 |
public DataStoreTransparency getTransparency() { |
|
693 |
if(fileTransparency == null) |
|
694 |
fileTransparency = new DataStoreTransparency(getColorInterpretation()); |
|
695 |
return fileTransparency; |
|
696 |
} |
|
697 |
|
|
698 |
/** |
|
699 |
* Informa de si el driver ha supersampleado en el �ltimo dibujado. Es el driver el que colocar� |
|
700 |
* el valor de esta variable cada vez que dibuja. |
|
701 |
* @return true si se ha supersampleado y false si no se ha hecho. |
|
702 |
*/ |
|
703 |
public boolean isSupersampling() { |
|
704 |
return false; |
|
705 |
} |
|
706 |
|
|
707 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
|
708 |
if(band >= getBandCount()) |
|
709 |
throw new BandAccessException("Wrong band"); |
|
710 |
return 0; |
|
711 |
} |
|
712 |
|
|
713 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
|
714 |
if (band >= getBandCount()) |
|
715 |
throw new BandAccessException("Wrong band"); |
|
716 |
return 0; |
|
717 |
} |
|
718 |
|
|
719 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
|
720 |
if (band >= getBandCount()) |
|
721 |
throw new BandAccessException("Wrong band"); |
|
722 |
return 0; |
|
723 |
} |
|
724 |
|
|
725 |
public boolean isMultiFile() { |
|
726 |
return true; |
|
727 |
} |
|
728 |
|
|
729 |
public boolean isOverviewsSupported() { |
|
730 |
return true; |
|
731 |
} |
|
732 |
|
|
733 |
public boolean isReproyectable() { |
|
734 |
return true; |
|
735 |
} |
|
736 |
|
|
737 |
public String getName() { |
|
738 |
return NAME; |
|
739 |
} |
|
740 |
|
|
741 |
public void setStatus(RasterProvider provider) { |
|
742 |
if(provider instanceof MultiFileProvider) { |
|
743 |
//Not implemented yet |
|
744 |
} |
|
745 |
} |
|
746 |
|
|
747 |
public boolean isTimeSupported() { |
|
748 |
return true; |
|
749 |
} |
|
750 |
|
|
751 |
public String getURIByBand(int band) { |
|
752 |
int[] sub = getSubBandByBandNumber(band); |
|
753 |
RasterProvider prov = getParameters().getProviders().get(sub[0]); |
|
754 |
return prov.getURIOfFirstProvider(); |
|
755 |
} |
|
756 |
|
|
757 |
public void addFile(String file) throws InvalidSourceException { |
|
758 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
759 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
760 |
|
|
761 |
// if(providerList.size() > 0 && providerList.get(0).isTiled()) { |
|
762 |
// //Comentado hasta que se puedan incorporar fuentes tileadas a aun MultiFile |
|
763 |
// //en su lugar se sustituye el primer proveedor tileado por uno sin tilear |
|
764 |
// |
|
765 |
// RasterDataParameters storeParameters = provServ.createParametersForTiledFiled(file); |
|
766 |
// |
|
767 |
// try { |
|
768 |
// RasterProvider newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParameters); |
|
769 |
// if(checkNewProvider(newFileProv)) { |
|
770 |
// getParameters().addProvider(newFileProv); |
|
771 |
// } |
|
772 |
// } catch (InitializeException e) { |
|
773 |
// throw new InvalidSourceException("", e); |
|
774 |
// } catch (ProviderNotRegisteredException e) { |
|
775 |
// throw new InvalidSourceException("", e); |
|
776 |
// } |
|
777 |
// } |
|
778 |
|
|
779 |
setFirstProviderToNotTiled(); |
|
780 |
|
|
781 |
List<RasterDataParameters> storeParametersList = provServ.createParametersList(file); |
|
782 |
|
|
783 |
for (int j = 0; j < storeParametersList.size(); j++) { |
|
784 |
RasterProvider newFileProv; |
|
785 |
try { |
|
786 |
newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j)); |
|
787 |
if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) { |
|
788 |
getParameters().addProvider(newFileProv); |
|
789 |
} |
|
790 |
} catch (InitializeException e) { |
|
791 |
throw new InvalidSourceException("", e); |
|
792 |
} catch (ProviderNotRegisteredException e) { |
|
793 |
throw new InvalidSourceException("", e); |
|
794 |
} |
|
795 |
} |
|
796 |
} |
|
797 |
|
|
798 |
private void setFirstProviderToNotTiled() throws InvalidSourceException { |
|
799 |
List<RasterProvider> providerList = getParameters().getProviders(); |
|
800 |
if(providerList == null || providerList.size() <= 0 || !providerList.get(0).isTiled()) |
|
801 |
return; |
|
802 |
|
|
803 |
//Si el primer proveedor es tileado se cambia a no tileado |
|
804 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
805 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
806 |
|
|
807 |
RasterDataParameters firstDataParameters = providerList.get(0).getDataParameters(); |
|
808 |
String uri = firstDataParameters.getURI(); |
|
809 |
|
|
810 |
List<RasterDataParameters> storeParametersList = provServ.createParametersList(uri); |
|
811 |
|
|
812 |
for (int j = 0; j < storeParametersList.size(); j++) { |
|
813 |
RasterProvider newFileProv; |
|
814 |
try { |
|
815 |
newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j)); |
|
816 |
if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) { |
|
817 |
getParameters().setFirstProvider(newFileProv); |
|
818 |
} |
|
819 |
} catch (InitializeException e) { |
|
820 |
throw new InvalidSourceException("Error replacing the first provider", e); |
|
821 |
} catch (ProviderNotRegisteredException e) { |
|
822 |
throw new InvalidSourceException("Error replacing the first provider", e); |
|
823 |
} |
|
824 |
} |
|
825 |
} |
|
826 |
|
|
827 |
public void removeFile(String file) { |
|
828 |
getParameters().removeProvider(file); |
|
829 |
} |
|
830 |
|
|
831 |
public TileServer getTileServer() { |
|
832 |
if(tileServer == null) { |
|
833 |
DefaultRasterStore store = new DefaultRasterStore(); |
|
834 |
store.setProvider(this); |
|
835 |
tileServer = new FileTileServer(store); |
|
836 |
} |
|
837 |
return tileServer; |
|
838 |
} |
|
839 |
} |
|
0 | 840 |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/java/org/gvsig/raster/multifile/io/MultiFileServerExplorerParameters.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.multifile.io; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
31 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
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.DynObjectManager; |
|
36 |
|
|
37 |
/** |
|
38 |
* Parameters for the Multifile explorer provider |
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
40 |
*/ |
|
41 |
public class MultiFileServerExplorerParameters extends AbstractDataParameters implements DataServerExplorerParameters { |
|
42 |
public static final String DYNCLASS_NAME = "MultifileServerExplorerParameters"; |
|
43 |
protected static DynClass DYNCLASS = null; |
|
44 |
private DelegatedDynObject delegatedDynObject = null; |
|
45 |
|
|
46 |
|
|
47 |
public MultiFileServerExplorerParameters() { |
|
48 |
super(); |
|
49 |
initialize(); |
|
50 |
} |
|
51 |
|
|
52 |
protected void initialize() { |
|
53 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
54 |
.getDynObjectManager().createDynObject( |
|
55 |
DYNCLASS); |
|
56 |
} |
|
57 |
|
|
58 |
public static void registerDynClass() { |
|
59 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
60 |
DynClass dynClass; |
|
61 |
|
|
62 |
if(dynman == null) |
|
63 |
return; |
|
64 |
|
|
65 |
if (DYNCLASS == null) { |
|
66 |
dynClass = dynman.add(DYNCLASS_NAME); |
|
67 |
|
|
68 |
DYNCLASS = dynClass; |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
74 |
return delegatedDynObject; |
|
75 |
} |
|
76 |
|
|
77 |
public String getDataStoreName() { |
|
78 |
return MultiFileProvider.NAME; |
|
79 |
} |
|
80 |
|
|
81 |
public String getDescription() { |
|
82 |
return MultiFileProvider.DESCRIPTION; |
|
83 |
} |
|
84 |
|
|
85 |
public String getExplorerName() { |
|
86 |
return MultiFileProvider.NAME; |
|
87 |
} |
|
88 |
} |
|
0 | 89 |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/java/org/gvsig/raster/multifile/io/MultiFileDataParameters.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.multifile.io; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
34 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
35 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
36 |
|
|
37 |
/** |
|
38 |
* Parameters for the Multifile provider |
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
40 |
*/ |
|
41 |
public interface MultiFileDataParameters extends RasterDataParameters { |
|
42 |
public static final String FIELD_PROVIDERS = "Providers"; |
|
43 |
|
|
44 |
/** |
|
45 |
* Removes all providers |
|
46 |
*/ |
|
47 |
public void removeAllProviders(); |
|
48 |
|
|
49 |
/** |
|
50 |
* Returns true if this multifile has providers loaded |
|
51 |
* @return |
|
52 |
*/ |
|
53 |
public boolean hasProviders(); |
|
54 |
|
|
55 |
/** |
|
56 |
* Removes a provider from the list |
|
57 |
* @param uri |
|
58 |
*/ |
|
59 |
public void removeProvider(String uri); |
|
60 |
|
|
61 |
/** |
|
62 |
* Adds a provider to the list if the this is not tiled |
|
63 |
* @param prov |
|
64 |
*/ |
|
65 |
public void addProviderNotTiled(DataStoreProvider provider); |
|
66 |
|
|
67 |
/** |
|
68 |
* Set the selected provider in the first position |
|
69 |
* @param provider |
|
70 |
*/ |
|
71 |
public void setFirstProvider(DataStoreProvider provider); |
|
72 |
|
|
73 |
/** |
|
74 |
* Adds a provider to the list |
|
75 |
* @param prov |
|
76 |
*/ |
|
77 |
public void addProvider(DataStoreProvider provider); |
|
78 |
|
|
79 |
/** |
|
80 |
* Adds a provider to the list from a RasterDataStore |
|
81 |
* @param rasterDataStore |
|
82 |
*/ |
|
83 |
public void addProvider(RasterDataStore rasterDataStore); |
|
84 |
|
|
85 |
/** |
|
86 |
* Gets the list of providers |
|
87 |
*/ |
|
88 |
public List<RasterProvider> getProviders(); |
|
89 |
} |
|
0 | 90 |
org.gvsig.raster.multifile/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.multifile.io/src/main/java/org/gvsig/raster/multifile/io/MultiFileDataParametersImpl.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 |
* |
Also available in: Unified diff