Revision 2074
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuración general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
|
0 | 152 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/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.1.0-SNAPSHOT</version> |
|
7 |
<name>org.gvsig.raster.wmts</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.16-SNAPSHOT</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<scm> |
|
18 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/trunk/org.gvsig.raster.wmts</connection> |
|
19 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/trunk/org.gvsig.raster.wmts</developerConnection> |
|
20 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.wmts/trunk/org.gvsig.raster.wmts</url> |
|
21 |
</scm> |
|
22 |
|
|
23 |
<dependencyManagement> |
|
24 |
<dependencies> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.raster.wmts.swing.api</artifactId> |
|
28 |
<version>2.1.0-SNAPSHOT</version> |
|
29 |
</dependency> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.raster.wmts.ogc.api</artifactId> |
|
33 |
<version>2.1.0-SNAPSHOT</version> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.raster.wmts.ogc.impl</artifactId> |
|
38 |
<version>2.1.0-SNAPSHOT</version> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
42 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
43 |
<version>2.1.0-SNAPSHOT</version> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
48 |
<version>2.1.0-SNAPSHOT</version> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
53 |
<version>2.1.0-SNAPSHOT</version> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>org.gvsig</groupId> |
|
57 |
<artifactId>org.gvsig.raster.tools.app.basic</artifactId> |
|
58 |
<version>2.1.0-SNAPSHOT</version> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.raster.wmts.io</artifactId> |
|
63 |
<version>2.1.0-SNAPSHOT</version> |
|
64 |
</dependency> |
|
65 |
<dependency> |
|
66 |
<groupId>org.gvsig</groupId> |
|
67 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
68 |
<version>2.1.0-SNAPSHOT</version> |
|
69 |
</dependency> |
|
70 |
</dependencies> |
|
71 |
</dependencyManagement> |
|
72 |
|
|
73 |
<developers> |
|
74 |
<developer> |
|
75 |
<id>nbrodin</id> |
|
76 |
<name>Nacho Brodin</name> |
|
77 |
<email>nachobrodin@gmail.com</email> |
|
78 |
<roles> |
|
79 |
<role>Architect</role> |
|
80 |
<role>Developer</role> |
|
81 |
</roles> |
|
82 |
</developer> |
|
83 |
</developers> |
|
84 |
|
|
85 |
<build> |
|
86 |
<plugins> |
|
87 |
<plugin> |
|
88 |
<groupId>org.apache.maven.plugins</groupId> |
|
89 |
<artifactId>maven-release-plugin</artifactId> |
|
90 |
<configuration> |
|
91 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wmts/tags/</tagBase> |
|
92 |
<goals>deploy</goals> |
|
93 |
</configuration> |
|
94 |
</plugin> |
|
95 |
</plugins> |
|
96 |
</build> |
|
97 |
|
|
98 |
<modules> |
|
99 |
<!--<module>org.gvsig.raster.wmts.swing</module>--> |
|
100 |
<module>org.gvsig.raster.wmts.io</module> |
|
101 |
<module>org.gvsig.raster.wmts.app.wmtsclient</module> |
|
102 |
<module>org.gvsig.raster.wmts.ogc</module> |
|
103 |
</modules> |
|
104 |
</project> |
|
0 | 105 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.wmts.io.DefaultWMTSIOLibrary |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/TileDownloaderForWMTS.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wmts.io.downloader; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.net.ConnectException; |
|
27 |
import java.net.URL; |
|
28 |
|
|
29 |
import org.gvsig.compat.net.ICancellable; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
31 |
import org.gvsig.raster.cache.tile.Tile; |
|
32 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
33 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
|
34 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
35 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
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(WMTSProvider prov, |
|
50 |
int tilePxWidth, |
|
51 |
int tilePxHeight) { |
|
52 |
super(prov, 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)prov.getDataParameters(); |
|
63 |
ogcClient = p.getOGCClient(); |
|
64 |
if(ogcClient != null) |
|
65 |
return ogcClient; |
|
66 |
|
|
67 |
URL url = null; |
|
68 |
try { |
|
69 |
url = new URL(p.getURI()); |
|
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 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#getTile(org.gvsig.raster.cache.tile.Tile) |
|
96 |
*/ |
|
97 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
98 |
try { |
|
99 |
WMTSStatus status = (WMTSStatus)tile.getDownloaderParams("WMTSStatus"); |
|
100 |
status.setTileRow(tile.getRow()); |
|
101 |
status.setTileCol(tile.getCol()); |
|
102 |
File f = getOGCClient().getTile(status, tile.getCancelled(), tile.getFile()); |
|
103 |
tile.setFile(f); |
|
104 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
|
105 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
|
106 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
|
107 |
//if(rmf.exists()) |
|
108 |
//rmf.delete(); |
|
109 |
} catch (WMTSException e) { |
|
110 |
throw new TileGettingException(e); |
|
111 |
} catch (ServerErrorException e) { |
|
112 |
throw new TileGettingException(e); |
|
113 |
} |
|
114 |
readTileFromDisk(tile); |
|
115 |
return tile; |
|
116 |
} |
|
117 |
|
|
118 |
} |
|
0 | 119 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSTileServer.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wmts.io.downloader; |
|
23 |
|
|
24 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
25 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
26 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
27 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
28 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
29 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
30 |
|
|
31 |
/** |
|
32 |
* Data server for the tile cache in a WMTSProvider |
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
34 |
*/ |
|
35 |
public class WMTSTileServer implements TileServer { |
|
36 |
private CacheStruct struct = null; |
|
37 |
private Downloader downloader = null; |
|
38 |
private WMTSProvider provider = null; |
|
39 |
private String suffix = ".tif"; |
|
40 |
private WMTSTileMatrixSetLink tileMatrixSetLink = null; |
|
41 |
|
|
42 |
public WMTSTileServer(WMTSProvider prov, |
|
43 |
WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
44 |
this.provider = prov; |
|
45 |
this.tileMatrixSetLink = tileMatrixSetLink; |
|
46 |
} |
|
47 |
|
|
48 |
/* |
|
49 |
* (non-Javadoc) |
|
50 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getDownloader() |
|
51 |
*/ |
|
52 |
public Downloader getDownloader() { |
|
53 |
//if(downloader == null) { |
|
54 |
int tileWidth = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileWidth(); |
|
55 |
int tileHeight = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileHeight(); |
|
56 |
downloader = new TileDownloaderForWMTS(provider, tileWidth, tileHeight); |
|
57 |
//} |
|
58 |
return downloader; |
|
59 |
} |
|
60 |
|
|
61 |
public CacheStruct getStruct() { |
|
62 |
if(struct == null) { |
|
63 |
struct = new WMTSCacheStruct(provider, tileMatrixSetLink); |
|
64 |
} |
|
65 |
return struct; |
|
66 |
} |
|
67 |
|
|
68 |
/* |
|
69 |
* (non-Javadoc) |
|
70 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setStruct(org.gvsig.raster.cache.tile.provider.CacheStruct) |
|
71 |
*/ |
|
72 |
public void setStruct(CacheStruct struct) { |
|
73 |
//La structura de cache es proporcionada por el servidor |
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getFileSuffix() |
|
79 |
*/ |
|
80 |
public String getFileSuffix() { |
|
81 |
return suffix; |
|
82 |
} |
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setFileExtension(java.lang.String) |
|
87 |
*/ |
|
88 |
public void setFileSuffix(String extension) { |
|
89 |
this.suffix = extension; |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSCacheStruct.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wmts.io.downloader; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
31 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
32 |
import org.gvsig.raster.cache.tile.Tile; |
|
33 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
34 |
import org.gvsig.raster.cache.tile.exception.TileBuildException; |
|
35 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
36 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
37 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
38 |
import org.gvsig.raster.wmts.ogc.WMTSStatus; |
|
39 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTile; |
|
40 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
41 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixLimits; |
|
42 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSet; |
|
43 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
44 |
|
|
45 |
/** |
|
46 |
* Implementation for a structure of a cache |
|
47 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
48 |
*/ |
|
49 |
public class WMTSCacheStruct implements CacheStruct { |
|
50 |
private String layerName = null; |
|
51 |
private String serverURL = null; |
|
52 |
private WMTSTileMatrixSet tileMatrixSet = null; |
|
53 |
private List<WMTSTileMatrixLimits> tileMatrixSetLimits = null; |
|
54 |
private double[] pixelSize = null; |
|
55 |
private WMTSProvider provider = null; |
|
56 |
|
|
57 |
public WMTSCacheStruct(WMTSProvider provider, WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
58 |
this.provider = provider; |
|
59 |
this.tileMatrixSet = tileMatrixSetLink.getTileMatrixSet(); |
|
60 |
this.tileMatrixSetLimits = tileMatrixSetLink.getTileMatrixLimits(); |
|
61 |
pixelSize = provider.getPixelSizeByLevel(); |
|
62 |
serverURL = provider.getURIOfFirstProvider(); |
|
63 |
layerName = ((WMTSDataParameters)provider.getDataParameters()).getLayer().getTitle(); |
|
64 |
} |
|
65 |
|
|
66 |
/* |
|
67 |
* (non-Javadoc) |
|
68 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getNumberOfLevels() |
|
69 |
*/ |
|
70 |
public int getNumberOfLevels() { |
|
71 |
return tileMatrixSet.getTileMatrix().size(); |
|
72 |
} |
|
73 |
|
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerName() |
|
77 |
*/ |
|
78 |
public String getLayerName() { |
|
79 |
return layerName; |
|
80 |
} |
|
81 |
|
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getServerURL() |
|
85 |
*/ |
|
86 |
public String getServerURL() { |
|
87 |
return serverURL; |
|
88 |
} |
|
89 |
|
|
90 |
/* |
|
91 |
* (non-Javadoc) |
|
92 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileSizeByLevel(int) |
|
93 |
*/ |
|
94 |
public int[] getTileSizeByLevel(int level) { |
|
95 |
return new int[] { |
|
96 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(), |
|
97 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight() |
|
98 |
}; |
|
99 |
} |
|
100 |
|
|
101 |
/* |
|
102 |
* (non-Javadoc) |
|
103 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerWidthOfTileMatrixByLevel(int) |
|
104 |
*/ |
|
105 |
public int getLayerWidthOfTileMatrixByLevel(int level) { |
|
106 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
107 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
108 |
return l.getMaxTileRow() - l.getMinTileRow(); |
|
109 |
} else { |
|
110 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
111 |
return (int)tm.getMatrixWidth(); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerHeightOfTileMatrixByLevel(int) |
|
118 |
*/ |
|
119 |
public int getLayerHeightOfTileMatrixByLevel(int level) { |
|
120 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
121 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
122 |
return l.getMaxTileCol() - l.getMinTileCol(); |
|
123 |
} else { |
|
124 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
125 |
return (int)tm.getMatrixHeight(); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
/* |
|
130 |
* (non-Javadoc) |
|
131 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerInitXTilePositionByLevel(int) |
|
132 |
*/ |
|
133 |
public int getLayerInitXTilePositionByLevel(int level) { |
|
134 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
135 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
136 |
return l.getMinTileCol(); |
|
137 |
} else |
|
138 |
return 0; |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
* (non-Javadoc) |
|
143 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerInitYTilePositionByLevel(int) |
|
144 |
*/ |
|
145 |
public int getLayerInitYTilePositionByLevel(int level) { |
|
146 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
147 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
148 |
return l.getMinTileRow(); |
|
149 |
} else |
|
150 |
return 0; |
|
151 |
} |
|
152 |
|
|
153 |
/* |
|
154 |
* (non-Javadoc) |
|
155 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getWorldHeightOfTileMatrixByLevel(int) |
|
156 |
*/ |
|
157 |
public long getWorldHeightOfTileMatrixByLevel(int level) { |
|
158 |
return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixWidth(); |
|
159 |
} |
|
160 |
|
|
161 |
/* |
|
162 |
* (non-Javadoc) |
|
163 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getWorldWidthOfTileMatrixByLevel(int) |
|
164 |
*/ |
|
165 |
public long getWorldWidthOfTileMatrixByLevel(int level) { |
|
166 |
return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixHeight(); |
|
167 |
} |
|
168 |
|
|
169 |
/* |
|
170 |
* (non-Javadoc) |
|
171 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getPixelSizeByLevel(int) |
|
172 |
*/ |
|
173 |
public double getPixelSizeByLevel(int level) { |
|
174 |
if(level < pixelSize.length) |
|
175 |
return pixelSize[level]; |
|
176 |
else |
|
177 |
return pixelSize[pixelSize.length - 1]; |
|
178 |
} |
|
179 |
|
|
180 |
/* |
|
181 |
* (non-Javadoc) |
|
182 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileExtent(org.gvsig.raster.cache.tile.Tile) |
|
183 |
*/ |
|
184 |
public Point2D[] getTileExtent(Tile tile) { |
|
185 |
return getTileExtent(tile.getLevel(), tile.getCol(), tile.getRow()); |
|
186 |
} |
|
187 |
|
|
188 |
/* |
|
189 |
* (non-Javadoc) |
|
190 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileExtent(int, int, int) |
|
191 |
*/ |
|
192 |
public Point2D[] getTileExtent(int level, int col, int row) { |
|
193 |
double[] ul = tileMatrixSet.getBoundingBox().getUpperCorner(); |
|
194 |
long tileWidth = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(); |
|
195 |
long tileHeight = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight(); |
|
196 |
double mtsWidthTile = tileWidth * pixelSize[level]; |
|
197 |
double mtsHeightTile = tileHeight * pixelSize[level]; |
|
198 |
double ulx = ul[0] + (col * mtsWidthTile); |
|
199 |
double uly = ulx + mtsWidthTile; |
|
200 |
double lrx = ul[1] - (row * mtsHeightTile); |
|
201 |
double lry = lrx - mtsHeightTile; |
|
202 |
return new Point2D[]{new Point2D.Double(ulx, uly), new Point2D.Double(lrx, lry)}; |
|
203 |
} |
|
204 |
|
|
205 |
/* |
|
206 |
* (non-Javadoc) |
|
207 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileStructure(int, int, int, java.awt.geom.Point2D, java.awt.geom.Point2D) |
|
208 |
*/ |
|
209 |
public Tile getTileStructure(int level, int tileCol, int tileRow, Point2D ul, Point2D lr) throws TileBuildException { |
|
210 |
int[] size = getTileSizeByLevel(level); |
|
211 |
Tile tile = TileCacheLocator.getManager().createTile(level, tileRow, tileCol); |
|
212 |
tile.setUl(ul); |
|
213 |
tile.setLr(lr); |
|
214 |
tile.setWidthPx(size[0]); |
|
215 |
tile.setHeightPx(size[1]); |
|
216 |
|
|
217 |
Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()), |
|
218 |
Math.min(ul.getY(), lr.getY()), |
|
219 |
Math.abs(ul.getX() - lr.getX()), |
|
220 |
Math.abs(ul.getY() - lr.getY())); |
|
221 |
int bufWidth = (int)(r.getWidth() / getPixelSizeByLevel(level)); |
|
222 |
int bufHeight = (int)(r.getHeight() / getPixelSizeByLevel(level)); |
|
223 |
try { |
|
224 |
WMTSStatus status = provider.buildWMTSStatus(r, bufWidth, bufHeight); |
|
225 |
tile.setDownloaderParams("WMTSStatus", status); |
|
226 |
} catch (RasterDriverException e) { |
|
227 |
throw new TileBuildException(e); |
|
228 |
} |
|
229 |
|
|
230 |
return tile; |
|
231 |
} |
|
232 |
|
|
233 |
public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest) throws TileBuildException { |
|
234 |
Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()), |
|
235 |
Math.min(ul.getY(), lr.getY()), |
|
236 |
Math.abs(ul.getX() - lr.getX()), |
|
237 |
Math.abs(ul.getY() - lr.getY())); |
|
238 |
int bufWidth = (int)(r.getWidth() / mtsPixelRequest); |
|
239 |
int bufHeight = (int)(r.getHeight() / mtsPixelRequest); |
|
240 |
try { |
|
241 |
WMTSStatus status = provider.buildWMTSStatus(r, bufWidth, bufHeight); |
|
242 |
|
|
243 |
//Conversi?n a tiles de la librer?a |
|
244 |
List<WMTSTile> tiles = status.getTileList(); |
|
245 |
List<Tile> tileList = new ArrayList<Tile>(); |
|
246 |
for (int i = 0; i < tiles.size(); i++) { |
|
247 |
WMTSTile tOrigin = (WMTSTile) tiles.get(i); |
|
248 |
Tile t = TileCacheLocator.getManager().createTile(status.getLevel(), tOrigin.getCol(), tOrigin.getRow()); |
|
249 |
t.setUl(new Point2D.Double(tOrigin.getULX(), tOrigin.getULY())); |
|
250 |
t.setLr(new Point2D.Double(tOrigin.getLRX(), tOrigin.getLRY())); |
|
251 |
t.setWidthPx(tOrigin.getWidthPx()); |
|
252 |
t.setHeightPx(tOrigin.getHeightPx()); |
|
253 |
t.setDownloaderParams("WMTSStatus", status.cloneStatus()); |
|
254 |
tileList.add(t); |
|
255 |
} |
|
256 |
return tileList; |
|
257 |
} catch (RasterDriverException e) { |
|
258 |
throw new TileBuildException(e); |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
/* |
|
263 |
* (non-Javadoc) |
|
264 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileSizeInRealCoordsByLevel(int) |
|
265 |
*/ |
|
266 |
public double[] getTileSizeInRealCoordsByLevel(int level) { |
|
267 |
return new double[] { |
|
268 |
getPixelSizeByLevel(level) * getTileSizeByLevel(level)[0], |
|
269 |
getPixelSizeByLevel(level) * getTileSizeByLevel(level)[1] |
|
270 |
}; |
|
271 |
} |
|
272 |
|
|
273 |
/* |
|
274 |
* (non-Javadoc) |
|
275 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getFileSuffix() |
|
276 |
*/ |
|
277 |
public String getFileSuffix() { |
|
278 |
return provider.getFileSuffix(); |
|
279 |
} |
|
280 |
|
|
281 |
/* |
|
282 |
* (non-Javadoc) |
|
283 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#compare(org.gvsig.raster.cache.tile.provider.CacheStruct) |
|
284 |
*/ |
|
285 |
public boolean compare(CacheStruct struct) { |
|
286 |
MathUtils mu = RasterLocator.getManager().getMathUtils(); |
|
287 |
//Compara: n?mero de niveles, tama?o de tile, |
|
288 |
//anchoXalto de la matriz, tama?o de pixel por nivel, |
|
289 |
//coordenadas de al menos un tile de la matriz |
|
290 |
if(struct.getNumberOfLevels() == getNumberOfLevels()) { |
|
291 |
for (int i = 0; i < getNumberOfLevels(); i++) { |
|
292 |
if( struct.getTileSizeByLevel(i)[0] == getTileSizeByLevel(i)[0] && |
|
293 |
struct.getTileSizeByLevel(i)[1] == getTileSizeByLevel(i)[1] && |
|
294 |
struct.getWorldHeightOfTileMatrixByLevel(i) == getWorldHeightOfTileMatrixByLevel(i) && |
|
295 |
struct.getWorldWidthOfTileMatrixByLevel(i) == getWorldWidthOfTileMatrixByLevel(i) && |
|
296 |
mu.clipDecimals(struct.getPixelSizeByLevel(i), 2) == mu.clipDecimals(getPixelSizeByLevel(i), 2) && |
|
297 |
compareExtents(struct.getTileExtent(i, 0, 0), getTileExtent(i, 0, 0))) { |
|
298 |
return true; |
|
299 |
} |
|
300 |
} |
|
301 |
} |
|
302 |
return false; |
|
303 |
} |
|
304 |
|
|
305 |
private boolean compareExtents(Point2D[] p, Point2D[] p1) { |
|
306 |
return (p[0].getX() == p1[0].getX() && p[0].getY() == p1[0].getY() && |
|
307 |
p[1].getX() == p1[1].getX() && p[1].getY() == p1[1].getY()); |
|
308 |
} |
|
309 |
|
|
310 |
/* |
|
311 |
* (non-Javadoc) |
|
312 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getEPSG() |
|
313 |
*/ |
|
314 |
public String getEPSG() { |
|
315 |
/*IProjection proj = provider.getProjection(); |
|
316 |
if(proj != null) |
|
317 |
return proj.getAbrev(); |
|
318 |
return null;*/ |
|
319 |
return provider.getSRSCode(); |
|
320 |
} |
|
321 |
|
|
322 |
/* |
|
323 |
* (non-Javadoc) |
|
324 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getFileSize() |
|
325 |
*/ |
|
326 |
public String getFileSize() { |
|
327 |
return "0"; |
|
328 |
} |
|
329 |
|
|
330 |
public List<Tile> getTileList(int x, int y, int w, int h) { |
|
331 |
return null; |
|
332 |
} |
|
333 |
|
|
334 |
public ArrayList<Tile> getTileList(Rectangle2D r) { |
|
335 |
return null; |
|
336 |
} |
|
337 |
} |
|
0 | 338 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.raster.wmts.io package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>WMTS provider</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSServerExplorer.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.raster.wmts.io; |
|
29 |
|
|
30 |
import java.io.IOException; |
|
31 |
import java.io.InputStream; |
|
32 |
import java.net.InetAddress; |
|
33 |
import java.net.MalformedURLException; |
|
34 |
import java.net.URL; |
|
35 |
import java.net.URLConnection; |
|
36 |
import java.net.UnknownHostException; |
|
37 |
import java.util.List; |
|
38 |
|
|
39 |
import org.gvsig.compat.net.ICancellable; |
|
40 |
import org.gvsig.fmap.dal.DALLocator; |
|
41 |
import org.gvsig.fmap.dal.DataManager; |
|
42 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
43 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
44 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
45 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
46 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
47 |
import org.gvsig.fmap.dal.exception.DataException; |
|
48 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
49 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
50 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
51 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
52 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
53 |
import org.gvsig.raster.wmts.ogc.WMTSOGCLocator; |
|
54 |
import org.gvsig.raster.wmts.ogc.exception.WMTSException; |
|
55 |
|
|
56 |
/** |
|
57 |
* Explorer for a WMTS server |
|
58 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
59 |
*/ |
|
60 |
public class WMTSServerExplorer implements DataServerExplorer, DataServerExplorerProvider { |
|
61 |
public static final String NAME = "WMTSRemoteServerExplorer"; |
|
62 |
private WMTSClient ogcClient = null; |
|
63 |
private WMTSServerExplorerParameters parameters = null; |
|
64 |
|
|
65 |
public WMTSServerExplorer( |
|
66 |
WMTSServerExplorerParameters parameters, |
|
67 |
DataServerExplorerProviderServices services) |
|
68 |
throws InitializeException { |
|
69 |
this.parameters = parameters; |
|
70 |
} |
|
71 |
|
|
72 |
public String getDataStoreProviderName() { |
|
73 |
return WMTSProvider.NAME; |
|
74 |
} |
|
75 |
|
|
76 |
public String getDescription() { |
|
77 |
return WMTSProvider.DESCRIPTION; |
|
78 |
} |
|
79 |
|
|
80 |
public DataStoreParameters getStoreParameters() { |
|
81 |
DataManager manager = DALLocator.getDataManager(); |
|
82 |
WMTSDataParameters wmtsParams = null; |
|
83 |
try { |
|
84 |
wmtsParams = (WMTSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName()); |
|
85 |
wmtsParams.setURI(parameters.getHost()); |
|
86 |
wmtsParams.setOGCClient(getOGCClient()); |
|
87 |
|
|
88 |
if(WMTSProvider.TILED) { |
|
89 |
TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store"); |
|
90 |
tileParams.setDataParameters(wmtsParams); |
|
91 |
return tileParams; |
|
92 |
} |
|
93 |
} catch (InitializeException e) { |
|
94 |
e.printStackTrace(); |
|
95 |
} catch (ProviderNotRegisteredException e) { |
|
96 |
e.printStackTrace(); |
|
97 |
} |
|
98 |
return wmtsParams; |
|
99 |
} |
|
100 |
|
|
101 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
102 |
boolean overwrite) throws DataException { |
|
103 |
return false; |
|
104 |
} |
|
105 |
|
|
106 |
public boolean canAdd() { |
|
107 |
return false; |
|
108 |
} |
|
109 |
|
|
110 |
public boolean canAdd(String storeName) throws DataException { |
|
111 |
return false; |
|
112 |
} |
|
113 |
|
|
114 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
115 |
throws DataException { |
|
116 |
return null; |
|
117 |
} |
|
118 |
|
|
119 |
public List<?> getDataStoreProviderNames() { |
|
120 |
return null; |
|
121 |
} |
|
122 |
|
|
123 |
/* |
|
124 |
* (non-Javadoc) |
|
125 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getParameters() |
|
126 |
*/ |
|
127 |
public DataServerExplorerParameters getParameters() { |
|
128 |
return parameters; |
|
129 |
} |
|
130 |
|
|
131 |
public List<?> list() throws DataException { |
|
132 |
return null; |
|
133 |
} |
|
134 |
|
|
135 |
public List<?> list(int mode) throws DataException { |
|
136 |
return null; |
|
137 |
} |
|
138 |
|
|
139 |
public void remove(DataStoreParameters parameters) throws DataException { |
|
140 |
|
|
141 |
} |
|
142 |
|
|
143 |
public void dispose() { |
|
144 |
|
|
145 |
} |
|
146 |
|
|
147 |
public String getProviderName() { |
|
148 |
return null; |
|
149 |
} |
|
150 |
|
|
151 |
//********************************************** |
|
152 |
//Connector |
|
153 |
//********************************************** |
|
154 |
|
|
155 |
public void connect(ICancellable cancellable) throws WMTSException { |
|
156 |
URL url = null; |
|
157 |
boolean override = false; |
|
158 |
|
|
159 |
try { |
|
160 |
url = new URL(parameters.getHost()); |
|
161 |
} catch (Exception e) { |
|
162 |
throw new WMTSException("Malformed URL",e); |
|
163 |
} |
|
164 |
try { |
|
165 |
ogcClient = WMTSOGCLocator.getManager().createWMTSClient(url.toString()); |
|
166 |
ogcClient.setForceLongitudeFirstAxisOrder(parameters.isLongitudeFirst()); |
|
167 |
if (!ogcClient.connect(override, cancellable)) |
|
168 |
throw new WMTSException("Error connecting"); |
|
169 |
} catch (IOException e) { |
|
170 |
throw new WMTSException(e.getMessage(), e); |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Checks if the network and host are reachable |
|
176 |
* @param timeout for the host |
|
177 |
* @return true if both are reachable and false if they are not |
|
178 |
*/ |
|
179 |
public boolean isHostReachable(int timeout) { |
|
180 |
URL url = null; |
|
181 |
URLConnection con = null; |
|
182 |
try { |
|
183 |
url = new URL(parameters.getHost()); |
|
184 |
con = url.openConnection(); |
|
185 |
if(con == null) |
|
186 |
return false; |
|
187 |
con.connect(); |
|
188 |
} catch (MalformedURLException e) { |
|
189 |
return false; |
|
190 |
} catch (IOException e) { |
|
191 |
return false; |
|
192 |
} |
|
193 |
|
|
194 |
InputStream stream = null; |
|
195 |
try { |
|
196 |
stream = con.getInputStream(); |
|
197 |
if(stream == null) |
|
198 |
return false; |
|
199 |
} catch (IOException e) { |
|
200 |
} |
|
201 |
|
|
202 |
return true; |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* Checks if the network and host are reachable |
|
207 |
* @return true if both are reachable and false if they are not |
|
208 |
*/ |
|
209 |
public boolean isHostReachable() { |
|
210 |
int timeout = 10000; |
|
211 |
return isHostReachable(timeout); |
|
212 |
} |
|
213 |
|
|
214 |
public boolean isConnected() { |
|
215 |
if(ogcClient != null) |
|
216 |
return true; |
|
217 |
return false; |
|
218 |
} |
|
219 |
|
|
220 |
public WMTSClient getOGCClient() { |
|
221 |
return ogcClient; |
|
222 |
} |
|
223 |
|
|
224 |
/*public WMTSThemes getThemes() { |
|
225 |
return connector.getThemes(); |
|
226 |
} |
|
227 |
|
|
228 |
public WMTSLayer getLayer(String layerName) { |
|
229 |
return connector.getLayer(layerName); |
|
230 |
} |
|
231 |
|
|
232 |
public List<WMTSTileMatrixSet> getTileMatrixSet() { |
|
233 |
return connector.getTileMatrixSet(); |
|
234 |
} |
|
235 |
|
|
236 |
public WMTSServiceIdentification getServiceIdentification() { |
|
237 |
return connector.getServiceIdentification(); |
|
238 |
} |
|
239 |
|
|
240 |
public WMTSServiceProvider getServiceProvider() { |
|
241 |
return connector.getServiceProvider(); |
|
242 |
}*/ |
|
243 |
|
|
244 |
public String getHost() { |
|
245 |
return parameters.getHost(); |
|
246 |
} |
|
247 |
|
|
248 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() { |
|
249 |
return null; |
|
250 |
} |
|
251 |
} |
|
0 | 252 |
org.gvsig.raster.wmts/tags/tagdate_29082013_14_01/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSProvider.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wmts.io; |
|
23 |
|
|
24 |
import java.awt.Image; |
|
25 |
import java.awt.geom.AffineTransform; |
|
26 |
import java.awt.geom.NoninvertibleTransformException; |
|
27 |
import java.awt.geom.Point2D; |
|
28 |
import java.awt.geom.Rectangle2D; |
|
29 |
import java.io.File; |
|
30 |
import java.io.IOException; |
|
31 |
import java.net.ConnectException; |
|
32 |
import java.net.MalformedURLException; |
|
33 |
import java.net.URL; |
|
34 |
import java.util.List; |
|
35 |
|
|
36 |
import javax.swing.ImageIcon; |
|
37 |
|
|
38 |
import org.gvsig.compat.net.ICancellable; |
|
39 |
import org.gvsig.fmap.dal.DALLocator; |
|
40 |
import org.gvsig.fmap.dal.DataStore; |
|
41 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
42 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
43 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
44 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
45 |
import org.gvsig.fmap.dal.coverage.datastruct.DatasetBand; |
|
46 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
47 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
|
48 |
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException; |
|
49 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
50 |
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException; |
|
51 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
52 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
53 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
54 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
55 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
56 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
57 |
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer; |
|
58 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
59 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
60 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
61 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
62 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
63 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
64 |
import org.gvsig.metadata.MetadataLocator; |
|
65 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
66 |
import org.gvsig.raster.cache.tile.TileCacheManager; |
|
67 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
68 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
69 |
import org.gvsig.raster.cache.tile.provider.TileListener; |
|
70 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
71 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
72 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery; |
|
73 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
|
74 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl; |
|
75 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
76 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
|
77 |
import org.gvsig.raster.impl.provider.MemoryMatrixBuffer; |
|
78 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
79 |
import org.gvsig.raster.impl.provider.RemoteRasterProvider; |
|
80 |
import org.gvsig.raster.impl.provider.TiledRasterProvider; |
|
81 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
|
82 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
83 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
84 |
import org.gvsig.raster.impl.store.properties.RemoteStoreHistogram; |
|
85 |
import org.gvsig.raster.util.DefaultProviderServices; |
|
86 |
import org.gvsig.raster.wmts.io.downloader.WMTSTileServer; |
|
87 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
88 |
import org.gvsig.raster.wmts.ogc.WMTSOGCLocator; |
|
89 |
import org.gvsig.raster.wmts.ogc.WMTSStatus; |
|
90 |
import org.gvsig.raster.wmts.ogc.exception.DownloadException; |
|
91 |
import org.gvsig.raster.wmts.ogc.exception.ServerErrorException; |
|
92 |
import org.gvsig.raster.wmts.ogc.exception.WMTSException; |
|
93 |
import org.gvsig.raster.wmts.ogc.struct.WMTSBoundingBox; |
|
94 |
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer; |
|
95 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTile; |
|
96 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
97 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixLimits; |
|
98 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSet; |
|
99 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
100 |
import org.gvsig.tools.ToolsLocator; |
|
101 |
import org.gvsig.tools.task.TaskStatus; |
|
102 |
import org.slf4j.Logger; |
|
103 |
import org.slf4j.LoggerFactory; |
|
104 |
/** |
|
105 |
* Provider for WMTS service |
|
106 |
* |
|
107 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
108 |
*/ |
|
109 |
public class WMTSProvider extends DefaultRasterProvider implements RemoteRasterProvider, TiledRasterProvider { |
|
110 |
public static String NAME = "Wmts Store"; |
|
111 |
public static String DESCRIPTION = "Wmts Raster file"; |
|
112 |
public static final String METADATA_DEFINITION_NAME = "WmtsStore"; |
|
113 |
private static Logger logger = LoggerFactory.getLogger(WMTSProvider.class); |
|
114 |
public static boolean TILED = true; |
|
115 |
|
|
116 |
//Los tiles se piden de forma secuencial y sin lanzar threads para ello (+Lento) |
|
117 |
public static int SEQUENTIAL = 0; |
|
118 |
//Los tiles se piden en threads y hay un thread manager para gestionar que no se pidan m?s de cierto n?mero |
|
119 |
public static int LIMITED_THREADS = 1; |
|
120 |
//Los tiles se piden en threads y se lanzan tantos threads como tiles haya |
|
121 |
public static int UNLIMITED_THREADS = 2; |
|
122 |
private int requestType = LIMITED_THREADS; |
|
123 |
|
|
124 |
private static final double MTS_X_GRADO = 111319.490793274; |
|
125 |
|
|
126 |
private Extent viewRequest = null; |
|
127 |
private WMTSClient ogcClient = null; |
|
128 |
//private static Hashtable<URL, WMTSConnector> |
|
129 |
// drivers = new Hashtable<URL, WMTSConnector> (); |
|
130 |
private boolean open = false; |
|
131 |
private File lastRequest = null; |
|
132 |
private DataStoreTransparency lastFileTransparency = null; |
|
133 |
private int lastWidthRequest = 0; |
|
134 |
private int lastHeightRequest = 0; |
|
135 |
private WMTSStatus lastStatus = null; |
|
136 |
private boolean gridSubsets = true; |
|
137 |
private Extent[] extentByLevel = null; //Only for layers without gridSubsets |
|
138 |
private Extent bbox = null; |
|
139 |
private MathUtils math = RasterLocator.getManager().getMathUtils(); |
|
140 |
|
|
141 |
/** |
|
142 |
* This thread manages the number of tiles that have been thrown. |
|
143 |
* This number is controlled by the NTHREADS_QUEUE variable. |
|
144 |
* |
|
145 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
146 |
*/ |
|
147 |
public class RequestThreadManager extends Thread { |
|
148 |
private TilePipe pipe = null; |
|
149 |
private List<WMTSTile> tiles = null; |
|
150 |
private WMTSStatus status = null; |
|
151 |
|
|
152 |
public RequestThreadManager(TilePipe pipe, List<WMTSTile> tiles, WMTSStatus status) { |
|
153 |
this.pipe = pipe; |
|
154 |
this.tiles = tiles; |
|
155 |
this.status = status; |
|
156 |
} |
|
157 |
|
|
158 |
public void run() { |
|
159 |
for (int i = 0; i < tiles.size(); i++) { |
|
160 |
WMTSTile tile = tiles.get(i); |
|
161 |
WMTSStatus statusCopy = status.cloneStatus(); |
|
162 |
statusCopy.setTileRow(tile.getRow()); |
|
163 |
statusCopy.setTileCol(tile.getCol()); |
|
164 |
if (pipe.getSize() > TilePipe.NTHREADS_QUEUE) { |
|
165 |
try { |
|
166 |
synchronized (this) { |
|
167 |
wait(); |
|
168 |
} |
|
169 |
} catch( InterruptedException e ) { |
|
170 |
} |
|
171 |
} |
|
172 |
new RequestTileLauncher(pipe, statusCopy, tile).start(); |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Thread to download a tile |
|
179 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
180 |
*/ |
|
181 |
class RequestTileLauncher extends Thread { |
|
182 |
private TilePipe pipe = null; |
|
183 |
private WMTSStatus status = null; |
|
184 |
private WMTSTile tile = null; |
|
185 |
|
|
186 |
public RequestTileLauncher(TilePipe pipe, WMTSStatus status, WMTSTile tile) { |
|
187 |
this.pipe = pipe; |
|
188 |
this.status = status; |
|
189 |
this.tile = tile; |
|
190 |
} |
|
191 |
|
|
192 |
public void run() { |
|
193 |
try { |
|
194 |
//File file = getConnector().getTile(status, null); |
|
195 |
URL url = getOGCClient().getTileURL(status); |
|
196 |
tile.setFile(getOGCClient().downloadFile(url, null)); |
|
197 |
pipe.setTile(tile); |
|
198 |
} catch (DownloadException e) { |
|
199 |
logger.info("Error downloading files", e); |
|
200 |
} catch (MalformedURLException e) { |
|
201 |
logger.info("Malformed URL", e); |
|
202 |
} catch (WMTSException e) { |
|
203 |
logger.info("", e); |
|
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Point information |
|
210 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
211 |
*/ |
|
212 |
public class PointInfo { |
|
213 |
public Point2D worldCoord; |
|
214 |
public Point2D tile; |
|
215 |
public Point2D pixelInTile; |
|
216 |
public int level; |
|
217 |
|
|
218 |
public PointInfo(Point2D worldCoord) { |
|
219 |
this.worldCoord = worldCoord; |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
public static void register() { |
|
224 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
225 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
|
226 |
dataman.registerStoreProvider(NAME, |
|
227 |
WMTSProvider.class, WMTSDataParametersImpl.class); |
|
228 |
} |
|
229 |
|
|
230 |
if (!dataman.getExplorerProviders().contains(WMTSServerExplorer.NAME)) { |
|
231 |
dataman.registerExplorerProvider(WMTSServerExplorer.NAME, WMTSServerExplorer.class, WMTSServerExplorerParameters.class); |
|
232 |
} |
|
233 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
|
234 |
} |
|
235 |
|
|
236 |
public WMTSProvider() throws NotSupportedExtensionException { |
|
237 |
super(); |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Constructor. Abre el dataset. |
|
242 |
* @param proj Proyecci?n |
|
243 |
* @param fName Nombre del fichero |
|
244 |
* @throws NotSupportedExtensionException |
|
245 |
*/ |
|
246 |
public WMTSProvider(String params) throws NotSupportedExtensionException { |
|
247 |
super(params); |
|
248 |
if(params instanceof String) { |
|
249 |
WMTSDataParameters p = new WMTSDataParametersImpl(); |
|
250 |
p.setURI((String)params); |
|
251 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
|
252 |
.createDynObject( |
|
253 |
MetadataLocator.getMetadataManager().getDefinition( |
|
254 |
DataStore.METADATA_DEFINITION_NAME))); |
|
255 |
init(p, null); |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
public WMTSProvider(WMTSDataParameters params, |
|
260 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException { |
|
261 |
super(params, storeServices, ToolsLocator.getDynObjectManager() |
|
262 |
.createDynObject( |
|
263 |
MetadataLocator.getMetadataManager().getDefinition( |
|
264 |
DataStore.METADATA_DEFINITION_NAME))); |
|
265 |
init(params, storeServices); |
|
266 |
} |
|
267 |
|
|
268 |
/** |
|
269 |
* Gets the connector from the URL |
|
270 |
* @return |
|
271 |
* @throws RemoteServiceException |
|
272 |
*/ |
|
273 |
public WMTSClient getOGCClient() throws WMTSException { |
|
274 |
if(ogcClient == null) { |
|
275 |
WMTSDataParameters p = (WMTSDataParameters)parameters; |
|
276 |
ogcClient = p.getOGCClient(); |
|
277 |
if(ogcClient != null) |
|
278 |
return ogcClient; |
|
279 |
|
|
280 |
URL url = null; |
|
281 |
try { |
|
282 |
url = new URL(p.getURI()); |
|
283 |
} catch (Exception e) { |
|
284 |
throw new WMTSException("Malformed URL",e); |
|
285 |
} |
|
286 |
try { |
|
287 |
ogcClient = WMTSOGCLocator.getManager().createWMTSClient(url.toString()); |
|
288 |
ogcClient.connect(true, new ICancellable() { |
|
289 |
|
|
290 |
public boolean isCanceled() { |
|
291 |
return false; |
|
292 |
} |
|
293 |
|
|
294 |
public Object getID() { |
|
295 |
return null; |
|
296 |
} |
|
297 |
}); |
|
298 |
} catch (ConnectException e) { |
|
299 |
throw new WMTSException("Connect exception",e); |
|
300 |
} catch (IOException e) { |
|
301 |
throw new WMTSException("Connect exception",e); |
|
302 |
} |
|
303 |
} |
|
304 |
return ogcClient; |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* Crea las referencias al fichero y carga |
|
309 |
* las estructuras con la informaci?n y los metadatos. |
|
310 |
* @param proj Proyecci?n |
|
311 |
* @param param Parametros de carga |
|
312 |
* @throws NotSupportedExtensionException |
|
313 |
*/ |
|
314 |
public void init (DataStoreParameters params, |
|
315 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException { |
|
316 |
setParam(storeServices, params); |
|
317 |
if(((WMTSDataParameters)params).getImageFormat().compareTo("image/gif") == 0) { |
|
318 |
setDataType(new int[]{Buffer.TYPE_BYTE}); |
|
319 |
bandCount = 1; |
|
320 |
} else { |
|
321 |
setDataType(new int[]{Buffer.TYPE_BYTE, Buffer.TYPE_BYTE, Buffer.TYPE_BYTE, Buffer.TYPE_BYTE}); |
|
322 |
bandCount = 4; |
|
323 |
} |
|
324 |
|
|
325 |
if(!(param instanceof WMTSDataParameters)) |
|
326 |
return; |
|
327 |
|
|
328 |
gridSubsets = hasGridSubsets((WMTSDataParameters)param); |
|
329 |
open = true; |
|
330 |
} |
|
331 |
|
|
332 |
/** |
|
333 |
* Returns true if this layer has grid subsets |
|
334 |
* @return |
|
335 |
*/ |
|
336 |
public boolean hasGridSubsets() { |
|
337 |
return gridSubsets; |
|
338 |
} |
|
339 |
|
|
340 |
/** |
|
341 |
* Checks if this layer has grid subsets or doesn't |
|
342 |
* @param p |
|
343 |
* @return |
|
344 |
*/ |
|
345 |
private boolean hasGridSubsets(WMTSDataParameters p) { |
|
346 |
List<WMTSTileMatrixLimits> tileMatrixSetLimits = null; |
Also available in: Unified diff