Revision 22335

View differences:

org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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.241</version>
7
	<name>${project.artifactId}</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.445</version>
14
  </parent>
15
        <properties>
16
            <!-- El plugin versions:use-latest-versions falla con scope import -->
17
            <!-- asi que toca usar el versions:update-properties que si que funciona -->
18
            <org.gvsig.raster.version>2.2.265</org.gvsig.raster.version>
19
        </properties>
20

  
21
    <repositories>
22
      <repository>
23
        <id>gvsig-public-http-repository</id>
24
        <name>gvSIG maven public HTTP repository</name>
25
        <url>http://devel.gvsig.org/m2repo/j2se</url>
26
        <releases>
27
          <enabled>true</enabled>
28
          <updatePolicy>daily</updatePolicy>
29
          <checksumPolicy>warn</checksumPolicy>
30
        </releases>
31
        <snapshots>
32
          <enabled>true</enabled>
33
          <updatePolicy>daily</updatePolicy>
34
          <checksumPolicy>warn</checksumPolicy>
35
        </snapshots>
36
      </repository>
37
    </repositories>
38

  
39
    <scm>
40
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241</connection>
41
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241</developerConnection>
42
        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241</url>
43
    </scm>
44

  
45
	<developers>
46
		<developer>
47
			<id>nbrodin</id>
48
			<name>Nacho Brodin</name>
49
			<email>nachobrodin@gmail.com</email>
50
			<roles>
51
				<role>Architect</role>
52
				<role>Developer</role>
53
			</roles>
54
		</developer>
55
	</developers>
56

  
57
	<dependencyManagement>
58
    	<dependencies>
59
                        <dependency>
60
                                <groupId>org.gvsig</groupId>
61
                                <artifactId>org.gvsig.raster</artifactId>
62
                                <version>${org.gvsig.raster.version}</version>
63
                                <type>pom</type>
64
                                <scope>import</scope>
65
                        </dependency>
66

  
67
        <dependency>
68
          <groupId>org.gvsig</groupId>
69
          <artifactId>org.gvsig.raster.multifile.io</artifactId>
70
          <version>2.2.241</version>
71
        </dependency>
72

  
73
    	</dependencies>
74
    </dependencyManagement>
75
	<build>
76
        <plugins>
77
            <plugin>
78
                <groupId>org.apache.maven.plugins</groupId>
79
                <artifactId>maven-release-plugin</artifactId>
80
                <configuration>
81
                    <tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.multifile/tags/</tagBase>
82
                    <goals>deploy</goals>
83
                </configuration>
84
            </plugin>
85
        </plugins>
86
    </build>
87

  
88
	<modules>
89
		<module>org.gvsig.raster.multifile.io</module>
90
		<module>org.gvsig.raster.multifile.app.multifileclient</module>
91
	</modules>
92

  
93
</project>
0 94

  
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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
package org.gvsig.raster.multifile.io;
24

  
25
import java.util.List;
26

  
27
import org.gvsig.fmap.dal.DataServerExplorer;
28
import org.gvsig.fmap.dal.DataStoreParameters;
29
import org.gvsig.fmap.dal.NewDataStoreParameters;
30
import org.gvsig.fmap.dal.exception.DataException;
31
import org.gvsig.fmap.dal.exception.InitializeException;
32
import org.gvsig.fmap.dal.exception.RemoveException;
33
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer;
34
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
35
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
36

  
37
/**
38
 * Explorer for a Multifile
39
 */
40
public class MultiFileServerExplorer extends AbstractDataServerExplorer implements DataServerExplorerProvider  {
41

  
42
	/**
43
	 * 
44
	 */
45
	public MultiFileServerExplorer() {
46
            super(null, null);
47
	}
48

  
49
	/**
50
	 * @param parameters
51
	 * @param services
52
	 * @throws InitializeException
53
	 */
54
	public MultiFileServerExplorer(
55
			MultiFileServerExplorerParameters parameters,
56
			DataServerExplorerProviderServices services)
57
			throws InitializeException {
58
            super(parameters, services);
59
	}
60

  
61
        @Override
62
        public DataStoreParameters get(String string) throws DataException {
63
            return null;
64
        }
65

  
66
	public String getDataStoreProviderName() {
67
		return MultiFileProvider.NAME;
68
	}
69

  
70
	public String getDescription() {
71
		return MultiFileProvider.DESCRIPTION;
72
	}
73

  
74
	public List<String> getDataStoreProviderNames() {
75
		return null;
76
	}
77

  
78
	public String getProviderName() {
79
		return MultiFileProvider.NAME;
80
	}
81

  
82
	public void remove(DataStoreParameters parameters) throws RemoveException {
83
		throw new UnsupportedOperationException();
84
	}
85

  
86
	public boolean add(String provider, NewDataStoreParameters parameters,
87
			boolean overwrite) throws DataException {
88
		return false;
89
	}
90

  
91
	public boolean canAdd() {
92
		return false;
93
	}
94

  
95
	public boolean canAdd(String storeName) throws DataException {
96
		return false;
97
	}
98

  
99
	public NewDataStoreParameters getAddParameters(String storeName)
100
			throws DataException {
101
		return null;
102
	}
103

  
104
	public List<DataStoreParameters> list() throws DataException {
105
		return null;
106
	}
107

  
108
	public List<DataStoreParameters> list(int mode) throws DataException {
109
		return null;
110
	}
111

  
112
	public int getMode() {
113
		return DataServerExplorer.MODE_RASTER;
114
	}
115

  
116

  
117
}
0 118

  
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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 String
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 int
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 String
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
	/**
87
	 * @param fileName
88
	 * @param path
89
	 * @param uriList
90
	 * @return String
91
	 * @throws IOException
92
	 */
