Revision 3099

View differences:

org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/DefaultWCSIOLibrary.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.wcs.io;
23

  
24
import org.gvsig.i18n.Messages;
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
/**
28
 *
29
 * @author Nacho Brodin (nachobrodin@gmail.com)
30
 */
31
public class DefaultWCSIOLibrary extends AbstractLibrary {	
32

  
33
	public DefaultWCSIOLibrary() {
34
		/*super(DefaultWCSIOLibrary.class,Library.TYPE.IMPL);
35
		require(ToolsLibrary.class);
36
		require(DALLibrary.class);
37
		require(DALFileLibrary.class);*/
38
	}
39
	
40
	@Override
41
	protected void doInitialize() throws LibraryException {
42
		//RasterLibrary.wakeUp();
43
		WCSDataParametersImpl.registerDynClass();
44
		
45
		Messages.addResourceFamily("org.gvsig.raster.wcs.io.i18n.text",
46
				DefaultWCSIOLibrary.class.getClassLoader(),
47
				DefaultWCSIOLibrary.class.getClass().getName()); 
48
	}
49

  
50
	@Override
51
	protected void doPostInitialize() throws LibraryException {
52
		WCSServerExplorerParameters.registerDynClass();
53
		WCSDataParametersImpl.registerDynClass();
54
		WCSProvider.register();
55
	}
56
}
0 57

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/downloader/TileDownloaderForWCS.java
1
package org.gvsig.raster.wcs.io.downloader;
2

  
3
import java.awt.geom.Rectangle2D;
4

  
5
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
6
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
7
import org.gvsig.raster.cache.tile.Tile;
8
import org.gvsig.raster.cache.tile.exception.TileGettingException;
9
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader;
10
import org.gvsig.raster.wcs.io.WCSConnector;
11
import org.gvsig.raster.wcs.io.WCSDataParametersImpl;
12
import org.gvsig.remoteclient.wcs.WCSStatus;
13

  
14
/** 
15
 * Tile getter 
16
 * @author Nacho Brodin (nachobrodin@gmail.com)
17
 */
18
public class TileDownloaderForWCS extends BaseTileDownloader {
19
	private WCSConnector             connector  = null;
20
	
21
	public TileDownloaderForWCS(RasterDataStore store, 
22
			int tilePxWidth,
23
			int tilePxHeight,
24
			WCSConnector connector) {
25
		super(store, tilePxWidth, tilePxHeight);
26
		this.connector = connector;
27
	}
28
	
29
	public synchronized Tile downloadTile(Tile tile) throws TileGettingException {
30
		try {
31
			Rectangle2D r = new Rectangle2D.Double(tile.getExtent().getMinX(), 
32
					tile.getExtent().getMinY() - tile.getExtent().getHeight(), 
33
					tile.getExtent().getWidth(), 
34
					tile.getExtent().getHeight());
35
			WCSDataParametersImpl p = (WCSDataParametersImpl)store.getParameters();
36
			WCSStatus wcsStatus = new WCSStatus();
37
			wcsStatus.setCoveraName(p.getCoverageName());
38
			wcsStatus.setSrs((String)p.getSRSCode());
39
			wcsStatus.setFormat((String)p.getFormat());
40
			wcsStatus.setDepth(p.getDepth());
41
			wcsStatus.setOnlineResource(p.getOnlineResource() != null ? (String) p.getOnlineResource().get("GetCoverage") : null);
42
			wcsStatus.setExtent(r);
43
			wcsStatus.setHeight(tile.getHeightPx());
44
			wcsStatus.setWidth(tile.getWidthPx());
45
			
46
			connector.getCoverageURL(wcsStatus, tile.getCancelled(), tile.getFile());
47
			//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para
48
			//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros
49
			//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf");
50
			//if(rmf.exists())
51
				//rmf.delete();
52
		} catch (RemoteServiceException e) {
53
			throw new TileGettingException(e);
54
		}
55
		readTileFromDisk(tile);
56
		return tile;
57
	}
58
	
59
}
0 60

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/downloader/WCSTileServer.java
1
package org.gvsig.raster.wcs.io.downloader;
2

  
3
import org.cresques.cts.IProjection;
4
import org.gvsig.fmap.dal.coverage.RasterLibrary;
5
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
6
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
7
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
8
import org.gvsig.raster.cache.tile.TileCacheLibrary;
9
import org.gvsig.raster.cache.tile.TileCacheLocator;
10
import org.gvsig.raster.cache.tile.TileCacheManager;
11
import org.gvsig.raster.cache.tile.provider.CacheStruct;
12
import org.gvsig.raster.cache.tile.provider.Downloader;
13
import org.gvsig.raster.cache.tile.provider.TileServer;
14
import org.gvsig.raster.impl.provider.RasterProvider;
15
import org.gvsig.raster.wcs.io.WCSProvider;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

  
19
/** 
20
* Data server for the tile cache in a WMSProvider 
21
* @author Nacho Brodin (nachobrodin@gmail.com)
22
*/
23
public class WCSTileServer implements TileServer {
24
	private static Logger              logger               = LoggerFactory.getLogger(WCSTileServer.class);
25
	private CacheStruct                struct               = null;
26
	private Downloader                 downloader           = null;
27
	private RasterDataStore            store                = null;
28
	private String                     suffix               = ".tif";
29
	
30
	public WCSTileServer(RasterDataStore store) {
31
		this.store = store;
32
		this.suffix = ((RasterProvider)store.getProvider()).getFileSuffix();
33
	}
34
	
35
	public Downloader getDownloader() {
36
		if(downloader == null ||
37
		   ((TileDownloaderForWCS)downloader).getTileSize()[0] != TileCacheLibrary.ALTERNATIVE_TILESIZE ||
38
		   ((TileDownloaderForWCS)downloader).getTileSize()[1] != TileCacheLibrary.ALTERNATIVE_TILESIZE) {
39
							
40
			try {
41
				downloader = new TileDownloaderForWCS(
42
						store, 
43
						TileCacheLibrary.ALTERNATIVE_TILESIZE, 
44
						TileCacheLibrary.ALTERNATIVE_TILESIZE, 
45
						((WCSProvider)store.getProvider()).getConnector());
46
			} catch (RemoteServiceException e) {
47
				return null;
48
			}
49
		}
50
		return downloader;
51
	}
52

  
53
	public CacheStruct getStruct() {
54
		if(struct == null) {
55
			TileCacheManager  manager = TileCacheLocator.getManager();
56
			
57
			int coordinates = CacheStruct.FLAT;
58
			if(store.getProjection() != null)
59
				coordinates = (store.getProjection() != null && store.getProjection().isProjected()) ? CacheStruct.FLAT : CacheStruct.GEOGRAFIC;
60
			else {
61
				Extent e = store.getExtent();
62
				if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 && 
63
					e.getULY() >= -90 && e.getULY() <= 90 && e.getLRY() >= -90 && e.getLRY() <= 90) {
64
					coordinates = CacheStruct.GEOGRAFIC;
65
				}
66
			}
67
			
68
			String epsg = null;
69
			IProjection proj = store.getProjection();
70
			if(proj != null)
71
				epsg = proj.getAbrev();
72
			
73
			struct = manager.createCacheStructure(coordinates, 
74
					TileCacheLibrary.DEFAULT_LEVELS, 
75
					store.getExtent().toRectangle2D(), 
76
					store.getCellSize(), 
77
					TileCacheLibrary.ALTERNATIVE_TILESIZE, 
78
					TileCacheLibrary.ALTERNATIVE_TILESIZE,
79
					((WCSProvider)store.getProvider()).getURIOfFirstProvider(),
80
					((WCSProvider)store.getProvider()).getParameters().getCoverageName(),
81
					TileCacheLibrary.DEFAULT_STRUCTURE,
82
					RasterLibrary.pathTileCache,
83
					getFileSuffix(),
84
					epsg,
85
					0);
86
		}
87
		return struct;
88
	}
