Revision 9232

View differences:

org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.raster.wmts</artifactId>
5
    <packaging>pom</packaging>
6
    <version>2.2.71</version>
7
    <name>${project.artifactId}</name>
8
    <description>WMTS client</description>
9
    <inceptionYear>2011</inceptionYear>
10
	
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.desktop</artifactId>
14
        <version>2.0.234</version>
15
    </parent>
16

  
17
        <properties>
18
            <!-- El plugin versions:use-latest-versions falla con scope import -->
19
            <!-- asi que toca usar el versions:update-properties que si que funciona -->
20
            <org.gvsig.raster.version>2.2.88</org.gvsig.raster.version>
21
        </properties>
22
    
23
    <repositories>
24
        <repository>
25
            <id>gvsig-public-http-repository</id>
26
            <name>gvSIG maven public HTTP repository</name>
27
            <url>http://devel.gvsig.org/m2repo/j2se</url>
28
            <releases>
29
                <enabled>true</enabled>
30
                <updatePolicy>daily</updatePolicy>
31
                <checksumPolicy>warn</checksumPolicy>
32
            </releases>
33
            <snapshots>
34
                <enabled>true</enabled>
35
                <updatePolicy>daily</updatePolicy>
36
                <checksumPolicy>warn</checksumPolicy>
37
            </snapshots>
38
        </repository>
39
    </repositories>
40
    
41
    <scm>
42
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71</connection>
43
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71</developerConnection>
44
        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71</url>
45
    </scm>
46
    
47
    <dependencyManagement>
48
        <dependencies>
49
                        <dependency>
50
                                <groupId>org.gvsig</groupId>
51
                                <artifactId>org.gvsig.raster</artifactId>
52
                                <version>${org.gvsig.raster.version}</version>
53
                                <type>pom</type>
54
                                <scope>import</scope>
55
                        </dependency>
56

  
57
            <dependency>
58
                <groupId>org.gvsig</groupId>
59
                <artifactId>org.gvsig.raster.wmts.swing.api</artifactId>
60
                <version>2.2.71</version>
61
            </dependency>
62
            <dependency>
63
                <groupId>org.gvsig</groupId>
64
                <artifactId>org.gvsig.raster.wmts.swing.impl</artifactId>
65
                <version>2.2.71</version>
66
            </dependency>
67
            <dependency>
68
                <groupId>org.gvsig</groupId>
69
                <artifactId>org.gvsig.raster.wmts.ogc.api</artifactId>
70
                <version>2.2.71</version>
71
            </dependency>
72
            <dependency>
73
                <groupId>org.gvsig</groupId>
74
                <artifactId>org.gvsig.raster.wmts.ogc.impl</artifactId>
75
                <version>2.2.71</version>
76
            </dependency>
77
            <dependency>
78
                <groupId>org.gvsig</groupId>
79
                <artifactId>org.gvsig.raster.wmts.app.wmtsclient</artifactId>
80
                <version>2.2.71</version>
81
            </dependency>
82
            <dependency>
83
                <groupId>org.gvsig</groupId>
84
                <artifactId>org.gvsig.raster.wmts.io</artifactId>
85
                <version>2.2.71</version>
86
            </dependency>
87

  
88
        </dependencies>
89
    </dependencyManagement>
90
	
91
    <developers>
92
        <developer>
93
            <id>nbrodin</id>
94
            <name>Nacho Brodin</name>
95
            <email>nachobrodin@gmail.com</email>
96
            <roles>
97
                <role>Architect</role>
98
                <role>Developer</role>
99
            </roles>
100
        </developer>
101
    </developers>
102
	
103
    <build>
104
        <plugins>
105
            <plugin>
106
                <groupId>org.apache.maven.plugins</groupId>
107
                <artifactId>maven-release-plugin</artifactId>
108
                <configuration>
109
                    <tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/tags/</tagBase>
110
                    <goals>deploy</goals>
111
                </configuration>
112
            </plugin>
113
        </plugins>
114
    </build>
115
    
116
    <modules>
117
        <module>org.gvsig.raster.wmts.swing</module>
118
        <module>org.gvsig.raster.wmts.io</module>
119
        <module>org.gvsig.raster.wmts.app.wmtsclient</module>
120
        <module>org.gvsig.raster.wmts.ogc</module>
121
    </modules>
122
</project>
0 123

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/org.gvsig.raster.wmts.io/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/org.gvsig.raster.wmts.io/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.raster">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/org.gvsig.raster.wmts.io/src/test/resources/TemplateRasterProvider.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.fmap.dal.coverage.dataset.io.netcdf;
23

  
24
import java.awt.geom.AffineTransform;
25

  
26
import org.gvsig.fmap.dal.DALFileLocator;
27
import org.gvsig.fmap.dal.DALLocator;
28
import org.gvsig.fmap.dal.DataStore;
29
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
30
import org.gvsig.fmap.dal.coverage.dataset.io.tile.downloader.FileTileServer;
31
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
32
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
33
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
34
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
35
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
36
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
37
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
38
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
39
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
40
import org.gvsig.fmap.dal.coverage.store.RasterFileStoreParameters;
41
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
42
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
43
import org.gvsig.metadata.MetadataLocator;
44
import org.gvsig.raster.cache.tile.provider.TileListener;
45
import org.gvsig.raster.cache.tile.provider.TileServer;
46
import org.gvsig.raster.impl.datastruct.ExtentImpl;
47
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
48
import org.gvsig.raster.impl.provider.RasterProvider;
49
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
50
import org.gvsig.raster.impl.store.AbstractRasterDataStore;
51
import org.gvsig.raster.impl.store.DefaultStoreFactory;
52
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
53
import org.gvsig.raster.impl.store.properties.DataStoreMetadata;
54
import org.gvsig.raster.impl.store.properties.DataStoreTransparency;
55
import org.gvsig.tools.ToolsLocator;
56
import org.gvsig.tools.extensionpoint.ExtensionPoint;
57
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
58
/**
59
 * Data provider for ...
60
 *
61
 * @author Nacho Brodin (nachobrodin@gmail.com)
62
 */
63
public class NetCDFProvider extends DefaultRasterProvider {
64
	public static String        NAME                     = "Template Store";
65
	public static String        DESCRIPTION              = "Template Raster file";
66
	public final String         METADATA_DEFINITION_NAME = "TemplateStore";
67
	
68
	private static String[]     formatList               = new String[]{"*"};
69

  
70
	private Extent              viewRequest              = null;
71
	private TileServer          tileServer               = null;
72
	private boolean             open                     = false;
73

  
74
	public static void register() {
75
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
76
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
77
			dataman.registerStoreProvider(NAME,
78
					NetCDFProvider.class, NetCDFDataParameters.class);
79
		}
80
		
81
		if(DALFileLocator.getFilesystemServerExplorerManager() != null)
82
			DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
83
					NAME, DESCRIPTION,
84
					NetCDFFilesystemServerExplorer.class);
85
		
86
		dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
87
	}
88

  
89
	/**
90
	 * Returns true if the extension is supported and false if doesn't
91
	 * @param ext
92
	 * @return
93
	 */
94
	public static boolean isExtensionSupported(String ext) {
95
		for (int i = 0; i < formatList.length; i++) {
96
			if(formatList[i].compareTo(ext) == 0)
97
				return true;
98
		}
99
		return false;
100
	}
101
	
102
	/**
103
	 * Constructor. Abre el dataset.
104
	 * @param proj Proyecci?n
105
	 * @param fName Nombre del fichero
106
	 * @throws NotSupportedExtensionException
107
	 */
108
	public NetCDFProvider(String params) throws NotSupportedExtensionException {
109
		super(params);
110
		if(params instanceof String) {
111
			NetCDFDataParameters p = new NetCDFDataParameters();
112
			p.setURI((String)params);
113
			super.init(p, null, ToolsLocator.getDynObjectManager()
114
					.createDynObject(
115
							MetadataLocator.getMetadataManager().getDefinition(
116
									DataStore.METADATA_DEFINITION_NAME)));
117
			init(p, null);
118
		}
119
	}
120
	
121
	public NetCDFProvider (NetCDFDataParameters params,
122
			AbstractRasterDataStore storeServices) throws NotSupportedExtensionException {
123
		super(params, storeServices, ToolsLocator.getDynObjectManager()
124
				.createDynObject(
125
						MetadataLocator.getMetadataManager().getDefinition(
126
								DataStore.METADATA_DEFINITION_NAME)));
127
		init(params, storeServices);
128
	}
129

  
130
	/**
131
	 * Crea las referencias al fichero y carga
132
	 * las estructuras con la informaci?n y los metadatos.
133
	 * @param proj Proyecci?n
134
	 * @param param Parametros de carga
135
	 * @throws NotSupportedExtensionException
136
	 */
137
	public void init (AbstractRasterDataParameters params,
138
			DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
139
		//TODO:
140
		
141
		if(((RasterFileStoreParameters)params).getFile().exists()) {
142
			setParam(params);
143
			colorTable = null;
144
			noData = 0;
145
			wktProjection = null;
146
			//CrsWkt crs = new CrsWkt(wktProjection);
147
			//IProjection proj = CRSFactory.getCRS("EPSG:23030");
148
			noDataEnabled = true;
149
			ownTransformation = null;
150
			externalTransformation = (AffineTransform)ownTransformation.clone();
151
			load();
152
		} else
153
			setParam(params);
154
		bandCount = 0;
155
		setDataType(null);
156
		super.init();
157

  
158
		try {
159
			loadFromRmf(getRmfBlocksManager());
160
		} catch (ParsingException e) {
161
			//No lee desde rmf
162
		}
163
	}
164
	
165
	/*
166
	 * (non-Javadoc)
167
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#load()
168
	 */
169
	public RasterProvider load() {
170
		return this;
171
	}
172
	
173
	/*
174
	 * (non-Javadoc)
175
	 * @see org.gvsig.raster.impl.provider.RasterProvider#isOpen()
176
	 */
177
	public boolean isOpen() {
178
		return open;
179
	}
180

  
181
	/*
182
	 * (non-Javadoc)
183
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#close()
184
	 */
185
	public void close() {
186
		//TODO:
187
	}
188

  
189
	/*
190
	 * (non-Javadoc)
191
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#translateFileName(java.lang.String)
192
	 */
193
	public String translateFileName(String fileName) {
194
		return fileName;
195
	}
196

  
197
	/**
198
	 * Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n
199
	 * de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v)
200
	 * ha de estar en coordenadas del fichero.
201
	 */
202
	public void setView(Extent e) {
203
		viewRequest = new ExtentImpl(e);
204
	}
205

  
206
	/*
207
	 * (non-Javadoc)
208
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getView()
209
	 */
210
	public Extent getView() {
211
		return viewRequest;
212
	}
213

  
214
	/*
215
	 * (non-Javadoc)
216
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWidth()
217
	 */
218
	public double getWidth() {
219
		//TODO:
220
		return 0;
221
	}
222

  
223
	/*
224
	 * (non-Javadoc)
225
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getHeight()
226
	 */
227
	public double getHeight() {
228
		//TODO:
229
		return 0;
230
	}
231

  
232
	/**
233
	 * Read a line from the file
234
	 * @param line
235
	 * @param band
236
	 * @return
237
	 * @throws InvalidSetViewException
238
	 * @throws FileNotOpenException
239
	 * @throws RasterDriverException
240
	 * @Deprecated This operation is deprecated because is not useful and in the future
241
	 * it will not be maintained. The abstract operation has dissapear
242
	 */
243
	public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
244
		if(line > this.getHeight() || band > this.getBandCount())
245
			throw new InvalidSetViewException("Request out of grid");
246

  
247
		//TODO:
248
		return null;
249
	}
250

  
251
	/*
252
	 *  (non-Javadoc)
253
	 * @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int)
254
	 */
255
	public Object readBlock(int pos, int blockHeight)
256
		throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
257
		if(pos < 0)
258
			throw new InvalidSetViewException("Request out of grid");
259

  
260
		if((pos + blockHeight) > getHeight())
261
			blockHeight = Math.abs(((int)getHeight()) - pos);
262
		
263
		//TODO:
264
		return null;
265
	}
266

  
267
	/*
268
	 * (non-Javadoc)
269
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getData(int, int, int)
270
	 */
271
	public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
272
		if(x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
273
			throw new InvalidSetViewException("Request out of grid");
274
		
275
		//TODO
276
		return null;
277
	}
278

  
279
	/*
280
	 * (non-Javadoc)
281
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.raster.cache.tile.provider.TileListener)
282
	 */
283
	public void getWindow(Extent ex, int bufWidth, int bufHeight, 
284
			BandList bandList, TileListener listener) throws ProcessInterruptedException, RasterDriverException {
285
		//TODO
286
	}
287

  
288
	/*
289
	 * (non-Javadoc)
290
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(org.gvsig.fmap.dal.coverage.datastruct.Extent, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
291
	 */
292
	public Buffer getWindow(Extent ex, BandList bandList, Buffer rasterBuf) 
293
		throws ProcessInterruptedException, RasterDriverException {
294
		//TODO
295

  
296
		return rasterBuf;
297
	}
298

  
299
	/*
300
	 * (non-Javadoc)
301
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean)
302
	 */
303
	public Buffer getWindow(double ulx, double uly, double w, double h, 
304
			BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException {
305
		//TODO
306

  
307
		return rasterBuf;
308
	}
309

  
310
	/*
311
	 * (non-Javadoc)
312
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean)
313
	 */
314
	public Buffer getWindow(Extent extent, 
315
			int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException {
316
		//TODO
317
		
318
		return rasterBuf;
319
	}
320

  
321
	/*
322
	 * (non-Javadoc)
323
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(int, int, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
324
	 */
325
	public Buffer getWindow(int x, int y, int w, int h, 
326
			BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException {
327
		//TODO
328
		
329
		return rasterBuf;
330
	}
331

  
332
	/*
333
	 * (non-Javadoc)
334
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(int, int, int, int, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
335
	 */
336
	public Buffer getWindow(int x, int y, int w, int h, 
337
			int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException {
338
		//TODO
339
		
340
		return rasterBuf;
341
	}
342

  
343
	/*
344
	 * (non-Javadoc)
345
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getBlockSize()
346
	 */
347
	public int getBlockSize(){
348
		//TODO
349
		
350
		return 0;
351
	}
352

  
353
	/*
354
	 * (non-Javadoc)
355
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getMetadata()
356
	 */
357
	public DataStoreMetadata getMetadata() {
358
		//TODO
359
		
360
		return null;
361
	}
362

  
363
	/*
364
	 * (non-Javadoc)
365
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getColorInterpretation()
366
	 */
367
	public DataStoreColorInterpretation getColorInterpretation(){
368
		//TODO
369
		
370
		return null;
371
	}
372

  
373
	/*
374
	 * (non-Javadoc)
375
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setColorInterpretation(org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation)
376
	 */
377
	public void setColorInterpretation(DataStoreColorInterpretation colorInterpretation){
378
		//TODO
379
	}
380

  
381
	/*
382
	 * (non-Javadoc)
383
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getTransparency()
384
	 */
385
	public DataStoreTransparency getTransparency() {
386
		//TODO
387
		
388
		return null;
389
	}
390

  
391
	/*
392
	 * (non-Javadoc)
393
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isGeoreferenced()
394
	 */
395
	public boolean isGeoreferenced() {
396
		//TODO
397
		
398
		return false;
399
	}
400

  
401
	/**
402
	 * Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar?
403
	 * el valor de esta variable cada vez que dibuja.
404
	 * @return true si se ha supersampleado y false si no se ha hecho.
405
	 */
406
	public boolean isSupersampling() {
407
		//TODO
408
		
409
		return false;
410
	}
411

  
412
	/*
413
	 * (non-Javadoc)
414
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setAffineTransform(java.awt.geom.AffineTransform)
415
	 */
416
	public void setAffineTransform(AffineTransform t){
417
		super.setAffineTransform(t);
418
	}
419

  
420
	/*
421
	 * (non-Javadoc)
422
	 * @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewCount(int)
423
	 */
424
	public int getOverviewCount(int band) throws BandAccessException, RasterDriverException {
425
		if(band >= getBandCount())
426
			throw new BandAccessException("Wrong band");
427
		//TODO
428
		
429
		return 0;
430
	}
431

  
432
	/*
433
	 * (non-Javadoc)
434
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewWidth(int, int)
435
	 */
436
	public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException {
437
		if (band >= getBandCount())
438
			throw new BandAccessException("Wrong band");
439
		//TODO
440
		
441
		return 0;
442
	}
443

  
444
	/*
445
	 * (non-Javadoc)
446
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewHeight(int, int)
447
	 */
448
	public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException {
449
		if (band >= getBandCount())
450
			throw new BandAccessException("Wrong band");
451
		//TODO
452
		
453
		return 0;
454
	}
455

  
456
	/*
457
	 * (non-Javadoc)
458
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#overviewsSupport()
459
	 */
460
	public boolean overviewsSupport() {
461
		return true;
462
	}
463

  
464
	/*
465
	 * (non-Javadoc)
466
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isReproyectable()
467
	 */
468
	public boolean isReproyectable() {
469
		return true;
470
	}
471

  
472
	/*
473
	 * (non-Javadoc)
474
	 * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getName()
475
	 */
476
	public String getName() {
477
		return NAME;
478
	}
479
	
480
	/*
481
	 * (non-Javadoc)
482
	 * @see org.gvsig.raster.impl.provider.RasterProvider#setStatus(org.gvsig.raster.impl.provider.RasterProvider)
483
	 */
484
	public void setStatus(RasterProvider provider) {
485
		if(provider instanceof NetCDFProvider) {
486
			//Not implemented yet
487
		}
488
	}
489
	
490
	/*
491
	 * (non-Javadoc)
492
	 * @see org.gvsig.raster.impl.provider.RasterProvider#getTileServer()
493
	 */
494
	public TileServer getTileServer() {
495
		if(tileServer == null)
496
			tileServer = new FileTileServer(this);
497
		return tileServer;
498
	}
499
}
0 500

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/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.raster.wmts.ogc.struct.WMTSTile;
25

  
26

  
27
/**
28
 * This class manages transactions between the producer and the consumer. The
29
 * producer download tiles from a server and the consumer is a tile provider
30
 * which will return downloaded tiles.
31
 *
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 */
34
public class TilePipe {
35
	//N?mero de threads m?ximos a lanzar para descarga. Cuando se lanzan m?s de estos el 
36
	//invocador debe dormir hasta que se haya liberado alguno.
37
	public static int            NTHREADS_QUEUE = 5;
38
	//N?mero m?ximo de elementos en la tuberia. Cuando se llene esta el setTile de esta clase debe
39
	//dormir hasta que getTile lo despierte.
40
	private final static int     BUFFER_SIZE    = 10;
41
	
42
	private WMTSTile             buffer[]       = new WMTSTile[BUFFER_SIZE];
43
	private int                  next           = 0;
44
	private boolean              isFull         = false;
45
	private boolean              isEmpty        = true;
46
	private Thread               threadManager  = null;
47

  
48
	/**
49
	 * El thread manager no se usa con la pool solo para la implementaci?n de RequestThreadManager
50
	 * @param threadManager
51
	 */
52
	public void setRequestManager(Thread threadManager) {
53
		this.threadManager = threadManager;
54
	}
55
	
56
	/**
57
	 * Sets a tile in the pipe
58
	 * @param tile
59
	 */
60
	public synchronized void setTile(WMTSTile tile) {
61
		while( isFull == true ) {
62
			try {
63
				wait();
64
			} catch( InterruptedException e ) {
65
			}
66
		}
67
		buffer[next] = tile;
68
		next++;
69
		if( next == BUFFER_SIZE )
70
			isFull = true;
71
		isEmpty = false;
72
		notify();
73
	}
74

  
75
	/**
76
	 * Gets a tile from the pipe
77
	 * @return
78
	 */
79
	public synchronized WMTSTile getTile() {
80
		while( isEmpty == true ) {
81
			try {
82
				wait();
83
			} catch( InterruptedException e ) {
84
			}
85
		}
86
        next--;
87
        if( next == 0 )
88
        	isEmpty = true;
89
        isFull = false;
90
        notify();
91
        if(threadManager != null && getSize() <= NTHREADS_QUEUE) {
92
        	synchronized(threadManager) {
93
        		threadManager.notify();
94
        	}
95
        }
96
        	
97
        return buffer[next] ;
98
	}
99
	
100
	/**
101
	 * Returns the number of elements in the queue
102
	 * @return
103
	 */
104
	public synchronized int getSize() {
105
		return next;
106
	}
107
}
0 108

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/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
	}
50
}
0 51

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/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.io.File;
27
import java.net.URL;
28
import java.util.ArrayList;
29
import java.util.List;
30

  
31
import org.gvsig.fmap.dal.coverage.RasterLocator;
32
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
33
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
34
import org.gvsig.fmap.dal.coverage.util.MathUtils;
35
import org.gvsig.raster.cache.tile.Tile;
36
import org.gvsig.raster.cache.tile.TileCacheLocator;
37
import org.gvsig.raster.cache.tile.exception.TileBuildException;
38
import org.gvsig.raster.cache.tile.provider.CacheStruct;
39
import org.gvsig.raster.wmts.io.WMTSDataParameters;
40
import org.gvsig.raster.wmts.io.WMTSProvider;
41
import org.gvsig.raster.wmts.ogc.WMTSStatus;
42
import org.gvsig.raster.wmts.ogc.struct.WMTSTile;
43
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix;
44
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixLimits;
45
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSet;
46
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink;
47

  
48
/**
49
 * Implementation for a structure of a cache
50
 * @author Nacho Brodin (nachobrodin@gmail.com)
51
 */
52
public class WMTSCacheStruct implements CacheStruct {
53
    private String                        layerName           = null;
54
	private String                        serverURL           = null;
55
	private WMTSTileMatrixSet             tileMatrixSet       = null;
56
	private List<WMTSTileMatrixLimits>    tileMatrixSetLimits = null;
57
	private double[]                      pixelSize           = null;
58
    private RasterDataStore               store               = null;
59

  
60
    public WMTSCacheStruct(RasterDataStore store, WMTSTileMatrixSetLink tileMatrixSetLink) {
61
    	this.store = store;
62
    	this.tileMatrixSet = tileMatrixSetLink.getTileMatrixSet();
63
		this.tileMatrixSetLimits = tileMatrixSetLink.getTileMatrixLimits();
64
		pixelSize = ((WMTSProvider)store.getProvider()).getPixelSizeByLevel();
65
		serverURL = ((WMTSProvider)store.getProvider()).getURIOfFirstProvider().getPath();
66
		layerName = ((WMTSDataParameters)store.getParameters()).getLayer().getTitle();
67
    }
68

  
69
	public int getNumberOfLevels() {
70
		return tileMatrixSet.getTileMatrix().size();
71
	}
72

  
73
	public String getLayerName() {
74
		return layerName;
75
	}
76

  
77
	public String getServerURL() {
78
		return serverURL + getDimension();
79
	}
80

  
81
	public int[] getTileSizeByLevel(int level) {
82
		return new int[] {
83
			((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(),
84
			((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight()
85
		};
86
	}
87

  
88
	public int getLayerWidthOfTileMatrixByLevel(int level) {
89
		if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) {
90
			WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level);
91
			return l.getMaxTileRow() - l.getMinTileRow();
92
		} else {
93
			WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level);
94
			return (int)tm.getMatrixWidth();
95
		}
96
	}
97

  
98
	public int getLayerHeightOfTileMatrixByLevel(int level) {
99
		if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) {
100
			WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level);
101
			return l.getMaxTileCol() - l.getMinTileCol();
102
		} else {
103
			WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level);
104
			return (int)tm.getMatrixHeight();
105
		}
106
	}
107

  
108
	public int getLayerInitXTilePositionByLevel(int level) {
109
		if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) {
110
			WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level);
111
			return l.getMinTileCol();
112
		} else
113
			return 0;
114
	}
115

  
116
	public int getLayerInitYTilePositionByLevel(int level) {
117
		if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) {
118
			WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level);
119
			return l.getMinTileRow();
120
		} else
121
			return 0;
122
	}
123

  
124
	public long getWorldHeightOfTileMatrixByLevel(int level) {
125
		return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixWidth();
126
	}
127

  
128
	public long getWorldWidthOfTileMatrixByLevel(int level) {
129
		return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixHeight();
130
	}
131

  
132
	public double getPixelSizeByLevel(int level) {
133
		if(level < pixelSize.length)
134
			return pixelSize[level];
135
		else
136
			return pixelSize[pixelSize.length - 1];
137
	}
138

  
139
	public Point2D[] getTileExtent(Tile tile) {
140
		return getTileExtent(tile.getLevel(), tile.getCol(), tile.getRow());
141
	}
142

  
143
	public Point2D[] getTileExtent(int level, int col, int row) {
144
		double[] ul = tileMatrixSet.getBoundingBox().getUpperCorner();
145
		long tileWidth = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth();
146
		long tileHeight = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight();
147
		double mtsWidthTile = tileWidth * pixelSize[level];
148
		double mtsHeightTile = tileHeight * pixelSize[level];
149
		double ulx = ul[0] + (col * mtsWidthTile);
150
		double uly = ulx + mtsWidthTile;
151
		double lrx = ul[1] - (row * mtsHeightTile);
152
		double lry = lrx - mtsHeightTile;
153
		return new Point2D[]{new Point2D.Double(ulx, uly), new Point2D.Double(lrx, lry)};
154
	}
155

  
156
	public Tile getTileStructure(int level, int tileCol, int tileRow, Point2D ul, Point2D lr) throws TileBuildException  {
157
		int[] size = getTileSizeByLevel(level);
158
		Tile tile = TileCacheLocator.getManager().createTile(level, tileRow, tileCol);
159
		tile.setUl(ul);
160
		tile.setLr(lr);
161
		tile.setWidthPx(size[0]);
162
		tile.setHeightPx(size[1]);
163

  
164
		Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()),
165
				Math.min(ul.getY(), lr.getY()),
166
				Math.abs(ul.getX() - lr.getX()),
167
				Math.abs(ul.getY() - lr.getY()));
168
		int bufWidth = (int)(r.getWidth() / getPixelSizeByLevel(level));
169
		int bufHeight = (int)(r.getHeight() / getPixelSizeByLevel(level));
170
		try {
171
			WMTSStatus status = ((WMTSProvider)store.getProvider()).buildWMTSStatus(r, bufWidth, bufHeight);
172
			tile.setDownloaderParams("WMTSStatus", status);
173
		} catch (RasterDriverException e) {
174
			throw new TileBuildException(e);
175
		}
176

  
177
		return tile;
178
	}
179

  
180
	public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest) throws TileBuildException {
181
		Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()),
182
				Math.min(ul.getY(), lr.getY()),
183
				Math.abs(ul.getX() - lr.getX()),
184
				Math.abs(ul.getY() - lr.getY()));
185
		int bufWidth = (int)(r.getWidth() / mtsPixelRequest);
186
		int bufHeight = (int)(r.getHeight() / mtsPixelRequest);
187
		try {
188
			WMTSStatus status = ((WMTSProvider)store.getProvider()).buildWMTSStatus(r, bufWidth, bufHeight);
189

  
190
			//Conversi?n a tiles de la librer?a
191
			List<WMTSTile> tiles = status.getTileList();
192
			List<Tile> tileList = new ArrayList<Tile>();
193
			for (int i = 0; i < tiles.size(); i++) {
194
				WMTSTile tOrigin = (WMTSTile) tiles.get(i);
195
				Tile t = TileCacheLocator.getManager().createTile(status.getLevel(), tOrigin.getCol(), tOrigin.getRow());
196
				t.setUl(new Point2D.Double(tOrigin.getULX(), tOrigin.getULY()));
197
				t.setLr(new Point2D.Double(tOrigin.getLRX(), tOrigin.getLRY()));
198
				t.setWidthPx(tOrigin.getWidthPx());
199
				t.setHeightPx(tOrigin.getHeightPx());
200
				t.setDownloaderParams("WMTSStatus", status.cloneStatus());
201
				tileList.add(t);
202
			}
203
			return tileList;
204
		} catch (RasterDriverException e) {
205
			throw new TileBuildException(e);
206
		}
207
	}
208

  
209
	public double[] getTileSizeInRealCoordsByLevel(int level) {
210
		return new double[] {
211
				getPixelSizeByLevel(level) * getTileSizeByLevel(level)[0],
212
				getPixelSizeByLevel(level) *  getTileSizeByLevel(level)[1]
213
			};
214
	}
215

  
216
	public String getFileSuffix() {
217
		return ((WMTSProvider)store.getProvider()).getFileSuffix();
218
	}
219

  
220
	public boolean compare(CacheStruct struct) {
221
		MathUtils mu = RasterLocator.getManager().getMathUtils();
222
		//Compara: n?mero de niveles, tama?o de tile,
223
		//anchoXalto de la matriz, tama?o de pixel por nivel,
224
		//coordenadas de al menos un tile de la matriz
225
		if(struct.getNumberOfLevels() == getNumberOfLevels()) {
226
			for (int i = 0; i < getNumberOfLevels(); i++) {
227
				if(	struct.getTileSizeByLevel(i)[0] == getTileSizeByLevel(i)[0] &&
228
					struct.getTileSizeByLevel(i)[1] == getTileSizeByLevel(i)[1] &&
229
					struct.getWorldHeightOfTileMatrixByLevel(i) == getWorldHeightOfTileMatrixByLevel(i) &&
230
					struct.getWorldWidthOfTileMatrixByLevel(i) == getWorldWidthOfTileMatrixByLevel(i) &&
231
					mu.clipDecimals(struct.getPixelSizeByLevel(i), 2) == mu.clipDecimals(getPixelSizeByLevel(i), 2) &&
232
					compareExtents(struct.getTileExtent(i, 0, 0), getTileExtent(i, 0, 0))) {
233
					return true;
234
				}
235
			}
236
		}
237
		return false;
238
	}
239

  
240
	private boolean compareExtents(Point2D[] p, Point2D[] p1) {
241
		return (p[0].getX() == p1[0].getX() && p[0].getY() == p1[0].getY() &&
242
				p[1].getX() == p1[1].getX() && p[1].getY() == p1[1].getY());
243
	}
244

  
245
	public String getEPSG() {
246
		/*IProjection proj = provider.getProjection();
247
		if(proj != null)
248
			return proj.getAbrev();
249
		return null;*/
250
		return ((WMTSProvider)store.getProvider()).getSRSCode();
251
	}
252

  
253
	private String getDimension() {
254
		WMTSDataParameters p = (WMTSDataParameters)(((WMTSProvider)store.getProvider()).getDataParameters());
255
		String dimension = p.getDimension();
256
		String dimensionValue = p.getDimensionSelectedValue();
257
		if(dimension != null && dimensionValue != null)
258
			return dimension + "_" + dimensionValue;
259
		return "";
260
	}
261

  
262
	public String getFileSize() {
263
		return "0";
264
	}
265

  
266
	public List<Tile> getTileList(int x, int y, int w, int h) {
267
		return null;
268
	}
269

  
270
	public ArrayList<Tile> getTileList(Rectangle2D r) {
271
		return null;
272
	}
273
}
0 274

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/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.compat.net.ICancellable;
30
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
31
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
32
import org.gvsig.raster.cache.tile.Tile;
33
import org.gvsig.raster.cache.tile.exception.TileGettingException;
34
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader;
35
import org.gvsig.raster.wmts.io.WMTSDataParameters;
36
import org.gvsig.raster.wmts.ogc.WMTSClient;
37
import org.gvsig.raster.wmts.ogc.WMTSOGCLocator;
38
import org.gvsig.raster.wmts.ogc.WMTSStatus;
39
import org.gvsig.raster.wmts.ogc.exception.ServerErrorException;
40
import org.gvsig.raster.wmts.ogc.exception.WMTSException;
41

  
42
/**
43
 * Tile getter
44
 * @author Nacho Brodin (nachobrodin@gmail.com)
45
 */
46
public class TileDownloaderForWMTS extends BaseTileDownloader {
47
	private WMTSClient             ogcClient  = null;
48

  
49
	public TileDownloaderForWMTS(RasterDataStore store,
50
			int tilePxWidth,
51
			int tilePxHeight) {
52
		super(store, tilePxWidth, tilePxHeight);
53
	}
54

  
55
	/**
56
	 * Gets the connector from the URL
57
	 * @return
58
	 * @throws RemoteServiceException
59
	 */
60
	public WMTSClient getOGCClient() throws WMTSException {
61
		if(ogcClient == null) {
62
			WMTSDataParameters p = (WMTSDataParameters)store.getParameters();
63
			ogcClient = p.getOGCClient();
64
			if(ogcClient != null)
65
				return ogcClient;
66

  
67
			URL url = null;
68
			try {
69
				url = p.getURI().toURL();
70
			} catch (Exception e) {
71
				throw new WMTSException("Malformed URL",e);
72
			}
73
			try {
74
				ogcClient = WMTSOGCLocator.getManager().createWMTSClient(url.toString());
75
				ogcClient.connect(false, new ICancellable() {
76
					public boolean isCanceled() {
77
						return false;
78
					}
79

  
80
					public Object getID() {
81
						return null;
82
					}
83
				});
84
			} catch (ConnectException e) {
85
				throw new WMTSException("Connect exception",e);
86
			} catch (IOException e) {
87
				throw new WMTSException("Connect exception",e);
88
			}
89
		}
90
		return ogcClient;
91
	}
92

  
93
	public synchronized Tile downloadTile(Tile tile) throws TileGettingException {
94
		try {
95
			WMTSStatus status = (WMTSStatus)tile.getDownloaderParams("WMTSStatus");
96
			status.setTileRow(tile.getRow());
97
			status.setTileCol(tile.getCol());
98

  
99
			String urlFromTemplate = status.getResourceURL(tile.getRow() + "" + tile.getCol() + "");
100
			//System.out.println(urlFromTemplate);
101
			File f = null;
102
			if(urlFromTemplate != null)
103
				f = getOGCClient().getTile(urlFromTemplate, tile.getCancelled(), tile.getFile());
104
			else
105
				f = getOGCClient().getTile(status, tile.getCancelled(), tile.getFile());
106
			tile.setFile(f);
107
			//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para
108
			//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros
109
			//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf");
110
			//if(rmf.exists())
111
				//rmf.delete();
112
		} catch (WMTSException e) {
113
			throw new TileGettingException(e);
114
		} catch (ServerErrorException e) {
115
			throw new TileGettingException(e);
116
		}
117
		readTileFromDisk(tile);
118
		return tile;
119
	}
120

  
121
}
0 122

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSTileServer.java
1
package org.gvsig.raster.wmts.io.downloader;
2

  
3
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
4
import org.gvsig.raster.cache.tile.provider.CacheStruct;
5
import org.gvsig.raster.cache.tile.provider.Downloader;
6
import org.gvsig.raster.cache.tile.provider.TileServer;
7
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix;
8
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink;
9

  
10
/** 
11
* Data server for the tile cache in a WMTSProvider 
12
* @author Nacho Brodin (nachobrodin@gmail.com)
13
*/
14
public class WMTSTileServer implements TileServer {
15
	private CacheStruct                struct               = null;
16
	private Downloader                 downloader           = null;
17
	private RasterDataStore            store                = null;
18
	private String                     suffix               = ".tif";
19
	private WMTSTileMatrixSetLink      tileMatrixSetLink    = null;
20
	
21
	public WMTSTileServer(RasterDataStore store, 
22
			WMTSTileMatrixSetLink tileMatrixSetLink) {
23
		this.store = store;
24
		this.tileMatrixSetLink = tileMatrixSetLink;
25
	}
26
	
27
	public Downloader getDownloader() {
28
		//if(downloader == null) {
29
			int tileWidth = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileWidth();
30
			int tileHeight = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileHeight();
31
			downloader = new TileDownloaderForWMTS(store, tileWidth, tileHeight);
32
		//}
33
		return downloader;
34
	}
35

  
36
	public CacheStruct getStruct() {
37
		if(struct == null) {
38
			struct = new WMTSCacheStruct(store, tileMatrixSetLink);
39
		}
40
		return struct;
41
	}
42
	
43
	public void setStruct(CacheStruct struct) {
44
		//La structura de cache es proporcionada por el servidor
45
	}
46
	
47
	public String getFileSuffix() {
48
		return suffix;
49
	}
50
	
51
	public void setFileSuffix(String extension) {
52
		this.suffix = extension;
53
	}
54
}
0 55

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.71/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/org.gvsig.raster.wmts-2.2.71/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.io.InputStream;
32
import java.net.MalformedURLException;
33
import java.net.URI;
34
import java.net.URISyntaxException;
35
import java.net.URL;
36
import java.net.URLConnection;
37
import java.util.List;
38

  
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

  
42
import org.gvsig.compat.net.ICancellable;
43
import org.gvsig.fmap.dal.DALLocator;
44
import org.gvsig.fmap.dal.DataManager;
45
import org.gvsig.fmap.dal.DataServerExplorerParameters;
46
import org.gvsig.fmap.dal.DataStoreParameters;
47
import org.gvsig.fmap.dal.NewDataStoreParameters;
48
import org.gvsig.fmap.dal.coverage.exception.ConnectException;
49
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer;
50
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
51
import org.gvsig.fmap.dal.exception.DataException;
52
import org.gvsig.fmap.dal.exception.InitializeException;
53
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
54
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer;
55
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
56
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
57
import org.gvsig.raster.wmts.ogc.WMTSClient;
58
import org.gvsig.raster.wmts.ogc.WMTSOGCLocator;
59

  
60
/**
61
 * Explorer for a WMTS server
62
 * @author Nacho Brodin (nachobrodin@gmail.com)
63
 */
64
public class WMTSServerExplorer extends AbstractDataServerExplorer implements RasterDataServerExplorer, DataServerExplorerProvider {
65
	public static final String           NAME                     = WMTSProvider.NAME;
66
	private WMTSClient                   ogcClient                = null;
67
//	private WMTSServerExplorerParameters parameters               = null;
68
	private static final Logger         logger                    = LoggerFactory.getLogger(WMTSServerExplorer.class);
69

  
70
	public WMTSServerExplorer(
71
			WMTSServerExplorerParameters parameters,
72
			DataServerExplorerProviderServices services)
73
			throws InitializeException {
74
                super(parameters, services);
75
//		this.parameters = parameters;
76
	}
77

  
78
	public String getDataStoreProviderName() {
79
		return WMTSProvider.NAME;
80
	}
81

  
82
	public String getDescription() {
83
		return WMTSProvider.DESCRIPTION;
84
	}
85

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

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

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

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff