Revision 33953

View differences:

tags/v2_0_0_Build_2020/libraries/libFMap_dalRaster/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/maven-v4_0_0.xsd">
6

  
7
	<modelVersion>4.0.0</modelVersion>
8
	<groupId>org.gvsig</groupId>
9
	<artifactId>org.gvsig.fmap.dal.store.raster</artifactId>
10
	<packaging>jar</packaging>
11
	<version>2.0-SNAPSHOT</version>
12
	<name>libFMap_dalRaster</name>
13
	<url>http://gvsig.org</url>
14
	<parent>
15
		<groupId>org.gvsig</groupId>
16
		<artifactId>gvsig-base-library-pom</artifactId>
17
		<version>2.0-SNAPSHOT</version>
18
	</parent>	
19
	<distributionManagement>
20
		<site>
21
			<id>gvsig-repository</id>
22
			<url>${site-repository}/</url>
23
		</site>
24
	</distributionManagement>
25

  
26
	<dependencies>
27
		<dependency>
28
			<groupId>org.gvsig</groupId>
29
			<artifactId>org.gvsig.tools.lib</artifactId>
30
		</dependency>
31
		<dependency>
32
			<groupId>org.gvsig</groupId>
33
			<artifactId>org.gvsig.fmap.dal</artifactId>
34
			<version>2.0-SNAPSHOT</version>
35
		</dependency>
36
		<dependency>
37
			<groupId>org.gvsig</groupId>
38
			<artifactId>org.gvsig.fmap.dal</artifactId>
39
			<version>2.0-SNAPSHOT</version>
40
			<classifier>spi</classifier>
41
		</dependency>
42
		<dependency>
43
			<groupId>org.gvsig</groupId>
44
			<artifactId>org.gvsig.fmap.dal.file</artifactId>
45
			<version>2.0-SNAPSHOT</version>
46
		</dependency>
47
		<dependency>
48
			<groupId>org.gvsig</groupId>
49
			<artifactId>org.gvsig.raster</artifactId>
50
			<version>2.0-SNAPSHOT</version>
51
		</dependency>
52
	</dependencies>
53
	<properties>
54
		<build-dir>${basedir}/../build</build-dir>
55
	</properties>
56
	<build>
57
		<sourceDirectory>src</sourceDirectory>
58
		<testSourceDirectory>src-test</testSourceDirectory>
59
		<resources>
60
			<resource>
61
				<directory>src</directory>
62
				<includes>
63
					<include>**/*.gif</include>
64
					<include>**/*.png</include>
65
					<include>**/*.PNG</include>
66
					<include> **/*.bmp</include>
67
					<include> **/*.jpg</include>
68
					<include> **/*.jpeg</include>
69
				</includes>
70
			</resource>
71
			<resource>
72
				<directory>resources</directory>
73
			</resource>
74
		</resources>
75
	</build>
76
</project>
tags/v2_0_0_Build_2020/libraries/libFMap_dalRaster/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.raster.RasterStoreLibrary
tags/v2_0_0_Build_2020/libraries/libFMap_dalRaster/src/org/gvsig/fmap/dal/store/raster/RasterFilesystemServerProvider.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.fmap.dal.store.raster;
29

  
30
import java.io.File;
31
import java.io.FileInputStream;
32

  
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.DataManager;
35
import org.gvsig.fmap.dal.DataStoreParameters;
36
import org.gvsig.fmap.dal.NewDataStoreParameters;
37
import org.gvsig.fmap.dal.exception.CreateException;
38
import org.gvsig.fmap.dal.exception.DataException;
39
import org.gvsig.fmap.dal.exception.RemoveException;
40
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
41
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider;
42
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
43
import org.gvsig.raster.dataset.RasterDataset;
44

  
45
public class RasterFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider 
46
	implements FilesystemServerExplorerProvider {
47

  
48
	public boolean canCreate() {
49
		return false;
50
	}
51

  
52
	public boolean canCreate(NewDataStoreParameters parameters) {
53
		return false;
54
	}
55

  
56
	public void create(NewDataStoreParameters parameters, boolean overwrite)
57
			throws CreateException {
58
		throw new UnsupportedOperationException();
59
	}
60

  
61
	public NewDataStoreParameters getCreateParameters() throws DataException {
62
		return null;
63
	}
64

  
65
	public void initialize(
66
			FilesystemServerExplorerProviderServices serverExplorer) {
67
		// TODO Auto-generated method stub
68

  
69
	}
70

  
71
	public void remove(DataStoreParameters parameters) throws RemoveException {
72
		// FIXME
73
		throw new UnsupportedOperationException();
74

  
75
	}
76

  
77
	protected FilesystemServerExplorerProviderServices serverExplorer;
78

  
79
	public String getDataStoreProviderName() {
80
		return RasterStoreProvider.NAME;
81
	}
82

  
83
	public boolean accept(File pathname) {
84

  
85

  
86
		if (pathname.getParentFile().getName().equals("cellhd")) {
87
			if (pathname.getName().endsWith(".rmf")
88
					|| pathname.getName().endsWith(".rmf~")) {
89
				return false;
90
			}
91
			return true;
92
		}
93

  
94
		// Comprobamos que no sea un rmf propio, osea, que contenga xml
95
		if (pathname.getName().toLowerCase().endsWith(".rmf")) {
96
			FileInputStream reader = null;
97
			try {
98
				reader = new FileInputStream(pathname);
99
				String xml = "";
100
				for (int i = 0; i < 6; i++) {
101
					xml += (char) reader.read();
102
				}
103
				if (xml.equals("<?xml ")) {
104
					return false;
105
				}
106
			} catch (Exception e) {
107
			} finally {
108
				try {
109
					reader.close();
110
				} catch (Exception e) {
111
				}
112
			}
113
		}
114
		return RasterDataset.fileIsSupported(pathname.getName());
115

  
116
	}
117

  
118
	public String getDescription() {
119
		return RasterStoreProvider.DESCRIPTION;
120
	}
121

  
122
	public DataStoreParameters getParameters(File file) throws DataException {
123
		DataManager manager = DALLocator.getDataManager();
124
		RasterStoreParameters params = (RasterStoreParameters) manager
125
				.createStoreParameters(this.getDataStoreProviderName());
126
		params.setFile(file);
127
		return params;
128
	}
129

  
130
}
0 131

  
tags/v2_0_0_Build_2020/libraries/libFMap_dalRaster/src/org/gvsig/fmap/dal/store/raster/RasterStoreProvider.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.fmap.dal.store.raster;
29

  
30
import java.util.Iterator;
31

  
32
import org.gvsig.fmap.dal.DALLocator;
33
import org.gvsig.fmap.dal.DataManager;
34
import org.gvsig.fmap.dal.DataServerExplorer;
35
import org.gvsig.fmap.dal.DataStore;
36
import org.gvsig.fmap.dal.exception.CloseException;
37
import org.gvsig.fmap.dal.exception.DataException;
38
import org.gvsig.fmap.dal.exception.OpenException;
39
import org.gvsig.fmap.dal.exception.ReadException;
40
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
41
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider;
42
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices;
43
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
44
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
45
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
46
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
47
import org.gvsig.metadata.MetadataLocator;
48
import org.gvsig.metadata.MetadataManager;
49
import org.gvsig.metadata.exceptions.MetadataException;
50
import org.gvsig.tools.ToolsLocator;
51
import org.gvsig.tools.dynobject.DynStruct;
52

  
53
public class RasterStoreProvider extends AbstractCoverageStoreProvider {
54
	public static String NAME = "RasterStore";
55
	public static String DESCRIPTION = "Raster file";
56

  
57
	private static final String METADATA_DEFINITION_NAME = "RasterStore";
58
	
59
	public RasterStoreProvider(RasterStoreParameters params,
60
			DataStoreProviderServices storeServices) {
61
		super(params, storeServices, ToolsLocator.getDynObjectManager()
62
				.createDynObject(
63
						MetadataLocator.getMetadataManager().getDefinition(
64
								METADATA_DEFINITION_NAME)));
65
		init(params);
66
	}
67

  
68
	public ResourceProvider getResource() {
69
		// TODO Create Raster resource
70
		return null;
71
	}
72

  
73
	private void init(RasterStoreParameters params) {
74
		this.getStoreServices().setDynValue("CRS",
75
				params.getSRS());			
76
		this.getStoreServices().setDynValue("Envelope", null);
77
	}
78

  
79
	protected static void registerMetadataDefinition() throws MetadataException {
80
		MetadataManager manager = MetadataLocator.getMetadataManager();
81
		if( manager.getDefinition(METADATA_DEFINITION_NAME)==null  ) {
82
			DynStruct defnition = manager.addDefinition(
83
					METADATA_DEFINITION_NAME,
84
					METADATA_DEFINITION_NAME 
85
			);
86
			defnition.extend(
87
					MetadataManager.METADATA_NAMESPACE, 
88
					DataStore.METADATA_DEFINITION_NAME
89
			);
90
		}
91
	}
92

  
93

  
94
	public void close() throws CloseException {
95
		// TODO Auto-generated method stub
96

  
97
	}
98

  
99
	public Iterator getChilds() {
100
		// TODO Auto-generated method stub
101
		return null;
102
	}
103

  
104
	public DataServerExplorer getExplorer() throws ReadException,
105
			ValidateDataParametersException {
106
		DataManager manager = DALLocator.getDataManager();
107
		FilesystemServerExplorerParameters params;
108
		try {
109
			params = (FilesystemServerExplorerParameters) manager
110
					.createServerExplorerParameters(FilesystemServerExplorer.NAME);
111
			params.setRoot(this.getRasterParameters().getFile().getParent());
112
			return manager.createServerExplorer(params);
113
		} catch (DataException e) {
114
			throw new ReadException(this.getProviderName(), e);
115
		}
116
	}
117

  
118
	public RasterStoreParameters getRasterParameters() {
119
		return (RasterStoreParameters)getDataStoreParameters();
120
	}
121

  
122

  
123

  
124
	public void open() throws OpenException {
125
		// TODO Auto-generated method stub
126

  
127
	}
128

  
129
	public void refresh() throws OpenException {
130
		// TODO Auto-generated method stub
131

  
132
	}
133

  
134
	public CoverageStoreProviderServices getStoreServices() {
135
		return this.store;
136
	}
137

  
138
	public String getProviderName() {
139
		return NAME;
140
	}
141

  
142
	public Object getSourceId() {
143
		return this.getRasterParameters().getFile();
144
	}
145

  
146
	public String getName() {
147
		String name = this.getRasterParameters().getFile().getName();
148
		int n = name.lastIndexOf(".");
149
		if( n<1 ) {
150
			return name;
151
		}
152
		return name.substring(0, n);
153
	}
154
	
155
	public String getFullName() {
156
		return this.getRasterParameters().getFile().getAbsolutePath();
157
	}
158
	
159

  
160
}
0 161

  
tags/v2_0_0_Build_2020/libraries/libFMap_dalRaster/src/org/gvsig/fmap/dal/store/raster/RasterStoreParameters.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.fmap.dal.store.raster;
29

  
30
import java.io.File;
31

  
32
import org.cresques.cts.IProjection;
33
import org.gvsig.fmap.crs.CRSFactory;
34
import org.gvsig.fmap.dal.DataStoreParameters;
35
import org.gvsig.fmap.dal.DataTypes;
36
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
37
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.dynobject.DelegatedDynObject;
40
import org.gvsig.tools.dynobject.DynClass;
41
import org.gvsig.tools.dynobject.DynField;
42
import org.gvsig.tools.dynobject.DynObjectManager;
43

  
44
public class RasterStoreParameters extends AbstractDataParameters implements
45
		DataStoreParameters, FilesystemStoreParameters {
46

  
47
    public static final String DYNCLASS_NAME = "RasterStoreParameters";
48

  
49
	protected static final String FIELD_FILENAME = "filename";
50
	private static final String FIELD_SRS = "srs";
51

  
52
	protected static DynClass DYNCLASS = null;
53

  
54
	private DelegatedDynObject delegatedDynObject;
55

  
56
	protected static void registerDynClass() {
57
		DynObjectManager dynman = ToolsLocator.getDynObjectManager();
58
		DynClass dynClass;
59
		DynField field;
60
		if (DYNCLASS == null) {
61
			dynClass = dynman.add(DYNCLASS_NAME);
62

  
63
			field = dynClass.addDynField(FIELD_FILENAME);
64
			field.setTheTypeOfAvailableValues(DynField.ANY);
65
			field.setDescription("File name");
66
			field.setType(DataTypes.STRING);
67
			field.setMandatory(true);
68

  
69

  
70
			field = dynClass.addDynField(FIELD_SRS);
71
			field.setTheTypeOfAvailableValues(DynField.ANY);
72
			field.setDescription("SRS");
73
			field.setType(DataTypes.CRS);
74
			field.setMandatory(true);
75

  
76
			DYNCLASS = dynClass;
77
		}
78

  
79
	}
80

  
81
	public RasterStoreParameters() {
82
		super();
83
		initialize();
84
	}
85

  
86
	protected void initialize() {
87
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
88
				.getDynObjectManager().createDynObject(
89
						DYNCLASS);
90
	}
91

  
92
	protected DelegatedDynObject getDelegatedDynObject() {
93
		return delegatedDynObject;
94
	}
95

  
96
	public String getDataStoreName() {
97
		return RasterStoreProvider.NAME;
98
	}
99

  
100
	public boolean isValid() {
101
		return (this.getFileName() != null);
102
	}
103

  
104

  
105
	public String getFileName() {
106
		return (String) this.getDynValue(FIELD_FILENAME);
107
	}
108

  
109
	public File getFile() {
110
		return new File((String) this.getDynValue(FIELD_FILENAME));
111
	}
112

  
113
	public void setFile(File aFile) {
114
		this.setDynValue(FIELD_FILENAME, aFile.getPath());
115
	}
116

  
117
	public void setFileName(String aFileName) {
118
		this.setDynValue(FIELD_FILENAME, aFileName);
119
	}
120

  
121
	public String getDescription() {
122
		return RasterStoreProvider.DESCRIPTION;
123
	}
124

  
125
	public String getSRSID() {
126
		IProjection srs = (IProjection) getDynValue(FIELD_SRS);
127
		if (srs == null) {
128
			return null;
129
		}
130
		return srs.getAbrev();
131
	}
132

  
133
	public void setSRSID(String srsid) {
134
		if (srsid == null) {
135
			setDynValue(FIELD_SRS, null);
136
		} else {
137
			setDynValue(FIELD_SRS, CRSFactory.getCRS(srsid));
138
		}
139
	}
140

  
141
	public void setSRS(IProjection srs) {
142
		setDynValue(FIELD_SRS, srs);
143
	}
144

  
145
	public IProjection getSRS() {
146
		if (this.getSRSID() == null) {
147
			return null;
148
		}
149
		return (IProjection) getDynValue(FIELD_SRS);
150
	}
151

  
152
}
0 153

  
tags/v2_0_0_Build_2020/libraries/libFMap_dalRaster/src/org/gvsig/fmap/dal/store/raster/RasterStoreLibrary.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.fmap.dal.store.raster;
29

  
30
import java.util.ArrayList;
31
import java.util.List;
32

  
33
import org.gvsig.fmap.dal.DALFileLibrary;
34
import org.gvsig.fmap.dal.DALFileLocator;
35
import org.gvsig.fmap.dal.DALLibrary;
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.raster.DefaultCoverageStoreFactory;
38
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
39
import org.gvsig.metadata.exceptions.MetadataException;
40
import org.gvsig.raster.RasterLibrary;
41
import org.gvsig.tools.library.AbstractLibrary;
42
import org.gvsig.tools.library.Library;
43
import org.gvsig.tools.library.LibraryException;
44

  
45
public class RasterStoreLibrary extends AbstractLibrary {
46

  
47
	public RasterStoreLibrary() {
48
		super(RasterStoreLibrary.class,Library.TYPE.IMPL);
49
		require(DALLibrary.class);
50
		require(DALFileLibrary.class);
51
		require(RasterLibrary.class);
52
	}
53
	
54
	@Override
55
	protected void doInitialize() throws LibraryException {
56
	}
57

  
58
	@Override
59
	protected void doPostInitialize() throws LibraryException {
60
		List<Throwable> exs = new ArrayList<Throwable>();
61
		
62
		RasterStoreParameters.registerDynClass();
63
		
64
		try {
65
			RasterStoreProvider.registerMetadataDefinition();
66
		} catch (MetadataException e) {
67
			exs.add(e);
68
		}
69

  
70
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
71
				.getDataManager();
72

  
73
		if (!dataman.getStoreProviders().contains(RasterStoreProvider.NAME)) {
74
			dataman.registerStoreProvider(RasterStoreProvider.NAME,
75
					RasterStoreProvider.class, RasterStoreParameters.class);
76
		}
77

  
78
		DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
79
				RasterStoreProvider.NAME, RasterStoreProvider.DESCRIPTION,
80
				RasterFilesystemServerProvider.class);
81

  
82
		((DataManagerProviderServices)DALLocator.getDataManager()).registerStoreFactory(RasterStoreProvider.NAME, DefaultCoverageStoreFactory.class);
83

  
84
		if (exs.size() > 0) {
85
			throw new LibraryException(this.getClass(), exs);
86
		}
87
	}
88
}
0 89

  

Also available in: Unified diff