89
	
90
	public void setStruct(CacheStruct struct) {
91
		if(struct != null) {
92
			this.struct = struct;
93
			if(struct.getTileSizeByLevel(0) != null) {
94
				try {
95
					downloader = new TileDownloaderForWCS(store, 
96
							struct.getTileSizeByLevel(0)[0], 
97
							struct.getTileSizeByLevel(0)[1],
98
							((WCSProvider)store.getProvider()).getConnector());
99
				} catch (RemoteServiceException ex) {
100
					logger.error("Constructing TileDownloaderForWCS: " + ex.getMessage());
101
				}
102
			}
103
		}
104
	}
105
	
106
	public String getFileSuffix() {
107
		return suffix;
108
	}
109
	
110
	public void setFileSuffix(String extension) {
111
		this.suffix = extension;
112
	}
113
}
0 114

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.raster.wcs.io package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>WCS provider</p>
11

  
12
</body>
13
</html>
0 14

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSLayerNode.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.wcs.io;
23

  
24
import java.awt.geom.Point2D;
25
import java.awt.geom.Rectangle2D;
26
import java.util.ArrayList;
27
import java.util.Hashtable;
28

  
29
/**
30
 * Class defining the node of the layer tree of a common WCS service.
31
 * @author jaume
32
 */
33
@SuppressWarnings("unchecked")
34
public class WCSLayerNode {
35
	private String       name                  = null;
36
	private ArrayList    srs                   = null;
37
	private String       title                 = null;
38
	private String       nativeSRS             = null;
39
	private ArrayList    formats               = null;
40
	private Point2D      maxRes                = null;
41
	private int          width                 = 0;
42
	private int          height                = 0;
43
	private ArrayList    timePositions         = null;
44
	private String       description           = null;
45
	private ArrayList    interpolationMethods  = null;
46
	private ArrayList    pList                 = null;
47
	private Hashtable    extents               = null;
48
	private String       latLonBox             = null;
49
	private String       lAbstract             = null;
50
	private ArrayList    children              = new ArrayList();
51
	private boolean      transparency;
52

  
53
	public void setName(String name) {
54
		this.name = name;
55
	}
56

  
57
	public void addAllSrs(ArrayList srs) {
58
		if (this.srs == null)
59
			this.srs = new ArrayList();
60
		this.srs.addAll(srs);
61
	}
62

  
63
	public void setTitle(String title) {
64
		this.title = title;
65
	}
66

  
67
	public void setNativeSRS(String nativeSRS) {
68
		this.nativeSRS = nativeSRS;
69
	}
70

  
71
	public String getName() {
72
		return name;
73
	}
74

  
75
	public void setFormats(ArrayList formats) {
76
		this.formats = formats;
77
	}
78

  
79
	public ArrayList getFormats() {
80
		return formats;
81
	}
82

  
83
	public ArrayList getSRSs() {
84
		if (!srs.contains(nativeSRS)) {
85
			ArrayList l = new ArrayList(srs);
86
			l.add(nativeSRS);
87
			return l;
88
		}
89
		return srs;
90
	}
91

  
92
	public String getTitle() {
93
		return title;
94
	}
95

  
96
	public Rectangle2D getExtent(String srs) {
97
		if ( extents != null ) {
98
			return (Rectangle2D) extents.get(srs);
99
		}
100
		return null;
101
	}
102
	
103
	public void addExtent(String srs, Rectangle2D extent) {
104
		if ( extents == null ) extents = new Hashtable();
105
		extents.put(srs, extent);
106
	}
107

  
108
	public Point2D getMaxRes() {
109
		return maxRes;
110
	}
111
	
112

  
113
	public void setMaxRes(Point2D maxRes) {
114
		this.maxRes = maxRes;
115
	}
116
	
117
	public String toString(){
118
    	String str;
119
    	if (getName()==null)
120
    		str = getTitle();
121
    	else
122
    		str = "["+getName()+"] "+getTitle();
123
        return str;
124
    }
125

  
126
	public void setTimePositions(ArrayList timePositions) {
127
		this.timePositions = timePositions;
128
	}
129
    
130
	public ArrayList getTimePositions() {
131
		return this.timePositions;
132
	}
133

  
134
	public String getDescription() {
135
		return this.description;
136
	}
137
	
138
	public void setDescription(String descr) {
139
		this.description = descr;
140
	}
141

  
142
	public String getLonLatEnvelope() {
143
		return "yet unimplemented";
144
	}
145

  
146
	public void setInterpolationMethods(ArrayList interpolationMethods) {
147
		this.interpolationMethods = interpolationMethods;
148
	}
149
	
150
	public ArrayList getInterpolationMethods() {
151
		return interpolationMethods;
152
	}
153

  
154
	public ArrayList getParameterList() {
155
		return pList;
156
	}
157
	
158
	public void addParameter(FMapWCSParameter p) {
159
		if (pList == null) pList = new ArrayList();
160
		pList.add(p);
161
	}
162
	
163
	/**
164
     * Gets the layer abstract.
165
     * @return Returns the abstract.
166
     */
167
    public String getAbstract() {
168
        return lAbstract;
169
    }
170

  
171
    /**
172
     * Sets the layer abstract.
173
     * @param abstract The abstract to set.
174
     */
175
    public void setAbstract(String _abstract) {
176
        lAbstract = _abstract;
177
    }
178
    
179
    public void setLatLonBox(String _latLonBox) {
180
        latLonBox = _latLonBox;
181
    }
182

  
183
    public String getLatLonBox() {
184
        return latLonBox;
185
    }
186
    
187
    /**
188
     * Gets the list of sons of this layer.
189
     */
190
    public ArrayList getChildren() {
191
        return children;
192
    }
193
    
194
    /**
195
     * Sets the list of sons of this layer.
196
     * @param children
197
     */
198
    public void setChildren(ArrayList children) {
199
        this.children = children;
200
    }
201
    
202
    /**
203
     * @return Returns the transparency.
204
     */
205
    public boolean isTransparent() {
206
        return transparency;
207
    }
208

  
209
    /**
210
     * @param transparency The transparency to set.
211
     */
212
    public void setTransparency(boolean transparency) {
213
        this.transparency = transparency;
214
    }
215

  
216
	public int getWidth() {
217
		return width;
218
	}
219

  
220
	public void setWidth(int width) {
221
		this.width = width;
222
	}
223

  
224
	public int getHeight() {
225
		return height;
226
	}
227

  
228
	public void setHeight(int height) {
229
		this.height = height;
230
	}
231

  
232
}
0 233

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/FMapWCSParameter.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.wcs.io;
23

  
24
import java.util.ArrayList;
25

  
26
/**
27
 * Class abstracting WCS's axis descriptions into FMap
28
 * @author jaume dominguez faus - jaume.dominguez@iver.es
29
 * @TODO add interval parameters support
30
 */
31
@SuppressWarnings("unchecked")
32
public class FMapWCSParameter {
33
	public static final int VALUE_LIST = 0;
34
	public static final int INTERVAL = 1;
35
	private String name;
36
	private int type;
37
	private ArrayList valueList;
38
	private String label;
39

  
40
	public void setName(String name) {
41
		this.name = name;
42
	}
43

  
44
	public void setType(int type) {
45
		this.type = type;
46
	}
47

  
48
	public int getType() {
49
		return type;
50
	}
51

  
52
	public void setValueList(ArrayList singleValues) {
53
		this.valueList = singleValues;
54
	}
55

  
56
	public void setLabel(String label) {
57
		this.label = label;
58
	}
59

  
60
	public String toString() {
61
		return (label!=null) ? label : name;
62
	}
63

  
64
	public ArrayList getValueList() {
65
		return valueList;
66
	}
67

  
68
	public String getName() {
69
		return name;
70
	}
71
}
0 72

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSServerExplorer.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.wcs.io;
29

  
30
import java.awt.geom.Point2D;
31
import java.io.IOException;
32
import java.io.InputStream;
33
import java.net.MalformedURLException;
34
import java.net.URL;
35
import java.net.URLConnection;
36
import java.util.Hashtable;
37
import java.util.List;
38

  
39
import org.gvsig.compat.net.ICancellable;
40
import org.gvsig.fmap.dal.DALLocator;
41
import org.gvsig.fmap.dal.DataManager;
42
import org.gvsig.fmap.dal.DataServerExplorerParameters;
43
import org.gvsig.fmap.dal.DataStoreParameters;
44
import org.gvsig.fmap.dal.NewDataStoreParameters;
45
import org.gvsig.fmap.dal.coverage.exception.ConnectException;
46
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
47
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer;
48
import org.gvsig.fmap.dal.exception.DataException;
49
import org.gvsig.fmap.dal.exception.InitializeException;
50
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
51
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
52
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
53
import org.gvsig.i18n.Messages;
54

  
55
/**
56
 * Explorer for a WCS server
57
 * @author Nacho Brodin (nachobrodin@gmail.com)
58
 */
59
public class WCSServerExplorer implements RasterDataServerExplorer, DataServerExplorerProvider {
60
	private WCSConnector                connector                = null;
61
	private WCSServerExplorerParameters parameters               = null;
62
	
63
	public WCSServerExplorer(
64
			WCSServerExplorerParameters parameters,
65
			DataServerExplorerProviderServices services)
66
			throws InitializeException {
67
		this.parameters = parameters;
68
	}
69
	
70
	/**
71
	 * Gets the provider's name
72
	 * @return
73
	 */
74
	public String getDataStoreProviderName() {
75
		return WCSProvider.NAME;
76
	}
77
	
78
	public String getDescription() {
79
		return WCSProvider.DESCRIPTION;
80
	}
81
	
82
	public boolean add(String provider, NewDataStoreParameters parameters,
83
			boolean overwrite) throws DataException {
84
		return false;
85
	}
86

  
87
	public boolean canAdd() {
88
		return false;
89
	}
90

  
91
	public boolean canAdd(String storeName) throws DataException {
92
		return false;
93
	}
94

  
95
	public NewDataStoreParameters getAddParameters(String storeName)
96
			throws DataException {
97
		return null;
98
	}
99

  
100
	public List getDataStoreProviderNames() {
101
		return null;
102
	}
103

  
104
	public DataServerExplorerParameters getParameters() {
105
		return parameters;
106
	}
107

  
108
	public List list() throws DataException {
109
		return null;
110
	}
111

  
112
	public List list(int mode) throws DataException {
113
		return null;
114
	}
115

  
116
	public void remove(DataStoreParameters parameters) throws DataException {
117
		
118
	}
119

  
120
	public void dispose() {
121
		
122
	}
123

  
124
	public String getProviderName() {
125
		return null;
126
	}
127
	
128
	/**
129
	 * Gets the online resources
130
	 * @return
131
	 */
132
	public Hashtable getOnlineResources() {
133
		/*if(connector != null) {
134
			return connector.getOnlineResources();
135
		}*/
136
		return null;
137
	}
138
	
139
	//**********************************************
140
	//Connector
141
	//**********************************************
142
	
143
	public DataStoreParameters getStoredParameters() {
144
		DataManager manager = DALLocator.getDataManager();
145
		WCSDataParametersImpl params = null;
146
		try {
147
			params = (WCSDataParametersImpl) manager.createStoreParameters(this.getDataStoreProviderName());
148

  
149
			/*if(WCSProvider.TILED) {
150
				TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
151
				tileParams.setDataParameters(params);
152
				return tileParams;
153
			} */
154
			
155
		} catch (InitializeException e) {
156
			e.printStackTrace();
157
		} catch (ProviderNotRegisteredException e) {
158
			e.printStackTrace();
159
		}
160
		params.setURI(parameters.getHost());
161
		return params;
162
	}
163

  
164
	/**
165
	 * Connects to the server and throws a getCapabilities. This loads 
166
	 * the basic information to make requests.
167
	 * @throws RemoteServiceException 
168
	 */
169
	public void connect(ICancellable cancellable) throws ConnectException {
170
		URL url = null;
171
		boolean override = false;
172
		
173
		try {
174
			url = new URL(parameters.getHost());
175
		} catch (Exception e) {
176
			throw new ConnectException(Messages.getText("malformed_url"), e);
177
		}
178
        try {
179
        	connector = WCSProvider.getConnectorFromURL(url);
180
        	if (!connector.connect(override, cancellable))
181
        		throw new ConnectException(Messages.getText("error_connecting"));
182
        } catch (IOException e) {
183
			throw new ConnectException(Messages.getText("error_connecting"), e);
184
		}
185
		
186
	}
187
	
188
	/**
189
	 * Checks if the network and host are reachable
190
	 * @param timeout for the host
191
	 * @return true if both are reachable and false if they are not
192
	 */
193
	public boolean isHostReachable(int timeout) {
194
		URL url = null;
195
		try {
196
			url = new URL(parameters.getHost());
197
			URLConnection con = url.openConnection();
198
			if(con == null)
199
				return false;
200
			con.connect();
201
			InputStream stream = con.getInputStream();
202
			if(stream == null)
203
				return false;
204
		} catch (MalformedURLException e) {
205
			return false;
206
		} catch (IOException e) {
207
			return false;
208
		}
209
		
210
		return true;
211
	}
212

  
213
	/**
214
	 * Checks if the network and host are reachable
215
	 * @return true if both are reachable and false if they are not
216
	 */
217
	public boolean isHostReachable() {
218
		int timeout = 10000;
219
		return isHostReachable(timeout);
220
	}
221

  
222
	/**
223
	 * Returns true if this provider is connected to the server
224
	 * @return
225
	 */
226
	public boolean isConnected() {
227
		if(connector != null)
228
			return true;
229
		return false;
230
	}
231

  
232
	/**
233
	 * Gets the description of this service
234
	 * @return
235
	 */
236
	public String getAbstract() {
237
		if(connector != null)
238
			return connector.getDescription();
239
		return null;
240
	}
241

  
242
	/**
243
	 * Gets the server title
244
	 * @return
245
	 */
246
	public String getServerType() {
247
		if (getVersion() == null) 
248
			return "WCS";
249
        return "WCS "+ getVersion();
250
	}
251

  
252
	/**
253
	 * Gets the protocol supported by the server
254
	 * @return
255
	 */
256
	public String getVersion() {
257
		if(connector != null) {
258
			return (connector.getVersion() == null) ? "" : connector.getVersion();
259
		}
260
		return null;
261
	}
262

  
263
	/**
264
	 * Gets the host URI
265
	 * @return
266
	 */
267
	public String getHost() {
268
		return parameters.getHost();
269
	}
270
	
271
	/**
272
	 * Gets the title
273
	 * @return
274
	 */
275
	public String getTitle() {
276
		return null;
277
	}
278

  
279
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
280
		return null;
281
	}
282

  
283
	public Point2D getMaxResolution(String layerName) {
284
		return connector.getMaxResolution(layerName);
285
	}
286

  
287
	/**
288
	 * Gets the coverage list
289
	 * @return
290
	 */
291
	public WCSLayerNode[] getCoverageList() {
292
		return connector.getLayerList();
293
	}
294
	
295
	/**
296
	 * Gets a layer searching by its name 
297
	 * @return
298
	 */
299
	public WCSLayerNode getCoverageByName(String name) {
300
		WCSLayerNode[] list = getCoverageList();
301
		for (int i = 0; i < list.length; i++) {
302
			if(list[i].getName().compareTo(name) == 0)
303
				return list[i];
304
		}
305
		return null;
306
	}
307
}
0 308

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSConnector.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.wcs.io;
23

  
24
import java.awt.geom.Point2D;
25
import java.awt.geom.Rectangle2D;
26
import java.io.BufferedOutputStream;
27
import java.io.DataInputStream;
28
import java.io.DataOutputStream;
29
import java.io.File;
30
import java.io.FileOutputStream;
31
import java.io.IOException;
32
import java.io.OutputStreamWriter;
33
import java.net.ConnectException;
34
import java.net.HttpURLConnection;
35
import java.net.URL;
36
import java.security.KeyManagementException;
37
import java.security.NoSuchAlgorithmException;
38
import java.util.ArrayList;
39
import java.util.Hashtable;
40
import java.util.Iterator;
41
import java.util.Set;
42
import java.util.prefs.Preferences;
43

  
44
import javax.net.ssl.HttpsURLConnection;
45
import javax.net.ssl.SSLContext;
46
import javax.net.ssl.TrustManager;
47
import javax.net.ssl.X509TrustManager;
48

  
49
import org.gvsig.compat.net.ICancellable;
50
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
51
import org.gvsig.remoteclient.exceptions.ServerErrorException;
52
import org.gvsig.remoteclient.exceptions.WCSException;
53
import org.gvsig.remoteclient.utils.BoundaryBox;
54
import org.gvsig.remoteclient.wcs.WCSClient;
55
import org.gvsig.remoteclient.wcs.WCSCoverage;
56
import org.gvsig.remoteclient.wcs.WCSStatus;
57
import org.gvsig.remoteclient.wcs.WCSCoverage.AxisDescription;
58
import org.gvsig.remoteclient.wcs.WCSCoverage.RectifiedGrid;
59

  
60
/**
61
 * Connector between a WCS data provider and a WCSClient. 
62
 *
63
 * @author Nacho Brodin (nachobrodin@gmail.com)
64
 */
65
public class WCSConnector  {
66
	private WCSClient                         client;
67
	private Hashtable<String, WCSLayerNode>   coverages;
68
    private WCSLayerNode[]                    layerList;
69
    
70
    public WCSConnector(URL url) throws ConnectException, IOException {
71
    	client = new WCSClient(url.toString());
72
    }
73

  
74
	/**
75
	 * Returns the string "WCSDriver", which is the driver's name.
76
	 * @return String
77
	 */
78
	public String getName() { 
79
		return "WCSDriver"; 
80
	}
81

  
82
	/**
83
	 * Sets the server that we want to connect to.
84
	 *
85
	 * @param host
86
	 * @throws IOException
87
	 */
88
	public void setHost(String host) throws IOException{
89
		client = new WCSClient(host);
90
	}
91

  
92

  
93
	/**
94
	 * Returns a human-readable string containing the server's name.
95
	 *
96
	 * @return String
97
	 */
98
	public String getLabel() {
99
		return client.getServiceTitle();
100
	}
101

  
102
	/**
103
	 * Returns a string containing the server's WCS version number.
104
	 *
105
	 * @return String
106
	 */
107
	public String getVersion(){
108
		return client.getVersion();
109
	}
110

  
111
	/**
112
	 * <p>
113
	 * Returns name and description of the server. It is supposed to be used
114
	 * as the source of the abstract field in your application's interface.
115
	 * </p>
116
	 * <p>
117
	 * Devuelve nombre y descripci?n (abstract) del servidor.
118
	 * </p>
119
	 * @return String
120
	 */
121
	public String getDescription(){
122
		return client.getDescription();
123
	}
124

  
125
	/**
126
	 * Returns the layer descriptor for a given coverage name.
127
	 * @param layerName
128
	 * @return WCSLayer
129
	 */
130
	public WCSLayerNode getLayer(String layerName) {
131
		getLayerList();
132
		return (WCSLayerNode) getCoverages().get(layerName);
133
	}
134
	
135
	private Hashtable<String, WCSLayerNode> getCoverages() {
136
		if(coverages == null || coverages.isEmpty()) {
137
			getLayerList();
138
		}
139
		return coverages;
140
	}
141

  
142
	/**
143
	 * Returns an array of WCSLayer's with the descriptors of all coverages
144
	 * @return WCSLayer[]
145
	 */
146
	public WCSLayerNode[] getLayerList() {
147
		if (coverages == null || coverages.isEmpty()) {
148
			// the WCSLayer collection will be built
149
			coverages = new Hashtable<String, WCSLayerNode>();
150
			Hashtable wcsCoverages  = client.getCoverageList();
151
			int sz = wcsCoverages.size();
152

  
153
			// Create an array with the WCSCoverages
154
			WCSCoverage[] coverageList = new WCSCoverage[sz];
155
			Iterator it = wcsCoverages.keySet().iterator();
156
			int i = 0;
157
			while (it.hasNext()) {
158
				coverageList[i] = (WCSCoverage) wcsCoverages.get(it.next());
159
				i++;
160
			}
161

  
162
			// Create a WCSLayer array from the previous WCSCoverage array
163
			layerList = new WCSLayerNode[sz];
164
			for (int j = 0; j < layerList.length; j++) {
165
				WCSLayerNode lyr = new WCSLayerNode();
166
				WCSCoverage cov = coverageList[j];
167
				// name
168
				lyr.setName(cov.getName());
169

  
170
				// title
171
				lyr.setTitle(cov.getTitle());
172

  
173
				// description
174
				lyr.setDescription(cov.getAbstract());
175

  
176
				// srs
177
				lyr.addAllSrs(cov.getAllSrs());
178

  
179
				// native srs
180
				lyr.setNativeSRS(cov.getNativeSRS());
181

  
182
				// extents
183
				Set k = cov.getBBoxes().keySet();
184
				if (!k.isEmpty()) {
185
					it = k.iterator();
186
					while (it.hasNext()) {
187
						String srs = (String) it.next();
188
						BoundaryBox bBox = cov.getBbox(srs);
189
						Rectangle2D r = new Rectangle2D.Double(
190
								bBox.getXmin(),
191
								bBox.getYmin(),
192
								bBox.getXmax() - bBox.getXmin(),
193
								bBox.getYmax() - bBox.getYmin()
194
						);
195
						lyr.addExtent(srs, r);
196
					}
197
				}
198

  
199
				// formats
200
				lyr.setFormats(cov.getFormats());
201

  
202
				// time positions
203
				lyr.setTimePositions(cov.getTimePositions());
204
				
205
				RectifiedGrid rf = cov.getRectifiedGrid();
206
				int w = rf.getHighGridEnvelopLimits()[0][0] - rf.getLowGridEnvelopLimits()[0][0];
207
				int h = rf.getHighGridEnvelopLimits()[0][1] - rf.getLowGridEnvelopLimits()[0][1]; 
208
				
209
				lyr.setWidth(w);
210
				lyr.setHeight(h);
211
				
212
				// max res
213
				lyr.setMaxRes(new Point2D.Double(cov.getResX(), cov.getResY()));
214

  
215
				// interpolations
216
				lyr.setInterpolationMethods(cov.getInterpolationMethods());
217

  
218
				// parameters
219
				k = cov.axisPool.keySet();
220
				if (!k.isEmpty()) {
221
					it = k.iterator();
222
					while (it.hasNext()) {
223
						AxisDescription ad = (AxisDescription) cov.axisPool.get(it.next());
224
						FMapWCSParameter p = new FMapWCSParameter();
225
						p.setName(ad.getName());
226
						p.setLabel(ad.getLabel());
227
						p.setType(ad.getInterval() == null ? FMapWCSParameter.VALUE_LIST : FMapWCSParameter.INTERVAL);
228
						if (p.getType() == FMapWCSParameter.VALUE_LIST) {
229
							p.setValueList(ad.getSingleValues());
230
						} /*else {
231
							p.setInterval(ad.getInterval());
232
						}*/
233
						lyr.addParameter(p);
234
					}
235
				}
236
				layerList[j] = lyr;
237
				coverages.put(lyr.getName(), lyr);
238
			}
239
		}
240
		return layerList;
241
	}
242

  
243
	/**
244
	 * Establishes the connection to the WCS server. Connecting to a WCS is
245
	 * an abstraction.<br>
246
	 * <p>
247
	 * Actually, it sends a GetCapabilities and a general DescribeCoverage
248
	 * request (not a coverage-specific DescribeCoverage request) to read the
249
	 * necessary data for building further GetCoverage requests.
250
	 * </p>
251
	 * @param override
252
	 * @throws IOException.
253
	 */
254
	public boolean connect(boolean override, ICancellable cancel)
255
			throws IOException {
256
		coverages = null;
257
		setHost(client.getHost());
258
		return client.connect(override, cancel);
259
	}
260

  
261
	/**
262
	 * No close operation is needed since WCS service it is a non-session based
263
	 * protocol. So, this does nothing and you can omit it.<br>
264
	 */
265
	public void close() {
266
//		connected = false;
267
	}
268

  
269
	/**
270
	 * Returns the label of an specific coverage given by the coverage name
271
	 * @param coverage name (string)
272
	 * @return string
273
	 */
274
	public String getLabel(String coverageName) {
275
		return client.getLabel(coverageName);
276
	}
277

  
278
	/**
279
	 * Returns the coverage's MAX extent from the server.
280
	 * @return Rectangle2D
281
	 * @throws IOException
282
	 */
283
	public Rectangle2D getFullExtent(String coverageName, String srs)
284
			throws IOException {
285
		return client.getExtent(coverageName, srs);
286
	}
287

  
288
	/**
289
	 * Returns the max resolution of a specific coverage given by the coverage's name.
290
	 * @param coverage name (string)
291
	 * @return double
292
	 */
293
	public Point2D getMaxResolution(String coverageName) {
294
		if (getCoverages().containsKey(coverageName)) {
295
			return ((WCSLayerNode) getCoverages().get(coverageName)).getMaxRes();
296
		}
297
		return null;
298
	}
299
	
300
	/**
301
	 * Gets the maximum width in pixels of this coverage
302
	 * @param coverageName
303
	 * @return
304
	 */
305
	public int getWidth(String coverageName) {
306
		if (getCoverages().containsKey(coverageName)) {
307
			return ((WCSLayerNode) getCoverages().get(coverageName)).getWidth();
308
		}
309
		return 0;
310
	}
311

  
312
	/**
313
	 * Gets the maximum height in pixels of this coverage
314
	 * @param coverageName
315
	 * @return
316
	 */
317
	public int getHeight(String coverageName) {
318
		if (getCoverages().containsKey(coverageName)) {
319
			return ((WCSLayerNode) getCoverages().get(coverageName)).getHeight();
320
		}
321
		return 0;
322
	}
323

  
324
	/**
325
	 * Returns an ArrayList containing a set of Strings with the coverage's SRSs.
326
	 * @param coverage name (string)
327
	 * @return ArrayList
328
	 */
329
	public ArrayList getSRSs(String coverageName) {
330
		if (getCoverages().containsKey(coverageName)) {
331
			return ((WCSLayerNode) getCoverages().get(coverageName)).getSRSs();
332
		}
333
		return null;
334
	}
335

  
336
	/**
337
	 * Returns a String containing a description of an specific coverage.
338
	 * @param coverage name (string)
339
	 * @return string
340
	 */
341
	public String getCoverageDescription(String coverageName) {
342
		if (getCoverages().containsKey(coverageName)) {
343
			return ((WCSLayerNode) getCoverages().get(coverageName)).getDescription();
344
		}
345
		return null;
346
	}
347

  
348
	/**
349
	 * Returns an ArrayList containing strings for the time positions of an
350
	 * specific coverage given by the coverage's name.
351
	 * @param coverage name (string)
352
	 * @return ArrayList
353
	 */
354
	public ArrayList getTimes(String coverageName) {
355
		if (getCoverages().containsKey(coverageName)) {
356
			return ((WCSLayerNode) getCoverages().get(coverageName)).getTimePositions();
357
		}
358
		return null;
359
	}
360

  
361
	/**
362
	 * Sends a GetCoverage request to the client.
363
	 * @param status
364
	 * @return
365
	 * @throws WCSException
366
	 */
367
	public File getCoverage(WCSStatus status, ICancellable cancel) throws RemoteServiceException {
368
		try {
369
			return client.getCoverage(status, cancel);
370
		} catch (ServerErrorException e) {
371
			throw new RemoteServiceException(getName(), e);
372
		} catch (org.gvsig.remoteclient.exceptions.WCSException e) {
373
			throw new RemoteServiceException(e.getMessage(), e);
374
		}
375
	}
376
	
377
	/**
378
	 * Sends a GetCoverage request to the client.
379
	 * @param status
380
	 * @return
381
	 * @throws WCSException
382
	 */
383
	public void getCoverageURL(WCSStatus status, ICancellable cancel, File file) throws RemoteServiceException {
384
		try {
385
			URL url = client.getCoverageURL(status, cancel);
386
			downloadFile(url, file, cancel);
387
			String exceptionMessage = client.getExceptionMessage(file);
388
			if(exceptionMessage != null)
389
				throw new RemoteServiceException(exceptionMessage);
390
		} catch(IOException e) {
391
			throw new RemoteServiceException("WCS: error downloading the file. File:" + file.getAbsolutePath() + "...." + e.getMessage(),e);
392
		} catch (ServerErrorException e) {
393
			throw new RemoteServiceException("WCS Unexpected server error."+e.getMessage(),e);
394
//		}  catch (org.gvsig.remoteclient.exceptions.WMSException e) {
395
//			throw new RemoteServiceException(e.getMessage());
396
		}
397
	}
398
	
399
	public void downloadFile(URL url, File dstFile, ICancellable cancel) throws IOException {
400
		Preferences prefs = Preferences.userRoot().node( "gvsig.downloader" );
401
		// by default 1 minute (60000 milliseconds.
402
		int timeout = prefs.getInt("timeout", 60000);
403

  
404
		DataOutputStream dos;
405
		DataInputStream is;
406
		OutputStreamWriter os = null;
407
		HttpURLConnection connection = null;
408
		//If the used protocol is HTTPS
409
		if (url.getProtocol().equals("https")) {
410
			try {
411
				disableHttsValidation();
412
			} catch (KeyManagementException e) {
413
				e.printStackTrace();
414
			} catch (NoSuchAlgorithmException e) {
415
				e.printStackTrace();
416
			}
417
		}
418
		connection = (HttpURLConnection)url.openConnection();
419
		connection.setConnectTimeout(timeout);
420
		is = new DataInputStream(url.openStream());
421

  
422
		dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(dstFile)));
423
		byte[] buffer = new byte[1024 * 4];
424

  
425

  
426
		long readed = 0;
427
		for (int i = is.read(buffer); i > 0; i = is.read(buffer)){
428
			dos.write(buffer, 0, i);
429
			readed += i;
430
			if(cancel != null && cancel.isCanceled())
431
				return;
432
		}
433
		if(os != null) {
434
			os.close();
435
		}
436
		dos.close();
437
		is.close();
438
		is = null;
439
		dos = null;
440
	}
441

  
442
	/**
443
	 * This method disables the Https certificate validation.
444
	 * @throws KeyManagementException
445
	 * @throws NoSuchAlgorithmException
446
	 */
447
	private void disableHttsValidation() throws KeyManagementException, NoSuchAlgorithmException{
448
		// Create a trust manager that does not validate certificate chains
449
		TrustManager[] trustAllCerts = new TrustManager[] {
450
				new X509TrustManager() {
451
					public java.security.cert.X509Certificate[] getAcceptedIssuers() {
452
						return null;
453
					}
454
					public void checkClientTrusted(
455
							java.security.cert.X509Certificate[] certs, String authType) {
456
					}
457
					public void checkServerTrusted(
458
							java.security.cert.X509Certificate[] certs, String authType) {
459
					}
460
				}
461
		};
462

  
463
		// Install the all-trusting trust manager
464
		SSLContext sc = SSLContext.getInstance("SSL");
465
		sc.init(null, trustAllCerts, new java.security.SecureRandom());
466
		HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
467
	}
468
   
469
}
0 470

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.5/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSProvider.java
1
package org.gvsig.raster.wcs.io;
2

  
3
import java.awt.Rectangle;
4
import java.awt.geom.AffineTransform;
5
import java.awt.geom.NoninvertibleTransformException;
6
import java.awt.geom.Point2D;
7
import java.awt.geom.Rectangle2D;
8
import java.io.File;
9
import java.io.IOException;
10
import java.net.URL;
11
import java.util.Hashtable;
12

  
13
import org.gvsig.fmap.dal.DALLocator;
14
import org.gvsig.fmap.dal.DataStore;
15
import org.gvsig.fmap.dal.DataStoreParameters;
16
import org.gvsig.fmap.dal.coverage.RasterLocator;
17
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
18
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
19
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
20
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
21
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
22
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
23
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
24
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
25
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
26
import org.gvsig.fmap.dal.coverage.exception.QueryException;
27
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
28
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
29
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
30
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
31
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
32
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
33
import org.gvsig.fmap.dal.exception.InitializeException;
34
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
35
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
36
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
37
import org.gvsig.metadata.MetadataLocator;
38
import org.gvsig.raster.cache.tile.provider.TileServer;
39
import org.gvsig.raster.impl.buffer.DefaultRasterQuery;
40
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
41
import org.gvsig.raster.impl.datastruct.BandListImpl;
42
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
43
import org.gvsig.raster.impl.datastruct.ExtentImpl;
44
import org.gvsig.raster.impl.provider.AbstractRasterProvider;
45
import org.gvsig.raster.impl.provider.RasterProvider;
46
import org.gvsig.raster.impl.provider.RemoteRasterProvider;
47
import org.gvsig.raster.impl.store.DefaultRasterStore;
48
import org.gvsig.raster.impl.store.DefaultStoreFactory;
49
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
50
import org.gvsig.raster.impl.store.properties.DataStoreTransparency;
51
import org.gvsig.raster.impl.store.properties.RemoteDataStoreStatistics;
52
import org.gvsig.raster.impl.store.properties.RemoteStoreHistogram;
53
import org.gvsig.raster.util.DefaultProviderServices;
54
import org.gvsig.raster.wcs.io.downloader.WCSTileServer;
55
import org.gvsig.remoteclient.wcs.WCSStatus;
56
import org.gvsig.tools.ToolsLocator;
57
/**
58
 * Clase que representa al driver de acceso a datos de wcs.
59
 *
60
 * @author Nacho Brodin (nachobrodin@gmail.com)
61
 */
62
public class WCSProvider extends AbstractRasterProvider implements RemoteRasterProvider {
63
	public static String                NAME                     = "Wcs Store";
64
	public static String                DESCRIPTION              = "Wcs Raster file";
65
	public static final String          METADATA_DEFINITION_NAME = "WcsStore";
66
	
67
	private Extent                      viewRequest              = null;
68
	private static Hashtable<URL, WCSConnector>    
69
	                                    drivers                  = new Hashtable<URL, WCSConnector> ();
70
	private boolean                     open                     = false;
71
	private DataStoreTransparency       fileTransparency         = null;
72
	private File                        lastRequest              = null;
73
	private AbstractRasterProvider      lastRequestProvider      = null; 
74
	
75
	public static void register() {
76
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
77
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
78
			dataman.registerStoreProvider(NAME,
79
					WCSProvider.class, WCSDataParametersImpl.class);
80
		}
81

  
82
		if (!dataman.getExplorerProviders().contains(NAME)) {
83
			dataman.registerExplorerProvider(NAME, WCSServerExplorer.class, WCSServerExplorerParameters.class);
84
		}
85
		dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
86
	}
87
	
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff