Revision 9297

View differences:

org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.72/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.72</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.235</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.72</connection>
43
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.72</developerConnection>
44
        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.72</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.72</version>
61
            </dependency>
62
            <dependency>
63
                <groupId>org.gvsig</groupId>
64
                <artifactId>org.gvsig.raster.wmts.swing.impl</artifactId>
65
                <version>2.2.72</version>
66
            </dependency>
67
            <dependency>
68
                <groupId>org.gvsig</groupId>
69
                <artifactId>org.gvsig.raster.wmts.ogc.api</artifactId>
70
                <version>2.2.72</version>
71
            </dependency>
72
            <dependency>
73
                <groupId>org.gvsig</groupId>
74
                <artifactId>org.gvsig.raster.wmts.ogc.impl</artifactId>
75
                <version>2.2.72</version>
76
            </dependency>
77
            <dependency>
78
                <groupId>org.gvsig</groupId>
79
                <artifactId>org.gvsig.raster.wmts.app.wmtsclient</artifactId>
80
                <version>2.2.72</version>
81
            </dependency>
82
            <dependency>
83
                <groupId>org.gvsig</groupId>
84
                <artifactId>org.gvsig.raster.wmts.io</artifactId>
85
                <version>2.2.72</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.72/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSServerExplorerParameters.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 org.gvsig.fmap.dal.DataServerExplorerParameters;
31
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
32
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DelegatedDynObject;
35
import org.gvsig.tools.dynobject.DynClass;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.persistence.PersistenceManager;
38

  
39
/**
40
 * Parameters for the WMTS provider
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class WMTSServerExplorerParameters extends AbstractDataParameters implements DataServerExplorerParameters {
44
	protected static final String  FIELD_HOST          = "host";
45
	protected static DynClass      DYNCLASS            = null;
46
	private DelegatedDynObject     delegatedDynObject  = null;
47
	private static final String    AXIS_ORDER          = "axisorder";
48
	
49
	public WMTSServerExplorerParameters() {
50
		super();
51
		initialize();
52
	}
53

  
54
	protected void initialize() {
55
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
56
				.getDynObjectManager().createDynObject(
57
						registerDynClass());
58
	}
59
	
60
	public static DynStruct registerDynClass() {
61
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
62
		DynStruct definition = manager.getDefinition("WMTSServerExplorerParameters_Persistent");
63
		if( definition == null ) {
64
			definition = manager.addDefinition(
65
					WMTSDataParametersImpl.class,
66
					"WMTSServerExplorerParameters_Persistent",
67
					"WMTS Explorer DataParameters Persistency",
68
					null, 
69
					null
70
			);
71
		}
72

  
73
		AbstractRasterDataParameters.registerDynClass(definition);
74

  
75
		definition.addDynFieldBoolean(AXIS_ORDER)
76
		.setDescription("Longitude first in axis order")
77
		.setMandatory(false);
78

  
79
		definition.addDynFieldString(FIELD_HOST)
80
		.setDescription("Uniform Resource Identifier (File name or URL)")
81
		.setMandatory(false);		
82
		return definition;
83
	}
84
	
85
	protected DelegatedDynObject getDelegatedDynObject() {
86
		return delegatedDynObject;
87
	}
88
	
89
	/**
90
	 * Returns true if the longitude is first in axis order
91
	 * @return
92
	 */
93
	public boolean isLongitudeFirst() {
94
		Object obj = getDynValue(AXIS_ORDER);
95
		if(obj instanceof Boolean) {
96
			Boolean b = (Boolean)getDynValue(AXIS_ORDER);
97
			if(b != null)
98
				return ((Boolean)b).booleanValue();
99
		}
100
		if(obj instanceof String) {
101
			String b = (String)getDynValue(AXIS_ORDER);
102
			if(b != null)
103
				return new Boolean(((String)b));
104
		}
105
		return false;
106
	}
107
	
108
	/**
109
	 * Sets the longitude first in axis order
110
	 * @param longFirst
111
	 */
112
	public void setLongitudeFirst(boolean longFirst) {
113
		this.setDynValue(AXIS_ORDER, new Boolean(longFirst));
114
	}
115
	
116
	/**
117
	 * Gets the assigned host
118
	 * @return
119
	 */
120
	public String getHost() {
121
		return (String) this.getDynValue(FIELD_HOST);
122
	}
123

  
124
	public void setHost(String host) {
125
		this.setDynValue(FIELD_HOST, host);
126
	}
127

  
128
	public String getDataStoreName() {
129
		return WMTSProvider.NAME;
130
	}
131
	
132
	public String getDescription() {
133
		return WMTSProvider.DESCRIPTION;
134
	}
135
	
136
	public String getExplorerName() {
137
		return WMTSServerExplorer.NAME;
138
	}
139
}
0 140

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.72/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSDataParameters.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
package org.gvsig.raster.wmts.io;
24

  
25
import java.awt.geom.Rectangle2D;
26
import java.net.URI;
27

  
28
import org.cresques.cts.IProjection;
29

  
30
import org.gvsig.compat.net.ICancellable;
31
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters;
32
import org.gvsig.raster.wmts.ogc.WMTSClient;
33
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer;
34
import org.gvsig.raster.wmts.ogc.struct.WMTSStyle;
35

  
36
/**
37
 * Parameters for the WMTS provider
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public interface WMTSDataParameters extends RemoteStoreParameters {
41
	public static final String      DYNCLASS_NAME         = "WMTSDataParameters";
42
	public static final String      FIELD_IMAGE_FORMAT    = "imageformat";
43
	public static final String      FIELD_INFO_FORMAT     = "infoformat";
44
	public static final String      FIELD_NAME            = "name";
45
	public static final String      FIELD_SRSSTR          = "srsstr";
46
	public static final String      FIELD_OVERRIDE        = "override";
47
	public static final String      FIELD_WIDTH           = "width";
48
	public static final String      FIELD_HEIGHT          = "height";
49
	public static final String      FIELD_DELETECACHE     = "deletecache";
50
	public static final String      FIELD_STYLE_NAME      = "style";
51
	public static final String      FIELD_EXTENT          = "extent";
52
	public static final String      FIELD_DIMENSION       = "dimension";
53
	public static final String      FIELD_DIMENSION_VALUE = "selected_dimension_value";
54

  
55
	/**
56
	 * Gets the selected dimension
57
	 * @return
58
	 */
59
	public String getDimension();
60

  
61
	/**
62
	 * Sets the selected dimension
63
	 * @param dimension
64
	 */
65
	public void setDimension(String dimension);
66

  
67
	/**
68
	 * Gets the value for the selected dimension
69
	 * @return
70
	 */
71
	public String getDimensionSelectedValue();
72

  
73
	/**
74
	 * Sets the value for the selected dimension
75
	 * @param dimension
76
	 */
77
	public void setDimensionSelectedValue(String dimension);
78

  
79
	/**
80
	 * Sets the style selected
81
	 * @param layer
82
	 */
83
	public void setStyle(WMTSStyle layer);
84

  
85
	/**
86
	 * Gets the style
87
	 * @return
88
	 */
89
	public WMTSStyle getStyle();
90

  
91
	/**
92
	 * Gets the image format
93
	 * @return Format
94
	 */
95
	public String getImageFormat();
96

  
97
	/**
98
	 * Sets the image format
99
	 * @param format
100
	 */
101
	public void setImageFormat(String format);
102

  
103
	/**
104
	 * Gets the format of the info by point
105
	 * @return
106
	 */
107
	public String getInfoFormat();
108

  
109
	/**
110
	 * Sets the format of the info by point
111
	 */
112
	public void setInfoFormat(String format);
113

  
114
	/**
115
	 * Sets the layer selected
116
	 * @param layer
117
	 */
118
	public void setLayer(WMTSLayer layer);
119

  
120
	/**
121
	 * Gets the layer
122
	 * @return
123
	 */
124
	public WMTSLayer getLayer();
125

  
126
	/**
127
	 * Devuelve el SRS.
128
	 * @return SRS.
129
	 */
130
	public String getSRSCode();
131

  
132
	public void setSRS(String m_srs);
133

  
134
	public void setSRS(IProjection srs);
135

  
136
	/**
137
	 * Returns the projection
138
	 * @return
139
	 */
140
	public IProjection getSRS();
141

  
142
	/**
143
	 * Returns true if the layer is projected
144
	 * @return
145
	 */
146
	public boolean isProjected();
147

  
148
	public String getSRSID();
149

  
150
	public void setSRSID(String srsid);
151

  
152
	/**
153
	 * Returns the current selected SRS.
154
	 * @return
155
	 */
156
	public String getEPSG(String value);
157

  
158
	public String getName();
159

  
160
	public void setName(String name);
161

  
162
	public void setCancellable(ICancellable cancel);
163

  
164
	public ICancellable getCancellable();
165

  
166
	public boolean isOverridingHost();
167

  
168
	public void setOverrideHost(boolean over);
169
	/**
170
	 * Assigns the extent.
171
	 * When a provider is initialized this will need to know what is the extent before the request.
172
	 *
173
	 * @param bBox
174
	 */
175
	public void setExtent(Rectangle2D bBox);
176

  
177
	/**
178
	 * Sets the width
179
	 * When a provider is initialized this will need to know what is the width before the request.
180
	 * @param w
181
	 */
182
	public void setWidth(int w);
183

  
184
	/**
185
	 * Sets the height
186
	 * When a provider is initialized this will need to know what is the height before the request.
187
	 * @param h
188
	 */
189
	public void setHeight(int h);
190

  
191
	/**
192
	 * Gets the bounding box
193
	 * @return
194
	 */
195
	public Rectangle2D getExtent();
196

  
197
	/**
198
	 * Gets the width
199
	 * @return
200
	 */
201
	public int getWidth();
202

  
203
	/**
204
	 * Gets the height
205
	 * @return
206
	 */
207
	public int getHeight();
208

  
209
	public boolean isSizeFixed();
210

  
211
	public void setURI(URI uri);
212

  
213
	public URI getURI();
214

  
215
	public WMTSClient getOGCClient();
216

  
217
	public void setOGCClient(WMTSClient ogcClient);
218
}
0 219

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.72/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSDataParametersImpl.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
package org.gvsig.raster.wmts.io;
24

  
25

  
26
import java.awt.geom.Rectangle2D;
27
import java.util.List;
28

  
29
import org.cresques.cts.IProjection;
30
import org.gvsig.compat.net.ICancellable;
31
import org.gvsig.fmap.crs.CRSFactory;
32
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer;
33
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
34
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
35
import org.gvsig.raster.wmts.ogc.WMTSClient;
36
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer;
37
import org.gvsig.raster.wmts.ogc.struct.WMTSStyle;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.dynobject.DelegatedDynObject;
40
import org.gvsig.tools.dynobject.DynStruct;
41
import org.gvsig.tools.persistence.PersistenceManager;
42
import org.slf4j.LoggerFactory;
43

  
44
/**
45
 * Parameters for the WMTS provider
46
 * @author Nacho Brodin (nachobrodin@gmail.com)
47
 */
48
public class WMTSDataParametersImpl extends AbstractRasterDataParameters implements WMTSDataParameters {
49
	private DelegatedDynObject       delegatedDynObject    = null;
50
	private WMTSClient               ogcClient             = null;
51
	private ICancellable             cancel                = null;
52
	private WMTSStyle                style                 = null;
53
	private WMTSLayer                layer                 = null;
54
	
55
	public WMTSDataParametersImpl() {
56
		super();
57
		initialize();
58
	}
59
	
60
	protected void initialize() {
61
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
62
				.getDynObjectManager().createDynObject(registerDynClass());
63
	}
64
	
65
	public static DynStruct registerDynClass() {
66
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
67
		DynStruct definition = manager.getDefinition("WMTSDataParameters_Persistent");
68
		if( definition == null ) {
69
			definition = manager.addDefinition(
70
					WMTSDataParametersImpl.class,
71
					"WMTSDataParameters_Persistent",
72
					"WMTS DataParameters Persistency",
73
					null, 
74
					null
75
			);
76
		}
77

  
78
		AbstractRasterDataParameters.registerDynClass(definition);
79

  
80
		definition.addDynFieldBoolean(FIELD_DELETECACHE)
81
		.setDescription("Flag to delete cache the next request")
82
		.setMandatory(false);
83

  
84
		definition.addDynFieldInt(FIELD_WIDTH)
85
		.setDescription("Width")
86
		.setMandatory(false);
87

  
88
		definition.addDynFieldInt(FIELD_HEIGHT)
89
		.setDescription("Height")
90
		.setMandatory(false);
91

  
92
		definition.addDynFieldBoolean(FIELD_OVERRIDE)
93
		.setDescription("Override a host capabilities")
94
		.setMandatory(false);
95

  
96
		definition.addDynFieldString(FIELD_SRSSTR)
97
		.setDescription("String that represents the SRS")
98
		.setMandatory(false);		
99

  
100
		definition.addDynFieldString(FIELD_NAME)
101
		.setDescription("Layer name")
102
		.setMandatory(false);
103

  
104
		definition.addDynFieldString(FIELD_INFO_FORMAT)
105
		.setDescription("Info Format")
106
		.setMandatory(false);
107

  
108
		definition.addDynFieldString(FIELD_IMAGE_FORMAT)
109
		.setDescription("Image Format")
110
		.setMandatory(false);
111
		
112
		definition.addDynFieldString(FIELD_STYLE_NAME)
113
		.setDescription("Style")
114
		.setMandatory(false);
115
		
116
		definition.addDynFieldObject(FIELD_EXTENT)
117
		.setClassOfValue(Rectangle2D.class)
118
		.setDescription("Bounding box")
119
		.setMandatory(false);
120
		
121
		definition.addDynFieldString(FIELD_DIMENSION)
122
		.setDescription("Dimensions")
123
		.setMandatory(false);
124
		
125
		definition.addDynFieldString(FIELD_DIMENSION_VALUE)
126
		.setDescription("Value selected for the current dimension")
127
		.setMandatory(false);
128
		
129
		return definition;
130
	}
131
	
132
	/**
133
	 * Gets the selected dimension
134
	 * @return
135
	 */
136
	public String getDimension() {
137
		return (String)getDynValue(FIELD_DIMENSION);
138
	}
139
	
140
	/**
141
	 * Sets the selected dimension
142
	 * @param dimension
143
	 */
144
	public void setDimension(String dimension) {
145
		setDynValue(FIELD_DIMENSION, dimension);
146
	}
147
	
148
	/**
149
	 * Gets the value for the selected dimension
150
	 * @return
151
	 */
152
	public String getDimensionSelectedValue() {
153
		return (String)getDynValue(FIELD_DIMENSION_VALUE);
154
	}
155
	
156
	/**
157
	 * Sets the value for the selected dimension
158
	 * @param dimension
159
	 */
160
	public void setDimensionSelectedValue(String dimension) {
161
		setDynValue(FIELD_DIMENSION_VALUE, dimension);
162
	}
163
	
164
	/**
165
	 * Gets the bounding box
166
	 * @return
167
	 */
168
	public Rectangle2D getExtent() {
169
		return (Rectangle2D)getDynValue(FIELD_EXTENT);
170
	}
171
	
172
	/**
173
	 * Assigns the extent. 
174
	 * When a provider is initialized this will need to know what is the extent before the request.
175
	 * 
176
	 * @param bBox
177
	 */
178
	public void setExtent(Rectangle2D bBox) {
179
		setDynValue(FIELD_EXTENT, bBox);
180
	}
181
	
182
	/**
183
	 * Sets the style selected
184
	 * @param layer
185
	 */
186
	public void setStyle(WMTSStyle style) {
187
		setDynValue(FIELD_STYLE_NAME, style.getTitle());
188
		this.style = style;
189
	}
190
	
191
	/**
192
	 * Gets the style
193
	 * @return
194
	 */
195
	public WMTSStyle getStyle() {
196
		return style;
197
	}
198
	
199
	/**
200
	 * Gets the image format
201
	 * @return Format
202
	 */
203
	public String getImageFormat() {
204
		return (String) this.getDynValue(FIELD_IMAGE_FORMAT);
205
	}
206

  
207
	/**
208
	 * Sets the image format
209
	 * @param format
210
	 */
211
	public void setImageFormat(String format) {
212
		this.setDynValue(FIELD_IMAGE_FORMAT, format);
213
	}
214
	
215
	public String getInfoFormat() {
216
		return (String) this.getDynValue(FIELD_INFO_FORMAT);
217
	}
218

  
219
	public void setInfoFormat(String format) {
220
		this.setDynValue(FIELD_INFO_FORMAT, format);
221
	}
222
	
223
	/**
224
	 * Devuelve el SRS.
225
	 * @return SRS.
226
	 */
227
	public String getSRSCode() {
228
		return (String) this.getDynValue(FIELD_SRSSTR);
229
	}
230
	
231
	public void setSRS(String m_srs) {
232
		m_srs = srsValidation(m_srs);
233
		this.setDynValue(FIELD_SRSSTR, m_srs);
234
		if(getEPSG(m_srs) != null)
235
			setSRS(CRSFactory.getCRS(getEPSG(m_srs)));
236
	}
237
	
238
	private String srsValidation(String srs) {
239
		if(srs == null)
240
			return null;
241
		if(srs.contains("CRS:84") || srs.contains("CRS84")) {
242
			return "EPSG:4326";
243
		}
244
		
245
		if(srs.startsWith("EPSG") && !srs.startsWith("EPSG:")) {
246
			return "EPSG:" + srs.substring(srs.lastIndexOf("EPSG") + 1);
247
		}
248
 			
249
		if(srs.contains("EPSG:") && !srs.startsWith("EPSG:")) {
250
			return "EPSG:" + srs.substring(srs.lastIndexOf(":") + 1);
251
		}
252
		return srs;
253
	}
254
	
255
	/**
256
	 * Returns true if the layer is projected
257
	 * @return
258
	 */
259
	public boolean isProjected() {
260
		IProjection proj = getSRS();
261
		if(proj == null)
262
			return true;
263
		else {
264
			try {
265
				return proj.isProjected();
266
			} catch (Exception e) {
267
				LoggerFactory.getLogger(WMTSDataParameters.class).debug("error in projection", e);
268
				return true;
269
			}
270
		}
271
	}
272
	
273
	/**
274
	 * Returns the current selected SRS.
275
	 * @return
276
	 */
277
	public String getEPSG(String value) {
278
		if(value != null) {
279
			if(value.compareTo("CRS:84") == 0)
280
				return "EPSG:4326";
281

  
282
			String s = value.substring(value.lastIndexOf(":") + 1);
283
			return "EPSG:" + s;
284
		}
285
		return null;
286
	}
287
	
288
	public String getName() {
289
		return (String) this.getDynValue(FIELD_NAME);
290
	}
291

  
292
	public void setName(String name) {
293
		this.setDynValue(FIELD_NAME, name);
294
	}
295
	
296
	public boolean isOverridingHost() {
297
		Boolean b = (Boolean)getDynValue(FIELD_OVERRIDE);
298
		if(b != null)
299
			return ((Boolean)b).booleanValue();
300
		return false;
301
	}
302
	
303
	public void setOverrideHost(boolean over) {
304
		this.setDynValue(FIELD_OVERRIDE, new Boolean(over));;
305
	}
306

  
307
	/**
308
	 * Sets the width
309
	 * When a provider is initialized this will need to know what is the width before the request.
310
	 * @param w
311
	 */
312
	public void setWidth(int w) {
313
		this.setDynValue(FIELD_WIDTH, new Integer(w));
314
	}
315
	
316
	/**
317
	 * Sets the height
318
	 * When a provider is initialized this will need to know what is the height before the request.
319
	 * @param h
320
	 */
321
	public void setHeight(int h) {
322
		this.setDynValue(FIELD_HEIGHT, new Integer(h));
323
	}
324
	
325
	/**
326
	 * Gets the width
327
	 * @return
328
	 */
329
	public int getWidth() {
330
		Integer b = (Integer)getDynValue(FIELD_WIDTH);
331
		if(b != null)
332
			return ((Integer)b).intValue();
333
		return 0;
334
	}
335
	
336
	/**
337
	 * Gets the height
338
	 * @return
339
	 */
340
	public int getHeight() {
341
		Integer b = (Integer)getDynValue(FIELD_HEIGHT);
342
		if(b != null)
343
			return ((Integer)b).intValue();
344
		return 0;
345
	}
346
	
347
	public void deleteCache(boolean deleteCache) {
348
		this.setDynValue(FIELD_DELETECACHE, new Boolean(deleteCache));
349
	}
350
	
351
	public boolean isDeletingCache() {
352
		return ((Boolean)getDynValue(FIELD_DELETECACHE)).booleanValue();
353
	}
354

  
355
	//**********************************************
356
	
357
	public String getDataStoreName() {
358
		return WMTSProvider.NAME;
359
	}
360
	
361
	public String getDescription() {
362
		return WMTSProvider.DESCRIPTION;
363
	}
364

  
365
	public String getExplorerName() {
366
		return WMTSServerExplorer.NAME;
367
	}
368
	
369
	public boolean isValid() {
370
		return (this.getURI() != null);
371
	}
372
	
373
	protected DelegatedDynObject getDelegatedDynObject() {
374
		return delegatedDynObject;
375
	}
376
	
377
	/**
378
	 * Clones this structure
379
	 * @return
380
	 */
381
	public WMTSDataParameters clone() {
382
		WMTSDataParametersImpl p = new WMTSDataParametersImpl();
383
		p.setImageFormat(getImageFormat());
384
		p.setInfoFormat(getInfoFormat());
385
		p.setHeight(getHeight());
386
		p.setWidth(getWidth());
387
		p.setExtent(getExtent());
388
		p.setURI(getURI());
389
		p.setName(getName());
390
		p.setOverrideHost(isOverridingHost());
391
		p.setSRS(getSRS());
392
		p.setSRS(getSRSCode());
393
		p.setCancellable(getCancellable());
394
		return p;
395
	}
396

  
397
	public boolean isSizeFixed() {
398
		return true;
399
	}
400

  
401
	public WMTSClient getOGCClient() {
402
		return ogcClient;
403
	}
404
	
405
	public void setOGCClient(WMTSClient ogcClient) {
406
		this.ogcClient = ogcClient;
407
	}
408
	
409
	/**
410
	 * Sets the layer selected
411
	 * @param layer
412
	 */
413
	public void setLayer(WMTSLayer layer) {
414
		setName(layer.getTitle());
415
		this.layer = layer;
416
	}
417
	
418
	/**
419
	 * Gets the layer
420
	 * @return
421
	 */
422
	public WMTSLayer getLayer() {
423
		return layer;
424
	}
425
	
426
	public void setCancellable(ICancellable cancel) {
427
		this.cancel = cancel;
428
	}
429
	
430
	public ICancellable getCancellable() {
431
		return cancel;
432
	}
433
	
434
	public void assignFields(RasterDataParameters par, RasterDataServerExplorer explorer) {
435
		super.assignFields(par, explorer);
436
		WMTSDataParameters p = null;
437
		if(par instanceof WMTSDataParameters)
438
			p = (WMTSDataParameters)par;
439
		else
440
			return;
441
		
442
		setWidth(p.getWidth());
443
		setHeight(p.getHeight());
444
		setImageFormat(p.getImageFormat());
445
		setInfoFormat(p.getInfoFormat());
446
		setName(p.getName());
447
		setSRS(p.getSRSCode());
448
		setOverrideHost(p.isOverridingHost());
449
		setExtent(p.getExtent());
450
		
451
		if(explorer instanceof WMTSServerExplorer) {
452
			WMTSLayer wmtsLayer = ((WMTSServerExplorer)explorer).getOGCClient().getLayer(p.getName());
453
			setLayer(wmtsLayer);
454
			List<WMTSStyle> wmtsStyles = wmtsLayer.getStyle();
455
			for (int i = 0; i < wmtsStyles.size(); i++) {
456
				WMTSStyle style = wmtsStyles.get(i);
457
				if(style.getTitle() != null && style.getTitle().equals((String)getDynValue(FIELD_STYLE_NAME))) {
458
					this.style = style;
459
				}
460
			}
461
			if(this.style == null && wmtsStyles.size() > 0)
462
				this.style = wmtsStyles.get(0);
463
		}
464
	}
465
	
466
}
0 467

  
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.72/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.72/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.72/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.72/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.72/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

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

Also available in: Unified diff