root / tags / v2_0_0_Build_2020 / libraries / libFMap_dalRaster / src / org / gvsig / fmap / dal / store / raster / RasterStoreProvider.java @ 33900
History | View | Annotate | Download (4.78 KB)
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 |
} |