93
	public static String saveMultiFileFormat(String fileName, String path, ArrayList<File> uriList) throws IOException {
94
		path = path + File.separator + fileName + ".mff";
95

  
96
		MultiFileFormat format = new MultiFileFormat();
97
		for (int i = 0; i < uriList.size(); i++) {
98
			format.addFile(uriList.get(i));
99
		}
100
		format.setName(fileName);
101

  
102
		format.write(path);
103
		return path;
104
	}
105

  
106
	/**
107
	 * Writes a MultiFileFormat to disk
108
	 * @param fileName
109
	 * @param file
110
	 * @throws IOException
111
	 */
112
	public void write(String fileName) throws IOException {
113
		MultiFileFormatSerializer.write(this, fileName);
114
	}
115
}
0 116

  
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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

  
25
import java.awt.geom.AffineTransform;
26
import java.awt.geom.Point2D;
27
import java.awt.geom.Rectangle2D;
28
import java.io.File;
29
import java.io.IOException;
30
import java.net.URI;
31
import java.net.URISyntaxException;
32
import java.util.List;
33

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

  
37
import org.gvsig.fmap.dal.DALFileLocator;
38
import org.gvsig.fmap.dal.DALLocator;
39
import org.gvsig.fmap.dal.DataStore;
40
import org.gvsig.fmap.dal.DataStoreParameters;
41
import org.gvsig.fmap.dal.coverage.RasterLocator;
42
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
43
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
44
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
45
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
46
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
47
import org.gvsig.fmap.dal.coverage.exception.FileNotSupportedException;
48
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
49
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
50
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
51
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
52
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
53
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
54
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
55
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
56
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
57
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
58
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
59
import org.gvsig.fmap.dal.coverage.util.ProviderServices;
60
import org.gvsig.fmap.dal.exception.CloseException;
61
import org.gvsig.fmap.dal.exception.InitializeException;
62
import org.gvsig.fmap.dal.exception.OpenException;
63
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
64
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
65
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
66
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
67
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
68
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
69
import org.gvsig.fmap.dal.spi.DataStoreProvider;
70
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
71
import org.gvsig.metadata.MetadataLocator;
72
import org.gvsig.raster.cache.tile.provider.TileServer;
73
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
74
import org.gvsig.raster.impl.datastruct.BandListImpl;
75
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
76
import org.gvsig.raster.impl.datastruct.ExtentImpl;
77
import org.gvsig.raster.impl.provider.AbstractRasterProvider;
78
import org.gvsig.raster.impl.provider.RasterProvider;
79
import org.gvsig.raster.impl.provider.tile.FileTileServer;
80
import org.gvsig.raster.impl.store.DefaultRasterStore;
81
import org.gvsig.raster.impl.store.DefaultStoreFactory;
82
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
83
import org.gvsig.raster.impl.store.properties.DataStoreTransparency;
84
import org.gvsig.raster.impl.store.properties.MultiProviderHistogramComputer;
85
import org.gvsig.raster.impl.store.properties.MultiProviderStatistics;
86
import org.gvsig.tools.ToolsLocator;
87
import org.gvsig.tools.locator.LocatorException;
88
/**
89
 * A data provider for a multiband image readed from different files
90
 *
91
 * @author Nacho Brodin (nachobrodin@gmail.com)
92
 */
93
public class MultiFileProvider extends AbstractRasterProvider {
94
	public static String                     NAME                     = "Multifile Raster";
95
	public static String                     DESCRIPTION              = "Multifile Raster Support";
96
	public final String                      METADATA_DEFINITION_NAME = NAME;
97
	private Extent                           viewRequest              = null;
98
	private TileServer                       tileServer               = null;
99
	private boolean                          open                     = false;
100

  
101
    private DataStoreTransparency            fileTransparency         = null;
102
    private static final Logger              logger                   = LoggerFactory.getLogger(MultiFileProvider.class);
103
    protected static String[]                formatList               = null;
104

  
105
	/**
106
	 *
107
	 */
108
	public static void register() {
109
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
110
		registerFormats();
111

  
112
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
113
			dataman.registerStoreProvider(NAME,
114
					MultiFileProvider.class, MultiFileDataParametersImpl.class);
115
		}
116

  
117
//		if(DALFileLocator.getFilesystemServerExplorerManager() != null)
118
//			DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
119
//					NAME, DESCRIPTION,
120
//					MultiFileServerExplorer.class);
121
//
122
//		if (!dataman.getExplorerProviders().contains(NAME)) {
123
//			dataman.registerExplorerProvider(NAME, MultiFileServerExplorer.class, MultiFileServerExplorerParameters.class);
124
//		}
125

  
126
		dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
127
	}
128

  
129
	private static void registerFormats() {
130
		formatList      = new String[] {
131
				"mff"};
132
		for (int i = 0; i < formatList.length; i++)
133
			RasterLocator.getManager().getProviderServices().addFormat(
134
					formatList[i],
135
					MultiFileProvider.class);
136
	}
137

  
138
	/**
139
	 *
140
	 */
141
	public MultiFileProvider() {
142
	}
143

  
144
	/**
145
	 * Opens the dataset.
146
	 * @param params
147
	 * @param proj Projection
148
	 * @param fName File name
149
	 * @throws NotSupportedExtensionException
150
	 * @throws OpenException
151
     * @deprecated use {@link #MultiFileProvider(URI)}, this constructor will be removed in gvSIG 2.5
152
	 */
153
	public MultiFileProvider(String params) throws NotSupportedExtensionException, OpenException {
154
		super(params);
155
        logger.info("Deprecated use of MultiFileProvider constructor");
156
		if(params instanceof String) {
157
			MultiFileDataParameters p = new MultiFileDataParametersImpl();
158
			URI uriObj;
159
            try {
160
                uriObj = new URI((String)params);
161
            } catch (URISyntaxException e) {
162
                throw new OpenException("Can't create uri from "+(String)params, e);
163
            }
164
			p.setURI(uriObj);
165
			super.init(p, null, ToolsLocator.getDynObjectManager()
166
					.createDynObject(
167
							MetadataLocator.getMetadataManager().getDefinition(
168
									DataStore.METADATA_DEFINITION_NAME)));
169
			init(p, null);
170
		}
171
	}
172

  
173
	 /**
174
     * Opens the dataset.
175
	 * @param uri
176
     * @param proj Projection
177
     * @param fName File name
178
     * @throws NotSupportedExtensionException
179
	 * @throws OpenException
180
     */
181
    public MultiFileProvider(URI uri) throws NotSupportedExtensionException, OpenException {
182
        super(uri);
183
        MultiFileDataParameters p = new MultiFileDataParametersImpl();
184
        p.setURI(uri);
185
        super.init(
186
            p,
187
            null,
188
            ToolsLocator.getDynObjectManager().createDynObject(
189
                MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME)));
190
        init(p, null);
191
    }
192

  
193
    /**
194
     * @param params
195
     * @param storeServices
196
     * @throws NotSupportedExtensionException
197
     * @throws OpenException
198
     */
199
    public MultiFileProvider(MultiFileDataParametersImpl params,
200
			DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException {
201
		super(params, storeServices, ToolsLocator.getDynObjectManager()
202
				.createDynObject(
203
						MetadataLocator.getMetadataManager().getDefinition(
204
								DataStore.METADATA_DEFINITION_NAME)));
205
		init(params, storeServices);
206
	}
207

  
208
	/**
209
	 * Build file references
210
	 * @param params
211
	 * @param storeServices
212
	 * @param proj Projection
213
	 * @param param Load parameters
214
	 * @throws NotSupportedExtensionException
215
	 * @throws OpenException
216
	 */
217
	public void init(MultiFileDataParameters params,
218
			DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException {
219

  
220
		openFromMff();
221

  
222
		uri = getParameters().getURI();
223
		setParam(storeServices, params);
224

  
225
		try {
226
			setFirstProviderToNotTiled();
227
		} catch (InvalidSourceException e1) {
228
			throw new OpenException(e1.getMessage(), e1);
229
		}
230

  
231
		super.init();
232

  
233
		try {
234
			loadFromRmf(getRmfBlocksManager());
235
		} catch (ParsingException e) {
236
			logger.debug("Problems reading from RMF", e);
237
		}
238

  
239
		open = true;
240
	}
241

  
242
	/**
243
	 * Open from a .mff file.
244
	 * This method loads all providers and adds these to the parameters
245
	 * @throws OpenException
246
	 */
247
	private void openFromMff() throws OpenException {
248
		URI uriParam = getParameters().getURI();
249
        if (uriParam != null) {
250
            File fileFromUriParam = new File(uriParam);
251
            if (fileFromUriParam.exists()) {
252
                boolean loadedProviders = true;
253
                if (getParameters().hasProviders()) {
254
                    // solo se considera que est?n todos los providers cargados
255
                    // si existen y est?n open,
256
                    // sino se leer?n de disco
257
                    for (int i = 0; i < getParameters().getProviders().size(); i++) {
258
                        if (!getParameters().getProviders().get(i).isOpen())
259
                            loadedProviders = false;
260
                    }
261
                } else
262
                    loadedProviders = false;
263

  
264
                if (loadedProviders)
265
                    return;
266

  
267
                try {
268
                    if (getParameters().hasProviders())
269
                        getParameters().removeAllProviders();
270
                    MultiFileFormat multiFileFormat = new MultiFileFormat();
271
                    multiFileFormat = MultiFileFormatSerializer.read(multiFileFormat, fileFromUriParam.getAbsolutePath());
272
                    for (int i = 0; i < multiFileFormat.getNumberOfFiles(); i++) {
273
                        try {
274
                            File file = new File(multiFileFormat.getPathToFile(i));
275
                            if (file.exists()) {
276
                                RasterProvider prov = loadProvider(multiFileFormat.getPathToFile(i), storeServices);
277
                                getParameters().addProvider(prov);
278
                            }
279
                        } catch (ProviderNotRegisteredException e) {
280
                            throw new OpenException("A provider can't be loaded", e);
281
                        } catch (InitializeException e) {
282
                            throw new OpenException("A provider can't be initialized", e);
283
                        }
284
                    }
285
                } catch (IOException e1) {
286
                    throw new OpenException("File .mff can't be read", e1);
287
                } catch (ParsingException e1) {
288
                    throw new OpenException("File .mff can't be parsed", e1);
289
                }
290
            }
291
        }
292
	}
293

  
294
	/**
295
	 * Loads the specific provider
296
	 * @param file
297
	 * @return
298
	 * @throws NotSupportedExtensionException
299
	 * @throws FileNotSupportedException
300
	 */
301
	@SuppressWarnings("unchecked")
302
	private RasterProvider loadProvider(String file, DataStoreProviderServices storeServices) throws ProviderNotRegisteredException, InitializeException {
303
		DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
304
		DataStoreProvider prov = null;
305

  
306
		if(file != null) {
307
			//We have to locate a provider's name which manages the selected file
308
			//A FilesystemServerExplorer will give a getProviderNames service
309
			FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
310
			FilesystemServerExplorer serverExplorer = null;
311
			try {
312
				paramsExplorer.setRoot(File.separator);
313
				serverExplorer = (FilesystemServerExplorer)dataManager.openServerExplorer(FilesystemServerExplorer.NAME, paramsExplorer);
314
			} catch (ValidateDataParametersException e) {
315
				throw new InitializeException(e);
316
			}
317
			File f = new File(file);
318
			//Gets the list of provider's name to manage the file
319
			List<String> provName = serverExplorer.getProviderNameList(f);
320
			if(provName.size() > 0) {
321
				for (int i = 0; i < provName.size(); i++) {
322
					//Gets the first provider what is not a TileProvider
323
					if(provName.get(i).compareTo("Tile Store") != 0) {
324
						DataStoreParameters newparams = dataManager.createStoreParameters(provName.get(i));
325
						((FilesystemStoreParameters)newparams).setFile(f);
326
						prov = dataManager.createProvider(storeServices, newparams);
327
					}
328
				}
329
			}
330
		}
331

  
332
		if(prov != null && prov instanceof RasterProvider) {
333
			if(((RasterProvider)prov).isRotated())
334
				throw new InitializeException("Rotation not supported tiling files", new Throwable());
335

  
336
			return (RasterProvider)prov;
337
		}
338

  
339
		return null;
340
	}
341

  
342
	/**
343
	 * Checks if the new file is compatible with the old one
344
	 * @param file
345
	 * @return
346
	 * @throws LocatorException
347
	 * @throws NotSupportedExtensionException
348
	 * @throws RasterDriverException
349
	 * @throws CloseException
350
	 */
351
	private boolean checkNewProvider(RasterProvider p) {
352
		Rectangle2D extentOrigin = getExtent().toRectangle2D();
353

  
354
		Extent extentNewFile = p.getExtent();
355

  
356
		// Comprobamos que el extent y tama�o del fichero a�adido sea igual al
357
		// fichero original. Si no es as� no abrimos la capa y mostramos un aviso
358

  
359
		double widthNewFile = (extentNewFile.getMax().getX() - extentNewFile.getMin().getX());
360
		double heightNewFile = (extentNewFile.getMax().getY() - extentNewFile.getMin().getY());
361

  
362
		if ((widthNewFile - extentOrigin.getWidth()) > 1.0 || (widthNewFile - extentOrigin.getWidth()) < -1.0 || (heightNewFile - extentOrigin.getHeight()) > 1.0
363
				|| (heightNewFile - extentOrigin.getHeight()) < -1.0) {
364
			return false;
365
		}
366

  
367
		if ((extentNewFile.getMax().getX() - extentNewFile.getMin().getX()) != extentOrigin.getWidth()
368
				|| (extentNewFile.getMax().getY() - extentNewFile.getMin().getY()) != extentOrigin.getHeight()) {
369
			return false;
370
		}
371

  
372
		return true;
373
	}
374

  
375
	/**
376
	 * @return MultiFileDataParameters
377
	 */
378
	public MultiFileDataParameters getParameters() {
379
		try {
380
			return (MultiFileDataParameters)parameters;
381
		} catch (ClassCastException e) {
382
			return null;
383
		}
384
	}
385

  
386
	public RasterProvider load() {
387
		return this;
388
	}
389

  
390
	public int getBandCount() {
391
		List<RasterProvider> providerList = getParameters().getProviders();
392
		int bandCount = 0;
393
		for (int i = 0; i < providerList.size(); i++) {
394
			bandCount += providerList.get(i).getBandCount();
395
		}
396
		return bandCount;
397
	}
398

  
399
	public int[] getDataType() {
400
		List<RasterProvider> providerList = getParameters().getProviders();
401
		int[] datatypes = new int[getBandCount()];
402
		int k = 0;
403
		for (int i = 0; i < providerList.size(); i++) {
404
			int[] dtByProv = providerList.get(i).getDataType();
405
			for (int j = 0; j < dtByProv.length; j++) {
406
				datatypes[k] = dtByProv[j];
407
				k++;
408
			}
409
		}
410
		return datatypes;
411
	}
412

  
413
	public URI[] getURIByProvider() {
414
		List<RasterProvider> providerList = getParameters().getProviders();
415
		URI[] uris = new URI[providerList.size()];
416
		for (int i = 0; i < uris.length; i++) {
417
			uris[i] = providerList.get(i).getURIOfFirstProvider();
418
		}
419
		return uris;
420
	}
421

  
422
	public int getBandPositionByProvider(int band) {
423
		return getSubBandByBandNumber(band)[1];
424
	}
425

  
426
	public URI getURIOfFirstProvider() {
427
		List<RasterProvider> providerList = getParameters().getProviders();
428
		return providerList.get(0).getURIOfFirstProvider();
429
	}
430

  
431

  
432
	public Extent getExtent() {
433
		List<RasterProvider> providerList = getParameters().getProviders();
434
		if(providerList != null && providerList.size() > 0)
435
			return providerList.get(0).getExtent();
436
		return null;
437
	}
438

  
439
	public AffineTransform getAffineTransform() {
440
		List<RasterProvider> providerList = getParameters().getProviders();
441
		return providerList.get(0).getAffineTransform();
442
	}
443

  
444
	public void setAffineTransform(AffineTransform t) {
445
		List<RasterProvider> providerList = getParameters().getProviders();
446
		for (int i = 0; i < providerList.size(); i++) {
447
			providerList.get(i).setAffineTransform(t);
448
		}
449
	}
450

  
451
	public int getInternalProviderCount() {
452
		return getParameters().getProviders().size();
453
	}
454

  
455
	public RasterProvider getInternalProvider(int i) {
456
		return getParameters().getProviders().get(i);
457
	}
458

  
459
	public int[] getBandCountByProvider() {
460
		List<RasterProvider> providerList = getParameters().getProviders();
461
		int[] bc = new int[providerList.size()];
462
		for (int i = 0; i < bc.length; i++) {
463
			bc[i] = providerList.get(i).getBandCount();
464
		}
465
		return bc;
466
	}
467

  
468
	public long[] getFileSizeByProvider() {
469
		List<RasterProvider> providerList = getParameters().getProviders();
470
		long[] fs = new long[providerList.size()];
471
		for (int i = 0; i < fs.length; i++) {
472
			fs[i] = ((AbstractRasterProvider)providerList.get(i)).getFileSize();
473
		}
474
		return fs;
475
	}
476

  
477
	public Point2D rasterToWorld(Point2D pt) {
478
		List<RasterProvider> providerList = getParameters().getProviders();
479
		return providerList.get(0).rasterToWorld(pt);
480
	}
481

  
482
	public Point2D worldToRaster(Point2D pt) {
483
		List<RasterProvider> providerList = getParameters().getProviders();
484
		return providerList.get(0).worldToRaster(pt);
485
	}
486

  
487
	public boolean isInside(Point2D p){
488
		List<RasterProvider> providerList = getParameters().getProviders();
489
		return providerList.get(0).isInside(p);
490
	}
491

  
492
	public double getCellSize() {
493
		List<RasterProvider> providerList = getParameters().getProviders();
494
		return providerList.get(0).getCellSize();
495
	}
496

  
497
	public Statistics getStatistics() {
498
		if(stats == null || (stats instanceof MultiProviderStatistics &&
499
				((MultiProviderStatistics)stats).getNumberOfProviders() != getParameters().getProviders().size())) {
500
			List<RasterProvider> providerList = getParameters().getProviders();
501
			stats = new MultiProviderStatistics(providerList, this);
502
		}
503

  
504
		return stats;
505
	}
506

  
507
	public HistogramComputer getHistogramComputer() {
508
		if(histogram == null ||
509
			(histogram instanceof MultiProviderHistogramComputer &&
510
			((MultiProviderHistogramComputer)histogram).getNumberOfProviders() != getParameters().getProviders().size())) {
511
			histogram = new MultiProviderHistogramComputer(this);
512
		}
513

  
514
		return histogram;
515
	}
516

  
517
	/**
518
	 * A multiband provider doesn't have a color table because this will have
519
	 * more than one band.
520
	 */
521
	public ColorTable getColorTable() {
522
		return null;
523
	}
524

  
525
	public boolean isOpen() {
526
		return open;
527
	}
528

  
529
	public void close() {
530
	}
531

  
532
	public URI translateURI(URI uri) {
533
		return uri;
534
	}
535

  
536
	/**
537
	 * Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci�n
538
	 * de la vista asignada ya que la petici�n viene en coordenadas del fichero .rmf y la vista (v)
539
	 * ha de estar en coordenadas del fichero.
540
	 */
541
	public void setView(Extent e) {
542
		viewRequest = new ExtentImpl(e);
543
	}
544

  
545
	public Extent getView() {
546
		return viewRequest;
547
	}
548

  
549
	public double getWidth() {
550
		List<RasterProvider> providerList = getParameters().getProviders();
551
		if(providerList != null && providerList.size() > 0) {
552
			return providerList.get(0).getWidth();
553
		}
554
		return 0;
555
	}
556

  
557
	public double getHeight() {
558
		List<RasterProvider> providerList = getParameters().getProviders();
559
		if(providerList != null && providerList.size() > 0) {
560
			return providerList.get(0).getHeight();
561
		}
562
		return 0;
563

  
564
	}
565

  
566
	public Object readBlock(int pos, int blockHeight, double scale)
567
		throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
568
		return null;
569
	}
570

  
571
	/**
572
	 * Gets a number of provider and the band of this provider
573
	 * @param band
574
	 * @return
575
	 */
576
	private int[] getSubBandByBandNumber(int band) {
577
		List<RasterProvider> providerList = getParameters().getProviders();
578
		int[] res = new int[2];
579
		int acum = 0;
580
		for (int i = 0; i < providerList.size(); i++) {
581
			acum += providerList.get(i).getBandCount();
582
			if(acum > band) {
583
				res[0] = i;
584
				int aux = (acum - providerList.get(i).getBandCount());
585
				res[1] = band - aux;
586
				return res;
587
			}
588
		}
589
		return res;
590
	}
591

  
592
	@Override
593
	public void loadBuffer(SpiRasterQuery q)
594
			throws ProcessInterruptedException, RasterDriverException {
595
		List<RasterProvider> providerList = getParameters().getProviders();
596

  
597
		for (int i = 0; i < providerList.size(); i++) {
598
			SpiRasterQuery query = (SpiRasterQuery)q.clone();
599
			BandList bandListByFile = createBandListByProvider(q.getBandList(), providerList.get(i));
600
			query.setBandList(bandListByFile);
601
			providerList.get(i).getDataSet(q);
602
		}
603

  
604
		/*for (int i = 0; i < providerList.size(); i++) {
605
			DefaultRasterStore store = new DefaultRasterStore();
606
			store.setProvider(providerList.get(i));
607
			RasterQuery query = ((DefaultRasterQuery)q).clone();
608
			BandList bandListByFile = createBandListByProvider(q.getBandList(), providerList.get(i));
609
			query.set
610
			try {
611
				store.query((RasterQuery)q);
612
			} catch (QueryException e) {
613
				throw new RasterDriverException("Error in query to the provider " + i, e);
614
			}
615
		}*/
616
	}
617

  
618
	public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
619
		int[] sub = getSubBandByBandNumber(band);
620
		RasterProvider prov = getParameters().getProviders().get(sub[0]);
621
		return prov.getData(x, y, sub[1]);
622
	}
623

  
624

  
625
	/*public Buffer getWindow(Extent extent, BandList bandList, Buffer rasterBuf, TaskStatus status)
626
		throws ProcessInterruptedException, RasterDriverException {
627
		providerList = getParameters().getProviders();
628

  
629
		DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
630
		q.setAreaOfInterest(extent);
631
		q.setBandList(bandList);
632
		q.setBuffer(rasterBuf);
633

  
634
		for (int i = 0; i < providerList.size(); i++) {
635
			rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
636
		}
637
		return rasterBuf;
638
	}*/
639

  
640
	/*public Buffer getWindow(double ulx, double uly, double w, double h,
641
			BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
642
		providerList = getParameters().getProviders();
643

  
644
		DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
645
		q.setAreaOfInterest(ulx, uly, w, h);
646
		q.setBandList(bandList);
647
		q.setBuffer(rasterBuf);
648
		q.setAdjustToExtent(adjustToExtent);
649

  
650
		for (int i = 0; i < providerList.size(); i++) {
651
			rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
652
		}
653
		return rasterBuf;
654
	}*/
655

  
656
	/*public Buffer getWindow(Extent extent, int bufWidth, int bufHeight,
657
			BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
658
		providerList = getParameters().getProviders();
659

  
660
		DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
661
		q.setAreaOfInterest(extent, bufWidth, bufHeight);
662
		q.setBuffer(rasterBuf);
663
		q.setAdjustToExtent(adjustToExtent);
664

  
665
		for (int i = 0; i < providerList.size(); i++) {
666
			BandList bandListByFile = createBandListByProvider(bandList, providerList.get(i));
667
			if(bandListByFile != null) {
668
				q.setBandList(bandListByFile);
669
				rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
670
			}
671
		}
672
		return rasterBuf;
673
	}*/
674

  
675
	/**
676
	 * Creates a <code>BandList</code> for each provider of this <code>MultiFileProvider</code>.
677
	 * When a request is made, the <code>BandList</code> is global for all files. A specific
678
	 * <code>BandList</code> has to be built for each provider.
679
	 * @param globalBandList
680
	 * @param provider
681
	 * @return
682
	 */
683
	private BandList createBandListByProvider(BandList globalBandList, RasterProvider provider) {
684
		if(provider.isTiled()) {
685
			//Si los proveedores que hay por debajo son tileados estos crear�n su propio buffer para escribir
686
			//cada tile. Por ello no usar� el buffer que viene del store. Esto quiere decir que el BandList ha
687
			//de ser distinto para que escriba bien en su buffer
688

  
689
			//TODO: De momento no se permiten MultiFiles con proveedores tileados. Esto es porque
690
			//los tiles crean su propio buffer y no escriben en el buffer creado en el Store
691

  
692
		} else {
693
			BandList bandListByFile = new BandListImpl();
694
			String pathUriProvider = new File(provider.getURI()).getAbsolutePath();
695
            for (int i = 0; i < provider.getBandCount(); i++) {
696
				try {
697
					bandListByFile.addBand(new DatasetBandImpl(pathUriProvider, i, provider.getDataType()[0], provider.getBandCount()));
698
				} catch (BandNotFoundInListException e1) {
699
				}
700
			}
701

  
702
			boolean areThereBandsToDraw = false;
703
			for (int i = 0; i < provider.getBandCount(); i++) {
704
				int[] bandsToDrawByProviderBand = globalBandList.getBufferBandToDraw(pathUriProvider, i);
705
				if(bandsToDrawByProviderBand != null) {
706
					areThereBandsToDraw = true;
707
					for (int j = 0; j < bandsToDrawByProviderBand.length; j++) {
708
						bandListByFile.getBand(i).addPositionToDrawInBuffer(bandsToDrawByProviderBand[j]);
709
					}
710
				}
711
			}
712

  
713
			if(areThereBandsToDraw)
714
				return bandListByFile;
715
		}
716
		return null;
717
	}
718

  
719
	/*public Buffer getWindow(int x, int y, int w, int h,
720
			BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
721
		providerList = getParameters().getProviders();
722
		DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
723
		q.setAreaOfInterest(x, y, w, h);
724
		q.setBandList(bandList);
725
		q.setBuffer(rasterBuf);
726
		for (int i = 0; i < providerList.size(); i++) {
727
			rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
728
		}
729
		return rasterBuf;
730
	}*/
731

  
732
	public int getBlockSize() {
733
		return 0;
734
	}
735

  
736
	public ColorInterpretation getColorInterpretation() {
737
		if(super.getColorInterpretation() == null) {
738
			String[] cis = new String[getBandCount()];
739
			for (int i = 0; i < cis.length; i++) {
740
				if(i == 0)
741
					cis[i] = ColorInterpretation.GRAY_BAND;
742
				else
743
					cis[i] = ColorInterpretation.UNDEF_BAND;
744
			}
745
			setColorInterpretation(new DataStoreColorInterpretation(cis));
746
		}
747
		return super.getColorInterpretation();
748
	}
749

  
750
	public DataStoreTransparency getTransparency() {
751
		if(fileTransparency == null)
752
			fileTransparency = new DataStoreTransparency(getColorInterpretation());
753
		return fileTransparency;
754
	}
755

  
756
	/**
757
	 * Informa de si el driver ha supersampleado en el �ltimo dibujado. Es el driver el que colocar�
758
	 * el valor de esta variable cada vez que dibuja.
759
	 * @return true si se ha supersampleado y false si no se ha hecho.
760
	 */
761
	public boolean isSupersampling() {
762
		return false;
763
	}
764

  
765
	public int getOverviewCount(int band) throws BandAccessException, RasterDriverException {
766
		if(band >= getBandCount())
767
			throw new BandAccessException("Wrong band");
768
		return 0;
769
	}
770

  
771
	public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException {
772
		if (band >= getBandCount())
773
			throw new BandAccessException("Wrong band");
774
		return 0;
775
	}
776

  
777
	public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException {
778
		if (band >= getBandCount())
779
			throw new BandAccessException("Wrong band");
780
		return 0;
781
	}
782

  
783
	public boolean isMultiFile() {
784
		return true;
785
	}
786

  
787
	public boolean isOverviewsSupported() {
788
		return true;
789
	}
790

  
791
	public boolean isReproyectable() {
792
		return true;
793
	}
794

  
795
	public String getProviderName() {
796
		return NAME;
797
	}
798

  
799
	public void setStatus(RasterProvider provider) {
800
		if(provider instanceof MultiFileProvider) {
801
			//Not implemented yet
802
		}
803
	}
804

  
805
	public boolean isTimeSupported() {
806
		return true;
807
	}
808

  
809
	public URI getURIByBand(int band) {
810
		int[] sub = getSubBandByBandNumber(band);
811
		RasterProvider prov = getParameters().getProviders().get(sub[0]);
812
		return prov.getURIOfFirstProvider();
813
	}
814

  
815
	/**
816
	 * @param file
817
	 * @throws InvalidSourceException
818
	 */
819
	public void addFile(String file) throws InvalidSourceException {
820
		ProviderServices provServ = RasterLocator.getManager().getProviderServices();
821
		DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
822

  
823
		setFirstProviderToNotTiled();
824

  
825
		List<RasterDataParameters> storeParametersList = provServ.createParametersList(file);
826

  
827
		for (int j = 0; j < storeParametersList.size(); j++) {
828
			RasterProvider newFileProv;
829
			try {
830
				newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j));
831
				if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) {
832
					getParameters().addProvider(newFileProv);
833
				}
834
			} catch (InitializeException e) {
835
				throw new InvalidSourceException("", e);
836
			} catch (ProviderNotRegisteredException e) {
837
				throw new InvalidSourceException("", e);
838
			}
839
		}
840
	}
841

  
842
	private void setFirstProviderToNotTiled() throws InvalidSourceException {
843
		List<RasterProvider> providerList = getParameters().getProviders();
844
		if(providerList == null || providerList.size() <= 0 || !providerList.get(0).isTiled())
845
			return;
846

  
847
		//Si el primer proveedor es tileado se cambia a no tileado
848
		DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
849
		ProviderServices provServ = RasterLocator.getManager().getProviderServices();
850

  
851
		RasterDataParameters firstDataParameters = providerList.get(0).getDataParameters();
852
		URI uri = firstDataParameters.getURI();
853

  
854
		List<RasterDataParameters> storeParametersList = provServ.createParametersList(new File(uri).getAbsolutePath());
855

  
856
		for (int j = 0; j < storeParametersList.size(); j++) {
857
			RasterProvider newFileProv;
858
			try {
859
				newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j));
860
				if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) {
861
					getParameters().setFirstProvider(newFileProv);
862
				}
863
			} catch (InitializeException e) {
864
				throw new InvalidSourceException("Error replacing the first provider", e);
865
			} catch (ProviderNotRegisteredException e) {
866
				throw new InvalidSourceException("Error replacing the first provider", e);
867
			}
868
		}
869
	}
870

  
871
	public void removeFile(File file) {
872
		getParameters().removeProvider(file.toURI());
873
	}
874

  
875
	public TileServer getTileServer() {
876
		if(tileServer == null) {
877
			DefaultRasterStore store = new DefaultRasterStore();
878
			store.setProvider(this);
879
			tileServer = new FileTileServer(store);
880
		}
881
		return tileServer;
882
	}
883

  
884
    public void addFile(File file) throws InvalidSourceException {
885
        ProviderServices provServ = RasterLocator.getManager().getProviderServices();
886
        DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
887

  
888
        setFirstProviderToNotTiled();
889

  
890
        List<RasterDataParameters> storeParametersList = provServ.createParametersList(file);
891

  
892
        for (int j = 0; j < storeParametersList.size(); j++) {
893
            RasterProvider newFileProv;
894
            try {
895
                newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j));
896
                if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) {
897
                    getParameters().addProvider(newFileProv);
898
                }
899
            } catch (InitializeException e) {
900
                throw new InvalidSourceException("", e);
901
            } catch (ProviderNotRegisteredException e) {
902
                throw new InvalidSourceException("", e);
903
            }
904
        }
905
    }
906

  
907
}
0 908

  
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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 java.util.Objects;
31
import org.apache.commons.lang3.StringUtils;
32
import org.gvsig.fmap.dal.DataServerExplorerParameters;
33
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
34
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorerParameters;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.dynobject.DelegatedDynObject;
37
import org.gvsig.tools.dynobject.DynClass;
38
import org.gvsig.tools.dynobject.DynObjectManager;
39

  
40
/**
41
 * Parameters for the Multifile explorer provider
42
 * @author Nacho Brodin (nachobrodin@gmail.com)
43
 */
44
public class MultiFileServerExplorerParameters extends AbstractDataServerExplorerParameters implements DataServerExplorerParameters {
45
	public static final String     DYNCLASS_NAME       = "MultifileServerExplorerParameters";
46
	protected static DynClass      DYNCLASS            = null;
47
	private DelegatedDynObject     delegatedDynObject  = null;
48
	
49
	
50
	public MultiFileServerExplorerParameters() {
51
		super();
52
		initialize();
53
	}
54

  
55
	protected void initialize() {
56
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
57
				.getDynObjectManager().createDynObject(
58
						DYNCLASS);
59
	}
60
	
61
	public static void registerDynClass() {
62
		DynObjectManager dynman = ToolsLocator.getDynObjectManager();
63
		DynClass dynClass;
64
		
65
		if(dynman == null)
66
			return;
67
		
68
		if (DYNCLASS == null) {
69
			dynClass = dynman.add(DYNCLASS_NAME);
70

  
71
			DYNCLASS = dynClass;
72
		}
73

  
74
	}
75
	
76
	protected DelegatedDynObject getDelegatedDynObject() {
77
		return delegatedDynObject;
78
	}
79

  
80
	public String getDataStoreName() {
81
		return MultiFileProvider.NAME;
82
	}
83
	
84
	public String getDescription() {
85
		return MultiFileProvider.DESCRIPTION;
86
	}
87
	
88
	public String getExplorerName() {
89
		return MultiFileProvider.NAME;
90
	}
91
        
92
}
0 93

  
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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.net.URI;
31
import java.util.List;
32

  
33
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
34
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
35
import org.gvsig.fmap.dal.spi.DataStoreProvider;
36
import org.gvsig.raster.impl.provider.RasterProvider;
37

  
38
/**
39
 * Parameters for the Multifile provider
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
public interface MultiFileDataParameters extends RasterDataParameters {
43
	public static final String            FIELD_PROVIDERS           = "Providers";
44

  
45
	/**
46
	 * Removes all providers
47
	 */
48
	public void removeAllProviders();
49

  
50
	/**
51
	 * Returns true if this multifile has providers loaded
52
	 * @return boolean
53
	 */
54
	public boolean hasProviders();
55

  
56
	/**
57
	 * Removes a provider from the list
58
	 * @param uri
59
	 */
60
	public void removeProvider(URI uri);
61

  
62
	/**
63
	 * Adds a provider to the list if the this is not tiled
64
	 * @param provider
65
	 * @param prov
66
	 */
67
	public void addProviderNotTiled(DataStoreProvider provider);
68

  
69
	/**
70
	 * Set the selected provider in the first position
71
	 * @param provider
72
	 */
73
	public void setFirstProvider(DataStoreProvider provider);
74

  
75
	/**
76
	 * Adds a provider to the list
77
	 * @param provider
78
	 * @param prov
79
	 */
80
	public void addProvider(DataStoreProvider provider);
81

  
82
	/**
83
	 * Adds a provider to the list from a RasterDataStore
84
	 * @param rasterDataStore
85
	 */
86
	public void addProvider(RasterDataStore rasterDataStore);
87

  
88
	/**
89
	 * Gets the list of providers
90
	 * @return the list of providers
91
	 */
92
	public List<RasterProvider> getProviders();
93
}
0 94

  
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.241/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
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff