Revision 1124
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/TilePipe.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.wmts.io; |
|
23 |
|
|
24 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix.Tile; |
|
25 |
|
|
26 |
/** |
|
27 |
* This class manages transactions between the producer and the consumer. The |
|
28 |
* producer download tiles from a server and the consumer is a tile provider |
|
29 |
* which will return downloaded tiles. |
|
30 |
* |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class TilePipe { |
|
34 |
//N?mero de threads m?ximos a lanzar para descarga. Cuando se lanzan m?s de estos el |
|
35 |
//invocador debe dormir hasta que se haya liberado alguno. |
|
36 |
public static int NTHREADS_QUEUE = 5; |
|
37 |
//N?mero m?ximo de elementos en la tuberia. Cuando se llene esta el setTile de esta clase debe |
|
38 |
//dormir hasta que getTile lo despierte. |
|
39 |
private final static int BUFFER_SIZE = 10; |
|
40 |
|
|
41 |
private Tile buffer[] = new Tile[BUFFER_SIZE]; |
|
42 |
private int next = 0; |
|
43 |
private boolean isFull = false; |
|
44 |
private boolean isEmpty = true; |
|
45 |
private Thread threadManager = null; |
|
46 |
|
|
47 |
/** |
|
48 |
* El thread manager no se usa con la pool solo para la implementaci?n de RequestThreadManager |
|
49 |
* @param threadManager |
|
50 |
*/ |
|
51 |
public void setRequestManager(Thread threadManager) { |
|
52 |
this.threadManager = threadManager; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Sets a tile in the pipe |
|
57 |
* @param tile |
|
58 |
*/ |
|
59 |
public synchronized void setTile(Tile tile) { |
|
60 |
while( isFull == true ) { |
|
61 |
try { |
|
62 |
wait(); |
|
63 |
} catch( InterruptedException e ) { |
|
64 |
} |
|
65 |
} |
|
66 |
buffer[next] = tile; |
|
67 |
next++; |
|
68 |
if( next == BUFFER_SIZE ) |
|
69 |
isFull = true; |
|
70 |
isEmpty = false; |
|
71 |
notify(); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Gets a tile from the pipe |
|
76 |
* @return |
|
77 |
*/ |
|
78 |
public synchronized Tile getTile() { |
|
79 |
while( isEmpty == true ) { |
|
80 |
try { |
|
81 |
wait(); |
|
82 |
} catch( InterruptedException e ) { |
|
83 |
} |
|
84 |
} |
|
85 |
next--; |
|
86 |
if( next == 0 ) |
|
87 |
isEmpty = true; |
|
88 |
isFull = false; |
|
89 |
notify(); |
|
90 |
if(threadManager != null && getSize() <= NTHREADS_QUEUE) { |
|
91 |
synchronized(threadManager) { |
|
92 |
threadManager.notify(); |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
return buffer[next] ; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Returns the number of elements in the queue |
|
101 |
* @return |
|
102 |
*/ |
|
103 |
public synchronized int getSize() { |
|
104 |
return next; |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/DefaultWMTSIOLibrary.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.wmts.io; |
|
23 |
|
|
24 |
import org.gvsig.tools.library.AbstractLibrary; |
|
25 |
import org.gvsig.tools.library.LibraryException; |
|
26 |
/** |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class DefaultWMTSIOLibrary extends AbstractLibrary { |
|
31 |
|
|
32 |
public DefaultWMTSIOLibrary() { |
|
33 |
/*super(DefaultWMTSIOLibrary.class,Library.TYPE.IMPL); |
|
34 |
require(ToolsLibrary.class); |
|
35 |
require(DALLibrary.class); |
|
36 |
require(DALFileLibrary.class);*/ |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
protected void doInitialize() throws LibraryException { |
|
41 |
//RasterLibrary.wakeUp(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doPostInitialize() throws LibraryException { |
|
46 |
WMTSServerExplorerParameters.registerDynClass(); |
|
47 |
WMTSDataParametersImpl.registerDynClass(); |
|
48 |
WMTSProvider.register(); |
|
49 |
WMTSDataParametersImpl.registerPersistence(); |
|
50 |
} |
|
51 |
} |
|
0 | 52 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/TileDownloaderForWMTS.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.wmts.io.downloader; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.net.ConnectException; |
|
27 |
import java.net.URL; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
30 |
import org.gvsig.raster.cache.tile.Tile; |
|
31 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
32 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
|
33 |
import org.gvsig.raster.wmts.io.WMTSConnector; |
|
34 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
35 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
36 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
|
37 |
import org.gvsig.remoteclient.wmts.WMTSStatus; |
|
38 |
import org.gvsig.remoteclient.wmts.exception.WMTSException; |
|
39 |
|
|
40 |
/** |
|
41 |
* Tile getter |
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
43 |
*/ |
|
44 |
public class TileDownloaderForWMTS extends BaseTileDownloader { |
|
45 |
private WMTSConnector connector = null; |
|
46 |
|
|
47 |
public TileDownloaderForWMTS(WMTSProvider prov, |
|
48 |
int tilePxWidth, |
|
49 |
int tilePxHeight) { |
|
50 |
super(prov, tilePxWidth, tilePxHeight); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Gets the connector from the URL |
|
55 |
* @return |
|
56 |
* @throws RemoteServiceException |
|
57 |
*/ |
|
58 |
public WMTSConnector getConnector() throws WMTSException { |
|
59 |
if(connector == null) { |
|
60 |
WMTSDataParameters p = (WMTSDataParameters)prov.getDataParameters(); |
|
61 |
URL url = null; |
|
62 |
try { |
|
63 |
url = new URL(p.getURI()); |
|
64 |
} catch (Exception e) { |
|
65 |
throw new WMTSException("Malformed URL",e); |
|
66 |
} |
|
67 |
try { |
|
68 |
connector = new WMTSConnector(url); |
|
69 |
} catch (ConnectException e) { |
|
70 |
throw new WMTSException("Connect exception",e); |
|
71 |
} catch (IOException e) { |
|
72 |
throw new WMTSException("Connect exception",e); |
|
73 |
} |
|
74 |
} |
|
75 |
return connector; |
|
76 |
} |
|
77 |
|
|
78 |
/* |
|
79 |
* (non-Javadoc) |
|
80 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#getTile(org.gvsig.raster.cache.tile.Tile) |
|
81 |
*/ |
|
82 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
83 |
try { |
|
84 |
WMTSStatus status = (WMTSStatus)tile.getDownloaderParams("WMTSStatus"); |
|
85 |
status.setTileRow(tile.getRow()); |
|
86 |
status.setTileCol(tile.getCol()); |
|
87 |
File f = getConnector().getTile(status, tile.getCancelled(), tile.getFile()); |
|
88 |
tile.setFile(f); |
|
89 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
|
90 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
|
91 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
|
92 |
//if(rmf.exists()) |
|
93 |
//rmf.delete(); |
|
94 |
} catch (WMTSException e) { |
|
95 |
throw new TileGettingException(e); |
|
96 |
} catch (ServerErrorException e) { |
|
97 |
throw new TileGettingException(e); |
|
98 |
} |
|
99 |
readTileFromDisk(tile); |
|
100 |
return tile; |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
0 | 104 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSTileServer.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.wmts.io.downloader; |
|
23 |
|
|
24 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
25 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
26 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
27 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
28 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix; |
|
29 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSetLink; |
|
30 |
|
|
31 |
/** |
|
32 |
* Data server for the tile cache in a WMTSProvider |
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
34 |
*/ |
|
35 |
public class WMTSTileServer implements TileServer { |
|
36 |
private CacheStruct struct = null; |
|
37 |
private Downloader downloader = null; |
|
38 |
private WMTSProvider provider = null; |
|
39 |
private String suffix = ".tif"; |
|
40 |
private WMTSTileMatrixSetLink tileMatrixSetLink = null; |
|
41 |
|
|
42 |
public WMTSTileServer(WMTSProvider prov, |
|
43 |
WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
44 |
this.provider = prov; |
|
45 |
this.tileMatrixSetLink = tileMatrixSetLink; |
|
46 |
} |
|
47 |
|
|
48 |
/* |
|
49 |
* (non-Javadoc) |
|
50 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getDownloader() |
|
51 |
*/ |
|
52 |
public Downloader getDownloader() { |
|
53 |
//if(downloader == null) { |
|
54 |
int tileWidth = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileWidth(); |
|
55 |
int tileHeight = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileHeight(); |
|
56 |
downloader = new TileDownloaderForWMTS(provider, tileWidth, tileHeight); |
|
57 |
//} |
|
58 |
return downloader; |
|
59 |
} |
|
60 |
|
|
61 |
public CacheStruct getStruct() { |
|
62 |
if(struct == null) { |
|
63 |
struct = new WMTSCacheStruct(provider, tileMatrixSetLink); |
|
64 |
} |
|
65 |
return struct; |
|
66 |
} |
|
67 |
|
|
68 |
/* |
|
69 |
* (non-Javadoc) |
|
70 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setStruct(org.gvsig.raster.cache.tile.provider.CacheStruct) |
|
71 |
*/ |
|
72 |
public void setStruct(CacheStruct struct) { |
|
73 |
//La structura de cache es proporcionada por el servidor |
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getFileSuffix() |
|
79 |
*/ |
|
80 |
public String getFileSuffix() { |
|
81 |
return suffix; |
|
82 |
} |
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setFileExtension(java.lang.String) |
|
87 |
*/ |
|
88 |
public void setFileSuffix(String extension) { |
|
89 |
this.suffix = extension; |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSCacheStruct.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.wmts.io.downloader; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
import java.util.ArrayList; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
29 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
30 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
31 |
import org.gvsig.raster.cache.tile.Tile; |
|
32 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
33 |
import org.gvsig.raster.cache.tile.exception.TileBuildException; |
|
34 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
35 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
36 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
37 |
import org.gvsig.remoteclient.wmts.WMTSStatus; |
|
38 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix; |
|
39 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixLimits; |
|
40 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSet; |
|
41 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSetLink; |
|
42 |
|
|
43 |
/** |
|
44 |
* Implementation for a structure of a cache |
|
45 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
46 |
*/ |
|
47 |
public class WMTSCacheStruct implements CacheStruct { |
|
48 |
private String layerName = null; |
|
49 |
private String serverURL = null; |
|
50 |
private WMTSTileMatrixSet tileMatrixSet = null; |
|
51 |
private ArrayList<?> tileMatrixSetLimits = null; |
|
52 |
private double[] pixelSize = null; |
|
53 |
private WMTSProvider provider = null; |
|
54 |
|
|
55 |
public WMTSCacheStruct(WMTSProvider provider, WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
56 |
this.provider = provider; |
|
57 |
this.tileMatrixSet = tileMatrixSetLink.getTileMatrixSet(); |
|
58 |
this.tileMatrixSetLimits = tileMatrixSetLink.getTileMatrixLimits(); |
|
59 |
pixelSize = provider.getPixelSizeByLevel(); |
|
60 |
serverURL = provider.getURIOfFirstProvider(); |
|
61 |
layerName = ((WMTSDataParameters)provider.getDataParameters()).getLayer().getTitle(); |
|
62 |
} |
|
63 |
|
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getNumberOfLevels() |
|
67 |
*/ |
|
68 |
public int getNumberOfLevels() { |
|
69 |
return tileMatrixSet.getTileMatrix().size(); |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerName() |
|
75 |
*/ |
|
76 |
public String getLayerName() { |
|
77 |
return layerName; |
|
78 |
} |
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getServerURL() |
|
83 |
*/ |
|
84 |
public String getServerURL() { |
|
85 |
return serverURL; |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileSizeByLevel(int) |
|
91 |
*/ |
|
92 |
public int[] getTileSizeByLevel(int level) { |
|
93 |
return new int[] { |
|
94 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(), |
|
95 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight() |
|
96 |
}; |
|
97 |
} |
|
98 |
|
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerWidthOfTileMatrixByLevel(int) |
|
102 |
*/ |
|
103 |
public int getLayerWidthOfTileMatrixByLevel(int level) { |
|
104 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
105 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
106 |
return l.getMaxTileRow() - l.getMinTileRow(); |
|
107 |
} else { |
|
108 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
109 |
return (int)tm.getMatrixWidth(); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/* |
|
114 |
* (non-Javadoc) |
|
115 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerHeightOfTileMatrixByLevel(int) |
|
116 |
*/ |
|
117 |
public int getLayerHeightOfTileMatrixByLevel(int level) { |
|
118 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
119 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
120 |
return l.getMaxTileCol() - l.getMinTileCol(); |
|
121 |
} else { |
|
122 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
123 |
return (int)tm.getMatrixHeight(); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/* |
|
128 |
* (non-Javadoc) |
|
129 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerInitXTilePositionByLevel(int) |
|
130 |
*/ |
|
131 |
public int getLayerInitXTilePositionByLevel(int level) { |
|
132 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
133 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
134 |
return l.getMinTileCol(); |
|
135 |
} else |
|
136 |
return 0; |
|
137 |
} |
|
138 |
|
|
139 |
/* |
|
140 |
* (non-Javadoc) |
|
141 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerInitYTilePositionByLevel(int) |
|
142 |
*/ |
|
143 |
public int getLayerInitYTilePositionByLevel(int level) { |
|
144 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
145 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
146 |
return l.getMinTileRow(); |
|
147 |
} else |
|
148 |
return 0; |
|
149 |
} |
|
150 |
|
|
151 |
/* |
|
152 |
* (non-Javadoc) |
|
153 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getWorldHeightOfTileMatrixByLevel(int) |
|
154 |
*/ |
|
155 |
public long getWorldHeightOfTileMatrixByLevel(int level) { |
|
156 |
return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixWidth(); |
|
157 |
} |
|
158 |
|
|
159 |
/* |
|
160 |
* (non-Javadoc) |
|
161 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getWorldWidthOfTileMatrixByLevel(int) |
|
162 |
*/ |
|
163 |
public long getWorldWidthOfTileMatrixByLevel(int level) { |
|
164 |
return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixHeight(); |
|
165 |
} |
|
166 |
|
|
167 |
/* |
|
168 |
* (non-Javadoc) |
|
169 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getPixelSizeByLevel(int) |
|
170 |
*/ |
|
171 |
public double getPixelSizeByLevel(int level) { |
|
172 |
if(level < pixelSize.length) |
|
173 |
return pixelSize[level]; |
|
174 |
else |
|
175 |
return pixelSize[pixelSize.length - 1]; |
|
176 |
} |
|
177 |
|
|
178 |
/* |
|
179 |
* (non-Javadoc) |
|
180 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileExtent(org.gvsig.raster.cache.tile.Tile) |
|
181 |
*/ |
|
182 |
public Point2D[] getTileExtent(Tile tile) { |
|
183 |
return getTileExtent(tile.getLevel(), tile.getCol(), tile.getRow()); |
|
184 |
} |
|
185 |
|
|
186 |
/* |
|
187 |
* (non-Javadoc) |
|
188 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileExtent(int, int, int) |
|
189 |
*/ |
|
190 |
public Point2D[] getTileExtent(int level, int col, int row) { |
|
191 |
double[] ul = tileMatrixSet.getBoundingBox().getUpperCorner(); |
|
192 |
long tileWidth = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(); |
|
193 |
long tileHeight = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight(); |
|
194 |
double mtsWidthTile = tileWidth * pixelSize[level]; |
|
195 |
double mtsHeightTile = tileHeight * pixelSize[level]; |
|
196 |
double ulx = ul[0] + (col * mtsWidthTile); |
|
197 |
double uly = ulx + mtsWidthTile; |
|
198 |
double lrx = ul[1] - (row * mtsHeightTile); |
|
199 |
double lry = lrx - mtsHeightTile; |
|
200 |
return new Point2D[]{new Point2D.Double(ulx, uly), new Point2D.Double(lrx, lry)}; |
|
201 |
} |
|
202 |
|
|
203 |
/* |
|
204 |
* (non-Javadoc) |
|
205 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileStructure(int, int, int, java.awt.geom.Point2D, java.awt.geom.Point2D) |
|
206 |
*/ |
|
207 |
public Tile getTileStructure(int level, int tileCol, int tileRow, Point2D ul, Point2D lr) throws TileBuildException { |
|
208 |
int[] size = getTileSizeByLevel(level); |
|
209 |
Tile tile = TileCacheLocator.getManager().createTile(level, tileRow, tileCol); |
|
210 |
tile.setUl(ul); |
|
211 |
tile.setLr(lr); |
|
212 |
tile.setWidthPx(size[0]); |
|
213 |
tile.setHeightPx(size[1]); |
|
214 |
|
|
215 |
Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()), |
|
216 |
Math.min(ul.getY(), lr.getY()), |
|
217 |
Math.abs(ul.getX() - lr.getX()), |
|
218 |
Math.abs(ul.getY() - lr.getY())); |
|
219 |
int bufWidth = (int)(r.getWidth() / getPixelSizeByLevel(level)); |
|
220 |
int bufHeight = (int)(r.getHeight() / getPixelSizeByLevel(level)); |
|
221 |
try { |
|
222 |
WMTSStatus status = provider.buildWMTSStatus(r, bufWidth, bufHeight); |
|
223 |
tile.setDownloaderParams("WMTSStatus", status); |
|
224 |
} catch (RasterDriverException e) { |
|
225 |
throw new TileBuildException(e); |
|
226 |
} |
|
227 |
|
|
228 |
return tile; |
|
229 |
} |
|
230 |
|
|
231 |
/* |
|
232 |
* (non-Javadoc) |
|
233 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileList(java.awt.geom.Point2D, java.awt.geom.Point2D) |
|
234 |
*/ |
|
235 |
@SuppressWarnings("unchecked") |
|
236 |
public ArrayList<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest) throws TileBuildException { |
|
237 |
Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()), |
|
238 |
Math.min(ul.getY(), lr.getY()), |
|
239 |
Math.abs(ul.getX() - lr.getX()), |
|
240 |
Math.abs(ul.getY() - lr.getY())); |
|
241 |
int bufWidth = (int)(r.getWidth() / mtsPixelRequest); |
|
242 |
int bufHeight = (int)(r.getHeight() / mtsPixelRequest); |
|
243 |
try { |
|
244 |
WMTSStatus status = provider.buildWMTSStatus(r, bufWidth, bufHeight); |
|
245 |
|
|
246 |
//Conversi?n a tiles de la librer?a |
|
247 |
ArrayList<org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix.Tile> tiles = status.getTileList(); |
|
248 |
ArrayList<Tile> tileList = new ArrayList<Tile>(); |
|
249 |
for (int i = 0; i < tiles.size(); i++) { |
|
250 |
org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix.Tile tOrigin = (org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix.Tile) tiles.get(i); |
|
251 |
Tile t = TileCacheLocator.getManager().createTile(status.getLevel(), tOrigin.col, tOrigin.row); |
|
252 |
t.setUl(new Point2D.Double(tOrigin.ulx, tOrigin.uly)); |
|
253 |
t.setLr(new Point2D.Double(tOrigin.lrx, tOrigin.lry)); |
|
254 |
t.setWidthPx(tOrigin.wPx); |
|
255 |
t.setHeightPx(tOrigin.hPx); |
|
256 |
t.setDownloaderParams("WMTSStatus", provider.buildWMTSStatus(r, bufWidth, bufHeight)); |
|
257 |
tileList.add(t); |
|
258 |
} |
|
259 |
return tileList; |
|
260 |
} catch (RasterDriverException e) { |
|
261 |
throw new TileBuildException(e); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
/* |
|
266 |
* (non-Javadoc) |
|
267 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileSizeInRealCoordsByLevel(int) |
|
268 |
*/ |
|
269 |
public double[] getTileSizeInRealCoordsByLevel(int level) { |
|
270 |
return new double[] { |
|
271 |
getPixelSizeByLevel(level) * getTileSizeByLevel(level)[0], |
|
272 |
getPixelSizeByLevel(level) * getTileSizeByLevel(level)[1] |
|
273 |
}; |
|
274 |
} |
|
275 |
|
|
276 |
/* |
|
277 |
* (non-Javadoc) |
|
278 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getFileSuffix() |
|
279 |
*/ |
|
280 |
public String getFileSuffix() { |
|
281 |
return provider.getFileSuffix(); |
|
282 |
} |
|
283 |
|
|
284 |
/* |
|
285 |
* (non-Javadoc) |
|
286 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#compare(org.gvsig.raster.cache.tile.provider.CacheStruct) |
|
287 |
*/ |
|
288 |
public boolean compare(CacheStruct struct) { |
|
289 |
MathUtils mu = RasterLocator.getManager().getMathUtils(); |
|
290 |
//Compara: n?mero de niveles, tama?o de tile, |
|
291 |
//anchoXalto de la matriz, tama?o de pixel por nivel, |
|
292 |
//coordenadas de al menos un tile de la matriz |
|
293 |
if(struct.getNumberOfLevels() == getNumberOfLevels()) { |
|
294 |
for (int i = 0; i < getNumberOfLevels(); i++) { |
|
295 |
if( struct.getTileSizeByLevel(i)[0] == getTileSizeByLevel(i)[0] && |
|
296 |
struct.getTileSizeByLevel(i)[1] == getTileSizeByLevel(i)[1] && |
|
297 |
struct.getWorldHeightOfTileMatrixByLevel(i) == getWorldHeightOfTileMatrixByLevel(i) && |
|
298 |
struct.getWorldWidthOfTileMatrixByLevel(i) == getWorldWidthOfTileMatrixByLevel(i) && |
|
299 |
mu.clipDecimals(struct.getPixelSizeByLevel(i), 2) == mu.clipDecimals(getPixelSizeByLevel(i), 2) && |
|
300 |
compareExtents(struct.getTileExtent(i, 0, 0), getTileExtent(i, 0, 0))) { |
|
301 |
return true; |
|
302 |
} |
|
303 |
} |
|
304 |
} |
|
305 |
return false; |
|
306 |
} |
|
307 |
|
|
308 |
private boolean compareExtents(Point2D[] p, Point2D[] p1) { |
|
309 |
return (p[0].getX() == p1[0].getX() && p[0].getY() == p1[0].getY() && |
|
310 |
p[1].getX() == p1[1].getX() && p[1].getY() == p1[1].getY()); |
|
311 |
} |
|
312 |
|
|
313 |
/* |
|
314 |
* (non-Javadoc) |
|
315 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getEPSG() |
|
316 |
*/ |
|
317 |
public String getEPSG() { |
|
318 |
/*IProjection proj = provider.getProjection(); |
|
319 |
if(proj != null) |
|
320 |
return proj.getAbrev(); |
|
321 |
return null;*/ |
|
322 |
return provider.getSRSCode(); |
|
323 |
} |
|
324 |
|
|
325 |
/* |
|
326 |
* (non-Javadoc) |
|
327 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getFileSize() |
|
328 |
*/ |
|
329 |
public String getFileSize() { |
|
330 |
return "0"; |
|
331 |
} |
|
332 |
|
|
333 |
public ArrayList<Tile> getTileList(int x, int y, int w, int h) { |
|
334 |
return null; |
|
335 |
} |
|
336 |
|
|
337 |
public ArrayList<Tile> getTileList(Rectangle2D r) { |
|
338 |
return null; |
|
339 |
} |
|
340 |
} |
|
0 | 341 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/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.wmts.io package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>WMTS provider</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSServerExplorer.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.wmts.io; |
|
29 |
|
|
30 |
import java.io.IOException; |
|
31 |
import java.net.URL; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.List; |
|
34 |
|
|
35 |
import org.gvsig.compat.net.ICancellable; |
|
36 |
import org.gvsig.fmap.dal.DALLocator; |
|
37 |
import org.gvsig.fmap.dal.DataManager; |
|
38 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
39 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
40 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
41 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
43 |
import org.gvsig.fmap.dal.exception.DataException; |
|
44 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
45 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
46 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
47 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
48 |
import org.gvsig.remoteclient.wmts.exception.WMTSException; |
|
49 |
import org.gvsig.remoteclient.wmts.struct.WMTSLayer; |
|
50 |
import org.gvsig.remoteclient.wmts.struct.WMTSServiceIdentification; |
|
51 |
import org.gvsig.remoteclient.wmts.struct.WMTSServiceProvider; |
|
52 |
import org.gvsig.remoteclient.wmts.struct.WMTSThemes; |
|
53 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSet; |
|
54 |
|
|
55 |
/** |
|
56 |
* Explorer for a WMTS server |
|
57 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
58 |
*/ |
|
59 |
public class WMTSServerExplorer implements DataServerExplorer, DataServerExplorerProvider { |
|
60 |
public static final String NAME = "WMTSRemoteServerExplorer"; |
|
61 |
private WMTSConnector connector = null; |
|
62 |
private WMTSServerExplorerParameters parameters = null; |
|
63 |
|
|
64 |
public WMTSServerExplorer( |
|
65 |
WMTSServerExplorerParameters parameters, |
|
66 |
DataServerExplorerProviderServices services) |
|
67 |
throws InitializeException { |
|
68 |
this.parameters = parameters; |
|
69 |
} |
|
70 |
|
|
71 |
/* |
|
72 |
* (non-Javadoc) |
|
73 |
* @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDataStoreProviderName() |
|
74 |
*/ |
|
75 |
public String getDataStoreProviderName() { |
|
76 |
return WMTSProvider.NAME; |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDescription() |
|
82 |
*/ |
|
83 |
public String getDescription() { |
|
84 |
return WMTSProvider.DESCRIPTION; |
|
85 |
} |
|
86 |
|
|
87 |
/* |
|
88 |
* (non-Javadoc) |
|
89 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getStoreParameters() |
|
90 |
*/ |
|
91 |
public DataStoreParameters getStoreParameters() { |
|
92 |
DataManager manager = DALLocator.getDataManager(); |
|
93 |
WMTSDataParameters wmtsParams = null; |
|
94 |
try { |
|
95 |
wmtsParams = (WMTSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName()); |
|
96 |
wmtsParams.setURI(parameters.getHost()); |
|
97 |
|
|
98 |
if(WMTSProvider.TILED) { |
|
99 |
TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store"); |
|
100 |
tileParams.setDataParameters(wmtsParams); |
|
101 |
return tileParams; |
|
102 |
} |
|
103 |
} catch (InitializeException e) { |
|
104 |
e.printStackTrace(); |
|
105 |
} catch (ProviderNotRegisteredException e) { |
|
106 |
e.printStackTrace(); |
|
107 |
} |
|
108 |
return wmtsParams; |
|
109 |
} |
|
110 |
|
|
111 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
112 |
boolean overwrite) throws DataException { |
|
113 |
return false; |
|
114 |
} |
|
115 |
|
|
116 |
public boolean canAdd() { |
|
117 |
return false; |
|
118 |
} |
|
119 |
|
|
120 |
public boolean canAdd(String storeName) throws DataException { |
|
121 |
return false; |
|
122 |
} |
|
123 |
|
|
124 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
125 |
throws DataException { |
|
126 |
return null; |
|
127 |
} |
|
128 |
|
|
129 |
@SuppressWarnings("unchecked") |
|
130 |
public List getDataStoreProviderNames() { |
|
131 |
return null; |
|
132 |
} |
|
133 |
|
|
134 |
/* |
|
135 |
* (non-Javadoc) |
|
136 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getParameters() |
|
137 |
*/ |
|
138 |
public DataServerExplorerParameters getParameters() { |
|
139 |
return parameters; |
|
140 |
} |
|
141 |
|
|
142 |
@SuppressWarnings("unchecked") |
|
143 |
public List list() throws DataException { |
|
144 |
return null; |
|
145 |
} |
|
146 |
|
|
147 |
@SuppressWarnings("unchecked") |
|
148 |
public List list(int mode) throws DataException { |
|
149 |
return null; |
|
150 |
} |
|
151 |
|
|
152 |
public void remove(DataStoreParameters parameters) throws DataException { |
|
153 |
|
|
154 |
} |
|
155 |
|
|
156 |
public void dispose() { |
|
157 |
|
|
158 |
} |
|
159 |
|
|
160 |
public String getProviderName() { |
|
161 |
return null; |
|
162 |
} |
|
163 |
|
|
164 |
//********************************************** |
|
165 |
//Connector |
|
166 |
//********************************************** |
|
167 |
|
|
168 |
/* |
|
169 |
* (non-Javadoc) |
|
170 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#connect(org.gvsig.compat.net.ICancellable) |
|
171 |
*/ |
|
172 |
public void connect(ICancellable cancellable) throws WMTSException { |
|
173 |
URL url = null; |
|
174 |
boolean override = false; |
|
175 |
|
|
176 |
try { |
|
177 |
url = new URL(parameters.getHost()); |
|
178 |
} catch (Exception e) { |
|
179 |
throw new WMTSException("Malformed URL",e); |
|
180 |
} |
|
181 |
try { |
|
182 |
connector = new WMTSConnector(url); |
|
183 |
connector.setForceLongitudeFirstAxisOrder(parameters.isLongitudeFirst()); |
|
184 |
if (!connector.connect(override, cancellable)) |
|
185 |
throw new WMTSException("Error connecting"); |
|
186 |
} catch (IOException e) { |
|
187 |
throw new WMTSException(e.getMessage(), e); |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
/* |
|
192 |
* (non-Javadoc) |
|
193 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#isConnected() |
|
194 |
*/ |
|
195 |
public boolean isConnected() { |
|
196 |
if(connector != null) |
|
197 |
return true; |
|
198 |
return false; |
|
199 |
} |
|
200 |
|
|
201 |
/* |
|
202 |
* (non-Javadoc) |
|
203 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getThemes() |
|
204 |
*/ |
|
205 |
public WMTSThemes getThemes() { |
|
206 |
return connector.getThemes(); |
|
207 |
} |
|
208 |
|
|
209 |
/* |
|
210 |
* (non-Javadoc) |
|
211 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getLayer(java.lang.String) |
|
212 |
*/ |
|
213 |
public WMTSLayer getLayer(String layerName) { |
|
214 |
return connector.getLayer(layerName); |
|
215 |
} |
|
216 |
|
|
217 |
/* |
|
218 |
* (non-Javadoc) |
|
219 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getTileMatrixSet() |
|
220 |
*/ |
|
221 |
public ArrayList<WMTSTileMatrixSet> getTileMatrixSet() { |
|
222 |
return connector.getTileMatrixSet(); |
|
223 |
} |
|
224 |
|
|
225 |
/* |
|
226 |
* (non-Javadoc) |
|
227 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getServiceIdentification() |
|
228 |
*/ |
|
229 |
public WMTSServiceIdentification getServiceIdentification() { |
|
230 |
return connector.getServiceIdentification(); |
|
231 |
} |
|
232 |
|
|
233 |
/* |
|
234 |
* (non-Javadoc) |
|
235 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getServiceProvider() |
|
236 |
*/ |
|
237 |
public WMTSServiceProvider getServiceProvider() { |
|
238 |
return connector.getServiceProvider(); |
|
239 |
} |
|
240 |
|
|
241 |
/* |
|
242 |
* (non-Javadoc) |
|
243 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getHost() |
|
244 |
*/ |
|
245 |
public String getHost() { |
|
246 |
return parameters.getHost(); |
|
247 |
} |
|
248 |
|
|
249 |
/* |
|
250 |
* (non-Javadoc) |
|
251 |
* @see org.gvsig.fmap.dal.spi.DataServerExplorerProvider#getServerExplorerProviderServices() |
|
252 |
*/ |
|
253 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() { |
|
254 |
return null; |
|
255 |
} |
|
256 |
} |
|
0 | 257 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSConnector.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.wmts.io; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.net.ConnectException; |
|
27 |
import java.net.MalformedURLException; |
|
28 |
import java.net.URL; |
|
29 |
import java.util.ArrayList; |
|
30 |
|
|
31 |
import org.gvsig.compat.net.ICancellable; |
|
32 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
|
33 |
import org.gvsig.remoteclient.wmts.WMTSClient; |
|
34 |
import org.gvsig.remoteclient.wmts.WMTSStatus; |
|
35 |
import org.gvsig.remoteclient.wmts.exception.DownloadException; |
|
36 |
import org.gvsig.remoteclient.wmts.exception.WMTSException; |
|
37 |
import org.gvsig.remoteclient.wmts.struct.WMTSLayer; |
|
38 |
import org.gvsig.remoteclient.wmts.struct.WMTSServiceIdentification; |
|
39 |
import org.gvsig.remoteclient.wmts.struct.WMTSServiceProvider; |
|
40 |
import org.gvsig.remoteclient.wmts.struct.WMTSThemes; |
|
41 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSet; |
|
42 |
|
|
43 |
/** |
|
44 |
* This class offers an interface of services for a WMTS |
|
45 |
* |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class WMTSConnector { |
|
49 |
private WMTSClient client = null; |
|
50 |
|
|
51 |
public WMTSConnector(URL url) throws ConnectException, IOException { |
|
52 |
client = new WMTSClient(url.toString()); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Sets longitude first in the axis order |
|
57 |
* @param force |
|
58 |
*/ |
|
59 |
public void setForceLongitudeFirstAxisOrder(boolean force) { |
|
60 |
if(client != null) { |
|
61 |
client.setForceLongitudeFirstAxisOrder(force); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Establishes the connection. |
|
67 |
* @param override, if true the previous downloaded data will be overridden |
|
68 |
* @return <b>true</b> if the connection was successful, or <b>false</b> if it was no possible |
|
69 |
* to establish the connection for any reason such as version negotiation. |
|
70 |
*/ |
|
71 |
public boolean connect(boolean override, ICancellable cancel) { |
|
72 |
return client.connect(override, cancel); |
|
73 |
} |
|
74 |
|
|
75 |
public boolean connect(ICancellable cancel) { |
|
76 |
return client.connect(false, cancel); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the list of themes |
|
81 |
* @return |
|
82 |
*/ |
|
83 |
public WMTSThemes getThemes() { |
|
84 |
return client.getThemes(); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Gets a layer |
|
89 |
* @param layerName |
|
90 |
* @return |
|
91 |
*/ |
|
92 |
public WMTSLayer getLayer(String layerName) { |
|
93 |
return client.getLayer(layerName); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Gets the set of tiles definition |
|
98 |
* @return |
|
99 |
*/ |
|
100 |
@SuppressWarnings("unchecked") |
|
101 |
public ArrayList<WMTSTileMatrixSet> getTileMatrixSet() { |
|
102 |
return client.getTileMatrixSet(); |
|
103 |
} |
|
104 |
|
|
105 |
/* |
|
106 |
* (non-Javadoc) |
|
107 |
* @see org.gvsig.fmap.dal.coverage.explorer.WMTSServerExplorer#getServiceIdentification() |
|
108 |
*/ |
|
109 |
public WMTSServiceIdentification getServiceIdentification() { |
|
110 |
return client.getServiceIdentification(); |
|
111 |
} |
|
112 |
|
|
113 |
public WMTSServiceProvider getServiceProvider() { |
|
114 |
return client.getServiceProvider(); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* Gets the host |
|
119 |
* @return |
|
120 |
*/ |
|
121 |
public String getHost(){ |
|
122 |
return client.getHost(); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* <p>Gets a tile downloading using a specific path and file.</p> |
|
127 |
* @throws ServerErrorException |
|
128 |
*/ |
|
129 |
public synchronized File getTile(WMTSStatus status, ICancellable cancel, File file) throws WMTSException, ServerErrorException { |
|
130 |
return client.getTile(status, cancel, file); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* <p>One of the three interfaces that OGC WMTS defines. Request a map.</p> |
|
135 |
* @throws ServerErrorException |
|
136 |
*/ |
|
137 |
public synchronized File getTile(WMTSStatus status, ICancellable cancel) throws WMTSException, ServerErrorException { |
|
138 |
return client.getTile(status, cancel); |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* Builds the URL to get a tile using a WMTSStatus object |
|
143 |
* @throws ServerErrorException |
|
144 |
*/ |
|
145 |
public synchronized URL getTileURL(WMTSStatus status) throws MalformedURLException { |
|
146 |
return client.getTileURL(status); |
|
147 |
} |
|
148 |
|
|
149 |
/** |
|
150 |
* Downloads a file |
|
151 |
* @throws DownloadException |
|
152 |
* @throws ServerErrorException |
|
153 |
*/ |
|
154 |
public synchronized File downloadFile(URL url, ICancellable cancel) throws DownloadException { |
|
155 |
return client.downloadFile(url, cancel); |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* <p>It will send a GetFeatureInfo request to the WMTS |
|
160 |
* Parsing the response and redirecting the info to the WMTS client</p> |
|
161 |
*/ |
|
162 |
public String getFeatureInfo(WMTSStatus status, int x, int y, ICancellable cancel) throws WMTSException, ServerErrorException { |
|
163 |
return client.getFeatureInfo(status, x, y, cancel); |
|
164 |
} |
|
165 |
} |
|
0 | 166 |
org.gvsig.raster.wmts/tags/buildNumber_xx/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSProvider.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.wmts.io; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.awt.geom.NoninvertibleTransformException; |
|
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.ConnectException; |
|
31 |
import java.net.MalformedURLException; |
|
32 |
import java.net.URL; |
|
33 |
import java.util.ArrayList; |
|
34 |
|
|
35 |
import org.gvsig.compat.net.ICancellable; |
|
36 |
import org.gvsig.fmap.dal.DALLocator; |
|
37 |
import org.gvsig.fmap.dal.DataStore; |
|
38 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
39 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
40 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
41 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
42 |
import org.gvsig.fmap.dal.coverage.datastruct.DatasetBand; |
|
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.InvalidSetViewException; |
|
48 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
49 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
50 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
51 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
52 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
53 |
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer; |
|
54 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
55 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
56 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
57 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
58 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
59 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
60 |
import org.gvsig.metadata.MetadataLocator; |
|
61 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
62 |
import org.gvsig.raster.cache.tile.TileCacheManager; |
|
63 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
64 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
65 |
import org.gvsig.raster.cache.tile.provider.TileListener; |
|
66 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
67 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
68 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery; |
|
69 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
|
70 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl; |
|
71 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
72 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
|
73 |
import org.gvsig.raster.impl.provider.MemoryMatrixBuffer; |
|
74 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
75 |
import org.gvsig.raster.impl.provider.RemoteRasterProvider; |
|
76 |
import org.gvsig.raster.impl.provider.TiledRasterProvider; |
|
77 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
|
78 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
79 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
80 |
import org.gvsig.raster.impl.store.properties.RemoteStoreHistogram; |
|
81 |
import org.gvsig.raster.util.DefaultProviderServices; |
|
82 |
import org.gvsig.raster.wmts.io.downloader.WMTSTileServer; |
|
83 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
|
84 |
import org.gvsig.remoteclient.wmts.WMTSStatus; |
|
85 |
import org.gvsig.remoteclient.wmts.exception.DownloadException; |
|
86 |
import org.gvsig.remoteclient.wmts.exception.WMTSException; |
|
87 |
import org.gvsig.remoteclient.wmts.struct.WMTSBoundingBox; |
|
88 |
import org.gvsig.remoteclient.wmts.struct.WMTSLayer; |
|
89 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix; |
|
90 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixLimits; |
|
91 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSet; |
|
92 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSetLink; |
|
93 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix.Tile; |
|
94 |
import org.gvsig.tools.ToolsLocator; |
|
95 |
import org.gvsig.tools.task.Cancellable; |
|
96 |
import org.gvsig.tools.task.TaskStatus; |
|
97 |
import org.slf4j.Logger; |
|
98 |
import org.slf4j.LoggerFactory; |
|
99 |
/** |
|
100 |
* Provider for WMTS service |
|
101 |
* |
|
102 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
103 |
*/ |
|
104 |
@SuppressWarnings("deprecation") |
|
105 |
public class WMTSProvider extends DefaultRasterProvider implements RemoteRasterProvider, TiledRasterProvider { |
|
106 |
public static String NAME = "Wmts Store"; |
|
107 |
public static String DESCRIPTION = "Wmts Raster file"; |
|
108 |
public static final String METADATA_DEFINITION_NAME = "WmtsStore"; |
|
109 |
private static Logger logger = LoggerFactory.getLogger(WMTSProvider.class); |
|
110 |
public static boolean TILED = true; |
|
111 |
|
|
112 |
//Los tiles se piden de forma secuencial y sin lanzar threads para ello (+Lento) |
|
113 |
public static int SEQUENTIAL = 0; |
|
114 |
//Los tiles se piden en threads y hay un thread manager para gestionar que no se pidan m?s de cierto n?mero |
|
115 |
public static int LIMITED_THREADS = 1; |
|
116 |
//Los tiles se piden en threads y se lanzan tantos threads como tiles haya |
|
117 |
public static int UNLIMITED_THREADS = 2; |
|
118 |
private int requestType = LIMITED_THREADS; |
|
119 |
|
|
120 |
private static final double MTS_X_GRADO = 111319.490793274; |
|
121 |
|
|
122 |
private Extent viewRequest = null; |
|
123 |
private WMTSConnector connector = null; |
|
124 |
//private static Hashtable<URL, WMTSConnector> |
|
125 |
// drivers = new Hashtable<URL, WMTSConnector> (); |
|
126 |
private boolean open = false; |
|
127 |
private File lastRequest = null; |
|
128 |
private DataStoreTransparency lastFileTransparency = null; |
|
129 |
private int lastWidthRequest = 0; |
|
130 |
private int lastHeightRequest = 0; |
|
131 |
private WMTSStatus lastStatus = null; |
|
132 |
private boolean gridSubsets = true; |
|
133 |
private Extent[] extentByLevel = null; //Only for layers without gridSubsets |
|
134 |
private MathUtils math = RasterLocator.getManager().getMathUtils(); |
|
135 |
|
|
136 |
/** |
|
137 |
* This thread manages the number of tiles that have been thrown. |
|
138 |
* This number is controlled by the NTHREADS_QUEUE variable. |
|
139 |
* |
|
140 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
141 |
*/ |
|
142 |
public class RequestThreadManager extends Thread { |
|
143 |
private TilePipe pipe = null; |
|
144 |
private ArrayList<Tile> tiles = null; |
|
145 |
private WMTSStatus status = null; |
|
146 |
|
|
147 |
public RequestThreadManager(TilePipe pipe, ArrayList<Tile> tiles, WMTSStatus status) { |
|
148 |
this.pipe = pipe; |
|
149 |
this.tiles = tiles; |
|
150 |
this.status = status; |
|
151 |
} |
|
152 |
|
|
153 |
public void run() { |
|
154 |
for (int i = 0; i < tiles.size(); i++) { |
|
155 |
Tile tile = tiles.get(i); |
|
156 |
WMTSStatus statusCopy = status.cloneStatus(); |
|
157 |
statusCopy.setTileRow(tile.row); |
|
158 |
statusCopy.setTileCol(tile.col); |
|
159 |
if (pipe.getSize() > TilePipe.NTHREADS_QUEUE) { |
|
160 |
try { |
|
161 |
synchronized (this) { |
|
162 |
wait(); |
|
163 |
} |
|
164 |
} catch( InterruptedException e ) { |
|
165 |
} |
|
166 |
} |
|
167 |
new RequestTileLauncher(pipe, statusCopy, tile).start(); |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* Thread to download a tile |
|
174 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
175 |
*/ |
|
176 |
class RequestTileLauncher extends Thread { |
|
177 |
private TilePipe pipe = null; |
|
178 |
private WMTSStatus status = null; |
|
179 |
private Tile tile = null; |
|
180 |
|
|
181 |
public RequestTileLauncher(TilePipe pipe, WMTSStatus status, Tile tile) { |
|
182 |
this.pipe = pipe; |
|
183 |
this.status = status; |
|
184 |
this.tile = tile; |
|
185 |
} |
|
186 |
|
|
187 |
public void run() { |
|
188 |
try { |
|
189 |
//File file = getConnector().getTile(status, null); |
|
190 |
URL url = getConnector().getTileURL(status); |
|
191 |
tile.file = getConnector().downloadFile(url, null); |
|
192 |
pipe.setTile(tile); |
|
193 |
} catch (DownloadException e) { |
|
194 |
logger.info("Error downloading files", e); |
|
195 |
} catch (MalformedURLException e) { |
|
196 |
logger.info("Malformed URL", e); |
|
197 |
} catch (WMTSException e) { |
|
198 |
logger.info("", e); |
|
199 |
} |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* Point information |
|
205 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
206 |
*/ |
|
207 |
public class PointInfo { |
|
208 |
public Point2D worldCoord; |
|
209 |
public Point2D tile; |
|
210 |
public Point2D pixelInTile; |
|
211 |
public int level; |
|
212 |
|
|
213 |
public PointInfo(Point2D worldCoord) { |
|
214 |
this.worldCoord = worldCoord; |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
public static void register() { |
|
219 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
220 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
|
221 |
dataman.registerStoreProvider(NAME, |
|
222 |
WMTSProvider.class, WMTSDataParametersImpl.class); |
|
223 |
} |
|
224 |
|
|
225 |
if (!dataman.getExplorerProviders().contains(WMTSServerExplorer.NAME)) { |
|
226 |
dataman.registerExplorerProvider(WMTSServerExplorer.NAME, WMTSServerExplorer.class, WMTSServerExplorerParameters.class); |
|
227 |
} |
|
228 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
|
229 |
} |
|
230 |
|
|
231 |
public WMTSProvider() throws NotSupportedExtensionException { |
|
232 |
super(); |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Constructor. Abre el dataset. |
|
237 |
* @param proj Proyecci?n |
|
238 |
* @param fName Nombre del fichero |
|
239 |
* @throws NotSupportedExtensionException |
|
240 |
*/ |
|
241 |
public WMTSProvider(String params) throws NotSupportedExtensionException { |
|
242 |
super(params); |
|
243 |
if(params instanceof String) { |
|
244 |
WMTSDataParameters p = new WMTSDataParametersImpl(); |
|
245 |
p.setURI((String)params); |
|
246 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
|
247 |
.createDynObject( |
|
248 |
MetadataLocator.getMetadataManager().getDefinition( |
|
249 |
DataStore.METADATA_DEFINITION_NAME))); |
|
250 |
init(p, null); |
|
251 |
} |
|
252 |
} |
|
253 |
|
|
254 |
public WMTSProvider(WMTSDataParameters params, |
|
255 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException { |
|
256 |
super(params, storeServices, ToolsLocator.getDynObjectManager() |
|
257 |
.createDynObject( |
|
258 |
MetadataLocator.getMetadataManager().getDefinition( |
|
259 |
DataStore.METADATA_DEFINITION_NAME))); |
|
260 |
init(params, storeServices); |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* Gets the connector from the URL |
|
265 |
* @return |
|
266 |
* @throws RemoteServiceException |
|
267 |
*/ |
|
268 |
public WMTSConnector getConnector() throws WMTSException { |
|
269 |
if(connector == null) { |
|
270 |
WMTSDataParameters p = (WMTSDataParameters)parameters; |
|
271 |
URL url = null; |
|
272 |
try { |
|
273 |
url = new URL(p.getURI()); |
|
274 |
} catch (Exception e) { |
|
275 |
throw new WMTSException("Malformed URL",e); |
|
276 |
} |
|
277 |
try { |
|
278 |
connector = new WMTSConnector(url); |
|
279 |
} catch (ConnectException e) { |
|
280 |
throw new WMTSException("Connect exception",e); |
|
281 |
} catch (IOException e) { |
|
282 |
throw new WMTSException("Connect exception",e); |
Also available in: Unified diff